18 Nov, 2009

2 commits

  • Allow memory hotplug and hibernation in the same kernel

    Memory hotplug and hibernation were exclusive in Kconfig. This is
    obviously a problem for distribution kernels who want to support both in
    the same image.

    After some discussions with Rafael and others the only problem is with
    parallel memory hotadd or removal while a hibernation operation is in
    process. It was also working for s390 before.

    This patch removes the Kconfig level exclusion, and simply makes the
    memory add / remove functions grab the pm_mutex to exclude against
    hibernation.

    Fixes a regression - old kernels didn't exclude memory hotadd and
    hibernation.

    Signed-off-by: Andi Kleen
    Cc: Gerald Schaefer
    Cc: KOSAKI Motohiro
    Cc: Yasunori Goto
    Acked-by: Rafael J. Wysocki
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andi Kleen
     
  • With CONFIG_MEMORY_HOTPLUG I got following warning:

    WARNING: vmlinux.o(.text+0x1276b0): Section mismatch in reference from
    the function hotadd_new_pgdat() to the function
    .meminit.text:free_area_init_node()
    The function hotadd_new_pgdat() references
    the function __meminit free_area_init_node().
    This is often because hotadd_new_pgdat lacks a __meminit
    annotation or the annotation of free_area_init_node is wrong.

    Use __ref to fix this.

    Signed-off-by: Hidetoshi Seto
    Cc: Minchan Kim
    Cc: Mel Gorman
    Cc: Yasunori Goto
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Hidetoshi Seto
     

15 Nov, 2009

1 commit


12 Nov, 2009

5 commits

  • pcpu_extend_area_map() had the following two bugs.

    * It should return 1 if pcpu_lock was dropped and reacquired but it
    returned 0. This could lead to oops if free_percpu() races with
    area map extension.

    * pcpu_mem_free() was called under pcpu_lock. pcpu_mem_free() might
    end up calling vfree() which isn't IRQ safe. This could lead to
    deadlock through lock order inversion via IRQ.

    In addition, Linus pointed out that the temporary lock dropping and
    subtle three-way return value of pcpu_extend_area_map() was very ugly
    and suggested to split the function into two - pcpu_need_to_extend()
    and pcpu_extend_area_map().

    This patch restructures pcpu_extend_area_map() as suggested and fixes
    the two bugs.

    Signed-off-by: Tejun Heo
    Acked-by: Linus Torvalds
    Cc: Ingo Molnar

    Tejun Heo
     
  • Lee Schermerhorn reported that he saw bad pointer dereference in
    mem_cgroup_end_migration() when he disabled memcg by boot option.

    memcg's page migration logic works as

    mem_cgroup_prepare_migration(page, &ptr);
    do page migration
    mem_cgroup_end_migration(page, ptr);

    Now, ptr is not initialized in prepare_migration when memcg is disabled
    by boot option. This causes panic in end_migration. This patch fixes it.

    Reported-by: Lee Schermerhorn
    Cc: Balbir Singh
    Signed-off-by: KAMEZAWA Hiroyuki
    Reviewed-by: Daisuke Nishimura
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KAMEZAWA Hiroyuki
     
  • Commit 341ce06f69abfafa31b9468410a13dbd60e2b237 ("page allocator:
    calculate the alloc_flags for allocation only once") altered watermark
    logic slightly by allowing rt_tasks that are handling an interrupt to set
    ALLOC_HARDER. This patch brings the watermark logic more in line with
    2.6.30.

    This change results in a reduction of the number high-order GFP_ATOMIC
    allocation failures reported. See
    http://www.gossamer-threads.com/lists/linux/kernel/1144153

    [rientjes@google.com: Spotted the problem]
    Signed-off-by: Mel Gorman
    Reviewed-by: Pekka Enberg
    Reviewed-by: Rik van Riel
    Reviewed-by: KOSAKI Motohiro
    Cc: David Rientjes
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mel Gorman
     
  • If a direct reclaim makes no forward progress, it considers whether it
    should go OOM or not. Whether OOM is triggered or not, it may retry the
    allocation afterwards. In times past, this would always wake kswapd as
    well but currently, kswapd is not woken up after direct reclaim fails.
    For order-0 allocations, this makes little difference but if there is a
    heavy mix of higher-order allocations that direct reclaim is failing for,
    it might mean that kswapd is not rewoken for higher orders as much as it
    did previously.

    This patch wakes up kswapd when an allocation is being retried after a
    direct reclaim failure. It would be expected that kswapd is already
    awake, but this has the effect of telling kswapd to reclaim at the higher
    order as well.

    Signed-off-by: Mel Gorman
    Reviewed-by: Christoph Lameter
    Reviewed-by: Pekka Enberg
    Reviewed-by: KOSAKI Motohiro
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Mel Gorman
     
  • …/git/tip/linux-2.6-tip

    * 'core-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
    highmem: Fix debug_kmap_atomic() to also handle KM_IRQ_PTE, KM_NMI, and KM_NMI_PTE
    highmem: Fix race in debug_kmap_atomic() which could cause warn_count to underflow
    rcu: Fix long-grace-period race between forcing and initialization
    uids: Prevent tear down race

    Linus Torvalds
     

10 Nov, 2009

3 commits


04 Nov, 2009

2 commits


03 Nov, 2009

1 commit

  • In try_to_unuse(), swcount is a local copy of *swap_map, including the
    SWAP_HAS_CACHE bit; but a wrong comparison against swap_count(*swap_map),
    which masks off the SWAP_HAS_CACHE bit, succeeded where it should fail.

    That had the effect of resetting the mm from which to start searching
    for the next swap page, to an irrelevant mm instead of to an mm in which
    this swap page had been found: which may increase search time by ~20%.
    But we're used to swapoff being slow, so never noticed the slowdown.

    Remove that one spurious use of swap_count(): Bo Liu thought it merely
    redundant, Hugh rewrote the description since it was measurably wrong.

    Signed-off-by: Bo Liu
    Signed-off-by: Hugh Dickins
    Reviewed-by: KAMEZAWA Hiroyuki
    Cc: stable@kernel.org
    Signed-off-by: Linus Torvalds

    Bo Liu
     

01 Nov, 2009

1 commit

  • Don't pass NULL pointers to fput() in the error handling paths of the NOMMU
    do_mmap_pgoff() as it can't handle it.

    The following can be used as a test program:

    int main() { static long long a[1024 * 1024 * 20] = { 0 }; return a;}

    Without the patch, the code oopses in atomic_long_dec_and_test() as called by
    fput() after the kernel complains that it can't allocate that big a chunk of
    memory. With the patch, the kernel just complains about the allocation size
    and then the program segfaults during execve() as execve() can't complete the
    allocation of all the new ELF program segments.

    Reported-by: Robin Getz
    Signed-off-by: David Howells
    Acked-by: Robin Getz
    Cc: stable@kernel.org
    Signed-off-by: Linus Torvalds

    David Howells
     

30 Oct, 2009

2 commits


29 Oct, 2009

12 commits

  • * 'merge' of git://git.kernel.org/pub/scm/linux/kernel/git/benh/powerpc:
    powerpc/ppc64: Use preempt_schedule_irq instead of preempt_schedule
    powerpc: Minor cleanup to lib/Kconfig.debug
    powerpc: Minor cleanup to sound/ppc/Kconfig
    powerpc: Minor cleanup to init/Kconfig
    powerpc: Limit memory hotplug support to PPC64 Book-3S machines
    powerpc: Limit hugetlbfs support to PPC64 Book-3S machines
    powerpc: Fix compile errors found by new ppc64e_defconfig
    powerpc: Add a Book-3E 64-bit defconfig
    powerpc/booke: Fix xmon single step on PowerPC Book-E
    powerpc: Align vDSO base address
    powerpc: Fix segment mapping in vdso32
    powerpc/iseries: Remove compiler version dependent hack
    powerpc/perf_events: Fix priority of MSR HV vs PR bits
    powerpc/5200: Update defconfigs
    drivers/serial/mpc52xx_uart.c: Use UPIO_MEM rather than SERIAL_IO_MEM
    powerpc/boot/dts: drop obsolete 'fsl5200-clocking'
    of: Remove nested function
    mpc5200: support for the MAN mpc5200 based board mucmc52
    mpc5200: support for the MAN mpc5200 based board uc101

    Linus Torvalds
     
  • * 'hwpoison-2.6.32' of git://git.kernel.org/pub/scm/linux/kernel/git/ak/linux-mce-2.6:
    HWPOISON: fix invalid page count in printk output
    HWPOISON: Allow schedule_on_each_cpu() from keventd
    HWPOISON: fix/proc/meminfo alignment
    HWPOISON: fix oops on ksm pages
    HWPOISON: Fix page count leak in hwpoison late kill in do_swap_page
    HWPOISON: return early on non-LRU pages
    HWPOISON: Add brief hwpoison description to Documentation
    HWPOISON: Clean up PR_MCE_KILL interface

    Linus Torvalds
     
  • There are some places where we do like:

    pte = pte_map();
    do {
    (do break in some conditions)
    } while (pte++, ...);
    pte_unmap(pte - 1);

    But if the loop breaks at the first loop, pte_unmap() unmaps invalid pte.

    This patch is a fix for this problem.

    Signed-off-by: Daisuke Nishimura
    Reviewd-by: KAMEZAWA Hiroyuki
    Acked-by: Hugh Dickins
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Daisuke Nishimura
     
  • Currently, sparsemem is only available if EXPERIMENTAL is enabled.
    However, it hasn't ever been marked experimental.

    It's been about four years since sparsemem was merged, and we have
    platforms which depend on it; allow architectures to decide whether
    sparsemem should be the default memory model.

    Signed-off-by: Russell King
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Russell King
     
  • Isolators putting a page back to the LRU do not hold the page lock, and if
    the page is mlocked, another thread might munlock it concurrently.

    Expecting this, the putback code re-checks the evictability of a page when
    it just moved it to the unevictable list in order to correct its decision.

    The problem, however, is that ordering is not garuanteed between setting
    PG_lru when moving the page to the list and checking PG_mlocked
    afterwards:

    #0: #1

    spin_lock()
    if (TestClearPageMlocked())
    if (PageLRU())
    move to evictable list
    SetPageLRU()
    spin_unlock()
    if (!PageMlocked())
    move to evictable list

    The PageMlocked() check may get reordered before SetPageLRU() in #0,
    resulting in #0 not moving the still mlocked page, and in #1 failing to
    isolate and move the page as well. The page is now stranded on the
    unevictable list.

    The race condition is very unlikely. The consequence currently is one
    page falling off the reclaim grid and eventually getting freed with
    PG_unevictable set, which triggers a warning in the page allocator.

    TestClearPageMlocked() in #1 already provides full memory barrier
    semantics.

    This patch adds an explicit full barrier to force ordering between
    SetPageLRU() and PageMlocked() so that either one of the competitors
    rescues the page.

    Signed-off-by: Johannes Weiner
    Reviewed-by: KOSAKI Motohiro
    Cc: Hugh Dickins
    Cc: Mel Gorman
    Cc: Lee Schermerhorn
    Cc: Peter Zijlstra
    Reviewed-by: Rik van Riel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Johannes Weiner
     
  • If migrate_prep is failed, new variable is leaked. This patch fixes it.

    Signed-off-by: KOSAKI Motohiro
    Acked-by: Christoph Lameter
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • If mbind() receives an invalid address, do_mbind leaks a page. The
    following test program detects this leak.

    This patch fixes it.

    migrate_efault.c
    =======================================
    #include
    #include
    #include
    #include
    #include
    #include
    #include

    static unsigned long pagesize;

    static void* make_hole_mapping(void)
    {

    void* addr;

    addr = mmap(NULL, pagesize*3, PROT_READ|PROT_WRITE,
    MAP_ANON|MAP_PRIVATE, 0, 0);
    if (addr == MAP_FAILED)
    return NULL;

    /* make page populate */
    memset(addr, 0, pagesize*3);

    /* make memory hole */
    munmap(addr+pagesize, pagesize);

    return addr;
    }

    int main(int argc, char** argv)
    {
    void* addr;
    int ch;
    int node;
    struct bitmask *nmask = numa_allocate_nodemask();
    int err;
    int node_set = 0;

    while ((ch = getopt(argc, argv, "n:")) != -1){
    switch (ch){
    case 'n':
    node = strtol(optarg, NULL, 0);
    numa_bitmask_setbit(nmask, node);
    node_set = 1;
    break;
    default:
    ;
    }
    }
    argc -= optind;
    argv += optind;

    if (!node_set)
    numa_bitmask_setbit(nmask, 0);

    pagesize = getpagesize();

    addr = make_hole_mapping();

    err = mbind(addr, pagesize*3, MPOL_BIND, nmask->maskp, nmask->size, MPOL_MF_MOVE_ALL);
    if (err)
    perror("mbind ");

    return 0;
    }
    =======================================

    Signed-off-by: KOSAKI Motohiro
    Acked-by: Christoph Lameter
    Cc:
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • It is possible to have !Anon but SwapBacked pages, and some apps could
    create huge number of such pages with MAP_SHARED|MAP_ANONYMOUS. These
    pages go into the ANON lru list, and hence shall not be protected: we only
    care mapped executable files. Failing to do so may trigger OOM.

    Tested-by: Christian Borntraeger
    Reviewed-by: Rik van Riel
    Signed-off-by: Wu Fengguang
    Cc: Hugh Dickins
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Wu Fengguang
     
  • Revert

    commit 71de1ccbe1fb40203edd3beb473f8580d917d2ca
    Author: KOSAKI Motohiro
    AuthorDate: Mon Sep 21 17:01:31 2009 -0700
    Commit: Linus Torvalds
    CommitDate: Tue Sep 22 07:17:27 2009 -0700

    mm: oom analysis: add buffer cache information to show_free_areas()

    show_free_areas() is called during page allocation failures, and page
    allocation failures can occur in any calling context.

    But nr_blockdev_pages() takes VFS locks which should not be taken from
    hard IRQ context (at least). The result is lockdep warnings (and
    deadlockability) during page allocation failures.

    Cc: KOSAKI Motohiro
    Cc: Wu Fengguang
    Cc: Rik van Riel
    Cc: David Rientjes
    Cc: Alexey Dobriyan
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Andrew Morton
     
  • commit 8aa7e847d (Fix congestion_wait() sync/async vs read/write
    confusion) replace WRITE with BLK_RW_ASYNC. Unfortunately, concurrent mm
    development made the unchanged place accidentally.

    This patch fixes it too.

    Signed-off-by: KOSAKI Motohiro
    Acked-by: Jens Axboe
    Acked-by: Rik van Riel
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    KOSAKI Motohiro
     
  • Memory failure on a KSM page currently oopses on its NULL anon_vma in
    page_lock_anon_vma(): that may not be much worse than the consequence of
    ignoring it, but it is better to be consistent with how ZERO_PAGE and
    hugetlb pages and other awkward cases are treated. Just skip it.

    We could fix it for 2.6.32 at the KSM end, by putting a dummy anon_vma
    pointer in there; but that would get harder next time, when KSM will put a
    pointer to something else there (and I'm not currently planning to do any
    work to open that up to memory_failure). So I would prefer this simple
    PageKsm test, until the other exceptions are handled.

    Signed-off-by: Hugh Dickins
    Cc: Andi Kleen
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Hugh Dickins
     
  • When the bdi is being removed, we have to ensure that no super_blocks
    currently have that cached in sb->s_bdi. Normally this is ensured by
    the sb having a longer life span than the bdi, but if the device is
    suddenly yanked, we have to kill this reference. sb->s_bdi is pointed
    to freed memory at that point.

    This fixes a problem with sync(1) hanging when a USB stick is pulled
    without cleanly umounting it first.

    Reported-by: Pavel Machek
    Signed-off-by: Jens Axboe

    Jens Axboe
     

28 Oct, 2009

1 commit

  • pcpu_alloc() and pcpu_extend_area_map() perform a series of
    spin_lock_irq()/spin_unlock_irq() calls, which make them unsafe
    with respect to being called from contexts which have IRQs off.

    This patch converts the code to perform save/restore of flags instead,
    making pcpu_alloc() (or __alloc_percpu() respectively) to be called
    from early kernel startup stage, where IRQs are off.

    This is needed for proper initialization of per-cpu rq_weight data from
    sched_init().

    tj: added comment explaining why irqsave/restore is used in alloc path.

    Signed-off-by: Jiri Kosina
    Acked-by: Ingo Molnar
    Signed-off-by: Tejun Heo

    Jiri Kosina
     

27 Oct, 2009

1 commit


19 Oct, 2009

4 commits

  • The madvise injector already holds a reference when passing in a page
    to the memory-failure code. The code corrects for this additional reference
    for its checks, but the final printk output didn't. Fix that.

    Signed-off-by: Wu Fengguang
    Signed-off-by: Andi Kleen

    Wu Fengguang
     
  • Memory failure on a KSM page currently oopses on its NULL anon_vma in
    page_lock_anon_vma(): that may not be much worse than the consequence
    of ignoring it, but it is better to be consistent with how ZERO_PAGE
    and hugetlb pages and other awkward cases are treated. Just skip it.

    Signed-off-by: Hugh Dickins
    Signed-off-by: Andi Kleen

    Hugh Dickins
     
  • When returning due to a poisoned page drop the page count.

    It wasn't a fatal problem because noone cares about the page count
    on a poisoned page (except when it wraps), but it's cleaner to fix it.

    Pointed out by Linus.

    Signed-off-by: Andi Kleen

    Andi Kleen
     
  • Right now we have some trouble with non atomic access
    to page flags when locking the page. To plug this hole
    for now, limit error recovery to LRU pages for now.

    This could be better fixed by defining a suitable protocol,
    but let's go this simple way for now

    This avoids unnecessary races with __set_page_locked() and
    __SetPageSlab*() and maybe more non-atomic page flag operations.

    This loses isolated pages which are currently in page reclaim, but these
    are relatively limited compared to the total memory.

    Signed-off-by: Wu Fengguang
    Signed-off-by: Andi Kleen
    [AK: new description, bug fixes, cleanups]

    Wu Fengguang
     

14 Oct, 2009

2 commits

  • * 'for-linus' of git://git.kernel.dk/linux-2.6-block:
    cciss: Add cciss_allow_hpsa module parameter
    cciss: Fix multiple calls to pci_release_regions
    blk-settings: fix function parameter kernel-doc notation
    writeback: kill space in debugfs item name
    writeback: account IO throttling wait as iowait
    elv_iosched_store(): fix strstrip() misuse
    cfq-iosched: avoid probable slice overrun when idling
    cfq-iosched: apply bool value where we return 0/1
    cfq-iosched: fix think time allowed for seekers
    cfq-iosched: fix the slice residual sign
    cfq-iosched: abstract out the 'may this cfqq dispatch' logic
    block: use proper BLK_RW_ASYNC in blk_queue_start_tag()
    block: Seperate read and write statistics of in_flight requests v2
    block: get rid of kblock_schedule_delayed_work()
    cfq-iosched: fix possible problem with jiffies wraparound
    cfq-iosched: fix issue with rq-rq merging and fifo list ordering

    Linus Torvalds
     
  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/percpu:
    percpu: fix compile warnings

    Linus Torvalds
     

12 Oct, 2009

2 commits

  • Fix the following two compile warnings which show up on i386.

    mm/percpu.c:1873: warning: comparison of distinct pointer types lacks a cast
    mm/percpu.c:1879: warning: format '%lx' expects type 'long unsigned int', but argument 2 has type 'size_t'

    Signed-off-by: Tejun Heo
    Reported-by: Randy Dunlap

    Tejun Heo
     
  • After m68k's task_thread_info() doesn't refer to current,
    it's possible to remove sched.h from interrupt.h and not break m68k!
    Many thanks to Heiko Carstens for allowing this.

    Signed-off-by: Alexey Dobriyan

    Alexey Dobriyan
     

10 Oct, 2009

1 commit