From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.97 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796201267; b=yzcGcBvVV1PiGsP3lHYOC6adVCWl/HCO5lUe+btt/j4QZqLJHlQIa5+OFvWeJ57pSsa6 tkIZEhFslwSTd/Yh43oPyjVHNw/+M5Qrl3yfCFEuV19uZq1Mf29biBdOZKrmd/4GLNLg0 Y1854L31aA/ONjrgph+CD55A5WpZQTUQxPWlFGRvjthNbDXbMALjms9g7P/7OunBlsV/o O4rzzNmAfHxOEAiBX9rxYDjvz3czvhLJk1HAbMw0dN8wcS+UFGStH4aSC7W3fnEQ6zLhj AWdd2W4XcfTZ5Lu+maWOG+VIVraCSzPe2tvgDyjxmVQPOZ770aIG4sCn7JP24vZbRDg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796201267; 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=nXk5Lw/PHWd+KmJJXTlIbP30P8tcBs5RmA7uD4jJbmPGLTZkY/AKMbmCYm20Gx/Jmwyd BhEolvamCYzy0LbIGFPXUhSSLuKo0vnicdxMY/hXRS2IqMeaWkcrp8FcibGTUYkFMf9un sN2r86dxXP3a3/RPnXFtSw8C+FrmYYIVU18aWeIpXgGUNAsbL080gRS9edw/ID5A7Be72 jWlNWsFgksLZTpPvdumTyClc6A3Ri8f10GVogXy/J7SYcaJtR02PjxRMGtm22W+W/NXZ1 h83j339CvkoD9zB7CDkgoIDNp6iB0sFwz40aJuoX7Qo9SEkrThE2rsIbErSK06wOi5A== 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=EaObXy7V; arc=none smtp.remote-ip=115.124.30.97 Received: from out30-97.freemail.mail.aliyun.com (out30-97.freemail.mail.aliyun.com [115.124.30.97]) (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 9E78E606A330; Wed, 2 Dec 2026 08:47:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 9E78E606A330 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) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=EaObXy7V DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796201261; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=Kch9ac3GLPv1ldPVndLz9jmJYoyPqJcBNq8aPaX2nGc=; b=EaObXy7VAHHDH29cJY1L+9qpxDtN3yCIRVx11Fzu4Lnd7BuAy9/m67obtkV4ScSDTpErXzbMXtePq2ZTEPsjXog59BBmpaxBjmjyBpGM5i/uU84thP66Pmb+rtGenC7L+TEyaNDkHxM2lMtvakcmQ1zJLEohTJDUyT/9PVYR6Q0= 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-kernel@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 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