From: "David Hildenbrand (Arm)" <david@kernel.org>
To: Zi Yan <ziy@nvidia.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
"Liam R. Howlett" <liam@infradead.org>,
Nico Pache <nico.pache@linux.dev>,
Ryan Roberts <ryan.roberts@arm.com>, Dev Jain <dev.jain@arm.com>,
Barry Song <baohua@kernel.org>,
Lance Yang <lance.yang@linux.dev>,
Usama Arif <usama.arif@linux.dev>,
Kiryl Shutsemau <kas@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
"Matthew Wilcox (Oracle)" <willy@infradead.org>,
William Kucharski <william.kucharski@oracle.com>,
Heiko Carstens <hca@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Johannes Weiner <hannes@cmpxchg.org>,
"Lorenzo Stoakes (ARM)" <ljs@kernel.org>,
Matthew Brost <matthew.brost@intel.com>,
Joshua Hahn <joshua.hahnjy@gmail.com>,
Byungchul Park <byungchul@sk.com>,
Gregory Price <gourry@gourry.net>,
Ying Huang <ying.huang@linux.alibaba.com>,
Alistair Popple <apopple@nvidia.com>,
Christian Brauner <brauner@kernel.org>, Jan Kara <jack@suse.cz>,
Miklos Szeredi <miklos@szeredi.hu>,
Joanne Koong <joannelkoong@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org,
"David Hildenbrand (Arm)" <david@kernel.org>,
stable@vger.kernel.org, Chris Mason <mason@kernel.org>,
"Jose A. Perez de Azpillaga" <azpijr@gmail.com>,
Chris Down <chris@chrisdown.name>
Subject: [PATCH v2 0/2] mm: fix deadlock on the folio lock when migrating and splitting folios
Date: Tue, 24 Nov 2026 08:56:42 +0100 [thread overview]
Message-ID: <20261124-migrate_reclaim_deadlock-v2-0-03cc147e1e36@kernel.org> (raw)
Whenever we allocate memory with __GFP_FS while holding folio locks, we
can deadlock on the folio lock when triggering direct reclaim or
compaction.
For example, evicting inodes with a populated page cache takes folio
locks, and if we happen to need one of the folio locks we already hold,
we'll deadlock.
FUSE makes this example easier to trigger, because it evicts inodes on
the last reference. A similar deadlock with FUSE was recently fixed in
FUSE [1].
Let's handle folio splitting by simply running in NOFS context. We only
perform small allocations, so it doesn't really make a difference.
Interestingly, this also fixes one of a handful of possible memcg v1
deadlocks.
For page migration, change the code to allocate destination folios
without holding folio locks, which is in any case the right thing to do
to reduce folio lock holding times.
Some of this might also be fixable using Jan's work on deferred inode
reclaim [2]. However, that is not stable material, and not allocating
folios while holding other folio locks is an improvement on its own.
Unprivileged users can trigger this deadlock with FUSE and
mbind()/migrate_pages(); however, it requires multiple NUMA nodes and
quite some luck.
I reproduced the original deadlocks with FUSE and made sure they can no
longer be triggered with these fixes. Further, I ran the usual migration
and folio splitting selftests.
[1] https://lore.kernel.org/all/20250925224404.2058035-1-joannelkoong@gmail.com/
[2] https://lore.kernel.org/all/20261009133253.20102-1-jack@suse.cz/
Signed-off-by: David Hildenbrand (Arm) <david@kernel.org>
---
Changes in v2:
- Adjust cover letter (incl. subject), the patch descriptions and code
comments: allocating with __GFP_FS while holding folio locks can
deadlock also through compaction, independent of inode references
- Collect tags
- Link to v1: https://patch.msgid.link/20261122-migrate_reclaim_deadlock-v1-0-83c56185b0fb@kernel.org
---
David Hildenbrand (Arm) (2):
mm/huge_memory: use NOFS when allocating while splitting folios
mm/migrate: allocate destination folios before locking a batch
mm/huge_memory.c | 10 +++++
mm/migrate.c | 133 +++++++++++++++++++++++++++++++++++++++----------------
2 files changed, 106 insertions(+), 37 deletions(-)
---
base-commit: eb01811cc3713af1f78dfe18fa89c5270ebfc767
change-id: 20261121-migrate_reclaim_deadlock-44e28e226b9d
Best regards,
--
David Hildenbrand (Arm) <david@kernel.org>
next reply other threads:[~2026-11-24 7:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 7:56 David Hildenbrand (Arm) [this message]
2026-11-24 7:56 ` [PATCH v2 1/2] mm/huge_memory: use NOFS when allocating while " David Hildenbrand (Arm)
2026-11-24 7:56 ` [PATCH v2 2/2] mm/migrate: allocate destination folios before locking a batch David Hildenbrand (Arm)
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=20261124-migrate_reclaim_deadlock-v2-0-03cc147e1e36@kernel.org \
--to=david@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=apopple@nvidia.com \
--cc=azpijr@gmail.com \
--cc=baohua@kernel.org \
--cc=baolin.wang@linux.alibaba.com \
--cc=brauner@kernel.org \
--cc=byungchul@sk.com \
--cc=chris@chrisdown.name \
--cc=dev.jain@arm.com \
--cc=gourry@gourry.net \
--cc=hannes@cmpxchg.org \
--cc=hca@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=jack@suse.cz \
--cc=joannelkoong@gmail.com \
--cc=joshua.hahnjy@gmail.com \
--cc=kas@kernel.org \
--cc=lance.yang@linux.dev \
--cc=liam@infradead.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ljs@kernel.org \
--cc=mason@kernel.org \
--cc=matthew.brost@intel.com \
--cc=miklos@szeredi.hu \
--cc=nico.pache@linux.dev \
--cc=ryan.roberts@arm.com \
--cc=stable@vger.kernel.org \
--cc=usama.arif@linux.dev \
--cc=william.kucharski@oracle.com \
--cc=willy@infradead.org \
--cc=ying.huang@linux.alibaba.com \
--cc=ziy@nvidia.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
all inboxes | Powered by JetHome®