Skip to content

Commit

Permalink
HWPOISON: avoid grabbing the page count multiple times during madvise…
Browse files Browse the repository at this point in the history
… injection

If page is double referenced in madvise_hwpoison() and __memory_failure(),
remove_mapping() will fail because it expects page_count=2. Fix it by
not grabbing extra page count in __memory_failure().

Signed-off-by: Wu Fengguang <[email protected]>
Signed-off-by: Andi Kleen <[email protected]>
  • Loading branch information
Wu Fengguang authored and Andi Kleen committed Dec 16, 2009
1 parent a7560fc commit bd1ce5f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion mm/madvise.c
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ static int madvise_hwpoison(unsigned long start, unsigned long end)
page_to_pfn(p), start);
/* Ignore return value for now */
__memory_failure(page_to_pfn(p), 0, 1);
put_page(p);
}
return ret;
}
Expand Down
8 changes: 4 additions & 4 deletions mm/memory-failure.c
Original file line number Diff line number Diff line change
Expand Up @@ -627,15 +627,15 @@ static void action_result(unsigned long pfn, char *msg, int result)
}

static int page_action(struct page_state *ps, struct page *p,
unsigned long pfn, int ref)
unsigned long pfn)
{
int result;
int count;

result = ps->action(p, pfn);
action_result(pfn, ps->msg, result);

count = page_count(p) - 1 - ref;
count = page_count(p) - 1;
if (count != 0)
printk(KERN_ERR
"MCE %#lx: %s page still referenced by %d users\n",
Expand Down Expand Up @@ -773,7 +773,7 @@ int __memory_failure(unsigned long pfn, int trapno, int ref)
* In fact it's dangerous to directly bump up page count from 0,
* that may make page_freeze_refs()/page_unfreeze_refs() mismatch.
*/
if (!get_page_unless_zero(compound_head(p))) {
if (!ref && !get_page_unless_zero(compound_head(p))) {
action_result(pfn, "free or high order kernel", IGNORED);
return PageBuddy(compound_head(p)) ? 0 : -EBUSY;
}
Expand Down Expand Up @@ -821,7 +821,7 @@ int __memory_failure(unsigned long pfn, int trapno, int ref)
res = -EBUSY;
for (ps = error_states;; ps++) {
if (((p->flags | lru_flag)& ps->mask) == ps->res) {
res = page_action(ps, p, pfn, ref);
res = page_action(ps, p, pfn);
break;
}
}
Expand Down

0 comments on commit bd1ce5f

Please sign in to comment.