linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4 1/10] mm/hwpoison: fix lose PG_dirty flag for errors on mlocked pages
@ 2013-08-26  8:46 Wanpeng Li
  2013-08-26  8:46 ` [PATCH v4 2/10] mm/hwpoison: don't need to hold compound lock for hugetlbfs page Wanpeng Li
                   ` (9 more replies)
  0 siblings, 10 replies; 31+ messages in thread
From: Wanpeng Li @ 2013-08-26  8:46 UTC (permalink / raw)
  To: Andrew Morton
  Cc: Andi Kleen, Fengguang Wu, Naoya Horiguchi, Tony Luck, gong.chen,
	linux-mm, linux-kernel, Wanpeng Li

memory_failure() store the page flag of the error page before doing unmap,
and (only) if the first check with page flags at the time decided the error
page is unknown, it do the second check with the stored page flag since
memory_failure() does unmapping of the error pages before doing page_action().
This unmapping changes the page state, especially page_remove_rmap() (called
from try_to_unmap_one()) clears PG_mlocked, so page_action() can't catch
mlocked pages after that.

However, memory_failure() can't handle memory errors on dirty mlocked pages
correctly. try_to_unmap_one will move the dirty bit from pte to the physical
page, the second check lose it since it check the stored page flag. This patch
fix it by restore PG_dirty flag to stored page flag if the page is dirty.

Testcase:

#define _GNU_SOURCE
#include <stdlib.h>
#include <stdio.h>
#include <sys/mman.h>
#include <sys/types.h>
#include <errno.h>

#define PAGES_TO_TEST 2
#define PAGE_SIZE	4096

int main(void)
{
	char *mem;
	int i;

	mem = mmap(NULL, PAGES_TO_TEST * PAGE_SIZE,
			PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_LOCKED, 0, 0);

	for (i = 0; i < PAGES_TO_TEST; i++)
		mem[i * PAGE_SIZE] = 'a';

	if (madvise(mem, PAGES_TO_TEST * PAGE_SIZE, MADV_HWPOISON) == -1)
		return -1;

	return 0;
}

Before patch:

[  912.839247] Injecting memory failure for page 7dfb8 at 7f6b4e37b000
[  912.839257] MCE 0x7dfb8: clean mlocked LRU page recovery: Recovered
[  912.845550] MCE 0x7dfb8: clean mlocked LRU page still referenced by 1 users
[  912.852586] Injecting memory failure for page 7e6aa at 7f6b4e37c000
[  912.852594] MCE 0x7e6aa: clean mlocked LRU page recovery: Recovered
[  912.858936] MCE 0x7e6aa: clean mlocked LRU page still referenced by 1 users

After patch:

[  163.590225] Injecting memory failure for page 91bc2f at 7f9f5b0e5000
[  163.590264] MCE 0x91bc2f: dirty mlocked LRU page recovery: Recovered
[  163.596680] MCE 0x91bc2f: dirty mlocked LRU page still referenced by 1 users
[  163.603831] Injecting memory failure for page 91cdd3 at 7f9f5b0e6000
[  163.603852] MCE 0x91cdd3: dirty mlocked LRU page recovery: Recovered
[  163.610305] MCE 0x91cdd3: dirty mlocked LRU page still referenced by 1 users

Reviewed-by: Naoya Horiguchi <n-horiguchi@ah.jp.nec.com>
Signed-off-by: Wanpeng Li <liwanp@linux.vnet.ibm.com>
---
 mm/memory-failure.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 2c13aa7..d5686d4 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1204,6 +1204,9 @@ int memory_failure(unsigned long pfn, int trapno, int flags)
 	for (ps = error_states;; ps++)
 		if ((p->flags & ps->mask) == ps->res)
 			break;
+
+	page_flags |= (p->flags & (1UL << PG_dirty));
+
 	if (!ps->mask)
 		for (ps = error_states;; ps++)
 			if ((page_flags & ps->mask) == ps->res)
-- 
1.8.1.2

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

^ permalink raw reply related	[flat|nested] 31+ messages in thread

end of thread, other threads:[~2013-08-29  6:17 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-26  8:46 [PATCH v4 1/10] mm/hwpoison: fix lose PG_dirty flag for errors on mlocked pages Wanpeng Li
2013-08-26  8:46 ` [PATCH v4 2/10] mm/hwpoison: don't need to hold compound lock for hugetlbfs page Wanpeng Li
2013-08-26  8:46 ` [PATCH v4 3/10] mm/hwpoison: fix race against poison thp Wanpeng Li
2013-08-26  8:46 ` [PATCH v4 4/10] mm/hwpoison: replacing atomic_long_sub() with atomic_long_dec() Wanpeng Li
2013-08-26  8:46 ` [PATCH v4 5/10] mm/hwpoison: don't set migration type twice to avoid hold heavy contend zone->lock Wanpeng Li
2013-08-26  8:46 ` [PATCH v4 6/10] mm/hwpoison: drop forward reference declarations __soft_offline_page() Wanpeng Li
2013-08-26  8:46 ` [PATCH v4 7/10] mm/hwpoison: add '#' to madvise_hwpoison Wanpeng Li
2013-08-26  8:46 ` [PATCH v4 8/10] mm/hwpoison: fix memory failure still hold reference count after unpoison empty zero page Wanpeng Li
2013-08-26 15:45   ` Naoya Horiguchi
2013-08-26 23:26     ` Wanpeng Li
2013-08-27  0:12       ` Naoya Horiguchi
2013-08-27  0:21         ` Wanpeng Li
2013-08-27  0:21         ` Wanpeng Li
     [not found]         ` <521bf0fc.4950320a.76ab.0f2dSMTPIN_ADDED_BROKEN@mx.google.com>
2013-08-27  0:46           ` Naoya Horiguchi
2013-08-27  1:17             ` Wanpeng Li
2013-08-27  1:17             ` Wanpeng Li
     [not found]             ` <521bfe37.83892b0a.1b94.2e7cSMTPIN_ADDED_BROKEN@mx.google.com>
2013-08-27  1:34               ` Naoya Horiguchi
2013-08-27  1:48                 ` Wanpeng Li
2013-08-27  1:48                 ` Wanpeng Li
2013-08-26 23:26     ` Wanpeng Li
     [not found]     ` <521be416.a5e8420a.6786.09d1SMTPIN_ADDED_BROKEN@mx.google.com>
2013-08-26 23:31       ` Andrew Morton
2013-08-26 23:40         ` Wanpeng Li
2013-08-26 23:40         ` Wanpeng Li
2013-08-26  8:46 ` [PATCH v4 9/10] mm/hwpoison: change permission of corrupt-pfn/unpoison-pfn to 0400 Wanpeng Li
2013-08-26  9:08   ` Wanpeng Li
2013-08-26  9:08   ` Wanpeng Li
2013-08-26 15:47     ` Naoya Horiguchi
2013-08-26  8:46 ` [PATCH v4 10/10] mm/hwpoison: fix bug triggered by unpoison empty zero page Wanpeng Li
2013-08-29  6:00 ` [PATCH v4 1/10] mm/hwpoison: fix lose PG_dirty flag for errors on mlocked pages Andi Kleen
2013-08-29  6:17   ` Wanpeng Li
2013-08-29  6:17   ` Wanpeng Li

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