From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=95.215.58.34 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793784284; b=0JYZyVCVoJSX237CF5bPq9CtbWvCVhXTHRbsvKoVeoZ+DpWwrFHe31c3NugbmXFOK/Jc AdCryIj0Y85QtsnRFOF9W660r1lZQrgW1389/BM+P0pj9J/mLt1UL4TKwwCatiH3GfwR3 UiQAcRZcipBxeQiFWxXgMaZ6GnalRj1+rAu417dPPIcnjy7+Ew2FhbQGjUEZt5niMyoJD Ab7uG8DSQ/LoOXN1VIS462+KXXVV7Yen1sFSfwlcxaD0GDfppPnnRVh1+XCS8KmUAGp4i vI46Sa9JWQ7A+fLJwuXzVMO99VlMGuXAF0L817qBIRTFosdqP2W7WFZuceve5oqQcLw== 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=nAabCE63qW2cz19sEQrr//7hMBBepv7iInLw7kktIGEa5busHi8ecgvTquEuZKIPocFd AmahDOzZ8KaESFLH0hcKnqu5HI+BPf6998FXs5cmdEZO2fiiS/GJLHURRS/fOSJW0hw61 YVrZDKNbgkWqKXgRb//fm9Bvi9EymFbark8p7BqoEfXnIVDPrFnviE7y2C2EvDXN0Tr9S jLsdHItcbjxoAiOvEDPuC6Bl1A9f6QZx3lbBDu1+SvRjHEwGdw5CHbqhzYHvyHwV2X3ia wXWFbhT1XniOGYZn8+2pign4qv+FAwyWyfO7zPlRYt2f8WA8llvOSrxBl8PIXj9DfHw== 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.34 Received: from mta1.migadu.com (out-34.mta1.migadu.com [95.215.58.34]) (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 67634606A332 for ; Wed, 4 Nov 2026 09:24:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 67634606A332 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-kernel@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-kernel@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-kernel@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.