Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 177626
b: refs/heads/master
c: 7c116f2
h: refs/heads/master
v: v3
  • Loading branch information
Wu Fengguang authored and Andi Kleen committed Dec 16, 2009
1 parent cac2a11 commit 4a3367a
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 1 deletion.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 138ce286eb6ee6d39ca4fb50516e93adaf6b605f
refs/heads/master: 7c116f2b0dbac4a1dd051c7a5e8cef37701cafd4
7 changes: 7 additions & 0 deletions trunk/Documentation/vm/hwpoison.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,13 @@ memory failures.
Note these injection interfaces are not stable and might change between
kernel versions

corrupt-filter-dev-major
corrupt-filter-dev-minor

Only handle memory failures to pages associated with the file system defined
by block device major/minor. -1U is the wildcard value.
This should be only used for testing with artificial injection.

Architecture specific MCE injector

x86 has mce-inject, mce-test
Expand Down
11 changes: 11 additions & 0 deletions trunk/mm/hwpoison-inject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <linux/debugfs.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include "internal.h"

static struct dentry *hwpoison_dir;

Expand Down Expand Up @@ -54,6 +55,16 @@ static int pfn_inject_init(void)
if (!dentry)
goto fail;

dentry = debugfs_create_u32("corrupt-filter-dev-major", 0600,
hwpoison_dir, &hwpoison_filter_dev_major);
if (!dentry)
goto fail;

dentry = debugfs_create_u32("corrupt-filter-dev-minor", 0600,
hwpoison_dir, &hwpoison_filter_dev_minor);
if (!dentry)
goto fail;

return 0;
fail:
pfn_inject_exit();
Expand Down
3 changes: 3 additions & 0 deletions trunk/mm/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -250,3 +250,6 @@ int __get_user_pages(struct task_struct *tsk, struct mm_struct *mm,
#define ZONE_RECLAIM_SOME 0
#define ZONE_RECLAIM_SUCCESS 1
#endif

extern u32 hwpoison_filter_dev_major;
extern u32 hwpoison_filter_dev_minor;
51 changes: 51 additions & 0 deletions trunk/mm/memory-failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,50 @@ int sysctl_memory_failure_recovery __read_mostly = 1;

atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);

u32 hwpoison_filter_dev_major = ~0U;
u32 hwpoison_filter_dev_minor = ~0U;
EXPORT_SYMBOL_GPL(hwpoison_filter_dev_major);
EXPORT_SYMBOL_GPL(hwpoison_filter_dev_minor);

static int hwpoison_filter_dev(struct page *p)
{
struct address_space *mapping;
dev_t dev;

if (hwpoison_filter_dev_major == ~0U &&
hwpoison_filter_dev_minor == ~0U)
return 0;

/*
* page_mapping() does not accept slab page
*/
if (PageSlab(p))
return -EINVAL;

mapping = page_mapping(p);
if (mapping == NULL || mapping->host == NULL)
return -EINVAL;

dev = mapping->host->i_sb->s_dev;
if (hwpoison_filter_dev_major != ~0U &&
hwpoison_filter_dev_major != MAJOR(dev))
return -EINVAL;
if (hwpoison_filter_dev_minor != ~0U &&
hwpoison_filter_dev_minor != MINOR(dev))
return -EINVAL;

return 0;
}

int hwpoison_filter(struct page *p)
{
if (hwpoison_filter_dev(p))
return -EINVAL;

return 0;
}
EXPORT_SYMBOL_GPL(hwpoison_filter);

/*
* Send all the processes who have the page mapped an ``action optional''
* signal.
Expand Down Expand Up @@ -843,6 +887,13 @@ int __memory_failure(unsigned long pfn, int trapno, int flags)
res = 0;
goto out;
}
if (hwpoison_filter(p)) {
if (TestClearPageHWPoison(p))
atomic_long_dec(&mce_bad_pages);
unlock_page(p);
put_page(p);
return 0;
}

wait_on_page_writeback(p);

Expand Down

0 comments on commit 4a3367a

Please sign in to comment.