10 Aug, 2010

40 commits

  • Cleanup, no functional changes.

    - __set_personality() always changes ->exec_domain/personality, the
    special case when ->exec_domain remains the same buys nothing but
    complicates the code. Unify both cases to simplify the code.

    - The -EINVAL check in sys_personality() was never right. If we assume
    that set_personality() can fail we should check the value it returns
    instead of verifying that task->personality was actually changed.

    Remove it. Before the previous patch it was possible to hit this case
    due to overflow problems, but this -EINVAL just indicated the kernel
    bug.

    OTOH, probably it makes sense to change lookup_exec_domain() to return
    ERR_PTR() instead of default_exec_domain if the search in exec_domains
    list fails, and report this error to the user-space. But this means
    another user-space change, and we have in-kernel users which need fixes.
    For example, PER_OSF4 falls into PER_MASK for unkown reason and nobody
    cares to register this domain.

    Signed-off-by: Oleg Nesterov
    Cc: Wenming Zhang
    Cc: "H. Peter Anvin"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Oleg Nesterov
     
  • This driver adds support for the BMP085 digital pressure sensor from Bosch
    Sensortec. It exposes a sysfs api to userspace where pressure and
    temperature measurement results can be read from the pressure0_input and
    temp0_input file. The chip is able to calculate the average of up to
    eight samples to increase the accuracy. This feature can be controlled by
    writing to the oversampling file.

    The BMP085 digital pressure sensor can measure ambient air pressure and
    temperature. Both values can be obtained from sysfs files. The pressure
    is measured by reading from pressure0_input. Valid values range from
    30000 to 110000 pascal with a resolution of 1 pascal (=0.01 millibar).

    temp0_input holds the current temperature in degree celsius, multiplied by
    10. This results in a resolution of a tenth degree celsius. Values range
    from -400 to 850.

    To increase the accuracy, this chip can calculate the average of 1, 2, 4
    or 8 samples. This behavior is controlled through the oversampling sysfs
    file. Two to the power of the value written to that file specifies how
    many samples will be used. Valid values: 0..3.

    [akpm@linux-foundation.org: fix typo]
    [shubhrajyoti@ti.com: optimize the wait time for the pressure sensor, definition of long is arch dependent so make it u32]
    [akpm@linux-foundation.org: coding-style fixes]
    Signed-off-by: Christoph Mair
    Signed-off-by: Shubhrajyoti D
    Acked-by: Jonathan Cameron
    Cc: Stefan Schmidt
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Mair
     
  • Fix i386 PAE compile warning:

    drivers/misc/hpilo.c: In function `ilo_ccb_setup':
    drivers/misc/hpilo.c:274: warning: cast to pointer from integer of different size

    dma_addr_t is 64 on i386 PAE which causes a size mismatch.

    Signed-off-by: Prarit Bhargava
    Acked-by: David Altobelli
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Prarit Bhargava
     
  • Add support for ROHM BH1780GLI Ambient light sensor.

    BH1780 supports I2C interface. Driver supports read/update of power state
    and read of lux value (through SYSFS). Writing value 3 to power_state
    enables the sensor and current lux value could be read.

    Currently this driver follows the same sysfs convention as supported by
    drivers/misc/isl29003.c.

    Signed-off-by: Hemanth V
    Reviewed-by: Daniel Mack
    Acked-by: Jonathan Cameron
    Cc: Jean Delvare
    Cc: Wolfram Sang
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Hemanth V
     
  • sec2annotation returns malloc'ed buffer directly to printf as an argument.
    Free this buffer after printing.

    Signed-off-by: Alexey Fomenko
    Cc: Trevor Keith
    Cc: Rusty Russell
    Cc: Michal Marek
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Alexey Fomenko
     
  • A profile of a network benchmark showed iommu_num_pages rather high up:

    0.52% iommu_num_pages

    Looking at the profile, an integer divide is taking almost all of the time:

    %
    : c000000000376ea4 :
    1.93 : c000000000376ea4: fb e1 ff f8 std r31,-8(r1)
    0.00 : c000000000376ea8: f8 21 ff c1 stdu r1,-64(r1)
    0.00 : c000000000376eac: 7c 3f 0b 78 mr r31,r1
    3.86 : c000000000376eb0: 38 84 ff ff addi r4,r4,-1
    0.00 : c000000000376eb4: 38 05 ff ff addi r0,r5,-1
    0.00 : c000000000376eb8: 7c 84 2a 14 add r4,r4,r5
    46.95 : c000000000376ebc: 7c 00 18 38 and r0,r0,r3
    45.66 : c000000000376ec0: 7c 84 02 14 add r4,r4,r0
    0.00 : c000000000376ec4: 7c 64 2b 92 divdu r3,r4,r5
    0.00 : c000000000376ec8: 38 3f 00 40 addi r1,r31,64
    0.00 : c000000000376ecc: eb e1 ff f8 ld r31,-8(r1)
    1.61 : c000000000376ed0: 4e 80 00 20 blr

    Since every caller of iommu_num_pages passes in a constant power of two
    we can inline this such that the divide is replaced by a shift. The
    entire function is only a few instructions once optimised, so it is
    a good candidate for inlining overall.

    Signed-off-by: Anton Blanchard
    Cc: Akinobu Mita
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Anton Blanchard
     
  • Using:

    gcc (GCC) 4.5.0 20100610 (prerelease)

    The following warnings appear:

    fs/readdir.c: In function `filldir64':
    fs/readdir.c:240:15: warning: `dirent' is used uninitialized in this function
    fs/readdir.c: In function `filldir':
    fs/readdir.c:155:15: warning: `dirent' is used uninitialized in this function
    fs/compat.c: In function `compat_filldir64':
    fs/compat.c:1071:11: warning: `dirent' is used uninitialized in this function
    fs/compat.c: In function `compat_filldir':
    fs/compat.c:984:15: warning: `dirent' is used uninitialized in this function

    The warnings are related to the use of the NAME_OFFSET() macro. Luckily,
    it appears as though the standard offsetof() macro is what is being
    implemented by NAME_OFFSET(), thus we can fix the warning and use a more
    standard code construct at the same time.

    Signed-off-by: Kevin Winchester
    Cc: Al Viro
    Cc: Christoph Hellwig
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kevin Winchester
     
  • Add more information about patch descriptions.

    Signed-off-by: Randy Dunlap
    Reviewed-by: Christoph Lameter
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Randy Dunlap
     
  • There are no more uses of NIPQUAD or NIPQUAD_FMT. Remove the definitions.

    Signed-off-by: Joe Perches
    Cc: "David S. Miller"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     
  • Removal of these started in 2.3.43pre3, ca. 10 years ago.

    Reported-by: Arnd Bergmann
    Signed-off-by: Geert Uytterhoeven
    Cc: Richard Henderson
    Cc: Ivan Kokshaysky
    Cc: Yoshinori Sato
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Geert Uytterhoeven
     
  • We should use the __same_type() helper in __must_be_array().

    Signed-off-by: Rusty Russell
    Reported-by: Andrew Morton
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rusty Russell
     
  • The asm-generic/iomap.h provides these functions already, but the
    non-generic fallback defines do not.

    Signed-off-by: Mike Frysinger
    Cc: Arnd Bergmann
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mike Frysinger
     
  • PROC_MM doesn't exist in Kconfig. Looking around it looks like a
    left-over from 2.6.0 or even 2.4 times, last mentioned in a fedora patch
    for 2.6.10. I believe it's time to get rid of that last tiny parts here
    that are still around.

    Signed-off-by: Christoph Egger
    Cc: Jeff Dike
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Christoph Egger
     
  • When I use OpenSUSE-11.2 on UML (> 2.6.25)
    I get lots of such errors:

    Registering fd 1 twice
    Irqs : 3, 3
    Ids : 0x09cb41a0, 0x09cb4120
    ------------[ cut here ]------------
    WARNING: at kernel/irq/manage.c:896 __free_irq+0x79/0x11a()
    Trying to free already-free IRQ 3
    Modules linked in:
    09dadc6c: [] dump_stack+0x1c/0x20
    09dadc84: [] warn_slowpath_common+0x49/0x77
    09dadc9c: [] warn_slowpath_fmt+0x26/0x2a
    09dadcb4: [] __free_irq+0x79/0x11a
    09dadce4: [] free_irq+0x2d/0x49
    09dadcf4: [] close_one_chan+0x70/0x9c
    09dadd0c: [] close_chan+0x17/0x22
    09dadd1c: [] enable_chan+0x70/0x7c
    09dadd3c: [] line_open+0x34/0x9f
    09dadd54: [] con_open+0x13/0x35
    09dadd6c: [] tty_open+0x285/0x384
    09dadda0: [] chrdev_open+0xe0/0xf9
    09daddc0: [] __dentry_open+0xf3/0x1e2
    09dadde4: [] nameidata_to_filp+0x35/0x49
    09daddfc: [] do_last+0x409/0x50e
    09dade28: [] do_filp_open+0x175/0x446
    09dadecc: [] do_sys_open+0x4a/0x128
    09dadf04: [] sys_open+0x19/0x21
    09dadf28: [] handle_syscall+0x7a/0x98
    09dadf78: [] userspace+0x2c9/0x370
    09dadfe0: [] fork_handler+0x53/0x5b
    09dadffc: [] 0x766564

    ---[ end trace 9ebc1094aaf4bded ]---

    This patch fixes the issue.

    Signed-off-by: Richard Weinberger
    Cc: Jeff Dike
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Richard Weinberger
     
  • On some SoC chips, HW resources may be in use during any particular idle
    period. As a consequence, the cpuidle states that the SoC is safe to
    enter can change from idle period to idle period. In addition, the
    latency and threshold of each cpuidle state can vary, depending on the
    operating condition when the CPU becomes idle, e.g. the current cpu
    frequency, the current state of the HW blocks, etc.

    cpuidle core and the menu governor, in the current form, are geared
    towards cpuidle states that are static, i.e. the availabiltiy of the
    states, their latencies, their thresholds are non-changing during run
    time. cpuidle does not provide any hook that cpuidle drivers can use to
    adjust those values on the fly for the current idle period before the menu
    governor selects the target cpuidle state.

    This patch extends cpuidle core and the menu governor to handle states
    that are dynamic. There are three additions in the patch and the patch
    maintains backwards-compatibility with existing cpuidle drivers.

    1) add prepare() to struct cpuidle_device. A cpuidle driver can hook
    into the callback and cpuidle will call prepare() before calling the
    governor's select function. The callback gives the cpuidle driver a
    chance to update the dynamic information of the cpuidle states for the
    current idle period, e.g. state availability, latencies, thresholds,
    power values, etc.

    2) add CPUIDLE_FLAG_IGNORE as one of the state flags. In the prepare()
    function, a cpuidle driver can set/clear the flag to indicate to the
    menu governor whether a cpuidle state should be ignored, i.e. not
    available, during the current idle period.

    3) add power_specified bit to struct cpuidle_device. The menu governor
    currently assumes that the cpuidle states are arranged in the order of
    increasing latency, threshold, and power savings. This is true or can
    be made true for static states. Once the state parameters are dynamic,
    the latencies, thresholds, and power savings for the cpuidle states can
    increase or decrease by different amounts from idle period to idle
    period. So the assumption of increasing latency, threshold, and power
    savings from Cn to C(n+1) can no longer be guaranteed.

    It can be straightforward to calculate the power consumption of each
    available state and to specify it in power_usage for the idle period.
    Using the power_usage fields, the menu governor then selects the state
    that has the lowest power consumption and that still satisfies all other
    critieria. The power_specified bit defaults to 0. For existing cpuidle
    drivers, cpuidle detects that power_specified is 0 and fills in a dummy
    set of power_usage values.

    Signed-off-by: Ai Li
    Cc: Len Brown
    Acked-by: Arjan van de Ven
    Cc: Ingo Molnar
    Cc: Venkatesh Pallipadi
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Ai Li
     
  • When taking a memory snapshot in hibernate_snapshot(), all (directly
    called) memory allocations use GFP_ATOMIC. Hence swap misusage during
    hibernation never occurs.

    But from a pessimistic point of view, there is no guarantee that no page
    allcation has __GFP_WAIT. It is better to have a global indication "we
    enter hibernation, don't use swap!".

    This patch tries to freeze new-swap-allocation during hibernation. (All
    user processes are frozenm so swapin is not a concern).

    This way, no updates will happen to swap_map[] between
    hibernate_snapshot() and save_image(). Swap is thawed when swsusp_free()
    is called. We can be assured that swap corruption will not occur.

    Signed-off-by: KAMEZAWA Hiroyuki
    Cc: "Rafael J. Wysocki"
    Cc: Hugh Dickins
    Cc: KOSAKI Motohiro
    Cc: Ondrej Zary
    Cc: Balbir Singh
    Cc: Andrea Arcangeli
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KAMEZAWA Hiroyuki
     
  • Since 2.6.31, swap_map[]'s refcounting was changed to show that a used
    swap entry is just for swap-cache, can be reused. Then, while scanning
    free entry in swap_map[], a swap entry may be able to be reclaimed and
    reused. It was caused by commit c9e444103b5e7a5 ("mm: reuse unused swap
    entry if necessary").

    But this caused deta corruption at resume. The scenario is

    - Assume a clean-swap cache, but mapped.

    - at hibernation_snapshot[], clean-swap-cache is saved as
    clean-swap-cache and swap_map[] is marked as SWAP_HAS_CACHE.

    - then, save_image() is called. And reuse SWAP_HAS_CACHE entry to save
    image, and break the contents.

    After resume:

    - the memory reclaim runs and finds clean-not-referenced-swap-cache and
    discards it because it's marked as clean. But here, the contents on
    disk and swap-cache is inconsistent.

    Hance memory is corrupted.

    This patch avoids the bug by not reclaiming swap-entry during hibernation.
    This is a quick fix for backporting.

    Signed-off-by: KAMEZAWA Hiroyuki
    Cc: Rafael J. Wysocki
    Reported-by: Ondreg Zary
    Tested-by: Ondreg Zary
    Tested-by: Andrea Gelmini
    Acked-by: Hugh Dickins
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KAMEZAWA Hiroyuki
     
  • This implements hardware performance events for the EV67 and later CPUs
    within the Linux performance events subsystem. Only using the performance
    monitoring unit in HP/Compaq's so called "Aggregrate mode" is supported.

    The code has been implemented in a manner that makes extension to other
    older Alpha CPUs relatively straightforward should some mug wish to
    indulge themselves.

    Signed-off-by: Michael Cree
    Cc: Richard Henderson
    Cc: Ivan Kokshaysky
    Cc: Matt Turner
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Cc: Jay Estabrook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Cree
     
  • Signed-off-by: Michael Cree
    Cc: Richard Henderson
    Cc: Ivan Kokshaysky
    Cc: Matt Turner
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Cc: Jay Estabrook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Cree
     
  • The following patches implement hardware performance events for the Alpha
    EV67 and later CPUs. I have had this running on a Compaq XP1000 (EV67,
    single CPU) for a few days now. Pretty cool -- discovered that the glibc
    exp2() library routine uses on average 985 cycles to execute 777 CPU
    instructions whereas Compaq's CPML library version of exp2() uses on
    average 32 cycles to execute 47 CPU instructions to achieve the same
    thing!

    This patch:

    Add performance monitor interrupt counternd and export the count to user
    space via /proc/interrupts.

    Signed-off-by: Michael Cree
    Cc: Richard Henderson
    Cc: Ivan Kokshaysky
    Cc: Matt Turner
    Cc: Thomas Gleixner
    Cc: Peter Zijlstra
    Cc: Ingo Molnar
    Cc: Jay Estabrook
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Michael Cree
     
  • WB_SYNC_NONE writeback is done in rounds of 1024 pages so that we don't
    write out some huge inode for too long while starving writeout of other
    inodes. To avoid livelocks, we record time we started writeback in
    wbc->wb_start and do not write out inodes which were dirtied after this
    time. But currently, writeback_inodes_wb() resets wb_start each time it
    is called thus effectively invalidating this logic and making any
    WB_SYNC_NONE writeback prone to livelocks.

    This patch makes sure wb_start is set only once when we start writeback.

    Signed-off-by: Jan Kara
    Reviewed-by: Wu Fengguang
    Cc: Christoph Hellwig
    Acked-by: Jens Axboe
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jan Kara
     
  • Use compile-allocated memory instead of dynamic allocated memory for
    mm_slots_hash.

    Use hash_ptr() instead divisions for bucket calculation.

    Signed-off-by: Lai Jiangshan
    Signed-off-by: Izik Eidus
    Cc: Avi Kivity
    Cc: Andrea Arcangeli
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Lai Jiangshan
     
  • Fix "system goes unresponsive under memory pressure and lots of
    dirty/writeback pages" bug.

    http://lkml.org/lkml/2010/4/4/86

    In the above thread, Andreas Mohr described that

    Invoking any command locked up for minutes (note that I'm
    talking about attempted additional I/O to the _other_,
    _unaffected_ main system HDD - such as loading some shell
    binaries -, NOT the external SSD18M!!).

    This happens when the two conditions are both meet:
    - under memory pressure
    - writing heavily to a slow device

    OOM also happens in Andreas' system. The OOM trace shows that 3 processes
    are stuck in wait_on_page_writeback() in the direct reclaim path. One in
    do_fork() and the other two in unix_stream_sendmsg(). They are blocked on
    this condition:

    (sc->order && priority < DEF_PRIORITY - 2)

    which was introduced in commit 78dc583d (vmscan: low order lumpy reclaim
    also should use PAGEOUT_IO_SYNC) one year ago. That condition may be too
    permissive. In Andreas' case, 512MB/1024 = 512KB. If the direct reclaim
    for the order-1 fork() allocation runs into a range of 512KB
    hard-to-reclaim LRU pages, it will be stalled.

    It's a severe problem in three ways.

    Firstly, it can easily happen in daily desktop usage. vmscan priority can
    easily go below (DEF_PRIORITY - 2) on _local_ memory pressure. Even if
    the system has 50% globally reclaimable pages, it still has good
    opportunity to have 0.1% sized hard-to-reclaim ranges. For example, a
    simple dd can easily create a big range (up to 20%) of dirty pages in the
    LRU lists. And order-1 to order-3 allocations are more than common with
    SLUB. Try "grep -v '1 :' /proc/slabinfo" to get the list of high order
    slab caches. For example, the order-1 radix_tree_node slab cache may
    stall applications at swap-in time; the order-3 inode cache on most
    filesystems may stall applications when trying to read some file; the
    order-2 proc_inode_cache may stall applications when trying to open a
    /proc file.

    Secondly, once triggered, it will stall unrelated processes (not doing IO
    at all) in the system. This "one slow USB device stalls the whole system"
    avalanching effect is very bad.

    Thirdly, once stalled, the stall time could be intolerable long for the
    users. When there are 20MB queued writeback pages and USB 1.1 is writing
    them in 1MB/s, wait_on_page_writeback() will stuck for up to 20 seconds.
    Not to mention it may be called multiple times.

    So raise the bar to only enable PAGEOUT_IO_SYNC when priority goes below
    DEF_PRIORITY/3, or 6.25% LRU size. As the default dirty throttle ratio is
    20%, it will hardly be triggered by pure dirty pages. We'd better treat
    PAGEOUT_IO_SYNC as some last resort workaround -- its stall time is so
    uncomfortably long (easily goes beyond 1s).

    The bar is only raised for (order < PAGE_ALLOC_COSTLY_ORDER) allocations,
    which are easy to satisfy in 1TB memory boxes. So, although 6.25% of
    memory could be an awful lot of pages to scan on a system with 1TB of
    memory, it won't really have to busy scan that much.

    Andreas tested an older version of this patch and reported that it mostly
    fixed his problem. Mel Gorman helped improve it and KOSAKI Motohiro will
    fix it further in the next patch.

    Reported-by: Andreas Mohr
    Reviewed-by: Minchan Kim
    Reviewed-by: KOSAKI Motohiro
    Signed-off-by: Mel Gorman
    Signed-off-by: Wu Fengguang
    Cc: Rik van Riel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Wu Fengguang
     
  • kmalloc() may fail, if so return -ENOMEM.

    Signed-off-by: Kulikov Vasiliy
    Acked-by: Pekka Enberg
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Kulikov Vasiliy
     
  • Memcg also need to trace page isolation information as global reclaim.
    This patch does it.

    Signed-off-by: KOSAKI Motohiro
    Reviewed-by: KAMEZAWA Hiroyuki
    Acked-by: Mel Gorman
    Acked-by: Balbir Singh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • Mel Gorman recently added some vmscan tracepoints. Unfortunately they are
    covered only global reclaim. But we want to trace memcg reclaim too.

    Thus, this patch convert them to DEFINE_TRACE macro. it help to reuse
    tracepoint definition for other similar usage (i.e. memcg). This patch
    have no functionally change.

    Signed-off-by: KOSAKI Motohiro
    Reviewed-by: KAMEZAWA Hiroyuki
    Acked-by: Balbir Singh
    Acked-by: Mel Gorman
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • Memcg also need to trace reclaim progress as direct reclaim. This patch
    add it.

    Signed-off-by: KOSAKI Motohiro
    Reviewed-by: KAMEZAWA Hiroyuki
    Acked-by: Mel Gorman
    Acked-by: Balbir Singh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • Mel Gorman recently added some vmscan tracepoints. Unfortunately they are
    covered only global reclaim. But we want to trace memcg reclaim too.

    Thus, this patch convert them to DEFINE_TRACE macro. it help to reuse
    tracepoint definition for other similar usage (i.e. memcg). This patch
    have no functionally change.

    Signed-off-by: KOSAKI Motohiro
    Reviewed-by: KAMEZAWA Hiroyuki
    Acked-by: Mel Gorman
    Acked-by: Balbir Singh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • Presently shrink_slab() has the following scanning equation.

    lru_scanned max_pass
    basic_scan_objects = 4 x ------------- x -----------------------------
    lru_pages shrinker->seeks (default:2)

    scan_objects = min(basic_scan_objects, max_pass * 2)

    If we pass very small value as lru_pages instead real number of lru pages,
    shrink_slab() drop much objects rather than necessary. And now,
    __zone_reclaim() pass 'order' as lru_pages by mistake. That produces a
    bad result.

    For example, if we receive very low memory pressure (scan = 32, order =
    0), shrink_slab() via zone_reclaim() always drop _all_ icache/dcache
    objects. (see above equation, very small lru_pages make very big
    scan_objects result).

    This patch fixes it.

    [akpm@linux-foundation.org: fix layout, typos]
    Signed-off-by: KOSAKI Motohiro
    Reviewed-by: Minchan Kim
    Acked-by: Christoph Lameter
    Acked-by: Rik van Riel
    Cc: Johannes Weiner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • It is not appropriate for apply_to_page_range() to directly call any mmu
    notifiers, because it is a general purpose function whose effect depends
    on what context it is called in and what the callback function does.

    In particular, if it is being used as part of an mmu notifier
    implementation, the recursive calls can be particularly problematic.

    It is up to apply_to_page_range's caller to do any notifier calls if
    necessary. It does not affect any in-tree users because they all operate
    on init_mm, and mmu notifiers only pertain to usermode mappings.

    [stefano.stabellini@eu.citrix.com: remove unused local `start']
    Signed-off-by: Jeremy Fitzhardinge
    Signed-off-by: Stefano Stabellini
    Cc: Andrea Arcangeli
    Cc: Stefano Stabellini
    Cc: Avi Kivity
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Jeremy Fitzhardinge
     
  • Rik van Riel pointed out reading reclaim_stat should be protected
    lru_lock, otherwise vmscan might sweep 2x much pages.

    This fault was introduced by

    commit 4f98a2fee8acdb4ac84545df98cccecfd130f8db
    Author: Rik van Riel
    Date: Sat Oct 18 20:26:32 2008 -0700

    vmscan: split LRU lists into anon & file sets

    Signed-off-by: KOSAKI Motohiro
    Cc: Rik van Riel
    Reviewed-by: Minchan Kim
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • 'slab_reclaimable' and 'nr_pages' are unsigned. Subtraction is unsafe
    because negative results would be misinterpreted.

    Signed-off-by: KOSAKI Motohiro
    Reviewed-by: Minchan Kim
    Cc: Mel Gorman
    Cc: Rik van Riel
    Cc: Johannes Weiner
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • drivers/base/node.c: In function 'node_read_meminfo':
    drivers/base/node.c:139: warning: the frame size of 848 bytes is
    larger than 512 bytes

    Fix it by splitting the sprintf() into three parts. It has no functional
    change.

    Signed-off-by: KOSAKI Motohiro
    Cc: Greg KH
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • Set the flag if do_swap_page is decowing the page the same way do_wp_page
    would too.

    Signed-off-by: Andrea Arcangeli
    Cc: KOSAKI Motohiro
    Cc: Rik van Riel
    Cc: Nick Piggin
    Cc: Hugh Dickins
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrea Arcangeli
     
  • On swapin it is fairly common for a page to be owned exclusively by one
    process. In that case we want to add the page to the anon_vma of that
    process's VMA, instead of to the root anon_vma.

    This will reduce the amount of rmap searching that the swapout code needs
    to do.

    Signed-off-by: Rik van Riel
    Cc: Andrea Arcangeli
    Cc: KOSAKI Motohiro
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Rik van Riel
     
  • /proc/pid/oom_adj is now deprecated so that that it may eventually be
    removed. The target date for removal is August 2012.

    A warning will be printed to the kernel log if a task attempts to use this
    interface. Future warning will be suppressed until the kernel is rebooted
    to prevent spamming the kernel log.

    Signed-off-by: David Rientjes
    Cc: Nick Piggin
    Cc: KAMEZAWA Hiroyuki
    Cc: KOSAKI Motohiro
    Cc: Oleg Nesterov
    Cc: Balbir Singh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Rientjes
     
  • This a complete rewrite of the oom killer's badness() heuristic which is
    used to determine which task to kill in oom conditions. The goal is to
    make it as simple and predictable as possible so the results are better
    understood and we end up killing the task which will lead to the most
    memory freeing while still respecting the fine-tuning from userspace.

    Instead of basing the heuristic on mm->total_vm for each task, the task's
    rss and swap space is used instead. This is a better indication of the
    amount of memory that will be freeable if the oom killed task is chosen
    and subsequently exits. This helps specifically in cases where KDE or
    GNOME is chosen for oom kill on desktop systems instead of a memory
    hogging task.

    The baseline for the heuristic is a proportion of memory that each task is
    currently using in memory plus swap compared to the amount of "allowable"
    memory. "Allowable," in this sense, means the system-wide resources for
    unconstrained oom conditions, the set of mempolicy nodes, the mems
    attached to current's cpuset, or a memory controller's limit. The
    proportion is given on a scale of 0 (never kill) to 1000 (always kill),
    roughly meaning that if a task has a badness() score of 500 that the task
    consumes approximately 50% of allowable memory resident in RAM or in swap
    space.

    The proportion is always relative to the amount of "allowable" memory and
    not the total amount of RAM systemwide so that mempolicies and cpusets may
    operate in isolation; they shall not need to know the true size of the
    machine on which they are running if they are bound to a specific set of
    nodes or mems, respectively.

    Root tasks are given 3% extra memory just like __vm_enough_memory()
    provides in LSMs. In the event of two tasks consuming similar amounts of
    memory, it is generally better to save root's task.

    Because of the change in the badness() heuristic's baseline, it is also
    necessary to introduce a new user interface to tune it. It's not possible
    to redefine the meaning of /proc/pid/oom_adj with a new scale since the
    ABI cannot be changed for backward compatability. Instead, a new tunable,
    /proc/pid/oom_score_adj, is added that ranges from -1000 to +1000. It may
    be used to polarize the heuristic such that certain tasks are never
    considered for oom kill while others may always be considered. The value
    is added directly into the badness() score so a value of -500, for
    example, means to discount 50% of its memory consumption in comparison to
    other tasks either on the system, bound to the mempolicy, in the cpuset,
    or sharing the same memory controller.

    /proc/pid/oom_adj is changed so that its meaning is rescaled into the
    units used by /proc/pid/oom_score_adj, and vice versa. Changing one of
    these per-task tunables will rescale the value of the other to an
    equivalent meaning. Although /proc/pid/oom_adj was originally defined as
    a bitshift on the badness score, it now shares the same linear growth as
    /proc/pid/oom_score_adj but with different granularity. This is required
    so the ABI is not broken with userspace applications and allows oom_adj to
    be deprecated for future removal.

    Signed-off-by: David Rientjes
    Cc: Nick Piggin
    Cc: KAMEZAWA Hiroyuki
    Cc: KOSAKI Motohiro
    Cc: Oleg Nesterov
    Cc: Balbir Singh
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    David Rientjes
     
  • Cc: Minchan Kim
    Cc: David Rientjes
    Cc: KAMEZAWA Hiroyuki
    Cc: Oleg Nesterov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • Oleg pointed out current PF_EXITING check is wrong. Because PF_EXITING
    is per-thread flag, not per-process flag. He said,

    Two threads, group-leader L and its sub-thread T. T dumps the code.
    In this case both threads have ->mm != NULL, L has PF_EXITING.

    The first problem is, select_bad_process() always return -1 in this
    case (even if the caller is T, this doesn't matter).

    The second problem is that we should add TIF_MEMDIE to T, not L.

    I think we can remove this dubious PF_EXITING check. but as first step,
    This patch add the protection of multi threaded issue.

    Signed-off-by: KOSAKI Motohiro
    Cc: Oleg Nesterov
    Cc: Minchan Kim
    Cc: David Rientjes
    Cc: KAMEZAWA Hiroyuki
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • In a system under heavy load it was observed that even after the
    oom-killer selects a task to die, the task may take a long time to die.

    Right after sending a SIGKILL to the task selected by the oom-killer this
    task has its priority increased so that it can exit() soon, freeing
    memory. That is accomplished by:

    /*
    * We give our sacrificial lamb high priority and access to
    * all the memory it needs. That way it should be able to
    * exit() and clear out its resources quickly...
    */
    p->rt.time_slice = HZ;
    set_tsk_thread_flag(p, TIF_MEMDIE);

    It sounds plausible giving the dying task an even higher priority to be
    sure it will be scheduled sooner and free the desired memory. It was
    suggested on LKML using SCHED_FIFO:1, the lowest RT priority so that this
    task won't interfere with any running RT task.

    If the dying task is already an RT task, leave it untouched. Another good
    suggestion, implemented here, was to avoid boosting the dying task
    priority in case of mem_cgroup OOM.

    Signed-off-by: Luis Claudio R. Goncalves
    Signed-off-by: KOSAKI Motohiro
    Reviewed-by: Minchan Kim
    Cc: David Rientjes
    Cc: KAMEZAWA Hiroyuki
    Cc: Oleg Nesterov
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Luis Claudio R. Goncalves