All of lore.kernel.org
 help / color / mirror / Atom feed
From: Aili Yao <yaoaili@kingsoft.com>
To: <naoya.horiguchi@nec.com>, <linux-mm@kvack.org>,
	<osalvador@suse.de>, <YANGFENG1@kingsoft.com>
Subject: [PATCH v2] mm,hwpoison:Differentiate Action Required error in current and non current process
Date: Tue, 19 Jan 2021 12:15:30 +0800	[thread overview]
Message-ID: <20210119120956.7f901b76.yaoaili@kingsoft.com> (raw)

Hello,From 6f7f0582509e1b2aaa23e06868fee96f024e9551 Mon Sep 17 00:00:00 2001
From: Aili Yao <yaoaili@kingsoft.com>
Date: Tue, 19 Jan 2021 11:46:50 +0800
Subject: [PATCH] mm,hwpoison:Differentiate Action Required error in current
 and non current process

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 | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index 5a38e9eade94..808ff7c24f38 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
@@ -391,10 +394,14 @@ static void kill_procs(struct list_head *to_kill, int forcekill, bool fail,
 			 * signal and then access the memory. Just kill it.
 			 */
 			if (fail || tk->addr == -EFAULT) {
-				pr_err("Memory failure: %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n",
-				       pfn, tk->tsk->comm, tk->tsk->pid);
-				do_send_sig_info(SIGKILL, SEND_SIG_PRIV,
+				if (tk->tsk == current) {
+					pr_err("Memory failure: %#lx: forcibly killing %s:%d because of failure to unmap corrupted page\n",
+						pfn, tk->tsk->comm, tk->tsk->pid);
+					do_send_sig_info(SIGKILL, SEND_SIG_PRIV,
 						 tk->tsk, PIDTYPE_PID);
+				} else if (kill_proc(tk, pfn, flags) < 0)
+					pr_err("Memory failure: %#lx: Cannot send advisory machine check signal to %s:%d\n",
+						pfn, tk->tsk->comm, tk->tsk->pid);
 			}
 
 			/*
@@ -457,8 +464,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


             reply	other threads:[~2021-01-19  4:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-19  4:15 Aili Yao [this message]
2021-01-20  0:06 ` [PATCH v2] mm,hwpoison:Differentiate Action Required error in current and non current process HORIGUCHI NAOYA(堀口 直也)
2021-01-20  6:07   ` Aili Yao

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=20210119120956.7f901b76.yaoaili@kingsoft.com \
    --to=yaoaili@kingsoft.com \
    --cc=YANGFENG1@kingsoft.com \
    --cc=linux-mm@kvack.org \
    --cc=naoya.horiguchi@nec.com \
    --cc=osalvador@suse.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.