From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 210EB1E9906 for ; Sun, 14 Jun 2026 09:55:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781430921; cv=none; b=gv8KBCGw4PZAnNIw5ai/tl5vazz1qWScK3GXT/6ZB2ESpMsIhUrkEMaOMKriwxLpvW5zCiFdm8vky3PlGWermSZ/IksBVCMXblU/Afk4w5FPvEZxqMvtln/BQG9RzGSahPhU+M+7hOiU1ldcpzFVAD/oRIYfQ5W/xr4CWI3LvS0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781430921; c=relaxed/simple; bh=SGh9AujUnAY49hFVdYOOlbp+UVUZzlXZjOOgWViN4ts=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ay7UZntsv0kO3IMj0Q6ipbcp7iqthINruWYINfRPByP3eHEPa0G6QP8FFtRjjADf+OXcC8qm9wFC3TCYqXbNRACuRmYk3Vrzn0kgsLuwCGSIFb5H3RAbMy7XTXRbV4YfDfgrSB3hRM7JYvXQTUOB7lNFvEovTKjwAP0k1jhIm3s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=P70k8Eds; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="P70k8Eds" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D55211F000E9; Sun, 14 Jun 2026 09:55:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1781430919; bh=l+rYKnQxSik6h20p9v/FXlfKzLNE3EJSxpZIHMtaCF8=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=P70k8Edshz2WvKYbe98e+4xLaHZggUaZdsdYpyRf3z41TpiGJEgcwxn42JUi9MOZ4 wbbxm7AQkQw5Yu8ryL7XbUtPFNnrnlYtSC//PnfMNJ9UwUuJ8lVCtqHA4HVQZRocvc obPyuILakMsOZLjjgL7dbVLjrT8t3xFBZrb+tdl/eviRDBI84WhRs/eLjuT0n93XD5 7lwLh5RTs2QTcPZN4KeNOoBFM5f7zKS3ubJSWxBWlphEjJMC7kuKt1v1Nx7lXmzVY2 zHTUJ3mg1alCBZGJ/rhPEFvXmjVkMUbjvLfP57yOnTiAjivMFltddHWoFk5RO58JYW C1RHQPavfL2Ig== Date: Sun, 14 Jun 2026 12:55:11 +0300 From: Mike Rapoport To: Muchun Song Cc: Muchun Song , Oscar Salvador , David Hildenbrand , Andrew Morton , Madhavan Srinivasan , Michael Ellerman , Lorenzo Stoakes , "Liam R. Howlett" , Vlastimil Babka , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Nicholas Piggin , "Christophe Leroy (CS GROUP)" , "Ritesh Harjani (IBM)" , "Aneesh Kumar K.V" , linuxppc-dev@lists.ozlabs.org, rppt@kernel.org Subject: Re: [PATCH v3 14/19] mm/hugetlb: Free cross-zone bootmem gigantic pages after allocation Message-ID: References: <20260602101039.1867613-1-songmuchun@bytedance.com> <20260602101039.1867613-15-songmuchun@bytedance.com> <178041489395.457517.12727427621570734471.b4-review@b4> <1ABCD934-CA2C-4541-9B76-32FAEFD398FF@linux.dev> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1ABCD934-CA2C-4541-9B76-32FAEFD398FF@linux.dev> On Wed, Jun 03, 2026 at 10:53:04AM +0800, Muchun Song wrote: > > On Tue, 02 Jun 2026 18:10:34 +0800, Muchun Song wrote: > >> > >> diff --git a/mm/hugetlb.c b/mm/hugetlb.c > >> index 5e557c05d80a..218fb1ca45f4 100644 > >> --- a/mm/hugetlb.c > >> +++ b/mm/hugetlb.c > >> @@ -3073,22 +3076,38 @@ static bool __init alloc_bootmem_huge_page(struct hstate *h, int nid) > >> [ ... skip 26 lines ... ] > >> + * pages belonging to the requested node. > >> + */ > >> + if (WARN_ON_ONCE(nid_request != NUMA_NO_NODE && nid != nid_request)) > >> + list_add(&m->list, &huge_boot_pages[nid_request]); > >> + else > >> + list_add(&m->list, &huge_boot_pages[nid]); > > > > Can we just memblock_free() the page that intersects zones here? > > I had previously considered doing this, but then I realized that if we free the > allocated cross-zone memory here, memblock is very likely to select the exact > same block for the next allocation. This means we'd just end up with this > cross-zone memory again, degrading allocation efficiency. Unless there is a way > to mark the block so memblock avoids reallocating it, I ultimately chose to > defer the release to prevent this issue from happening. You are right, there's no simple way to avoid memblock using the same range. The comment at hugetlb_hstate_alloc_pages() hints that we might want to split allocation of gigantic pages to be more explicit as a followup rework and then freeing of cross-zone pages would be cleaner as well. > Thanks. -- Sincerely yours, Mike.