From: Muchun Song <muchun.song@linux.dev>
To: Wupeng Ma <mawupeng1@huawei.com>
Cc: osalvador@suse.de, david@kernel.org, akpm@linux-foundation.org,
ljs@kernel.org, Liam.Howlett@oracle.com, vbabka@kernel.org,
rppt@kernel.org, surenb@google.com, mhocko@suse.com,
linmiaohe@huawei.com, nao.horiguchi@gmail.com,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH resend] mm/memory-failure: fix hugetlb_lock AA deadlock in get_huge_page_for_hwpoison
Date: Fri, 22 May 2026 17:03:57 +0800 [thread overview]
Message-ID: <A6E5ED4F-EE5E-4AD6-AC7A-39B3E735A48C@linux.dev> (raw)
In-Reply-To: <20260522010305.4099834-1-mawupeng1@huawei.com>
> On May 22, 2026, at 09:03, Wupeng Ma <mawupeng1@huawei.com> wrote:
>
> Two concurrent madvise(MADV_HWPOISON) calls on the same hugetlb page
> can trigger a recursive spinlock self-deadlock (AA deadlock) on
> hugetlb_lock when racing with a concurrent unmap:
>
> thread#0 thread#1
> -------- --------
> madvise(folio, MADV_HWPOISON)
> -> poisons the folio successfully
> madvise(folio, MADV_HWPOISON) unmap(folio)
> try_memory_failure_hugetlb
> get_huge_page_for_hwpoison
> spin_lock_irq(&hugetlb_lock) <- held
> __get_huge_page_for_hwpoison
> hugetlb_update_hwpoison()
> -> MF_HUGETLB_FOLIO_PRE_POISONED
> goto out:
> folio_put()
> refcount: 1 -> 0
> free_huge_folio()
> spin_lock_irqsave(&hugetlb_lock)
> -> AA DEADLOCK!
>
> The out: path in __get_huge_page_for_hwpoison() calls folio_put() to
> drop the GUP reference while the hugetlb_lock is still held by the
> hugetlb.c wrapper get_huge_page_for_hwpoison(). If concurrent unmap
> has released the page table mapping reference, folio_put() drops the
> folio refcount to zero, triggering free_huge_folio() which attempts
> to re-acquire the non-recursive hugetlb_lock.
>
> Fix this by moving hugetlb_lock acquisition from the hugetlb.c wrapper
> into get_huge_page_for_hwpoison(). Place spin_unlock_irq() before the
> folio_put() at the out: label so the folio is always released outside
> the lock.
>
> Fixes: 405ce051236c ("mm/hwpoison: fix race between hugetlb free/demotion and memory_failure_hugetlb()")
> Signed-off-by: Wupeng Ma <mawupeng1@huawei.com>
Acked-by: Muchun Song <muchun.song@linux.dev>
Thanks.
next prev parent reply other threads:[~2026-05-22 9:04 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-22 1:03 Wupeng Ma
2026-05-22 8:18 ` Oscar Salvador (SUSE)
2026-05-22 9:03 ` Muchun Song [this message]
2026-05-22 9:14 ` Kefeng Wang
2026-05-22 9:21 ` Miaohe Lin
2026-05-23 3:50 ` Andrew Morton
2026-05-27 3:28 ` mawupeng
2026-05-27 3:35 ` 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=A6E5ED4F-EE5E-4AD6-AC7A-39B3E735A48C@linux.dev \
--to=muchun.song@linux.dev \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=david@kernel.org \
--cc=linmiaohe@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mawupeng1@huawei.com \
--cc=mhocko@suse.com \
--cc=nao.horiguchi@gmail.com \
--cc=osalvador@suse.de \
--cc=rppt@kernel.org \
--cc=surenb@google.com \
--cc=vbabka@kernel.org \
/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
all inboxes | Powered by JetHome®