16 Dec, 2009

40 commits

  • This is a simpler, gentler variant of memory_failure() for soft page
    offlining controlled from user space. It doesn't kill anything, just
    tries to invalidate and if that doesn't work migrate the
    page away.

    This is useful for predictive failure analysis, where a page has
    a high rate of corrected errors, but hasn't gone bad yet. Instead
    it can be offlined early and avoided.

    The offlining is controlled from sysfs, including a new generic
    entry point for hard page offlining for symmetry too.

    We use the page isolate facility to prevent re-allocation
    race. Normally this is only used by memory hotplug. To avoid
    races with memory allocation I am using lock_system_sleep().
    This avoids the situation where memory hotplug is about
    to isolate a page range and then hwpoison undoes that work.
    This is a big hammer currently, but the simplest solution
    currently.

    When the page is not free or LRU we try to free pages
    from slab and other caches. The slab freeing is currently
    quite dumb and does not try to focus on the specific slab
    cache which might own the page. This could be potentially
    improved later.

    Thanks to Fengguang Wu and Haicheng Li for some fixes.

    [Added fix from Andrew Morton to adapt to new migrate_pages prototype]
    Signed-off-by: Andi Kleen

    Andi Kleen
     
  • Signed-off-by: Andi Kleen

    Andi Kleen
     
  • shake_page handles more types of page caches than
    the much simpler lru_add_drain_all:

    - slab (quite inefficiently for now)
    - any other caches with a shrinker callback
    - per cpu page allocator pages
    - per CPU LRU

    Use this call to try to turn pages into free or LRU pages.
    Then handle the case of the page becoming free after drain everything.

    Signed-off-by: Andi Kleen

    Andi Kleen
     
  • Signed-off-by: Andi Kleen

    Andi Kleen
     
  • Signed-off-by: Andi Kleen

    Andi Kleen
     
  • The previous version didn't take the mmap_sem before calling gup(),
    which is racy.

    Use get_user_pages_fast() instead which doesn't need any locks.
    This is also faster of course, but then it doesn't really matter
    because this is just a testing path.

    Based on report from Nick Piggin.
    Cc: npiggin@suse.de

    Signed-off-by: Andi Kleen

    Andi Kleen
     
  • In some use cases, user doesn't need extra filtering. E.g. user program
    can inject errors through madvise syscall to its own pages, however it
    might not know what the page state exactly is or which inode the page
    belongs to.

    So introduce an one-off interface "corrupt-filter-enable".

    Echo 0 to switch off page filters, and echo 1 to switch on the filters.
    [AK: changed default to 0]

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

    Haicheng Li
     
  • The hwpoison test suite need to inject hwpoison to a collection of
    selected task pages, and must not touch pages not owned by them and
    thus kill important system processes such as init. (But it's OK to
    mis-hwpoison free/unowned pages as well as shared clean pages.
    Mis-hwpoison of shared dirty pages will kill all tasks, so the test
    suite will target all or non of such tasks in the first place.)

    The memory cgroup serves this purpose well. We can put the target
    processes under the control of a memory cgroup, and tell the hwpoison
    injection code to only kill pages associated with some active memory
    cgroup.

    The prerequisite for doing hwpoison stress tests with mem_cgroup is,
    the mem_cgroup code tracks task pages _accurately_ (unless page is
    locked). Which we believe is/should be true.

    The benefits are simplification of hwpoison injector code. Also the
    mem_cgroup code will automatically be tested by hwpoison test cases.

    The alternative interfaces pin-pfn/unpin-pfn can also delegate the
    (process and page flags) filtering functions reliably to user space.
    However prototype implementation shows that this scheme adds more
    complexity than we wanted.

    Example test case:

    mkdir /cgroup/hwpoison

    usemem -m 100 -s 1000 &
    echo `jobs -p` > /cgroup/hwpoison/tasks

    memcg_ino=$(ls -id /cgroup/hwpoison | cut -f1 -d' ')
    echo $memcg_ino > /debug/hwpoison/corrupt-filter-memcg

    page-types -p `pidof init` --hwpoison # shall do nothing
    page-types -p `pidof usemem` --hwpoison # poison its pages

    [AK: Fix documentation]
    [Add fix for problem noticed by Li Zefan ;
    dentry in the css could be NULL]

    CC: KOSAKI Motohiro
    CC: Hugh Dickins
    CC: Daisuke Nishimura
    CC: Balbir Singh
    CC: KAMEZAWA Hiroyuki
    CC: Li Zefan
    CC: Paul Menage
    CC: Nick Piggin
    CC: Andi Kleen
    Signed-off-by: Wu Fengguang
    Signed-off-by: Andi Kleen

    Andi Kleen
     
  • So that an outside user can free the reference count grabbed by
    try_get_mem_cgroup_from_page().

    CC: KOSAKI Motohiro
    CC: Hugh Dickins
    CC: Daisuke Nishimura
    CC: Balbir Singh
    Acked-by: KAMEZAWA Hiroyuki
    Signed-off-by: Wu Fengguang
    Signed-off-by: Andi Kleen

    Wu Fengguang
     
  • So that the hwpoison injector can get mem_cgroup for arbitrary page
    and thus know whether it is owned by some mem_cgroup task(s).

    [AK: Merged with latest git tree]

    CC: KOSAKI Motohiro
    CC: Hugh Dickins
    CC: Daisuke Nishimura
    CC: Balbir Singh
    Acked-by: KAMEZAWA Hiroyuki
    Signed-off-by: Wu Fengguang
    Signed-off-by: Andi Kleen

    Wu Fengguang
     
  • When specified, only poison pages if ((page_flags & mask) == value).

    - corrupt-filter-flags-mask
    - corrupt-filter-flags-value

    This allows stress testing of many kinds of pages.

    Strictly speaking, the buddy pages requires taking zone lock, to avoid
    setting PG_hwpoison on a "was buddy but now allocated to someone" page.
    However we can just do nothing because we set PG_locked in the beginning,
    this prevents the page allocator from allocating it to someone. (It will
    BUG() on the unexpected PG_locked, which is fine for hwpoison testing.)

    [AK: Add select PROC_PAGE_MONITOR to satisfy dependency]

    CC: Nick Piggin
    Signed-off-by: Wu Fengguang
    Signed-off-by: Andi Kleen

    Wu Fengguang
     
  • Rename get_uflags() to stable_page_flags() and make it a global function
    for use in the hwpoison page flags filter, which need to compare user
    page flags with the value provided by user space.

    Also move KPF_* to kernel-page-flags.h for use by user space tools.

    Acked-by: Matt Mackall
    Signed-off-by: Andi Kleen
    CC: Nick Piggin
    CC: Christoph Lameter
    Signed-off-by: Wu Fengguang
    Signed-off-by: Andi Kleen

    Wu Fengguang
     
  • __memory_failure()'s workflow is

    set PG_hwpoison
    //...
    unset PG_hwpoison if didn't pass hwpoison filter

    That could kill unrelated process if it happens to page fault on the
    page with the (temporary) PG_hwpoison. The race should be big enough to
    appear in stress tests.

    Fix it by grabbing the page and checking filter at inject time. This
    also avoids the very noisy "Injecting memory failure..." messages.

    - we don't touch madvise() based injection, because the filters are
    generally not necessary for it.
    - if we want to apply the filters to h/w aided injection, we'd better to
    rearrange the logic in __memory_failure() instead of this patch.

    AK: fix documentation, use drain all, cleanups

    CC: Haicheng Li
    Signed-off-by: Wu Fengguang
    Signed-off-by: Andi Kleen

    Wu Fengguang
     
  • Filesystem data/metadata present the most tricky-to-isolate pages.
    It requires careful code review and stress testing to get them right.

    The fs/device filter helps to target the stress tests to some specific
    filesystem pages. The filter condition is block device's major/minor
    numbers:
    - corrupt-filter-dev-major
    - corrupt-filter-dev-minor
    When specified (non -1), only page cache pages that belong to that
    device will be poisoned.

    The filters are checked reliably on the locked and refcounted page.

    Haicheng: clear PG_hwpoison and drop bad page count if filter not OK
    AK: Add documentation

    CC: Haicheng Li
    CC: Nick Piggin
    Signed-off-by: Wu Fengguang
    Signed-off-by: Andi Kleen

    Wu Fengguang
     
  • Return 0 to indicate success, when
    - action result is RECOVERED or DELAYED
    - no extra page reference

    Note that dirty swapcache pages are kept in swapcache, so can have one
    more reference count.

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

    Wu Fengguang
     
  • Change semantics for
    - IGNORED: not handled; it may well be _unsafe_
    - DELAYED: to be handled later; it is _safe_

    With this change,
    - IGNORED/FAILED mean (maybe) Error
    - DELAYED/RECOVERED mean Success

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

    Wu Fengguang
     
  • The unpoisoning interface is useful for stress testing tools to
    reclaim poisoned pages (to prevent OOM)

    There is no hardware level unpoisioning, so this
    cannot be used for real memory errors, only for software injected errors.

    Note that it may leak pages silently - those who have been removed from
    LRU cache, but not isolated from page cache/swap cache at hwpoison time.
    Especially the stress test of dirty swap cache pages shall reboot system
    before exhausting memory.

    AK: Fix comments, add documentation, add printks, rename symbol

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

    Wu Fengguang
     
  • Most free pages in the buddy system have no PG_buddy set.
    Introduce is_free_buddy_page() for detecting them reliably.

    CC: Nick Piggin
    CC: Mel Gorman
    Signed-off-by: Wu Fengguang
    Signed-off-by: Andi Kleen

    Wu Fengguang
     
  • The buddy page has already be handled in the very beginning.
    So remove redundant code.

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

    Wu Fengguang
     
  • Introduce delete_from_lru_cache() to
    - clear PG_active, PG_unevictable to avoid complains at unpoison time
    - move the isolate_lru_page() call back to the handlers instead of the
    entrance of __memory_failure(), this is more hwpoison filter friendly

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

    Wu Fengguang
     
  • AK: Improve comment

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

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

    Wu Fengguang
     
  • Don't try to isolate a still mapped page. Otherwise we will hit the
    BUG_ON(page_mapped(page)) in __remove_from_page_cache().

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

    Wu Fengguang
     
  • Now that "ref" is just a boolean turn it into
    a flags argument. First step is only a single flag
    that makes the code's intention more clear, but more
    may follow.

    Signed-off-by: Andi Kleen

    Andi Kleen
     
  • If page is double referenced in madvise_hwpoison() and __memory_failure(),
    remove_mapping() will fail because it expects page_count=2. Fix it by
    not grabbing extra page count in __memory_failure().

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

    Wu Fengguang
     
  • Use a different errno than the usual EIO for invalid page numbers.
    This is mainly for better reporting for the injector.

    This also avoids calling action_result() with invalid pfn.

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

    Wu Fengguang
     
  • (PG_swapbacked && !PG_lru) pages should not happen.
    Better to treat them as unknown pages.

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

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

    Wu Fengguang
     
  • shake_page handles more types of page caches than lru_drain_all()

    - per cpu page allocator pages
    - per CPU LRU

    Stops early when the page became free.

    Used in followon patches.

    Signed-off-by: Andi Kleen

    Andi Kleen
     
  • Signed-off-by: Andi Kleen

    Andi Kleen
     
  • Caused by commit 0b83ddebc6e884dc0221358cf68c461520fbdd8e ("MFD:
    twl4030: add twl4030_codec MFD as a new child to the core") interacting
    with commit b07682b6056eb6701f8cb86aa5800e6f2ea7919b ("mfd: Rename
    twl4030* driver files to enable re-use").

    This file seems to have been missed in the renaming.

    Signed-off-by: Stephen Rothwell
    Acked-by: Peter Ujfalusi
    Acked-by: Mark Brown
    Acked-by: Tony Lindgren
    Signed-off-by: Linus Torvalds

    Stephen Rothwell
     
  • * 'for-linus' of git://oss.sgi.com/xfs/xfs:
    xfs: event tracing support
    xfs: change the xfs_iext_insert / xfs_iext_remove
    xfs: cleanup bmap extent state macros

    Linus Torvalds
     
  • * git://git.kernel.org/pub/scm/linux/kernel/git/agk/linux-2.6-dm: (80 commits)
    dm snapshot: use merge origin if snapshot invalid
    dm snapshot: report merge failure in status
    dm snapshot: merge consecutive chunks together
    dm snapshot: trigger exceptions in remaining snapshots during merge
    dm snapshot: delay merging a chunk until writes to it complete
    dm snapshot: queue writes to chunks being merged
    dm snapshot: add merging
    dm snapshot: permit only one merge at once
    dm snapshot: support barriers in snapshot merge target
    dm snapshot: avoid allocating exceptions in merge
    dm snapshot: rework writing to origin
    dm snapshot: add merge target
    dm exception store: add merge specific methods
    dm snapshot: create function for chunk_is_tracked wait
    dm snapshot: make bio optional in __origin_write
    dm mpath: reject messages when device is suspended
    dm: export suspended state to targets
    dm: rename dm_suspended to dm_suspended_md
    dm: swap target postsuspend call and setting suspended flag
    dm crypt: add plain64 iv
    ...

    Linus Torvalds
     
  • * 'for-2.6.33' of git://git.kernel.dk/linux-2.6-block:
    cfq: set workload as expired if it doesn't have any slice left
    Fix a CFQ crash in "for-2.6.33" branch of block tree
    cfq: Remove wait_request flag when idle time is being deleted
    cfq-iosched: commenting non-obvious initialization
    cfq-iosched: Take care of corner cases of group losing share due to deletion
    cfq-iosched: Get rid of cfqq wait_busy_done flag
    cfq: Optimization for close cooperating queue searching
    block,xd: Delay allocation of DMA buffers until device is known
    drbd: Following the hmac change to SHASH (see linux commit 8bd1209cfff)
    cfq-iosched: reduce write depth only if sync was delayed

    Linus Torvalds
     
  • * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound-2.6:
    ALSA: ac97_codec - increase timeout for analog sections to 5 second
    ASoC: Correct code taking the size of a pointer
    ALSA: hda - Add PCI IDs for Nvidia G2xx-series
    ALSA: sound/isa/gus: Correct code taking the size of a pointer
    ALSA: hda: Fix max PCM level to 0 dB for AD1981_HP
    ALSA: hda: Use ALC260_WILL quirk for another Acer model (0x1025007f)

    Linus Torvalds
     
  • …el/git/tip/linux-2.6-tip

    * 'core-locking-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (26 commits)
    clockevents: Convert to raw_spinlock
    clockevents: Make tick_device_lock static
    debugobjects: Convert to raw_spinlocks
    perf_event: Convert to raw_spinlock
    hrtimers: Convert to raw_spinlocks
    genirq: Convert irq_desc.lock to raw_spinlock
    smp: Convert smplocks to raw_spinlocks
    rtmutes: Convert rtmutex.lock to raw_spinlock
    sched: Convert pi_lock to raw_spinlock
    sched: Convert cpupri lock to raw_spinlock
    sched: Convert rt_runtime_lock to raw_spinlock
    sched: Convert rq->lock to raw_spinlock
    plist: Make plist debugging raw_spinlock aware
    bkl: Fixup core_lock fallout
    locking: Cleanup the name space completely
    locking: Further name space cleanups
    alpha: Fix fallout from locking changes
    locking: Implement new raw_spinlock
    locking: Convert raw_rwlock functions to arch_rwlock
    locking: Convert raw_rwlock to arch_rwlock
    ...

    Linus Torvalds
     
  • * git://git.kernel.org/pub/scm/linux/kernel/git/hskinnemoen/avr32-2.6:
    avr32: update default configurations for ATNGW100, ATSTK1002 and ATSTK1006
    avr32: add default configurations for ATNGW100 mkII and EVKLCD10X
    avr32: add support for ATNGW100 mkII board
    avr32: convert to asm-generic/hardirq.h
    avr32: add two new at91 to cpu.h definition
    avr32: clean up linker script using standard macros.
    avr32: MRMT: correct setup of SPI slaves
    avr32: function for independently setting up SPI slaves
    avr32: re-instate MCI WP/CD pin assignments for ATNGW100

    Linus Torvalds
     
  • * git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6:
    sparc64: Fix clock event multiplier printf format.
    sparc64: Use clock{source,events}_calc_mult_shift().
    sparc64: Use free_bootmem_late() in mdesc_lmb_free().
    sparc: Add alignment and emulation fault perf events.
    sparc64: Add syscall tracepoint support.
    sparc: Stop trying to be so fancy and use __builtin_{memcpy,memset}()
    sparc: Use __builtin_object_size() to validate the buffer size for copy_from_user()
    sparc64: Add some missing __kprobes annotations to kernel fault paths.
    sparc64: Use kprobes_built_in() to avoid ifdefs in fault_64.c
    sparc: Validate that kprobe address is 4-byte aligned.
    sparc64: Don't specify IRQF_SHARED for LDC interrupts.
    sparc64: Fix stack debugging IRQ stack regression.
    sparc64: Fix overly strict range type matching for PCI devices.

    Linus Torvalds
     
  • * git://git.infradead.org/battery-2.6:
    power_supply_sysfs: Handle -ENODATA in a special way
    wm831x_backup: Remove unused variables
    gta02: Set pcf50633 charger_reference_current_ma
    pcf50633: Query charger status directly
    pcf50633: Properly reenable charging when the supply conditions change
    pcf50633: Get rid of charging restart software auto-triggering
    pcf50633: introduces battery charging current control
    pcf50633: Add ac power supply class to the charger
    wm831x: Factor out WM831x backup battery charger

    Linus Torvalds
     
  • * git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb-2.6:
    USB: Close usb_find_interface race v3
    Revert "USB: Close usb_find_interface race"

    Linus Torvalds