From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=91.218.175.105 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793784285; b=Ki2qr5Vos4UPoeT3D9knX4vLIE2i/02mu80MKpxpih+6jVaxoy9toCOx9dxQ/gay754x 4GhF6774y6KsE/FhYAQydE9Wvy1TdRsrkp4gJXvPp/o5KZbJK7R0C0bSGNd2+PEkmHz/e JO+dkLbMGXiqM7qua9OEpYw7fEVTUQUcBR8jVMj9hHTqIt50sY4UAQbC4DMcMy7PhEl4T EIMMU7OJb+XLFuTw3YpIrGWwQjdWVfru8oHPd97kPI8IRFXF0Ki94VR3k6lDAc78yOTIS KtLV8lXvNiAq29eCIrZf8+VK9Gd4Nx2uWfgPqH36pTYZqfJrjDOIEwsJbVI0kuRMUEg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793784285; 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=d4q9S+j5QeCzWacZERrcWabzT/r4dxMvNA9HWfSZ5+rB/VPLUx5uNMOL7qN6VXRpenRr MlZ4huRziAUI9tdZ5bEiSqkUzL4GUGKGRadlbn8sW95+hxm0ADWVt89M44hpa9R8q3vM+ C17z7V+QeS0BF3qaHVLRhfX7qK5dlYrHyxLXzuIOMclI1mZy63NIadkADUpn9vS56uDX/ ES1ejJh8R2leIpkqMYFO8ZPm8FDjUkrfjELn5zHXC7gMeX4ajXzlFHUWHpxd2ON8asOor uoWkVf0rPpO+FPOGYVzU62HUZUa/dPfk5vAEhJucTlwBaEWChV/6xI+J6bQ4AitC1RA== 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=91.218.175.105 Received: from mta0.migadu.com (out-105.mta0.migadu.com [91.218.175.105]) (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 692A0606A334 for ; Wed, 4 Nov 2026 09:24:42 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 692A0606A334 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-arch@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-arch@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-arch@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.