From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.219.48 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796246958; b=J0S85d/pHMdw0Gd6S0UYiE3U+B96Jmk8VJhMkWCLcGpcIoK5vC9m8/4FVLtatnSYQqQZ 6FGJ29ewJu7ExCE7E6IN6kD59T5V293j8oO/a7kQS4evEMFAcunlCdYCqM20UGzkXxvO2 oyezqLPktwmuHlTpEu4oyb7ec+7xFcZj9ClrgAkNAmJdX3IyOw0zQWfRhyeohJCWkdq+6 hayLR5XldtLWEkLlOj6wV7bPwQFL2XlWt266ctVO6aYIAUTOs5JLyWMAvF9rMFNhDtjW8 Jdo30vExOlt26SbXHqdC1lzCw1LHmIXgHAjL8hmsVC0JrY5wsCEx1LWtQuw692yn5IA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796246958; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: MIME-Version:Content-Type:Content-Transfer-Encoding:Subject:From:To: Cc:In-Reply-To:References:Date:Message-Id:X-Mailer; bh=R7l92Q2RZTEDdNTwi9jvRUcTTuCpooX/Nn0bZBc1K5I=; b=IpGCs/TcpATj7tVcG7bYKAdeqHOAtS8hcw9NJSSa7bFBJwg8T1Lp+l1iAoVaYlJqT48H i52a24hDFMtvBs9j/upr2Z7+DYu/sYH9Zvc6qTcClZWNdnC8vKGPlMyLV3h4w9S7/Yjzw Rl2Ub/fgKRbvU3pMVCho590gkRobRMFmltDNeJRHnqZDYD8p0kU3rqanvub1WEz7TS718 T6wezo8+Qejtej3bYaWkCP7i3US1TbsFce/Q5I+QB/MjV0Bh3WspNPw3v0Xm+hmxeAlmW niTrg+RfUL+uLQHvBRf3j/6pBiGVBf6ZBqqMRj/st/8qJtEtP37p3F6sDHN4mWkIxLg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass header.d=gourry.net header.i=@gourry.net header.a=rsa-sha256 header.s=google header.b=kVTT+5xI; arc=none smtp.remote-ip=209.85.219.48 Received: from mail-qv1-f48.google.com (mail-qv1-f48.google.com [209.85.219.48]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 86DB8606A32C for ; Wed, 2 Dec 2026 21:29:18 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 86DB8606A32C Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.a=rsa-sha256 header.s=google header.b=kVTT+5xI Received: by mail-qv1-f48.google.com with SMTP id 6a1803df08f44-91e7fc8265aso87836656d6.0 for ; Wed, 02 Dec 2026 13:29:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1796246957; x=1796851757; darn=vger.kernel.org; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=R7l92Q2RZTEDdNTwi9jvRUcTTuCpooX/Nn0bZBc1K5I=; b=kVTT+5xIqL5mIWkuOcH2UozlEkuWL1BgrsPEyXV/D5eycgKsqdEF2vZc0Lq3GDLpfN cqNuzc8Hw+K/OMAA5/sZYFunBQFVvDtD+RvWuJaCkaPfPYJ3yi+KkmjMwOeU6UKrFUP4 Sv2sKa8keGJREcxo5wc0dwkCfkT7L+zCD1JGKJ1zgsC6nUnFQL5QKhfGQCws+1lm3cWi xQB7kJohUTtTWTsq//EjGrdTRyzr9ibK2lTdEwsse3j7vHvGG7+z34WDZEYNX1jX/35q zThQjEVNLdF8VGotW01f3W/XwDYUfVqLIGoI/VJTgQquhe9tdH+mfU2yJkgKiWBwHQkC lpZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796246957; x=1796851757; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=R7l92Q2RZTEDdNTwi9jvRUcTTuCpooX/Nn0bZBc1K5I=; b=oFXhY9vpxHgMEUeEtUMETQXxe8/uuNspNHzvkHlLnjf7Br8+StEp4y7PPsHXvAiBh9 8EkRZ5rvBv+OS4tDvikO8a+7DtwhU7OUYXm6Ov2QoCGQ6JiICRt4YLjkZef4n3EoOwpR ZGj+hI7UeXP3CYdTmA+nhUKWMPqr5flLSs3rNPOZ5L+VlLNs+2PtgHp+Yr8zMFVmZhcY jj/F0JMoxjF2yMZbQYcVJhKxvaxpFSpcxq46+rCgHl1dIXQmi4s+ygQSpGDJtcuXuC7V J8WrKr0DfpjvFRrY6CwlZ287OVHwlMQahzU1T03nlmrvGQHjUWlfk9eYt9YNwjFfVBFJ Gc+A== X-Forwarded-Encrypted: i=1; AL+hErEWYYl6Kt/gqSFBhqnt7fkzcqSOGEFXkZVK2kRUt0jK0QdGZFmFh7zUJGY+QAbaLUgQaUctUVVu8kljAJo=@vger.kernel.org X-Gm-Message-State: APuU4Z+tFL0BjMvRxG7s1VQjNq0EEvMCKj7lokhW5u7n5qIdpCiKRHOI vMvO2RRho3Ux/YNxoCpXItmbN+oJ4QJAjWOwG0978XaPsO71ls8VTsmKaAgaRCZhsZM= X-Gm-Gg: AZFdTZfyRzOPa/hF06T2+zSnXwHH9gom5nK0QUOJw5R79wbKVsVqS1q8c0muyIL0yBD HSiStW8gisdW1/Cur3/Wrsqia0umjfKgbm6SeCbZo3DvKsL2b8VEOP4SZ8CJCjAQ3qMqhoqIPLL A7BgJrAakKP/Yql3MlxOtKSELRDUws0tOt7D8HDGTZ3dZP9dU9MLe8z8hEZFKjTckNFHp3iGT8+ voNmPedNB49RhlJsxjtOxThZwgn+4bWxnw92Q1kOboROaIYyWFafsKPVDmvccZRDY2Ascm5ifaW iX4GYcjutL4pikk1yb5FsDaAf0v01Boyk7egkqN+vQ0dzULV/ri+lG9kHZilZeGbosx5LtLiS7V ZfrIk4mG4uzHEkVv3ut5lyvkmA/Ez3FQZmCppAZX/9ktSTuW7P4pJSZAQtwi/teNFVR7295HgpP Qm0VFzyz0Kix53FtmrFdhpQHD0KfBQTClly+q88yWpPqYlVH623djEGjyqYYfSXVKKHYRBfU2Wb 0CLnVwsGCBcYffN1OrAMMiGUgELb4U2P+NtayKOsNBgq6wJZR4ietG24GDY7fq+6BYcPicYzv3X bDN2x6aS138NYeLCj+1vbD5N+LH+gKB4DMIPGbBpuJjDH2MXdCZWkW3LEEKRpE/ax8x+bDq8v6m 37KwRw0E= X-Received: by 2002:a05:6214:41a0:b0:921:b98f:7b7e with SMTP id 6a1803df08f44-921b98f7ba6mr150223306d6.36.1796246957530; Wed, 02 Dec 2026 13:29:17 -0800 (PST) Received: from [192.168.50.231] (pool-71-191-145-202.washdc.fios.verizon.net. [71.191.145.202]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-921349f2186sm365958666d6.29.2026.12.02.13.29.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 13:29:17 -0800 (PST) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Re: [PATCH 05/32] mm/shmem: don't pin inodes with eviction held off in the huge shrinker From: "Gregory Price (Meta)" To: "David Hildenbrand (Arm)" Cc: Hugh Dickins , Baolin Wang , 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 , 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 In-Reply-To: <20261129-fixes_core_3-v1-5-f66094116801@kernel.org> References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-5-f66094116801@kernel.org> Date: Wed, 02 Dec 2026 16:29:15 -0500 Message-Id: <179624695522.2841792.15334442200160929358.b4-reply@b4> X-Mailer: b4 0.17-dev On 2026-11-29 11:06 +0100, 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) I was able to produce the condition where the inode was grabbed / eviction stopping - but i could not produce the actual deadlock. regardless, the change looks reasonable and avoiding the grab seems correct either way. Tested-by: Gregory Price (Meta) Reviewed-by: Gregory Price (Meta) -- ~Gregory