Skip to contentSkip to conversation

HWPoison fixes for 2.6.36

PATCH In review Andi Kleen 5 participants 18 messages Oct 6, 2010 – Oct 8, 2010

Subsystems (5)
lore
Share & tools
lore
author
#1 lore raw

PATCH 1/4 page-types.c: fix name of unpoison interface

From: Naoya Horiguchi <[email protected]>

The page-types utility still uses an out of date name for the unpoison interface: debugfs:hwpoison/renew-pfn
This patch renames and fixes it.

---
 Documentation/vm/page-types.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Documentation/vm/page-types.c +1 -1
index ccd951f..cc96ee2 100644
@@ -478,7 +478,7 @@ static void prepare_hwpoison_fd(void)
 	}
 
 	if (opt_unpoison && !hwpoison_forget_fd) {
-		sprintf(buf, "%s/renew-pfn", hwpoison_debug_fs);
+		sprintf(buf, "%s/unpoison-pfn", hwpoison_debug_fs);
 		hwpoison_forget_fd = checked_open(buf, O_WRONLY);
 	}
 }
Signature · 7 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#2 lore raw

PATCH 2/4 HWPOISON: Copy si_addr_lsb to user

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

The original hwpoison code added a new siginfo field si_addr_lsb to pass the granuality of the fault address to user space. Unfortunately this field was never copied to user space. Fix this here.

I added explicit checks for the MCEERR codes to avoid having to patch all potential callers to initialize the field.

---
 kernel/signal.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
kernel/signal.c +8 -0
index bded651..919562c 100644
@@ -2215,6 +2215,14 @@ int copy_siginfo_to_user(siginfo_t __user *to, siginfo_t *from)
 #ifdef __ARCH_SI_TRAPNO
 		err |= __put_user(from->si_trapno, &to->si_trapno);
 #endif
+#ifdef BUS_MCEERR_AO
+		/* 
+		 * Other callers might not initialize the si_lsb field,
+	 	 * so check explicitely for the right codes here.
+		 */
+		if (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO)
+			err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb);
+#endif
 		break;
 	case __SI_CHLD:
 		err |= __put_user(from->si_pid, &to->si_pid);
Signature · 7 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v1 2/4
#3 lore raw

Re: [PATCH 2/4] HWPOISON: Copy si_addr_lsb to user

Just nitpicking...

kernel/signal.c int copy_siginfo_to_user(siginfo_t __user *to, siginfo_t *from) · line 2219

Quoted 6 lines
kernel/signal.c +2 -0
@@ -2215,6 +2215,14 @@ int copy_siginfo_to_user(siginfo_t __user *to, siginfo_t *from)
 #ifdef __ARCH_SI_TRAPNO
 		err |= __put_user(from->si_trapno, &to->si_trapno);
 #endif
+#ifdef BUS_MCEERR_AO
+		/* 

^
trailing white space

kernel/signal.c int copy_siginfo_to_user(siginfo_t __user *to, siginfo_t *from) · line 2221

Quoted 2 lines
kernel/signal.c +2 -0
+		 * Other callers might not initialize the si_lsb field,
+	 	 * so check explicitely for the right codes here.

^ ^^^^^^^^^^^
white space explicitly

kernel/signal.c int copy_siginfo_to_user(siginfo_t __user *to, siginfo_t *from) · line 2228

Quoted 7 lines
kernel/signal.c +4 -0
+		 */
+		if (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO)
+			err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb);
+#endif
 		break;
 	case __SI_CHLD:
 		err |= __put_user(from->si_pid, &to->si_pid);

Thanks,
Naoya Horiguchi

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

#4 lore raw

Re: [PATCH 2/4] HWPOISON: Copy si_addr_lsb to user

In reply to Andi Kleen
Quoted 8 lines · Andi Kleen

From: Andi Kleen <[email protected]>

The original hwpoison code added a new siginfo field si_addr_lsb to pass the granuality of the fault address to user space. Unfortunately this field was never copied to user space. Fix this here.

I added explicit checks for the MCEERR codes to avoid having to patch all potential callers to initialize the field.

Now QEMU uses signalfd to catch the SIGBUS delivered to the main thread, so I think similar fix to copy lsb to user is required for signalfd too.

Thanks,
H.Seto

=====

From: Hidetoshi Seto <[email protected]>
Subject: [PATCH] signalfd: add support addr_lsb

---
 fs/signalfd.c            |   10 ++++++++++
 include/linux/signalfd.h |    3 ++-
 2 files changed, 12 insertions(+), 1 deletions(-)
fs/signalfd.c +10 -0
index 1c5a6ad..3e28173 100644
@@ -99,6 +99,16 @@ static int signalfd_copyinfo(struct signalfd_siginfo __user *uinfo,
 #ifdef __ARCH_SI_TRAPNO
 		err |= __put_user(kinfo->si_trapno, &uinfo->ssi_trapno);
 #endif
+#ifdef BUS_MCEERR_AO
+		/* 
+		 * Other callers might not initialize the si_lsb field,
+		 * so check explicitely for the right codes here.
+		 */
+		if (kinfo->si_code == BUS_MCEERR_AR ||
+		    kinfo->si_code == BUS_MCEERR_AO)
+			err |= __put_user((short) kinfo->si_addr_lsb,
+					  &uinfo->ssi_addr_lsb);
+#endif
 		break;
 	case __SI_CHLD:
 		err |= __put_user(kinfo->si_pid, &uinfo->ssi_pid);
include/linux/signalfd.h +2 -1
index b363b91..3ff4961 100644
@@ -33,6 +33,7 @@ struct signalfd_siginfo {
 	__u64 ssi_utime;
 	__u64 ssi_stime;
 	__u64 ssi_addr;
+	__u16 ssi_addr_lsb;
 
 	/*
 	 * Pad strcture to 128 bytes. Remember to update the
@@ -43,7 +44,7 @@ struct signalfd_siginfo {
 	 * comes out of a read(2) and we really don't want to have
 	 * a compat on read(2).
 	 */
-	__u8 __pad[48];
+	__u8 __pad[46];
 };
 
 
Signature · 1 line
1.7.3.1
author
#5 lore raw

Re: [PATCH 2/4] HWPOISON: Copy si_addr_lsb to user

Quoted 7 lines · Hidetoshi Seto
Quoted 6 lines · Andi Kleen

From: Andi Kleen <[email protected]>

The original hwpoison code added a new siginfo field si_addr_lsb to pass the granuality of the fault address to user space. Unfortunately this field was never copied to user space. Fix this here.

Quoted 6 lines
Quoted 2 lines

I added explicit checks for the MCEERR codes to avoid having to patch all potential callers to initialize the field.

Now QEMU uses signalfd to catch the SIGBUS delivered to the main thread, so I think similar fix to copy lsb to user is required for signalfd too.

Good catch. I don't think qemu uses this today, but it should be fixed there too for .37 at least.

-Andi

#6 lore raw

Re: [PATCH 2/4] HWPOISON: Copy si_addr_lsb to user

In reply to Andi Kleen
Quoted 6 lines · Andi Kleen

The original hwpoison code added a new siginfo field si_addr_lsb to pass the granuality of the fault address to user space. Unfortunately this field was never copied to user space. Fix this here.

I added explicit checks for the MCEERR codes to avoid having to patch all potential callers to initialize the field.

That doesn't fly, see below.

Quoted 4 lines
kernel/signal.c +0 -0
@@ -2215,6 +2215,14 @@ int copy_siginfo_to_user(siginfo_t __user *to, siginfo_t *from)
 #ifdef __ARCH_SI_TRAPNO

kernel/signal.c int copy_siginfo_to_user(siginfo_t __user *to, siginfo_t *from) · line 2225

Quoted 10 lines
kernel/signal.c +8 -0
 		err |= __put_user(from->si_trapno, &to->si_trapno);
 #endif
+#ifdef BUS_MCEERR_AO
+		/* 
+		 * Other callers might not initialize the si_lsb field,
+	 	 * so check explicitely for the right codes here.
+		 */
+		if (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO)
+			err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb);
+#endif

include/asm-generic/siginfo.h defines BUS_MCEERR_AR unconditionally and is getting include in all <asm/siginfo.h> so that #ifdef condition is always true. struct siginfo.si_addr_lsb is defined only for the generic struct siginfo. The architectures that define HAVE_ARCH_SIGINFO_T (MIPS and IA-64) do not define this field so the build breaks.

Ralf

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#7 lore raw

Re: [PATCH 2/4] HWPOISON: Copy si_addr_lsb to user

Quoted 12 lines · Ralf Baechle
Quoted 12 lines
kernel/signal.c +6 -0
@@ -2215,6 +2215,14 @@ int copy_siginfo_to_user(siginfo_t __user *to, siginfo_t *from)
 #ifdef __ARCH_SI_TRAPNO
 		err |= __put_user(from->si_trapno, &to->si_trapno);
 #endif
+#ifdef BUS_MCEERR_AO
+		/* 
+		 * Other callers might not initialize the si_lsb field,
+	 	 * so check explicitely for the right codes here.
+		 */
+		if (from->si_code == BUS_MCEERR_AR || from->si_code == BUS_MCEERR_AO)
Quoted 8 lines

kernel/signal.c int copy_siginfo_to_user(siginfo_t __user *to, siginfo_t *from) · line 2225

Quoted 2 lines
kernel/signal.c +2 -0
+			err |= __put_user(from->si_addr_lsb, &to->si_addr_lsb);
+#endif

include/asm-generic/siginfo.h defines BUS_MCEERR_AR unconditionally and is getting include in all <asm/siginfo.h> so that #ifdef condition is always true. struct siginfo.si_addr_lsb is defined only for the generic struct siginfo. The architectures that define HAVE_ARCH_SIGINFO_T (MIPS and IA-64) do not define this field so the build breaks.

Oops. I see two possible solutions:

#undef BUS_MCEERR_AR in the ia64 and mips siginfo.h or simply add the si_addr_lsb field there too (it just sits over padding and should be harmless)

What do you prefer?

-Andi

Signature · 7 lines
[email protected] -- Speaking for myself only.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
author
#8 lore raw

PATCH 3/4 HWPOISON: Report correct address granuality for AO huge page errors

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

The SIGBUS user space signalling is supposed to report the address granuality of a corruption. Pass this information correctly for huge pages by querying the hpage order.

---
 mm/memory-failure.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
mm/memory-failure.c +9 -6
index 9c26eec..886144b 100644
@@ -183,10 +183,11 @@ EXPORT_SYMBOL_GPL(hwpoison_filter);
  * signal.
  */
 static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno,
-			unsigned long pfn)
+			unsigned long pfn, struct page *page)
 {
 	struct siginfo si;
 	int ret;
+	unsigned order;
 
 	printk(KERN_ERR
 		"MCE %#lx: Killing %s:%d early due to hardware memory corruption\n",
@@ -198,7 +199,8 @@ static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno,
 #ifdef __ARCH_SI_TRAPNO
 	si.si_trapno = trapno;
 #endif
-	si.si_addr_lsb = PAGE_SHIFT;
+	order = PageCompound(page) ? huge_page_order(page) : PAGE_SHIFT;
+	si.si_addr_lsb = order;
 	/*
 	 * Don't use force here, it's convenient if the signal
 	 * can be temporarily blocked.
@@ -327,7 +329,7 @@ static void add_to_kill(struct task_struct *tsk, struct page *p,
  * wrong earlier.
  */
 static void kill_procs_ao(struct list_head *to_kill, int doit, int trapno,
-			  int fail, unsigned long pfn)
+			  int fail, struct page *page, unsigned long pfn)
 {
 	struct to_kill *tk, *next;
 
@@ -341,7 +343,8 @@ static void kill_procs_ao(struct list_head *to_kill, int doit, int trapno,
 			if (fail || tk->addr_valid == 0) {
 				printk(KERN_ERR
 		"MCE %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n",
-					pfn, tk->tsk->comm, tk->tsk->pid);
+					pfn,	
+					tk->tsk->comm, tk->tsk->pid);
 				force_sig(SIGKILL, tk->tsk);
 			}
 
@@ -352,7 +355,7 @@ static void kill_procs_ao(struct list_head *to_kill, int doit, int trapno,
 			 * process anyways.
 			 */
 			else if (kill_proc_ao(tk->tsk, tk->addr, trapno,
-					      pfn) < 0)
+					      pfn, page) < 0)
 				printk(KERN_ERR
 		"MCE %#lx: Cannot send advisory machine check signal to %s:%d\n",
 					pfn, tk->tsk->comm, tk->tsk->pid);
@@ -928,7 +931,7 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
 	 * any accesses to the poisoned memory.
 	 */
 	kill_procs_ao(&tokill, !!PageDirty(hpage), trapno,
-		      ret != SWAP_SUCCESS, pfn);
+		      ret != SWAP_SUCCESS, p, pfn);
 
 	return ret;
 }
Signature · 7 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#9 lore raw

Re: [PATCH 3/4] HWPOISON: Report correct address granuality for AO huge page errors

mm/memory-failure.c static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno, · line 202

Quoted 6 lines
mm/memory-failure.c +1 -1
@@ -198,7 +199,8 @@ static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno,
 #ifdef __ARCH_SI_TRAPNO
 	si.si_trapno = trapno;
 #endif
-	si.si_addr_lsb = PAGE_SHIFT;
+	order = PageCompound(page) ? huge_page_order(page) : PAGE_SHIFT;
                                                     ^^^^
                                     huge_page_order(page_hstate(page)) ?
Quoted 4 lines
mm/memory-failure.c +1 -0
+	si.si_addr_lsb = order;
 	/*
 	 * Don't use force here, it's convenient if the signal
 	 * can be temporarily blocked.

...

mm/memory-failure.c static void kill_procs_ao(struct list_head *to_kill, int doit, int trapno, · line 347

Quoted 7 lines
mm/memory-failure.c +2 -1
@@ -341,7 +343,8 @@ static void kill_procs_ao(struct list_head *to_kill, int doit, int trapno,
 			if (fail || tk->addr_valid == 0) {
 				printk(KERN_ERR
 		"MCE %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n",
-					pfn, tk->tsk->comm, tk->tsk->pid);
+					pfn,	
+					tk->tsk->comm, tk->tsk->pid);

What's the point of this change?

Thanks,
Naoya Horiguchi

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#10 lore raw

Re: [PATCH 3/4] HWPOISON: Report correct address granuality for AO huge page errors

Quoted 8 lines · Naoya Horiguchi

mm/memory-failure.c static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno, · line 202

Quoted 6 lines
mm/memory-failure.c +1 -1
@@ -198,7 +199,8 @@ static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno,
 #ifdef __ARCH_SI_TRAPNO
 	si.si_trapno = trapno;
 #endif
-	si.si_addr_lsb = PAGE_SHIFT;
+	order = PageCompound(page) ? huge_page_order(page) : PAGE_SHIFT;
                                                     ^^^^
                                     huge_page_order(page_hstate(page)) ?

Ok.

Quoted 7 lines

mm/memory-failure.c static void kill_procs_ao(struct list_head *to_kill, int doit, int trapno, · line 347

Quoted 5 lines
mm/memory-failure.c +2 -1
 				printk(KERN_ERR
 		"MCE %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n",
-					pfn, tk->tsk->comm, tk->tsk->pid);
+					pfn,	
+					tk->tsk->comm, tk->tsk->pid);

What's the point of this change?

Probably left over from an earlier version; I will drop that hunk thanks.

-Andi

Signature · 7 lines
[email protected] -- Speaking for myself only.

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
#11 lore raw

Re: [PATCH 3/4] HWPOISON: Report correct address granuality for AO huge page errors

Quoted 11 lines · Andi Kleen
Quoted 8 lines · Naoya Horiguchi

mm/memory-failure.c static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno, · line 202

Quoted 6 lines
mm/memory-failure.c +1 -1
@@ -198,7 +199,8 @@ static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno,
 #ifdef __ARCH_SI_TRAPNO
 	si.si_trapno = trapno;
 #endif
-	si.si_addr_lsb = PAGE_SHIFT;
+	order = PageCompound(page) ? huge_page_order(page) : PAGE_SHIFT;
                                                     ^^^^
                                     huge_page_order(page_hstate(page)) ?

Ok.

order seems to represent a least significant bit of corrupted address, so is huge_page_order() + PAGE_SHIFT or huge_page_shift() correct?
And since @page can be a tail page, compound_head() is needed as Wu-san pointed out. So huge_page_shift(page_hstate(compound_head(page))) looks good for me.

Thanks,
Naoya Horiguchi

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#12 lore raw

Re: [PATCH 3/4] HWPOISON: Report correct address granuality for AO huge page errors

Quoted 11 lines · Naoya Horiguchi
Quoted 10 lines · Andi Kleen
Quoted 8 lines · Naoya Horiguchi

mm/memory-failure.c static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno, · line 202

Quoted 6 lines
mm/memory-failure.c +1 -1
@@ -198,7 +199,8 @@ static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno,
 #ifdef __ARCH_SI_TRAPNO
 	si.si_trapno = trapno;
 #endif
-	si.si_addr_lsb = PAGE_SHIFT;
+	order = PageCompound(page) ? huge_page_order(page) : PAGE_SHIFT;
                                                     ^^^^
                                     huge_page_order(page_hstate(page)) ?
Quoted 4 lines
Quoted 1 line

Ok.

order seems to represent a least significant bit of corrupted address, so is huge_page_order() + PAGE_SHIFT or huge_page_shift() correct?

Both I guess.

Quoted 2 lines

And since @page can be a tail page, compound_head() is needed as Wu-san pointed out. So huge_page_shift(page_hstate(compound_head(page))) looks good for me.

I used compound_order(compound_head(page)) + PAGE_SHIFT now. This even works for non compound, so the special case check can be dropped.

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only.
#13 lore raw

Re: [PATCH 3/4] HWPOISON: Report correct address granuality for AO huge page errors

Quoted 17 lines · Andi Kleen
Quoted 11 lines · Naoya Horiguchi
Quoted 10 lines · Andi Kleen
Quoted 8 lines · Naoya Horiguchi

mm/memory-failure.c static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno, · line 202

Quoted 6 lines
mm/memory-failure.c +1 -1
@@ -198,7 +199,8 @@ static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno,
 #ifdef __ARCH_SI_TRAPNO
 	si.si_trapno = trapno;
 #endif
-	si.si_addr_lsb = PAGE_SHIFT;
+	order = PageCompound(page) ? huge_page_order(page) : PAGE_SHIFT;
                                                     ^^^^
                                     huge_page_order(page_hstate(page)) ?
Quoted 4 lines
Quoted 1 line

Ok.

order seems to represent a least significant bit of corrupted address, so is huge_page_order() + PAGE_SHIFT or huge_page_shift() correct?

Quoted 8 lines

Both I guess.

Quoted 2 lines

And since @page can be a tail page, compound_head() is needed as Wu-san pointed out. So huge_page_shift(page_hstate(compound_head(page))) looks good for me.

I used compound_order(compound_head(page)) + PAGE_SHIFT now. This even works for non compound, so the special case check can be dropped.

OK.

Thanks,
Naoya Horiguchi

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#14 lore raw

Re: [PATCH 3/4] HWPOISON: Report correct address granuality for AO huge page errors

Quoted 5 lines
Quoted 3 lines

I used compound_order(compound_head(page)) + PAGE_SHIFT now. This even works for non compound, so the special case check can be dropped.

OK.

BTW it would be nice if mce-test checked this for the huge page case too. (I fixed this for small pages)

-Andi

Signature · 1 line
[email protected] -- Speaking for myself only.
Reviewed-by on v1 3/4
#15 lore raw

Re: [PATCH 3/4] HWPOISON: Report correct address granuality for AO huge page errors

In reply to Andi Kleen
Quoted 31 lines · Andi Kleen

From: Andi Kleen <[email protected]>

The SIGBUS user space signalling is supposed to report the address granuality of a corruption. Pass this information correctly for huge pages by querying the hpage order.

---
 mm/memory-failure.c |   15 +++++++++------
 1 files changed, 9 insertions(+), 6 deletions(-)
mm/memory-failure.c +2 -1
index 9c26eec..886144b 100644
@@ -183,10 +183,11 @@ EXPORT_SYMBOL_GPL(hwpoison_filter);
  * signal.
  */
 static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno,
-			unsigned long pfn)
+			unsigned long pfn, struct page *page)
 {
 	struct siginfo si;
 	int ret;
+	unsigned order;
 
 	printk(KERN_ERR
 		"MCE %#lx: Killing %s:%d early due to hardware memory corruption\n",

mm/memory-failure.c static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno, · line 202

Quoted 5 lines
mm/memory-failure.c +1 -1
@@ -198,7 +199,8 @@ static int kill_proc_ao(struct task_struct *t, unsigned long addr, int trapno,
 #ifdef __ARCH_SI_TRAPNO
 	si.si_trapno = trapno;
 #endif
-	si.si_addr_lsb = PAGE_SHIFT;
+	order = PageCompound(page) ? huge_page_order(page) : PAGE_SHIFT;

huge_page_order() expects struct hstate *h. Should be compound_order(compound_head(page)) or compound_order(page) if it's already a head page.

btw, I notice that force_sig_info_fault() sets

        info.si_addr_lsb = si_code == BUS_MCEERR_AR ? PAGE_SHIFT : 0;

What's the intention of conditional 0 here?

Quoted 33 lines
mm/memory-failure.c +5 -3
+	si.si_addr_lsb = order;
 	/*
 	 * Don't use force here, it's convenient if the signal
 	 * can be temporarily blocked.
@@ -327,7 +329,7 @@ static void add_to_kill(struct task_struct *tsk, struct page *p,
  * wrong earlier.
  */
 static void kill_procs_ao(struct list_head *to_kill, int doit, int trapno,
-			  int fail, unsigned long pfn)
+			  int fail, struct page *page, unsigned long pfn)
 {
 	struct to_kill *tk, *next;
 
@@ -341,7 +343,8 @@ static void kill_procs_ao(struct list_head *to_kill, int doit, int trapno,
 			if (fail || tk->addr_valid == 0) {
 				printk(KERN_ERR
 		"MCE %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n",
-					pfn, tk->tsk->comm, tk->tsk->pid);
+					pfn,	
+					tk->tsk->comm, tk->tsk->pid);
 				force_sig(SIGKILL, tk->tsk);
 			}
 
@@ -352,7 +355,7 @@ static void kill_procs_ao(struct list_head *to_kill, int doit, int trapno,
 			 * process anyways.
 			 */
 			else if (kill_proc_ao(tk->tsk, tk->addr, trapno,
-					      pfn) < 0)
+					      pfn, page) < 0)
 				printk(KERN_ERR
 		"MCE %#lx: Cannot send advisory machine check signal to %s:%d\n",
 					pfn, tk->tsk->comm, tk->tsk->pid);

mm/memory-failure.c static int hwpoison_user_mappings(struct page *p, unsigned long pfn, · line 934

Quoted 5 lines
mm/memory-failure.c +1 -1
@@ -928,7 +931,7 @@ static int hwpoison_user_mappings(struct page *p, unsigned long pfn,
 	 * any accesses to the poisoned memory.
 	 */
 	kill_procs_ao(&tokill, !!PageDirty(hpage), trapno,
-		      ret != SWAP_SUCCESS, pfn);
+		      ret != SWAP_SUCCESS, p, pfn);

It seems a bit better to pass "hpage" (the head page) instead of "p" since the function only referenced the head page, and "p" is somehow duplicated with "pfn".

Thanks,
Fengguang

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

author
#16 lore raw

PATCH 4/4 HWPOISON: Stop shrinking at right page count

In reply to Andi Kleen

From: Andi Kleen <[email protected]>

When we call the slab shrinker to free a page we need to stop at page count one because the caller always holds a single reference, not zero.

This avoids useless looping over slab shrinkers and freeing too much memory.

---
 mm/memory-failure.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/memory-failure.c +1 -1
index 886144b..7c1af9b 100644
@@ -237,7 +237,7 @@ void shake_page(struct page *p, int access)
 		int nr;
 		do {
 			nr = shrink_slab(1000, GFP_KERNEL, 1000);
-			if (page_count(p) == 0)
+			if (page_count(p) == 1)
 				break;
 		} while (nr > 10);
 	}
Signature · 7 lines
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>
Reviewed-by on v1 4/4
#17 lore raw

Re: [PATCH 4/4] HWPOISON: Stop shrinking at right page count

Quoted 9 lines · Andi Kleen

From: Andi Kleen <[email protected]>

When we call the slab shrinker to free a page we need to stop at page count one because the caller always holds a single reference, not zero.

This avoids useless looping over slab shrinkers and freeing too much memory.

Good catch!

Quoted 19 lines
---
 mm/memory-failure.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
mm/memory-failure.c +1 -1
index 886144b..7c1af9b 100644
@@ -237,7 +237,7 @@ void shake_page(struct page *p, int access)
 		int nr;
 		do {
 			nr = shrink_slab(1000, GFP_KERNEL, 1000);
-			if (page_count(p) == 0)
+			if (page_count(p) == 1)
 				break;
 		} while (nr > 10);
 	}
Signature · 1 line
1.7.1

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>