linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: shengminghu512 <shengminghu512@qq.com>
To: linmiaohe <linmiaohe@huawei.com>,
	"nao.horiguchi" <nao.horiguchi@gmail.com>,
	akpm <akpm@linux-foundation.org>
Cc: linux-mm <linux-mm@kvack.org>,
	linux-kernel <linux-kernel@vger.kernel.org>,
	"hu.shengming" <hu.shengming@zte.com.cn>,
	shengminghu512 <shengminghu512@qq.com>,
	"zhang.run" <zhang.run@zte.com.cn>
Subject: [PATCH V2] mm/memory-failure: Ensure collect_procs is retried when  unmap fails
Date: Tue, 23 Sep 2025 22:57:09 +0800	[thread overview]
Message-ID: <tencent_EDEED996FC685E61AADA14A23BCE9CCDAF09@qq.com> (raw)

From: Shengming Hu <shengminghu512@qq.com>
Date: Tue, 23 Sep 2025 20:56:28 +0800
Subject: [PATCH V2] mm/memory-failure: Ensure collect_procs is retried when
 unmap fails

In the memory_failure process, if collect_procs is not executed with the
flag set, the to_kill list may be empty. Even if there are pages that fail
to be unmapped, SIGKILL or SIGBUS cannot be sent to the process via
collect_procs.

This patch fixes the issue by re-executing collect_procs when the to_kill
list is empty and unmap fails. This collects processes with unmap failures
into the to_kill list, allowing SIGBUS or SIGKILL to terminate them in
subsequent code.

V2:
  - Resent as plain text (previous version was HTML).
  - No functional changes.

Signed-off-by: Shengming Hu <hu.shengming@zte.com.cn>
---
 mm/memory-failure.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index a24806bb8e82..8157823c7fb7 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -1600,9 +1600,12 @@ static bool hwpoison_user_mappings(struct folio *folio, struct page *p,
 	collect_procs(folio, p, &tokill, flags & MF_ACTION_REQUIRED);
 
 	unmap_success = !unmap_poisoned_folio(folio, pfn, flags & MF_MUST_KILL);
-	if (!unmap_success)
+	if (!unmap_success) {
 		pr_err("%#lx: failed to unmap page (folio mapcount=%d)\n",
 		       pfn, folio_mapcount(folio));
+		if (list_empty(&tokill))
+			collect_procs(folio, p, &tokill, 1);
+	}
 
 	/*
 	 * try_to_unmap() might put mlocked page in lru cache, so call
-- 
2.25.1

             reply	other threads:[~2025-09-23 14:57 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-23 14:57 shengminghu512 [this message]
2025-09-23 22:17 ` Jiaqi Yan
2025-09-24 13:33   ` =?gb18030?B?c2hlbmdtaW5naHU1MTI=?=
2025-09-24 13:55   ` [PATCH V2] mm/memory-failure: Ensure collect_procs is retriedwhen " shengminghu512

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=tencent_EDEED996FC685E61AADA14A23BCE9CCDAF09@qq.com \
    --to=shengminghu512@qq.com \
    --cc=akpm@linux-foundation.org \
    --cc=hu.shengming@zte.com.cn \
    --cc=linmiaohe@huawei.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=nao.horiguchi@gmail.com \
    --cc=zhang.run@zte.com.cn \
    /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