Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796201264; b=C57+bEQI6ldKRWX8hO3fAaLAqRVP7A5BgRJefHjsZS503i14q4AEFWnUMcVGlUz6Tg71 ZyG/PDQClSNcPDexzgVQKYLZTMkTfoqUCNCeRIgmNr36nEIUunVEJW82LNdZM2AQ+nv1L k5NkOAVDKrbE6E6thDGcNpbaIYlGqqpa5Bdg+g+ir8iTCJ4GPyE1wlAZua+RNVOGubLbV MI7jsBMOyOznJMtetgxfLViCECWittYjA7o29mLz3oDEz93exFCOW0pDVlXiH2fIkjOeS qlCYA9tlAJ4xSy4m2gYn/P38wbto3p3ITEgTEbjFWb92PgPGMElonWTahp+lliOAYsQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796201264; 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=Kch9ac3GLPv1ldPVndLz9jmJYoyPqJcBNq8aPaX2nGc=; b=zqwt+j/iKGG+QbIA9FOBCgOEMuTOHt0vbrSaUGP15y/91nrS2Tj6EsaKoM6jfUddiN+Y BT7OBK9tblp5MBN26TyKKYmwdUGdRi1oxmTd9HsHMoyTF7V1pjhWfgAGxtaC9Z+XrYkcI TW4R9an8YzNYGf4FvZdiAvxuwUTD/LSGMrkJw6DuY+vJw4LkU/LS4mx9EyD8rNa+rdMbE 5khRcYc4JR3o63vDQTdfj3HpfrAK+XYVUb2rn+IEqzJztaa/TIYLQkaqjYR24XNnI/FzO w3R6LWY7aJxwKMgr7SjzpK6Yv7Cbe0kAsXeM0e1Yq3KeL/3ELZC5Bohd5GtYnueu5ig== 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=iS56VAov; arc=none smtp.remote-ip=115.124.30.131 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (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 409AC606A684 for ; Wed, 2 Dec 2026 08:47:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 409AC606A684 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=iS56VAov DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796201260; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=Kch9ac3GLPv1ldPVndLz9jmJYoyPqJcBNq8aPaX2nGc=; b=iS56VAovXH6G+hLsYQ9UrY0Q+X6Oo2wla0Io7v5marskGBkH4RxGxe615A2G3N5xoCbzh8es10oj44Z5Z4TdUY0CJkwOsKCXIuSGe8hEMrLO6dkSrTrtaH9ERVsgki6cp8+z6gsY8adM9BGPfrSV6xHuwuX86F0jQTocCWm9Kfk= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037026112;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=81;SR=0;TI=SMTPD_---0XG8V3Jp_1796201250; Received: from 30.74.144.133(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0XG8V3Jp_1796201250 cluster:ay36) by smtp.aliyun-inc.com; Wed, 02 Dec 2026 16:47:35 +0800 Message-ID: Date: Wed, 2 Dec 2026 16:47:30 +0800 X-Mailing-List: linux-rt-devel@lists.linux.dev 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 05/32] mm/shmem: don't pin inodes with eviction held off in the huge shrinker To: "David Hildenbrand (Arm)" , Hugh Dickins , Andrew Morton , Mike Rapoport , Peter Xu , Michal Hocko , Kiryl Shutsemau , Manfred Spraul , Davidlohr Bueso , Cyrill Gorcunov , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Yang Shi , Zach O'Keefe , Song Liu , David Stevens , Kefeng Wang , Alex Williamson , Suren Baghdasaryan , Dave Jiang , Matthew Wilcox , Miaohe Lin , David Rientjes , Shakeel Butt , Jan Kara , Mel Gorman , Jason Gunthorpe , John Hubbard , Gerd Hoffmann , Vivek Kasireddy , Dave Airlie , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hagen Paul Pfeifer , James Bottomley , Felix Kuehling , Alex Sierra , Balbir Singh , Kairui Song , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Oscar Salvador , Muchun Song , Dan Williams , Rakie Kim , Hao Li , Christoph Lameter , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Alexei Starovoitov , Xu Xin , Chengming Zhou , Shivank Garg Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-rt-devel@lists.linux.dev, SJ Park , stable@vger.kernel.org, Chris Mason References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-5-f66094116801@kernel.org> From: Baolin Wang In-Reply-To: <20261129-fixes_core_3-v1-5-f66094116801@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/29/26 6:06 PM, David Hildenbrand (Arm) wrote: > shmem_unuse() disallows eviction of an inode while swapping in its > pages, and shmem_evict_inode() waits until eviction is allowed again. > > However, swapping in folios will end up allocating memory with __GFP_FS, > possibly triggering direct reclaim, where the superblock shrinkers can > drop the last reference to that very inode. > > For example, shmem_unused_huge_shrink() takes and drops an inode reference > to split large folios beyond i_size: > > swapoff another task > ======= ============ > shmem_unuse() > shmem_disallow_eviction() > shmem_swapin_folio() > direct reclaim > shmem_unused_huge_shrink() > igrab() > unlink(), close() > iput() > shmem_evict_inode() > waits for eviction to be allowed > > Consequently, swapoff can deadlock against itself. > > Let's fix it by not pinning inodes whose eviction is disallowed in > shmem_unused_huge_shrink(), effectively skipping them in this reclaim pass. > Within shmem, shmem_unused_huge_shrink() is the only place where reclaim > takes and drops a temporary reference to a shmem inode. > > We could also avoid the deadlock by swapping in under NOFS scope in > shmem_unuse(). However, allocating a lot of folios under NOFS does not > sound like the right approach. > > This has low urgency, as the race is hard to hit and swapoff is > privileged. > > Fixes: af53d3e9e040 ("mm: swapoff: shmem_unuse() stop eviction without igrab()") > Cc: stable@vger.kernel.org > Reported-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) > --- Make sense to me. Reviewed-by: Baolin Wang