From: Wu Fengguang <fengguang.wu@intel.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Haicheng Li <haicheng.li@intel.com>,
Nick Piggin <npiggin@suse.de>,
Wu Fengguang <fengguang.wu@intel.com>
Cc: <linux-mm@kvack.org>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 15/24] HWPOISON: add fs/device filters
Date: Wed, 02 Dec 2009 11:12:46 +0800 [thread overview]
Message-ID: <20091202043045.535248130@intel.com> (raw)
In-Reply-To: 20091202031231.735876003@intel.com
[-- Attachment #1: hwpoison-filter-fs.patch --]
[-- Type: text/plain, Size: 3519 bytes --]
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
CC: Haicheng Li <haicheng.li@intel.com>
CC: Nick Piggin <npiggin@suse.de>
CC: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
mm/hwpoison-inject.c | 11 +++++++++
mm/internal.h | 3 ++
mm/memory-failure.c | 48 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 62 insertions(+)
--- linux-mm.orig/mm/memory-failure.c 2009-11-30 20:44:31.000000000 +0800
+++ linux-mm/mm/memory-failure.c 2009-11-30 20:51:22.000000000 +0800
@@ -48,6 +48,47 @@ int sysctl_memory_failure_recovery __rea
atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
+u32 hwpoison_filter_dev_major = ~0U;
+u32 hwpoison_filter_dev_minor = ~0U;
+
+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;
+}
+
/*
* Send all the processes who have the page mapped an ``action optional''
* signal.
@@ -849,6 +890,13 @@ int __memory_failure(unsigned long pfn,
action_result(&hpc, "unpoisoned", IGNORED);
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);
--- linux-mm.orig/mm/hwpoison-inject.c 2009-11-30 20:30:55.000000000 +0800
+++ linux-mm/mm/hwpoison-inject.c 2009-11-30 20:44:41.000000000 +0800
@@ -3,6 +3,7 @@
#include <linux/debugfs.h>
#include <linux/kernel.h>
#include <linux/mm.h>
+#include "internal.h"
static struct dentry *hwpoison_dir;
@@ -49,6 +50,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();
--- linux-mm.orig/mm/internal.h 2009-11-30 20:06:01.000000000 +0800
+++ linux-mm/mm/internal.h 2009-11-30 20:44:41.000000000 +0800
@@ -263,3 +263,6 @@ int __get_user_pages(struct task_struct
#define ZONE_RECLAIM_SOME 0
#define ZONE_RECLAIM_SUCCESS 1
#endif
+
+extern u32 hwpoison_filter_dev_major;
+extern u32 hwpoison_filter_dev_minor;
WARNING: multiple messages have this Message-ID (diff)
From: Wu Fengguang <fengguang.wu@intel.com>
To: Andi Kleen <andi@firstfloor.org>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Haicheng Li <haicheng.li@intel.com>,
Nick Piggin <npiggin@suse.de>,
Wu Fengguang <fengguang.wu@intel.com>,
linux-mm@kvack.org, LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH 15/24] HWPOISON: add fs/device filters
Date: Wed, 02 Dec 2009 11:12:46 +0800 [thread overview]
Message-ID: <20091202043045.535248130@intel.com> (raw)
In-Reply-To: 20091202031231.735876003@intel.com
[-- Attachment #1: hwpoison-filter-fs.patch --]
[-- Type: text/plain, Size: 3744 bytes --]
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
CC: Haicheng Li <haicheng.li@intel.com>
CC: Nick Piggin <npiggin@suse.de>
CC: Andi Kleen <andi@firstfloor.org>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
mm/hwpoison-inject.c | 11 +++++++++
mm/internal.h | 3 ++
mm/memory-failure.c | 48 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 62 insertions(+)
--- linux-mm.orig/mm/memory-failure.c 2009-11-30 20:44:31.000000000 +0800
+++ linux-mm/mm/memory-failure.c 2009-11-30 20:51:22.000000000 +0800
@@ -48,6 +48,47 @@ int sysctl_memory_failure_recovery __rea
atomic_long_t mce_bad_pages __read_mostly = ATOMIC_LONG_INIT(0);
+u32 hwpoison_filter_dev_major = ~0U;
+u32 hwpoison_filter_dev_minor = ~0U;
+
+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;
+}
+
/*
* Send all the processes who have the page mapped an ``action optional''
* signal.
@@ -849,6 +890,13 @@ int __memory_failure(unsigned long pfn,
action_result(&hpc, "unpoisoned", IGNORED);
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);
--- linux-mm.orig/mm/hwpoison-inject.c 2009-11-30 20:30:55.000000000 +0800
+++ linux-mm/mm/hwpoison-inject.c 2009-11-30 20:44:41.000000000 +0800
@@ -3,6 +3,7 @@
#include <linux/debugfs.h>
#include <linux/kernel.h>
#include <linux/mm.h>
+#include "internal.h"
static struct dentry *hwpoison_dir;
@@ -49,6 +50,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();
--- linux-mm.orig/mm/internal.h 2009-11-30 20:06:01.000000000 +0800
+++ linux-mm/mm/internal.h 2009-11-30 20:44:41.000000000 +0800
@@ -263,3 +263,6 @@ int __get_user_pages(struct task_struct
#define ZONE_RECLAIM_SOME 0
#define ZONE_RECLAIM_SUCCESS 1
#endif
+
+extern u32 hwpoison_filter_dev_major;
+extern u32 hwpoison_filter_dev_minor;
--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to majordomo@kvack.org. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>
next prev parent reply other threads:[~2009-12-02 4:39 UTC|newest]
Thread overview: 122+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-02 3:12 [PATCH 00/24] hwpoison fixes and stress testing filters Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 01/24] page-types: add standard GPL license head Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 13:08 ` Andi Kleen
2009-12-02 13:08 ` Andi Kleen
2009-12-02 3:12 ` [PATCH 02/24] migrate: page could be locked by hwpoison, dont BUG() Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 13:09 ` Andi Kleen
2009-12-02 13:09 ` Andi Kleen
2009-12-02 14:50 ` Christoph Lameter
2009-12-02 14:50 ` Christoph Lameter
2009-12-03 1:34 ` Wu Fengguang
2009-12-03 1:34 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 03/24] HWPOISON: remove the anonymous entry Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 04/24] HWPOISON: return ENXIO on invalid pfn Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 05/24] HWPOISON: avoid grabbing page for two times Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 06/24] HWPOISON: abort on failed unmap Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 13:11 ` Andi Kleen
2009-12-02 13:11 ` Andi Kleen
2009-12-02 13:28 ` Wu Fengguang
2009-12-02 13:28 ` Wu Fengguang
2009-12-02 13:44 ` Andi Kleen
2009-12-02 13:44 ` Andi Kleen
2009-12-02 3:12 ` [PATCH 07/24] HWPOISON: comment the possible set_page_dirty() race Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 08/24] HWPOISON: comment dirty swapcache pages Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 09/24] HWPOISON: introduce delete_from_lru_cache() Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 10/24] HWPOISON: remove the free buddy page handler Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 13:13 ` Andi Kleen
2009-12-02 13:13 ` Andi Kleen
2009-12-02 13:31 ` Wu Fengguang
2009-12-02 13:31 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 11/24] HWPOISON: detect free buddy pages explicitly Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 12/24] HWPOISON: make it possible to unpoison pages Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 13:15 ` Andi Kleen
2009-12-02 13:15 ` Andi Kleen
2009-12-02 13:31 ` Wu Fengguang
2009-12-02 13:31 ` Wu Fengguang
2009-12-02 13:46 ` Wu Fengguang
2009-12-02 13:46 ` Wu Fengguang
2009-12-02 14:03 ` Andi Kleen
2009-12-02 14:03 ` Andi Kleen
2009-12-03 1:45 ` Wu Fengguang
2009-12-03 1:45 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 13/24] HWPOISON: introduce struct hwpoison_control Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 13:15 ` Andi Kleen
2009-12-02 13:15 ` Andi Kleen
2009-12-02 3:12 ` [PATCH 14/24] HWPOISON: return 0 if page is assured to be isolated Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 12:47 ` Andi Kleen
2009-12-02 12:47 ` Andi Kleen
2009-12-02 13:15 ` Wu Fengguang
2009-12-02 13:15 ` Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang [this message]
2009-12-02 3:12 ` [PATCH 15/24] HWPOISON: add fs/device filters Wu Fengguang
2009-12-02 3:12 ` [PATCH 16/24] HWPOISON: limit hwpoison injector to known page types Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 8:11 ` Ingo Molnar
2009-12-02 8:11 ` Ingo Molnar
2009-12-02 3:12 ` [PATCH 17/24] mm: export stable page flags Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 4:42 ` Wu Fengguang
2009-12-02 4:42 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 18/24] HWPOISON: add page flags filter Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 19/24] memcg: rename and export try_get_mem_cgroup_from_page() Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-03 1:58 ` Balbir Singh
2009-12-03 1:58 ` Balbir Singh
2009-12-02 3:12 ` [PATCH 20/24] memcg: add accessor to mem_cgroup.css Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 21/24] cgroup: define empty css_put() when !CONFIG_CGROUPS Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 22:48 ` Paul Menage
2009-12-02 22:48 ` Paul Menage
2009-12-02 22:52 ` Andi Kleen
2009-12-02 22:52 ` Andi Kleen
2009-12-03 1:53 ` Wu Fengguang
2009-12-03 1:53 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 22/24] HWPOISON: add memory cgroup filter Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 12:44 ` Andi Kleen
2009-12-02 12:44 ` Andi Kleen
2009-12-02 12:58 ` Wu Fengguang
2009-12-02 12:58 ` Wu Fengguang
2009-12-03 1:52 ` KAMEZAWA Hiroyuki
2009-12-03 1:52 ` KAMEZAWA Hiroyuki
2009-12-03 2:19 ` Wu Fengguang
2009-12-03 2:19 ` Wu Fengguang
2009-12-03 2:28 ` KAMEZAWA Hiroyuki
2009-12-03 2:28 ` KAMEZAWA Hiroyuki
2009-12-03 2:47 ` Wu Fengguang
2009-12-03 2:47 ` Wu Fengguang
2009-12-03 2:58 ` KAMEZAWA Hiroyuki
2009-12-03 2:58 ` KAMEZAWA Hiroyuki
2009-12-03 15:03 ` Wu Fengguang
2009-12-03 15:03 ` Wu Fengguang
2009-12-03 2:15 ` Li Zefan
2009-12-03 2:15 ` Li Zefan
2009-12-03 2:20 ` Wu Fengguang
2009-12-03 2:20 ` Wu Fengguang
2009-12-03 2:28 ` Wu Fengguang
2009-12-03 2:28 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 23/24] HWPOISON: add an interface to switch off/on all the page filters Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 3:12 ` [PATCH 24/24] HWPOISON: show corrupted file info Wu Fengguang
2009-12-02 3:12 ` Wu Fengguang
2009-12-02 13:20 ` Andi Kleen
2009-12-02 13:20 ` Andi Kleen
2009-12-02 13:37 ` Wu Fengguang
2009-12-02 13:37 ` Wu Fengguang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091202043045.535248130@intel.com \
--to=fengguang.wu@intel.com \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=haicheng.li@intel.com \
--cc=npiggin@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.