From: Wu Fengguang <fengguang.wu@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: LKML <linux-kernel@vger.kernel.org>,
Wu Fengguang <fengguang.wu@intel.com>,
Ingo Molnar <mingo@elte.hu>, Mel Gorman <mel@csn.ul.ie>,
Thomas Gleixner <tglx@linutronix.de>,
"H. Peter Anvin" <hpa@zytor.com>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Nick Piggin <npiggin@suse.de>,
Hugh Dickins <hugh.dickins@tiscali.co.uk>,
Andi Kleen <andi@firstfloor.org>,
"riel@redhat.com" <riel@redhat.com>,
"chris.mason@oracle.com" <chris.mason@oracle.com>,
"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: [PATCH 17/22] HWPOISON: introduce struct hwpoison_control
Date: Mon, 15 Jun 2009 10:45:37 +0800 [thread overview]
Message-ID: <20090615031254.740121710@intel.com> (raw)
In-Reply-To: 20090615024520.786814520@intel.com
[-- Attachment #1: hwpoison-control.patch --]
[-- Type: text/plain, Size: 9511 bytes --]
Code cleanups to allow passing around more parameters and states.
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
mm/memory-failure.c | 94 ++++++++++++++++++++++++------------------
1 file changed, 54 insertions(+), 40 deletions(-)
--- sound-2.6.orig/mm/memory-failure.c
+++ sound-2.6/mm/memory-failure.c
@@ -298,26 +298,32 @@ static void collect_procs(struct page *p
* Error handlers for various types of pages.
*/
-enum outcome {
+enum hwpoison_outcome {
FAILED, /* Error handling failed */
DELAYED, /* Will be handled later */
IGNORED, /* Error safely ignored */
RECOVERED, /* Successfully recovered */
};
-static const char *action_name[] = {
+static const char *hwpoison_outcome_name[] = {
[FAILED] = "Failed",
[DELAYED] = "Delayed",
[IGNORED] = "Ignored",
[RECOVERED] = "Recovered",
};
+struct hwpoison_control {
+ unsigned long pfn;
+ struct page *page;
+ int outcome;
+};
+
/*
* Error hit kernel page.
* Do nothing, try to be lucky and not touch this instead. For a few cases we
* could be more sophisticated.
*/
-static int me_kernel(struct page *p, unsigned long pfn)
+static int me_kernel(struct hwpoison_control *hpc)
{
return DELAYED;
}
@@ -325,7 +331,7 @@ static int me_kernel(struct page *p, uns
/*
* Already poisoned page.
*/
-static int me_ignore(struct page *p, unsigned long pfn)
+static int me_ignore(struct hwpoison_control *hpc)
{
return IGNORED;
}
@@ -333,16 +339,16 @@ static int me_ignore(struct page *p, uns
/*
* Page in unknown state. Do nothing.
*/
-static int me_unknown(struct page *p, unsigned long pfn)
+static int me_unknown(struct hwpoison_control *hpc)
{
- printk(KERN_ERR "MCE %#lx: Unknown page state\n", pfn);
+ printk(KERN_ERR "MCE %#lx: Unknown page state\n", hpc->pfn);
return FAILED;
}
/*
* Free memory
*/
-static int me_free(struct page *p, unsigned long pfn)
+static int me_free(struct hwpoison_control *hpc)
{
return DELAYED;
}
@@ -350,9 +356,10 @@ static int me_free(struct page *p, unsig
/*
* Clean (or cleaned) page cache page.
*/
-static int me_pagecache_clean(struct page *p, unsigned long pfn)
+static int me_pagecache_clean(struct hwpoison_control *hpc)
{
struct address_space *mapping;
+ struct page *p = hpc->page;
if (!isolate_lru_page(p))
page_cache_release(p);
@@ -372,14 +379,14 @@ static int me_pagecache_clean(struct pag
!invalidate_complete_page(mapping, p)) {
printk(KERN_ERR
"MCE %#lx: failed to invalidate metadata page\n",
- pfn);
+ hpc->pfn);
return FAILED;
}
truncate_inode_page(mapping, p);
if (page_has_private(p) && !try_to_release_page(p, GFP_NOIO)) {
pr_debug(KERN_ERR "MCE %#lx: failed to release buffers\n",
- pfn);
+ hpc->pfn);
return FAILED;
}
return RECOVERED;
@@ -390,11 +397,11 @@ static int me_pagecache_clean(struct pag
* Issues: when the error hit a hole page the error is not properly
* propagated.
*/
-static int me_pagecache_dirty(struct page *p, unsigned long pfn)
+static int me_pagecache_dirty(struct hwpoison_control *hpc)
{
- struct address_space *mapping = page_mapping(p);
+ struct address_space *mapping = page_mapping(hpc->page);
- SetPageError(p);
+ SetPageError(hpc->page);
/* TBD: print more information about the file. */
if (mapping) {
/*
@@ -434,7 +441,7 @@ static int me_pagecache_dirty(struct pag
mapping_set_error(mapping, EIO);
}
- return me_pagecache_clean(p, pfn);
+ return me_pagecache_clean(hpc);
}
/*
@@ -456,8 +463,10 @@ static int me_pagecache_dirty(struct pag
* Clean swap cache pages can be directly isolated. A later page fault will
* bring in the known good data from disk.
*/
-static int me_swapcache_dirty(struct page *p, unsigned long pfn)
+static int me_swapcache_dirty(struct hwpoison_control *hpc)
{
+ struct page *p = hpc->page;
+
ClearPageDirty(p);
/* Trigger EIO in shmem: */
ClearPageUptodate(p);
@@ -468,8 +477,10 @@ static int me_swapcache_dirty(struct pag
return DELAYED;
}
-static int me_swapcache_clean(struct page *p, unsigned long pfn)
+static int me_swapcache_clean(struct hwpoison_control *hpc)
{
+ struct page *p = hpc->page;
+
if (!isolate_lru_page(p))
page_cache_release(p);
@@ -489,7 +500,7 @@ static int me_swapcache_clean(struct pag
* Should handle free huge pages and dequeue them too, but this needs to
* handle huge page accounting correctly.
*/
-static int me_huge_page(struct page *p, unsigned long pfn)
+static int me_huge_page(struct hwpoison_control *hpc)
{
return FAILED;
}
@@ -525,7 +536,7 @@ static struct page_state {
unsigned long mask;
unsigned long res;
char *msg;
- int (*action)(struct page *p, unsigned long pfn);
+ int (*action)(struct hwpoison_control *hpc);
} error_states[] = {
{ reserved, reserved, "reserved kernel", me_ignore },
{ buddy, buddy, "free kernel", me_free },
@@ -567,24 +578,22 @@ static struct page_state {
{ 0, 0, "unknown page state", me_unknown },
};
-static void action_result(unsigned long pfn, char *msg, int result)
+static void action_result(struct hwpoison_control *hpc, char *msg, int result)
{
+ hpc->outcome = result;
printk(KERN_ERR "MCE %#lx: %s%s page recovery: %s\n",
- pfn, PageDirty(pfn_to_page(pfn)) ? "dirty " : "",
- msg, action_name[result]);
+ hpc->pfn, PageDirty(hpc->page) ? "dirty " : "",
+ msg, hwpoison_outcome_name[result]);
}
-static void page_action(struct page_state *ps, struct page *p,
- unsigned long pfn)
+static void page_action(struct page_state *ps, struct hwpoison_control *hpc)
{
- int result;
+ action_result(hpc, ps->msg, ps->action(hpc));
- result = ps->action(p, pfn);
- action_result(pfn, ps->msg, result);
- if (page_count(p) != 1)
+ if (page_count(hpc->page) != 1)
printk(KERN_ERR
"MCE %#lx: %s page still referenced by %d users\n",
- pfn, ps->msg, page_count(p) - 1);
+ hpc->pfn, ps->msg, page_count(hpc->page) - 1);
/* Could do more checks here if page looks ok */
atomic_long_add(1, &mce_bad_pages);
@@ -600,12 +609,12 @@ static void page_action(struct page_stat
* Do all that is necessary to remove user space mappings. Unmap
* the pages and send SIGBUS to the processes if the data was dirty.
*/
-static void hwpoison_user_mappings(struct page *p, unsigned long pfn,
- int trapno)
+static void hwpoison_user_mappings(struct hwpoison_control *hpc, int trapno)
{
enum ttu_flags ttu = TTU_UNMAP | TTU_IGNORE_MLOCK | TTU_IGNORE_ACCESS;
int kill = sysctl_memory_failure_early_kill;
struct address_space *mapping;
+ struct page *p = hpc->page;
LIST_HEAD(tokill);
int ret;
int i;
@@ -625,7 +634,8 @@ static void hwpoison_user_mappings(struc
if (PageSwapCache(p)) {
printk(KERN_ERR
- "MCE %#lx: keeping poisoned page in swap cache\n", pfn);
+ "MCE %#lx: keeping poisoned page in swap cache\n",
+ hpc->pfn);
ttu |= TTU_IGNORE_HWPOISON;
}
@@ -642,7 +652,7 @@ static void hwpoison_user_mappings(struc
ttu |= TTU_IGNORE_HWPOISON;
printk(KERN_INFO
"MCE %#lx: corrupted page was clean: dropped without side effects\n",
- pfn);
+ hpc->pfn);
}
}
@@ -670,12 +680,13 @@ static void hwpoison_user_mappings(struc
ret = try_to_unmap(p, ttu);
if (ret == SWAP_SUCCESS)
break;
- pr_debug("MCE %#lx: try_to_unmap retry needed %d\n", pfn, ret);
+ pr_debug("MCE %#lx: try_to_unmap retry needed %d\n",
+ hpc->pfn, ret);
}
if (ret != SWAP_SUCCESS)
printk(KERN_ERR "MCE %#lx: failed to unmap page (mapcount=%d)\n",
- pfn, page_mapcount(p));
+ hpc->pfn, page_mapcount(p));
/*
* Now that the dirty bit has been propagated to the
@@ -687,7 +698,7 @@ static void hwpoison_user_mappings(struc
* any accesses to the poisoned memory.
*/
kill_procs_ao(&tokill, !!PageDirty(p), trapno,
- ret != SWAP_SUCCESS, pfn);
+ ret != SWAP_SUCCESS, hpc->pfn);
}
/**
@@ -711,6 +722,7 @@ void memory_failure(unsigned long pfn, i
{
struct page_state *ps;
struct page *p;
+ struct hwpoison_control hpc;
if (!pfn_valid(pfn)) {
printk(KERN_ERR
@@ -720,8 +732,10 @@ void memory_failure(unsigned long pfn, i
}
p = pfn_to_page(pfn);
+ hpc.pfn = pfn;
+ hpc.page = p;
if (TestSetPageHWPoison(p)) {
- action_result(pfn, "already hardware poisoned", IGNORED);
+ action_result(&hpc, "already hardware poisoned", IGNORED);
return;
}
@@ -737,7 +751,7 @@ void memory_failure(unsigned long pfn, i
* that may make page_freeze_refs()/page_unfreeze_refs() mismatch.
*/
if (!get_page_unless_zero(compound_head(p))) {
- action_result(pfn, "free or high order kernel", IGNORED);
+ action_result(&hpc, "free or high order kernel", IGNORED);
return;
}
@@ -752,19 +766,19 @@ void memory_failure(unsigned long pfn, i
/*
* Now take care of user space mappings.
*/
- hwpoison_user_mappings(p, pfn, trapno);
+ hwpoison_user_mappings(&hpc, trapno);
/*
* Torn down by someone else?
*/
if (PageLRU(p) && !PageSwapCache(p) && p->mapping == NULL) {
- action_result(pfn, "already truncated LRU", IGNORED);
+ action_result(&hpc, "already truncated LRU", IGNORED);
goto out;
}
for (ps = error_states;; ps++) {
if ((p->flags & ps->mask) == ps->res) {
- page_action(ps, p, pfn);
+ page_action(ps, &hpc);
break;
}
}
--
--
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-06-15 3:14 UTC|newest]
Thread overview: 79+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-06-15 2:45 [PATCH 00/22] HWPOISON: Intro (v5) Wu Fengguang
2009-06-15 2:45 ` [PATCH 01/22] HWPOISON: Add page flag for poisoned pages Wu Fengguang
2009-06-15 2:45 ` [PATCH 02/22] HWPOISON: Export some rmap vma locking to outside world Wu Fengguang
2009-06-15 2:45 ` [PATCH 03/22] HWPOISON: Add support for poison swap entries v2 Wu Fengguang
2009-06-15 2:45 ` [PATCH 04/22] HWPOISON: Add new SIGBUS error codes for hardware poison signals Wu Fengguang
2009-06-15 2:45 ` [PATCH 05/22] HWPOISON: Add basic support for poisoned pages in fault handler v3 Wu Fengguang
2009-06-15 2:45 ` [PATCH 06/22] HWPOISON: x86: Add VM_FAULT_HWPOISON handling to x86 page fault handler v2 Wu Fengguang
2009-06-15 2:45 ` [PATCH 07/22] HWPOISON: define VM_FAULT_HWPOISON to 0 when feature is disabled Wu Fengguang
2009-06-15 2:45 ` [PATCH 08/22] HWPOISON: Use bitmask/action code for try_to_unmap behaviour Wu Fengguang
2009-06-15 2:45 ` [PATCH 09/22] HWPOISON: Handle hardware poisoned pages in try_to_unmap Wu Fengguang
2009-06-15 13:09 ` Minchan Kim
2009-06-15 15:26 ` Wu Fengguang
2009-06-16 0:03 ` Minchan Kim
2009-06-16 13:49 ` Wu Fengguang
2009-06-17 0:28 ` Minchan Kim
2009-06-17 7:23 ` Wu Fengguang
2009-06-17 13:27 ` Minchan Kim
2009-06-17 13:37 ` Wu Fengguang
2009-06-17 13:43 ` Minchan Kim
2009-06-17 14:03 ` Wu Fengguang
2009-06-17 14:08 ` Minchan Kim
2009-06-17 14:12 ` Wu Fengguang
[not found] ` <28c262360906170644w65c08a8y2d2805fb08045804@mail.gmail.com>
[not found] ` <20090617135543.GA8079@localhost>
[not found] ` <28c262360906170703h3363b68dp74471358f647921e@mail.gmail.com>
2009-06-18 12:14 ` Wu Fengguang
2009-06-18 13:31 ` Minchan Kim
2009-06-19 1:58 ` Wu Fengguang
2009-06-15 2:45 ` [PATCH 10/22] HWPOISON: check and isolate corrupted free pages v2 Wu Fengguang
2009-06-15 9:41 ` KAMEZAWA Hiroyuki
2009-06-15 10:16 ` Wu Fengguang
2009-06-15 23:52 ` KAMEZAWA Hiroyuki
2009-06-16 0:34 ` Wu Fengguang
2009-06-16 11:29 ` Hugh Dickins
2009-06-16 11:40 ` Wu Fengguang
2009-06-15 2:45 ` [PATCH 11/22] HWPOISON: Refactor truncate to allow direct truncating of page v3 Wu Fengguang
2009-06-15 2:45 ` [PATCH 12/22] HWPOISON: The high level memory error handler in the VM v7 Wu Fengguang
2009-06-15 2:45 ` [PATCH 13/22] HWPOISON: Add madvise() based injector for hardware poisoned pages v3 Wu Fengguang
2009-06-15 2:45 ` [PATCH 14/22] HWPOISON: Add simple debugfs interface to inject hwpoison on arbitary PFNs Wu Fengguang
2009-06-15 2:45 ` [PATCH 15/22] HWPOISON: early kill cleanups and fixes Wu Fengguang
2009-06-15 2:45 ` [PATCH 16/22] mm: move page flag numbers for user space to page-flags.h Wu Fengguang
2009-06-15 2:45 ` Wu Fengguang [this message]
2009-06-15 2:45 ` [PATCH 18/22] HWPOISON: use compound head page Wu Fengguang
2009-06-15 2:45 ` [PATCH 19/22] HWPOISON: detect free buddy pages explicitly Wu Fengguang
2009-06-15 2:45 ` [PATCH 20/22] HWPOISON: collect infos that reflect the impact of the memory corruption Wu Fengguang
2009-06-15 2:45 ` [PATCH 21/22] HWPOISON: send uevent to report " Wu Fengguang
2009-06-15 6:29 ` Andi Kleen
2009-06-15 9:56 ` Wu Fengguang
2009-06-16 0:35 ` Greg KH
2009-06-15 2:45 ` [PATCH 22/22] HWPOISON: FOR TESTING: Enable memory failure code unconditionally Wu Fengguang
2009-06-15 3:18 ` [PATCH 00/22] HWPOISON: Intro (v5) Balbir Singh
2009-06-15 4:27 ` Wu Fengguang
2009-06-15 6:44 ` Nick Piggin
2009-06-15 7:09 ` Andi Kleen
2009-06-15 7:19 ` Nick Piggin
2009-06-15 12:10 ` Wu Fengguang
2009-06-15 12:25 ` Nick Piggin
2009-06-15 14:22 ` Wu Fengguang
2009-06-17 6:37 ` [RFC][PATCH] HWPOISON: only early kill processes who installed SIGBUS handler Wu Fengguang
2009-06-17 8:04 ` Nick Piggin
2009-06-17 9:55 ` Wu Fengguang
2009-06-17 10:00 ` Nick Piggin
2009-06-17 11:56 ` Wu Fengguang
2009-06-18 9:56 ` Wu Fengguang
2009-06-15 8:14 ` [PATCH 00/22] HWPOISON: Intro (v5) Nick Piggin
2009-06-15 10:09 ` Wu Fengguang
2009-06-15 10:36 ` Nick Piggin
2009-06-15 11:41 ` Wu Fengguang
2009-06-15 12:51 ` Hugh Dickins
2009-06-15 13:00 ` Alan Cox
2009-06-15 13:29 ` Andi Kleen
2009-06-15 13:28 ` H. Peter Anvin
2009-06-15 14:48 ` Alan Cox
2009-06-15 15:24 ` Andi Kleen
2009-06-15 15:28 ` Alan Cox
2009-06-15 16:19 ` Andi Kleen
2009-06-15 16:28 ` Alan Cox
2009-06-15 17:07 ` Andi Kleen
2009-06-16 19:44 ` Russ Anderson
2009-06-16 20:28 ` H. Peter Anvin
2009-06-16 20:54 ` Russ Anderson
2009-06-16 20:58 ` H. Peter Anvin
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=20090615031254.740121710@intel.com \
--to=fengguang.wu@intel.com \
--cc=a.p.zijlstra@chello.nl \
--cc=akpm@linux-foundation.org \
--cc=andi@firstfloor.org \
--cc=chris.mason@oracle.com \
--cc=hpa@zytor.com \
--cc=hugh.dickins@tiscali.co.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mel@csn.ul.ie \
--cc=mingo@elte.hu \
--cc=npiggin@suse.de \
--cc=riel@redhat.com \
--cc=tglx@linutronix.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).