linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v4] mm,hwpoison: Differentiate Action Required error in current and non  current processes
@ 2021-01-20  7:03 Aili Yao
  2021-01-20  7:59 ` HORIGUCHI NAOYA(堀口 直也)
  0 siblings, 1 reply; 3+ messages in thread
From: Aili Yao @ 2021-01-20  7:03 UTC (permalink / raw)
  To: naoya.horiguchi, linux-mm, osalvador, YANGFENG1

When a memory uncorrected error is triggered by process A who accessed
the address with error; It's Action Required Case for only current
process which triggered this.this Action Required case means Action
optional to other process who share the same page. Usually, kill current
process will be sufficient, other process sharing the same page will
get be signaled when they really touch the poisoned page.

But there is another scenario that other processes
sharing the same page want to be signaled early with PF_MCE_EARLY set,
In this case, we should get them into kill list and signal
BUS_MCEERR_AO to them.

So in this patch, task_early_kill will check current process if
force_early is set, and if not current,check find_early_kill_thread
to see if there is PF_MCE_EARLY process which cares the error.

In kill_proc, BUS_MCEERR_AR is only send to current, other process in
kill list will be signaled BUS_MCEERR_AO.

Signed-off-by: Aili Yao <yaoaili@kingsoft.com>
---
 mm/memory-failure.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 5a38e9eade94..4586d501aeb9 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -243,9 +243,12 @@ static int kill_proc(struct to_kill *tk, unsigned long pfn, int flags)
 			pfn, t->comm, t->pid);
 
 	if (flags & MF_ACTION_REQUIRED) {
-		WARN_ON_ONCE(t != current);
-		ret = force_sig_mceerr(BUS_MCEERR_AR,
+		if (tk->tsk == current)
+			ret = force_sig_mceerr(BUS_MCEERR_AR,
 					 (void __user *)tk->addr, addr_lsb);
+		else
+			ret = send_sig_mceerr(BUS_MCEERR_AO, (void __user *)tk->addr,
+				addr_lsb, t);
 	} else {
 		/*
 		 * Don't use force here, it's convenient if the signal
@@ -440,10 +443,13 @@ static struct task_struct *find_early_kill_thread(struct task_struct *tsk)
  * Determine whether a given process is "early kill" process which expects
  * to be signaled when some page under the process is hwpoisoned.
  * Return task_struct of the dedicated thread (main thread unless explicitly
- * specified) if the process is "early kill," and otherwise returns NULL.
+ * specified) if the process is "early kill" and otherwise returns NULL.
  *
- * Note that the above is true for Action Optional case, but not for Action
- * Required case where SIGBUS should sent only to the current thread.
+ * Note that the above is true for Action Optional case. For Action Required
+ * case, it's only meaningful to the current thread which need to be signaled
+ * with SIGBUS, this error is Action Optional for other non current
+ * processes sharing the same error page,if the process is "early kill",the
+ * task_struct of the dedicated thread will also be returned.
  */
 static struct task_struct *task_early_kill(struct task_struct *tsk,
 					   int force_early)
@@ -457,8 +463,6 @@ static struct task_struct *task_early_kill(struct task_struct *tsk,
 		 */
 		if (tsk->mm == current->mm)
 			return current;
-		else
-			return NULL;
 	}
 	return find_early_kill_thread(tsk);
 }
-- 
2.25.1



-- 
Best Regards!

Aili Yao


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

* Re: [PATCH v4] mm,hwpoison: Differentiate Action Required error in current and non  current processes
  2021-01-20  7:03 [PATCH v4] mm,hwpoison: Differentiate Action Required error in current and non current processes Aili Yao
@ 2021-01-20  7:59 ` HORIGUCHI NAOYA(堀口 直也)
  2021-01-20  8:27   ` Aili Yao
  0 siblings, 1 reply; 3+ messages in thread
From: HORIGUCHI NAOYA(堀口 直也) @ 2021-01-20  7:59 UTC (permalink / raw)
  To: Aili Yao; +Cc: linux-mm, osalvador, YANGFENG1

It's desirable that $SUBJECT represents what that patch does, so
how about something like
"mm, hwpoison: send SIGBUS to PF_MCE_EARLY processes on action required events" ?

On Wed, Jan 20, 2021 at 03:03:02PM +0800, Aili Yao wrote:
> When a memory uncorrected error is triggered by process A who accessed
> the address with error; It's Action Required Case for only current
> process which triggered this.this Action Required case means Action
> optional to other process who share the same page. Usually, kill current
> process will be sufficient, other process sharing the same page will
> get be signaled when they really touch the poisoned page.
> 
> But there is another scenario that other processes
> sharing the same page want to be signaled early with PF_MCE_EARLY set,
> In this case, we should get them into kill list and signal
> BUS_MCEERR_AO to them.
> 
> So in this patch, task_early_kill will check current process if
> force_early is set, and if not current,check find_early_kill_thread
> to see if there is PF_MCE_EARLY process which cares the error.
> 
> In kill_proc, BUS_MCEERR_AR is only send to current, other process in
> kill list will be signaled BUS_MCEERR_AO.
> 
> Signed-off-by: Aili Yao <yaoaili@kingsoft.com>
...
> @@ -440,10 +443,13 @@ static struct task_struct *find_early_kill_thread(struct task_struct *tsk)
>   * Determine whether a given process is "early kill" process which expects
>   * to be signaled when some page under the process is hwpoisoned.
>   * Return task_struct of the dedicated thread (main thread unless explicitly
> - * specified) if the process is "early kill," and otherwise returns NULL.
> + * specified) if the process is "early kill" and otherwise returns NULL.
>   *
> - * Note that the above is true for Action Optional case, but not for Action
> - * Required case where SIGBUS should sent only to the current thread.
> + * Note that the above is true for Action Optional case. For Action Required
> + * case, it's only meaningful to the current thread which need to be signaled
> + * with SIGBUS, this error is Action Optional for other non current
> + * processes sharing the same error page,if the process is "early kill",the

Please insert a whitespace after commas (just for convention).

With these fixed, I agree with this patch.

Acked-by: Naoya Horiguchi <naoya.horiguchi@nec.com>

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

* Re: [PATCH v4] mm,hwpoison: Differentiate Action Required error in current and non  current processes
  2021-01-20  7:59 ` HORIGUCHI NAOYA(堀口 直也)
@ 2021-01-20  8:27   ` Aili Yao
  0 siblings, 0 replies; 3+ messages in thread
From: Aili Yao @ 2021-01-20  8:27 UTC (permalink / raw)
  To: HORIGUCHI NAOYA(堀口 直也)
  Cc: linux-mm, osalvador, YANGFENG1

On Wed, 20 Jan 2021 07:59:23 +0000
HORIGUCHI NAOYA(堀口 直也) <naoya.horiguchi@nec.com> wrote:

> It's desirable that $SUBJECT represents what that patch does, so
> how about something like
> "mm, hwpoison: send SIGBUS to PF_MCE_EARLY processes on action required events" ?

This one looks better, i will change to that. Thanks

> ...
> > @@ -440,10 +443,13 @@ static struct task_struct *find_early_kill_thread(struct task_struct *tsk)
> >   * Determine whether a given process is "early kill" process which expects
> >   * to be signaled when some page under the process is hwpoisoned.
> >   * Return task_struct of the dedicated thread (main thread unless explicitly
> > - * specified) if the process is "early kill," and otherwise returns NULL.
> > + * specified) if the process is "early kill" and otherwise returns NULL.
> >   *
> > - * Note that the above is true for Action Optional case, but not for Action
> > - * Required case where SIGBUS should sent only to the current thread.
> > + * Note that the above is true for Action Optional case. For Action Required
> > + * case, it's only meaningful to the current thread which need to be signaled
> > + * with SIGBUS, this error is Action Optional for other non current
> > + * processes sharing the same error page,if the process is "early kill",the  
> 

Thanks for reminding, I will fix this in v5 patch

Thank you!

-- 
Best Regards!

Aili Yao


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

end of thread, other threads:[~2021-01-20  8:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-20  7:03 [PATCH v4] mm,hwpoison: Differentiate Action Required error in current and non current processes Aili Yao
2021-01-20  7:59 ` HORIGUCHI NAOYA(堀口 直也)
2021-01-20  8:27   ` Aili Yao

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