From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.36 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793784284; b=iZMYKmUfEXEaNw+Fl2+D3JCklFdXSjodNL9swebbb1GG+mMPA/YHMvEoiD5Oq/1f+EGW MO8++UlCpBCh+WKP3qEcnH+FAqE3ENW/hWfVuP0mcE+Lsg9Dl4CrkoK+ybQZAmLws8+km kE5xQ6d21EbKiMksHaynmK1FdmfnWx6F3XGiELuxqJa6s3tv7nd+8o0t4tKgJUc3PAoag f7C1zZpq3bTeEtFA5YbP/zlJaHCg89m6Wld5iac1cFQo13Ur3MUU5AUC3vjXAl8gGTEH6 EwfdnLDjLtfNrTXf+DXQfOEuHPACLx3LGELDITmSNJulTkm57JT7Dc4pKKxtadJrVRw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793784284; h=DMARC-Filter:X-Envelope-To:DKIM-Signature:X-Envelope-To:Received: X-Mizu-Trace-ID:X-Migadu-Flow:Content-Type:Mime-Version:Subject:From: In-Reply-To:Date:Cc:Content-Transfer-Encoding:Message-Id:References: To:X-Mailer; bh=Z94cg7ac1Y7ssrM7pMXNVdha6WnPl9D8zeq/vd59B+M=; b=fJ5Z7djJ4CJNdxXe9yEXhKRkPK+zdjytRjUyzkTZcONrRLlI1QrcD1bFjqgp4sKGvmTM DP2GuJhR0lEyc6pub43sWuyeV/FrHqgBG61TS0PXBEbXInibtrTDCfJPCK8tT86p7x8eF EUS2bOzo0gc51FsZxHXfGHbMKDjoOkXCybW47Qz5h4LhgoukvVFlFqMJztTm7VwNj2x1Q bxxwTiRVpYkUnEVy87PTDUYVoiP3DCbDhUxnglK3rBQg45GRA8tPVZs5K5vuknisL2Njj MPxxyQAPWz5RmBvj/jbXy32FKbHj9htFmhNKei0gNBs/9K1n7y5WvgaYg/Mwj2J5hMw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=EX7ppEPP; arc=none smtp.remote-ip=95.215.58.36 Received: from mta1.migadu.com (out-36.mta1.migadu.com [95.215.58.36]) (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 5DB44606A32F for ; Wed, 4 Nov 2026 09:24:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 5DB44606A32F Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=linux.dev header.i=@linux.dev header.a=rsa-sha256 header.s=key1 header.b=EX7ppEPP X-Envelope-To: linux-doc@vger.kernel.org DKIM-Signature: a=rsa-sha256; bh=Z94cg7ac1Y7ssrM7pMXNVdha6WnPl9D8zeq/vd59B+M=; c=simple/simple; d=linux.dev; h=from:to:subject:date:message-id:mime-version:content-type; s=key1; t=1793784280; v=1; x=1794389080; b=EX7ppEPPaFtlHsu2VqjM1UaT7IQavLpZc2tjUMAdBemJipD4+ckQP/d52rZ59F0cF1x9DsBH IUxWJTDKJjptoy2MXwV8C9p+CbZwomGUWtnnf8b1zOhNujFY3axwLVkXUxUArQOvjUusimSdkPy NFEKajGaMsHkhUmJaP47nn6k= X-Envelope-To: linux-doc@vger.kernel.org Received: by mta12.migadu.com with ESMTPS id 0fb9feb80626b30b; Wed, 04 Nov 2026 09:24:39 +0000 X-Mizu-Trace-ID: 0fb9feb80626b30b X-Migadu-Flow: FLOW_OUT Content-Type: text/plain; charset=us-ascii X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3901.200.71.1.16\)) Subject: Re: [PATCH 09/15] mm/memfd: recheck the page cache before allocating a hugetlb folio From: Muchun Song In-Reply-To: <20261028-fixes_hugetlb-v1-9-a0a033db180f@kernel.org> Date: Wed, 4 Nov 2026 17:24:00 +0800 Cc: Oscar Salvador , Naoya Horiguchi , Andrew Morton , Mel Gorman , Andy Whitcroft , Miaohe Lin , Michal Hocko , Rik van Riel , Hugh Dickins , Baolin Wang , Vivek Kasireddy , Dave Airlie , Jason Gunthorpe , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Jonathan Corbet , Shuah Khan , Randy Dunlap , Peter Xu , Breno Leitao , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Peter Zijlstra , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Arnd Bergmann , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Gerd Hoffmann , linux-doc@vger.kernel.org, linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Josef Bacik Content-Transfer-Encoding: quoted-printable Message-Id: References: <20261028-fixes_hugetlb-v1-0-a0a033db180f@kernel.org> <20261028-fixes_hugetlb-v1-9-a0a033db180f@kernel.org> To: "David Hildenbrand (Arm)" X-Mailer: Apple Mail (2.3901.200.71.1.16) > On Oct 29, 2026, at 04:13, David Hildenbrand (Arm) = wrote: >=20 > A concurrent fault or PIN request can populate the page cache > after memfd_pin_folios() misses it in the page cache but before > memfd_alloc_folio() takes the fault mutex. The latter still tries to > allocate another folio and can return -ENOMEM even though the = requested > folio is already cached. >=20 > In particular, hugetlb_reserve_pages() finds the existing = reservation-map > entry and reserves nothing. If no global reservations remain, > alloc_hugetlb_folio_reserve() fails even when the pool has free pages, > effectively failing memfd_pin_folios(). >=20 > Recheck the page cache before reserving or allocating. If the folio is > present, drop the lookup reference and return -EEXIST so > memfd_pin_folios() retries its lookup. >=20 > This is probably not worth backporting to stable. >=20 > Fixes: 89c1905d9c14 ("mm/gup: introduce memfd_pin_folios() for pinning = memfd folios") > Reported-by: Josef Bacik > Signed-off-by: David Hildenbrand (Arm) Acked-by: Muchun Song Thanks.