From: Muchun Song <muchun.song@linux.dev>
To: Oscar Salvador <osalvador@suse.de>, Miaohe Lin <linmiaohe@huawei.com>
Cc: Muchun Song <songmuchun@bytedance.com>,
Vishal Verma <vishal.l.verma@intel.com>,
Ying Huang <huang.ying.caritas@gmail.com>,
Dan Williams <djbw@kernel.org>,
Naoya Horiguchi <nao.horiguchi@gmail.com>,
linux-mm@kvack.org, linux-cxl@vger.kernel.org,
driver-core@lists.linux.dev, linux-kernel@vger.kernel.org,
stable@vger.kernel.org, David Hildenbrand <david@kernel.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Rafael J Wysocki <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH v2 3/3] drivers/base/memory: fix locking for poison accounting lookup
Date: Wed, 29 Apr 2026 12:18:08 +0800 [thread overview]
Message-ID: <A3EF6D95-E3B9-4228-9AED-A7018ED494C5@linux.dev> (raw)
In-Reply-To: <afF7vI_fNXs4mCVA@localhost.localdomain>
> On Apr 29, 2026, at 11:32, Oscar Salvador <osalvador@suse.de> wrote:
>
> On Wed, Apr 29, 2026 at 11:08:51AM +0800, Miaohe Lin wrote:
>> Right, I missed that. Thanks. But I'm still worried that there might be potential issues.
>> For example, this function could be called while lock_page is held. Acquiring lock_device_hotplug
>> while already holding lock_page might cause problems, though I haven't seen any specific issues yet.
>> Also there might be some other potential scenarios that haven't been considered. Hope I'm just
>> overthinking it. :)
>
> lock_device_hotplug is a mutex lock, and we already take other mutex locks while
> holding lock_folio in other paths, so I am not sure I see what should be special
> in this case.
Hi Oscar and Miaohe,
I saw sashiko's report [1] related to folio lock and lock_device_hotplug.
Seems it is possible. You can correct me if I am wrong.
[1] https://sashiko.dev/#/patchset/20260428085219.1316047-1-songmuchun%40bytedance.com
We could fix this by calling action_result() without holding folio lock.
What do you think?
diff --git a/mm/memory-failure.c b/mm/memory-failure.c
index ee42d4361309..bc76066547ce 100644
--- a/mm/memory-failure.c
+++ b/mm/memory-failure.c
@@ -2534,8 +2534,9 @@ int memory_failure(unsigned long pfn, int flags)
* Abort on fail: __filemap_remove_folio() assumes unmapped page.
*/
if (!hwpoison_user_mappings(folio, p, pfn, flags)) {
+ folio_unlock(folio);
res = action_result(pfn, MF_MSG_UNMAP_FAILED, MF_FAILED);
- goto unlock_page;
+ goto unlock_mutex;
}
/*
@@ -2543,16 +2544,15 @@ int memory_failure(unsigned long pfn, int flags)
*/
if (folio_test_lru(folio) && !folio_test_swapcache(folio) &&
folio->mapping == NULL) {
+ folio_unlock(folio);
res = action_result(pfn, MF_MSG_TRUNCATED_LRU, MF_IGNORED);
- goto unlock_page;
+ goto unlock_mutex;
}
identify_page_state:
res = identify_page_state(pfn, p, page_flags);
mutex_unlock(&mf_mutex);
return res;
-unlock_page:
- folio_unlock(folio);
unlock_mutex:
mutex_unlock(&mf_mutex);
return res;
>
>
> --
> Oscar Salvador
> SUSE Labs
next prev parent reply other threads:[~2026-04-29 4:19 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-28 13:52 [PATCH v2 3/3] drivers/base/memory: fix locking for poison accounting lookup Muchun Song
2026-04-29 3:08 ` Miaohe Lin
2026-04-29 3:32 ` Oscar Salvador
2026-04-29 4:18 ` Muchun Song [this message]
2026-04-29 10:11 ` Usama Arif
2026-04-29 10:44 ` David Hildenbrand (Arm)
2026-04-30 7:59 ` Muchun Song
2026-04-30 15:50 ` Andrew Morton
[not found] <20260428085219.1316047-1-songmuchun@bytedance.com>
2026-04-28 8:52 ` Muchun Song
2026-04-28 9:17 ` Oscar Salvador
2026-04-28 9:21 ` Muchun Song
2026-04-28 11:37 ` Miaohe Lin
2026-04-28 11:40 ` Muchun Song
2026-04-28 12:34 ` 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=A3EF6D95-E3B9-4228-9AED-A7018ED494C5@linux.dev \
--to=muchun.song@linux.dev \
--cc=akpm@linux-foundation.org \
--cc=dakr@kernel.org \
--cc=david@kernel.org \
--cc=djbw@kernel.org \
--cc=driver-core@lists.linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=huang.ying.caritas@gmail.com \
--cc=linmiaohe@huawei.com \
--cc=linux-cxl@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=rafael@kernel.org \
--cc=songmuchun@bytedance.com \
--cc=stable@vger.kernel.org \
--cc=vishal.l.verma@intel.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