linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: Jane Chu <jane.chu@oracle.com>
To: Miaohe Lin <linmiaohe@huawei.com>,
	nao.horiguchi@gmail.com, akpm@linux-foundation.org,
	linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] mm/memory-failure: try to send SIGBUS even if unmap failed
Date: Thu, 9 May 2024 09:40:31 -0700	[thread overview]
Message-ID: <fdb287c4-1db9-425e-84fc-013ef539cf72@oracle.com> (raw)
In-Reply-To: <d5dc761e-3f66-99a3-5325-dd2f161235cf@huawei.com>

On 5/8/2024 7:54 PM, Miaohe Lin wrote:

> On 2024/5/2 7:24, Jane Chu wrote:
>> For years when it comes down to kill a process due to hwpoison,
>> a SIGBUS is delivered only if unmap has been successful.
>> Otherwise, a SIGKILL is delivered. And the reason for that is
>> to prevent the involved process from accessing the hwpoisoned
>> page again.
>>
>> Since then a lot has changed, a hwpoisoned page is marked and
>> upon being re-accessed, the process will be killed immediately.
>> So let's take out the '!unmap_success' factor and try to deliver
>> SIGBUS if possible.
>>
>> Signed-off-by: Jane Chu <jane.chu@oracle.com>
>> ---
>>   mm/memory-failure.c | 13 ++++---------
>>   1 file changed, 4 insertions(+), 9 deletions(-)
>>
>> diff --git a/mm/memory-failure.c b/mm/memory-failure.c
>> index 9e62a00b46dd..7fcf182abb96 100644
>> --- a/mm/memory-failure.c
>> +++ b/mm/memory-failure.c
>> @@ -519,19 +519,14 @@ void add_to_kill_ksm(struct task_struct *tsk, struct page *p,
>>    * Also when FAIL is set do a force kill because something went
>>    * wrong earlier.
>>    */
>> -static void kill_procs(struct list_head *to_kill, int forcekill, bool fail,
>> +static void kill_procs(struct list_head *to_kill, int forcekill,
>>   		unsigned long pfn, int flags)
>>   {
>>   	struct to_kill *tk, *next;
>>   
>>   	list_for_each_entry_safe(tk, next, to_kill, nd) {
>>   		if (forcekill) {
>> -			/*
>> -			 * In case something went wrong with munmapping
>> -			 * make sure the process doesn't catch the
>> -			 * signal and then access the memory. Just kill it.
>> -			 */
>> -			if (fail || tk->addr == -EFAULT) {
>> +			if (tk->addr == -EFAULT) {
>>   				pr_err("%#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,
>> @@ -1666,7 +1661,7 @@ static bool hwpoison_user_mappings(struct page *p, unsigned long pfn,
>>   	 */
> There is comment above the forcekill saying:
>
>      When there was a problem unmapping earlier use a more force-full
> uncatchable kill to prevent any accesses to the poisoned memory.
>
> This might need to be changed too.

Yes, will do.

thanks!

-jane

> Thanks.
> .
>
>>   	forcekill = PageDirty(hpage) || (flags & MF_MUST_KILL) ||
>>   		    !unmap_success;
>> -	kill_procs(&tokill, forcekill, !unmap_success, pfn, flags);
>> +	kill_procs(&tokill, forcekill, pfn, flags);
>>   
>>   	return unmap_success;
>>   }
>> @@ -1730,7 +1725,7 @@ static void unmap_and_kill(struct list_head *to_kill, unsigned long pfn,
>>   		unmap_mapping_range(mapping, start, size, 0);
>>   	}
>>   
>> -	kill_procs(to_kill, flags & MF_MUST_KILL, false, pfn, flags);
>> +	kill_procs(to_kill, flags & MF_MUST_KILL, pfn, flags);
>>   }
>>   
>>   /*
>>
>


  reply	other threads:[~2024-05-09 16:40 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-01 23:24 [PATCH 0/3] Enhance soft hwpoison handling and injection Jane Chu
2024-05-01 23:24 ` [PATCH 1/3] mm/memory-failure: try to send SIGBUS even if unmap failed Jane Chu
2024-05-07  9:02   ` Oscar Salvador
2024-05-07 17:54     ` Jane Chu
2024-05-08 12:06       ` Oscar Salvador
2024-05-08 16:51         ` Jane Chu
2024-05-08  7:47   ` Miaohe Lin
2024-05-08 16:58     ` Jane Chu
2024-05-09  2:54   ` Miaohe Lin
2024-05-09 16:40     ` Jane Chu [this message]
2024-05-01 23:24 ` [PATCH 2/3] mm/madvise: Add MF_ACTION_REQUIRED to madvise(MADV_HWPOISON) Jane Chu
2024-05-05  7:02   ` Miaohe Lin
2024-05-06 19:54     ` Jane Chu
2024-05-08  7:58       ` Miaohe Lin
2024-05-01 23:24 ` [PATCH 3/3] mm/memory-failure: send SIGBUS in the event of thp split fail Jane Chu
2024-05-05  7:00   ` Miaohe Lin
2024-05-06 20:26     ` Jane Chu
2024-05-08  8:08       ` Miaohe Lin
2024-05-08 17:45         ` Jane Chu
2024-05-09  8:30           ` Miaohe Lin
2024-05-09 15:34             ` Jane Chu
2024-05-10  2:59               ` Miaohe Lin
2024-05-10  3:18                 ` Jane Chu
2024-05-08  9:03   ` Miaohe Lin
2024-05-08 16:56     ` Jane Chu
2024-05-09  8:52       ` Miaohe Lin

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=fdb287c4-1db9-425e-84fc-013ef539cf72@oracle.com \
    --to=jane.chu@oracle.com \
    --cc=akpm@linux-foundation.org \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nao.horiguchi@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox