Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
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>,
	"Jose A. Perez de Azpillaga" <azpijr@gmail.com>
Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org,
	linux-fsdevel@vger.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: Re: [PATCH v2 0/2] mm: fix deadlock on the folio lock when migrating and splitting folios
Date: Tue, 24 Nov 2026 10:47:19 +0100	[thread overview]
Message-ID: <66e5f9e3-17d4-4635-8919-c67ed562f9f0@kernel.org> (raw)
In-Reply-To: <20261124-migrate_reclaim_deadlock-v2-0-03cc147e1e36@kernel.org>

On 11/24/26 08:56, David Hildenbrand (Arm) wrote:
> 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.

@Jose, could you find and fix other cases where we allocate under the folio lock
with __GFP_FS (and direct reclaim enabled?).

I think at least do_set_pmd() might have a problem when allocating a page table
through pte_alloc_one(). And I'm sure there's more.

-- 
Cheers,

David


      parent reply	other threads:[~2026-11-24  9:47 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24  7:56 [PATCH v2 0/2] mm: fix deadlock on the folio lock when migrating and splitting folios David Hildenbrand (Arm)
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)
2026-11-24  9:47 ` David Hildenbrand (Arm) [this message]

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=66e5f9e3-17d4-4635-8919-c67ed562f9f0@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