From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.98 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795422004; b=3TdSF1cxH/yZDoafMDCp7D6l4Ow9/B93cZWJxx6o8yuGneNJo8vOuomFXNVNEUEJFUuX 1GPODjYsJ5u6o+Xr3Q3WDNO22UdyN8gnUwTFS74FyJ5rZTaEmu7GH2a4dC/xXB7uOlXDz 7TQ5P+c/lNHlDQOw2oZG64ac/aE7kOkpXAlFcWltOJ2VgGjVhYaNTM151Ek1uwNQq/SmI NqvfDTHGk8r5v/aMs60Ee7MNoDb7kCShUy4Ms6SqOdjepnLUvvAq4ZKyI0kS8JLCKB1la P0wkC/TRZlphqcACzCcSAJnRgYBqJXn53iMyeDknocCroHICegSAxGDOpQK+wmp3bEA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795422004; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=YyCfuyIRnFb0vjbdiNcIJQQQT5nFp9YD6UGELLn0Xrk=; b=5PWU+j7J3jnGyZ5lIIcXCJtDqTLFyDdZhPgAet34+3sYOf1LObbzTtlW2JqqVKcPqS2X UlmUON3nfmykPnKKipEkHkeE8LI2QAZ83z9NzQAWwnMEWTEmRALdx+RVk/PctDh6SaL/o EPUrN1MUovyE053ThEeUOcc2lw+7Iab9p4QxwAS4rFvWNTrCnO8rZiqXxqNd9eEjgSC62 Ci+uq21ppaBCGWh4R7pVNWxQdT+QGYYXQf9czaFG33607dQ6cXrAs0k+lDoHvsuNHCfjE cgj93j18mxaAvqcxxgrhJtIcPTvD1Yzxcsqtl8Abhoq85iZ5GK4WSAChXBdl5xTQHeA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b="LG/i+4eL"; arc=none smtp.remote-ip=115.124.30.98 Received: from out30-98.freemail.mail.aliyun.com (out30-98.freemail.mail.aliyun.com [115.124.30.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98FD8606A31A; Mon, 23 Nov 2026 08:20:01 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 98FD8606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=LG/i+4eL DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1795421998; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=YyCfuyIRnFb0vjbdiNcIJQQQT5nFp9YD6UGELLn0Xrk=; b=LG/i+4eLIv9mR1miWY9+/Xze809kksW31GpkDjfGJCbWIMpqhUnbQgt4lPBjWry/rJDgEiNClv9kdeNVrpCuvqo9KIMdMUaDqwpsLxNulOhh8YF93sD1jthrV0VLyzAehEdZEC2rMoXXBID/QqZW8D/UtZ/cjE7Hh/ybRBbiWxI= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R171e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033032089153;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=33;SR=0;TI=SMTPD_---0XFFKHO-_1795421993; Received: from 30.74.144.153(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0XFFKHO-_1795421993 cluster:ay36) by smtp.aliyun-inc.com; Mon, 23 Nov 2026 16:19:56 +0800 Message-ID: <1ced7dbc-6ea3-4d2e-9388-755965765130@linux.alibaba.com> Date: Mon, 23 Nov 2026 16:19:52 +0800 X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/2] mm/huge_memory: use NOFS when allocating while splitting folios To: "David Hildenbrand (Arm)" , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Kiryl Shutsemau , Andrew Morton , "Matthew Wilcox (Oracle)" , William Kucharski , Heiko Carstens , Alexander Gordeev , Claudio Imbrenda , Johannes Weiner , "Lorenzo Stoakes (ARM)" , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Christian Brauner , Jan Kara , Miklos Szeredi , Joanne Koong Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, stable@vger.kernel.org, Chris Mason References: <20261122-migrate_reclaim_deadlock-v1-0-83c56185b0fb@kernel.org> <20261122-migrate_reclaim_deadlock-v1-1-83c56185b0fb@kernel.org> From: Baolin Wang In-Reply-To: <20261122-migrate_reclaim_deadlock-v1-1-83c56185b0fb@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/22/26 8:42 PM, David Hildenbrand (Arm) wrote: > Various callers (migration, memory-failure, s390_wiggle_split_folio) split > locked folios without holding a reference on the folio's inode. > > Splitting a file folio might allocate memory for the xarray and call > filemap_release_folio(). If either ends up in direct reclaim with > __GFP_FS, reclaim can evict the inode through the dcache shrinker, and > wait in truncate_inode_pages_final() for the folio that we hold locked: > > try_split_folio() > folio_lock(A) > split_folio_to_list(A) > xas_split_alloc() > try_to_free_pages() > super_cache_scan() > prune_dcache_sb() > iput_final() > evict() > truncate_inode_pages_final() > folio_lock(A) > > This requires that nothing else holds a reference on the inode, and can > be triggered most easily with FUSE, which evicts inodes on the last > reference. > > Further, xas_split_alloc() charges the XArray nodes to the memcg, and on > cgroup v1, memcg reclaim waits for file folios under writeback if > __GFP_FS is set. That can deadlock if writeback waits for a folio lock > that we hold, for example with ext4. > > Let's fix it by splitting folios in a NOFS scope, so callers don't have > to care. A NOFS scope also covers allocations that filesystems make with > their own gfp flags, for example in filemap_release_folio(). > > On NFS, splitting folios with pending writes or ongoing writes to > fscache might now fail slightly more often, until these writes have > completed. On netfs, only folios that are being written to fscache are > affected. All fairly irrelevant. > > This has medium urgency. > > Fixes: 6b24ca4a1a8d ("mm: Use multi-index entries in the page cache") > Fixes: eef88fe45ac9 ("s390/uv: Split large folios in gmap_make_secure()") > Fixes: 789763523fb4 ("xarray: honor XA_FLAGS_ACCOUNT in xas_split_alloc()") > Cc: stable@vger.kernel.org > Reported-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) > --- Make sense. Reviewed-by: Baolin Wang