lkml.org 
[lkml]   [2009]   [May]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH] [6/16] HWPOISON: Add basic support for poisoned pages in fault handler v2
    Date

    - Add a new VM_FAULT_HWPOISON error code to handle_mm_fault. Right now
    architectures have to explicitely enable poison page support, so
    this is forward compatible to all architectures. They only need
    to add it when they enable poison page support.
    - Add poison page handling in swap in fault code

    v2: Add missing delayacct_clear_flag (Hidehiro Kawai)

    Signed-off-by: Andi Kleen <ak@linux.intel.com>

    ---
    include/linux/mm.h | 3 ++-
    mm/memory.c | 18 +++++++++++++++---
    2 files changed, 17 insertions(+), 4 deletions(-)

    Index: linux/mm/memory.c
    ===================================================================
    --- linux.orig/mm/memory.c 2009-05-27 21:13:54.000000000 +0200
    +++ linux/mm/memory.c 2009-05-27 21:19:19.000000000 +0200
    @@ -1315,7 +1315,8 @@
    if (ret & VM_FAULT_ERROR) {
    if (ret & VM_FAULT_OOM)
    return i ? i : -ENOMEM;
    - else if (ret & VM_FAULT_SIGBUS)
    + if (ret &
    + (VM_FAULT_HWPOISON|VM_FAULT_SIGBUS))
    return i ? i : -EFAULT;
    BUG();
    }
    @@ -2459,8 +2460,15 @@
    goto out;

    entry = pte_to_swp_entry(orig_pte);
    - if (is_migration_entry(entry)) {
    - migration_entry_wait(mm, pmd, address);
    + if (unlikely(non_swap_entry(entry))) {
    + if (is_migration_entry(entry)) {
    + migration_entry_wait(mm, pmd, address);
    + } else if (is_hwpoison_entry(entry)) {
    + ret = VM_FAULT_HWPOISON;
    + } else {
    + print_bad_pte(vma, address, pte, NULL);
    + ret = VM_FAULT_OOM;
    + }
    goto out;
    }
    delayacct_set_flag(DELAYACCT_PF_SWAPIN);
    @@ -2484,6 +2492,10 @@
    /* Had to read the page from swap area: Major fault */
    ret = VM_FAULT_MAJOR;
    count_vm_event(PGMAJFAULT);
    + } else if (PageHWPoison(page)) {
    + ret = VM_FAULT_HWPOISON;
    + delayacct_set_flag(DELAYACCT_PF_SWAPIN);
    + goto out;
    }

    lock_page(page);
    Index: linux/include/linux/mm.h
    ===================================================================
    --- linux.orig/include/linux/mm.h 2009-05-27 21:13:54.000000000 +0200
    +++ linux/include/linux/mm.h 2009-05-27 21:19:18.000000000 +0200
    @@ -702,11 +702,12 @@
    #define VM_FAULT_SIGBUS 0x0002
    #define VM_FAULT_MAJOR 0x0004
    #define VM_FAULT_WRITE 0x0008 /* Special case for get_user_pages */
    +#define VM_FAULT_HWPOISON 0x0010 /* Hit poisoned page */

    #define VM_FAULT_NOPAGE 0x0100 /* ->fault installed the pte, not return page */
    #define VM_FAULT_LOCKED 0x0200 /* ->fault locked the returned page */

    -#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS)
    +#define VM_FAULT_ERROR (VM_FAULT_OOM | VM_FAULT_SIGBUS | VM_FAULT_HWPOISON)

    /*
    * Can be called by the pagefault handler when it gets a VM_FAULT_OOM.

    \
     
     \ /
      Last update: 2009-05-27 22:19    [W:4.072 / U:0.036 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site