All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: fengguang.wu@intel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH] [31/31] HWPOISON: Add a madvise() injector for soft page offlining
Date: Tue,  8 Dec 2009 22:16:47 +0100 (CET)	[thread overview]
Message-ID: <20091208211647.9B032B151F@basil.firstfloor.org> (raw)
In-Reply-To: <200912081016.198135742@firstfloor.org>


Process based injection is much easier to handle for test programs,
who can first bring a page into a specific state and then test.
So add a new MADV_SOFT_OFFLINE to soft offline a page, similar
to the existing hard offline injector.

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

---
 include/asm-generic/mman-common.h |    1 +
 mm/madvise.c                      |   15 ++++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

Index: linux/include/asm-generic/mman-common.h
===================================================================
--- linux.orig/include/asm-generic/mman-common.h
+++ linux/include/asm-generic/mman-common.h
@@ -35,6 +35,7 @@
 #define MADV_DONTFORK	10		/* don't inherit across fork */
 #define MADV_DOFORK	11		/* do inherit across fork */
 #define MADV_HWPOISON	100		/* poison a page for testing */
+#define MADV_SOFT_OFFLINE 101		/* soft offline page for testing */
 
 #define MADV_MERGEABLE   12		/* KSM may merge identical pages */
 #define MADV_UNMERGEABLE 13		/* KSM may not merge identical pages */
Index: linux/mm/madvise.c
===================================================================
--- linux.orig/mm/madvise.c
+++ linux/mm/madvise.c
@@ -9,6 +9,7 @@
 #include <linux/pagemap.h>
 #include <linux/syscalls.h>
 #include <linux/mempolicy.h>
+#include <linux/page-isolation.h>
 #include <linux/hugetlb.h>
 #include <linux/sched.h>
 #include <linux/ksm.h>
@@ -222,7 +223,7 @@ static long madvise_remove(struct vm_are
 /*
  * Error injection support for memory error handling.
  */
-static int madvise_hwpoison(unsigned long start, unsigned long end)
+static int madvise_hwpoison(int bhv, unsigned long start, unsigned long end)
 {
 	int ret = 0;
 
@@ -233,6 +234,14 @@ static int madvise_hwpoison(unsigned lon
 		int ret = get_user_pages_fast(start, 1, 0, &p);
 		if (ret != 1)
 			return ret;
+		if (bhv == MADV_SOFT_OFFLINE) {
+			printk(KERN_INFO "Soft offlining page %lx at %lx\n",
+				page_to_pfn(p), start);
+			ret = soft_offline_page(p, MF_COUNT_INCREASED);
+			if (ret)
+				break;
+			continue;
+		}
 		printk(KERN_INFO "Injecting memory failure for page %lx at %lx\n",
 		       page_to_pfn(p), start);
 		/* Ignore return value for now */
@@ -333,8 +342,8 @@ SYSCALL_DEFINE3(madvise, unsigned long,
 	size_t len;
 
 #ifdef CONFIG_MEMORY_FAILURE
-	if (behavior == MADV_HWPOISON)
-		return madvise_hwpoison(start, start+len_in);
+	if (behavior == MADV_HWPOISON || behavior == MADV_SOFT_OFFLINE)
+		return madvise_hwpoison(behavior, start, start+len_in);
 #endif
 	if (!madvise_behavior_valid(behavior))
 		return error;

WARNING: multiple messages have this Message-ID (diff)
From: Andi Kleen <andi@firstfloor.org>
To: fengguang.wu@intel.com, linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH] [31/31] HWPOISON: Add a madvise() injector for soft page offlining
Date: Tue,  8 Dec 2009 22:16:47 +0100 (CET)	[thread overview]
Message-ID: <20091208211647.9B032B151F@basil.firstfloor.org> (raw)
In-Reply-To: <200912081016.198135742@firstfloor.org>


Process based injection is much easier to handle for test programs,
who can first bring a page into a specific state and then test.
So add a new MADV_SOFT_OFFLINE to soft offline a page, similar
to the existing hard offline injector.

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

---
 include/asm-generic/mman-common.h |    1 +
 mm/madvise.c                      |   15 ++++++++++++---
 2 files changed, 13 insertions(+), 3 deletions(-)

Index: linux/include/asm-generic/mman-common.h
===================================================================
--- linux.orig/include/asm-generic/mman-common.h
+++ linux/include/asm-generic/mman-common.h
@@ -35,6 +35,7 @@
 #define MADV_DONTFORK	10		/* don't inherit across fork */
 #define MADV_DOFORK	11		/* do inherit across fork */
 #define MADV_HWPOISON	100		/* poison a page for testing */
+#define MADV_SOFT_OFFLINE 101		/* soft offline page for testing */
 
 #define MADV_MERGEABLE   12		/* KSM may merge identical pages */
 #define MADV_UNMERGEABLE 13		/* KSM may not merge identical pages */
Index: linux/mm/madvise.c
===================================================================
--- linux.orig/mm/madvise.c
+++ linux/mm/madvise.c
@@ -9,6 +9,7 @@
 #include <linux/pagemap.h>
 #include <linux/syscalls.h>
 #include <linux/mempolicy.h>
+#include <linux/page-isolation.h>
 #include <linux/hugetlb.h>
 #include <linux/sched.h>
 #include <linux/ksm.h>
@@ -222,7 +223,7 @@ static long madvise_remove(struct vm_are
 /*
  * Error injection support for memory error handling.
  */
-static int madvise_hwpoison(unsigned long start, unsigned long end)
+static int madvise_hwpoison(int bhv, unsigned long start, unsigned long end)
 {
 	int ret = 0;
 
@@ -233,6 +234,14 @@ static int madvise_hwpoison(unsigned lon
 		int ret = get_user_pages_fast(start, 1, 0, &p);
 		if (ret != 1)
 			return ret;
+		if (bhv == MADV_SOFT_OFFLINE) {
+			printk(KERN_INFO "Soft offlining page %lx at %lx\n",
+				page_to_pfn(p), start);
+			ret = soft_offline_page(p, MF_COUNT_INCREASED);
+			if (ret)
+				break;
+			continue;
+		}
 		printk(KERN_INFO "Injecting memory failure for page %lx at %lx\n",
 		       page_to_pfn(p), start);
 		/* Ignore return value for now */
@@ -333,8 +342,8 @@ SYSCALL_DEFINE3(madvise, unsigned long,
 	size_t len;
 
 #ifdef CONFIG_MEMORY_FAILURE
-	if (behavior == MADV_HWPOISON)
-		return madvise_hwpoison(start, start+len_in);
+	if (behavior == MADV_HWPOISON || behavior == MADV_SOFT_OFFLINE)
+		return madvise_hwpoison(behavior, start, start+len_in);
 #endif
 	if (!madvise_behavior_valid(behavior))
 		return error;

--
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>

  parent reply	other threads:[~2009-12-08 21:17 UTC|newest]

Thread overview: 122+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-08 21:16 [PATCH] [0/31] HWPOISON 2.6.33 pre-merge posting Andi Kleen
2009-12-08 21:16 ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [1/31] HWPOISON: Add Andi Kleen as hwpoison maintainer to MAINTAINERS Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [2/31] HWPOISON: Be more aggressive at freeing non LRU caches Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [3/31] page-types: add standard GPL license header Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [4/31] HWPOISON: remove the anonymous entry Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [5/31] HWPOISON: return ENXIO on invalid page number Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [6/31] HWPOISON: avoid grabbing the page count multiple times during madvise injection Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [7/31] HWPOISON: Turn ref argument into flags argument Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [8/31] HWPOISON: abort on failed unmap Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [9/31] HWPOISON: comment the possible set_page_dirty() race Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [10/31] HWPOISON: comment dirty swapcache pages Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [11/31] HWPOISON: introduce delete_from_lru_cache() Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [12/31] HWPOISON: remove the free buddy page handler Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [13/31] HWPOISON: detect free buddy pages explicitly Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [14/31] HWPOISON: Add unpoisoning support Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [15/31] HWPOISON: make semantics of IGNORED/DELAYED clear Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [16/31] HWPOISON: return 0 to indicate success reliably Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [17/31] HWPOISON: add fs/device filters Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [18/31] HWPOISON: limit hwpoison injector to known page types Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [19/31] mm: export stable page flags Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 22:27   ` Matt Mackall
2009-12-08 22:27     ` Matt Mackall
2009-12-09  2:00     ` Wu Fengguang
2009-12-09  2:00       ` Wu Fengguang
2009-12-09 21:38       ` Matt Mackall
2009-12-09 21:38         ` Matt Mackall
2009-12-10  1:50       ` Andi Kleen
2009-12-10  1:50         ` Andi Kleen
2009-12-10  2:09         ` Wu Fengguang
2009-12-10  2:09           ` Wu Fengguang
2009-12-10 13:42           ` Andi Kleen
2009-12-10 13:42             ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [20/31] HWPOISON: add page flags filter Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [21/31] memcg: rename and export try_get_mem_cgroup_from_page() Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [22/31] memcg: add accessor to mem_cgroup.css Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [23/31] HWPOISON: add memory cgroup filter Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-09  5:04   ` Li Zefan
2009-12-09  5:04     ` Li Zefan
2009-12-09  5:06     ` KAMEZAWA Hiroyuki
2009-12-09  5:06       ` KAMEZAWA Hiroyuki
2009-12-09  5:33       ` Balbir Singh
2009-12-09  5:33         ` Balbir Singh
2009-12-09  9:15     ` Andi Kleen
2009-12-09  9:15       ` Andi Kleen
2009-12-09 20:47   ` Paul Menage
2009-12-09 20:47     ` Paul Menage
2009-12-09 23:56     ` KAMEZAWA Hiroyuki
2009-12-09 23:56       ` KAMEZAWA Hiroyuki
2009-12-10  1:42     ` Andi Kleen
2009-12-10  1:42       ` Andi Kleen
2009-12-10  2:21       ` Balbir Singh
2009-12-10  2:21         ` Balbir Singh
2009-12-11  2:14         ` Wu Fengguang
2009-12-11  2:14           ` Wu Fengguang
2009-12-14 12:53           ` Andi Kleen
2009-12-14 12:53             ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [24/31] HWPOISON: add an interface to switch off/on all the page filters Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [25/31] HWPOISON: Don't do early filtering if filter is disabled Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [26/31] HWPOISON: mention HWPoison in Kconfig entry Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [27/31] HWPOISON: Use correct name for MADV_HWPOISON in documentation Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [28/31] HWPOISON: Use new shake_page in memory_failure Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [29/31] HWPOISON: Undefine short-hand macros after use to avoid namespace conflict Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` [PATCH] [30/31] HWPOISON: Add soft page offline support Andi Kleen
2009-12-08 21:16   ` Andi Kleen
2009-12-08 21:16 ` Andi Kleen [this message]
2009-12-08 21:16   ` [PATCH] [31/31] HWPOISON: Add a madvise() injector for soft page offlining Andi Kleen
2010-06-19 12:36   ` Michael Kerrisk
2010-06-19 12:36     ` Michael Kerrisk
2010-06-19 13:20     ` Andi Kleen
2010-06-19 13:20       ` Andi Kleen
2010-06-19 13:25       ` Michael Kerrisk
2010-06-19 13:25         ` Michael Kerrisk
2010-06-19 13:30         ` Andi Kleen
2010-06-19 13:30           ` Andi Kleen
2010-06-19 13:43           ` Michael Kerrisk
2010-06-19 13:43             ` Michael Kerrisk
2010-06-19 14:09             ` Andi Kleen
2010-06-19 14:09               ` Andi Kleen
2010-06-19 14:17               ` Michael Kerrisk
2010-06-19 14:17                 ` Michael Kerrisk
2010-06-19 19:52                 ` Andi Kleen
2010-06-19 19:52                   ` Andi Kleen
2010-06-20  6:19                   ` Michael Kerrisk
2010-06-20  6:19                     ` Michael Kerrisk
2010-06-20  7:14                     ` Wu Fengguang
2010-06-20  7:14                       ` Wu Fengguang
2010-06-26 13:18                       ` Michael Kerrisk
2010-06-26 13:18                         ` Michael Kerrisk
2010-06-26 23:30                         ` Wu Fengguang
2010-06-26 23:30                           ` Wu Fengguang
2010-06-27  4:38                           ` Michael Kerrisk
2010-06-27  4:38                             ` Michael Kerrisk

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=20091208211647.9B032B151F@basil.firstfloor.org \
    --to=andi@firstfloor.org \
    --cc=fengguang.wu@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /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.