From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-185.mta0.migadu.com (out-185.mta0.migadu.com [91.218.175.185]) (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 D00D53DC87A for ; Wed, 3 Jun 2026 02:53:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=91.218.175.185 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780455228; cv=none; b=CL5fKskAXKtNRmGrXFWCaf824cWQmo5592ApPZ3QE/eFkzr5N6yK8S+mebN56H3RfSk4rj5SnFlqetxIKeY/gK+4SC0p3yj9TliaG4/J0KbdxIWT8J2jrKWzJVrDH+tBaLKo8+0wHFu+AC/9vVI6FEytql0//qaBI0S8nC3fguw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780455228; c=relaxed/simple; bh=7Y5V+ZcZaOsnsFZE6c1uX6zfrhZQNtfZbfDZkhkUc8Q=; h=Content-Type:Mime-Version:Subject:From:In-Reply-To:Date:Cc: Message-Id:References:To; b=RLFdYN4Dolct4KwQW8X5ezfzxvE7vCWAmp4U2uMe2hephQpzflm5NuX1hdt/dqSPssJlycGvTU6rUS/16zF06QMEVvPwWOWkdg+BFz/KZUcBvrzakHoT81lGwJ6Tu8p5mYdBVm1T15MjOi0VIts7qmy77E3Gb0zRkBG/Jbs1KcA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=NxkwUBap; arc=none smtp.client-ip=91.218.175.185 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) header.d=linux.dev header.i=@linux.dev header.b="NxkwUBap" Content-Type: text/plain; charset=us-ascii DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1780455224; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hXR0DDEnySpzbdiRagAYl7c+e0VnGF+jVNLwTxCwhtQ=; b=NxkwUBapuP1ubsUtM+nqUc6e4oSWGPNe4k31tuYXqiMtmjlN0lcSrZnvD3S1gKNAmwVuGH BWAVmV+hhsZHg8TnjTJTi7EcLw5Ltoqml4bZKx0imJFPYB0OSlIrf44wgUtDsgUABdYzSL 2dSD2TNsXlmQsElmo9BS8yvl/dij+d0= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3864.600.51.1.1\)) Subject: Re: [PATCH v3 14/19] mm/hugetlb: Free cross-zone bootmem gigantic pages after allocation X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Muchun Song In-Reply-To: <178041489395.457517.12727427621570734471.b4-review@b4> Date: Wed, 3 Jun 2026 10:53:04 +0800 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 Content-Transfer-Encoding: quoted-printable Message-Id: <1ABCD934-CA2C-4541-9B76-32FAEFD398FF@linux.dev> References: <20260602101039.1867613-1-songmuchun@bytedance.com> <20260602101039.1867613-15-songmuchun@bytedance.com> <178041489395.457517.12727427621570734471.b4-review@b4> To: Mike Rapoport X-Migadu-Flow: FLOW_OUT > On Jun 2, 2026, at 23:41, Mike Rapoport wrote: >=20 > On Tue, 02 Jun 2026 18:10:34 +0800, Muchun Song = wrote: >=20 > Hi Muchun, Hi Mike, >=20 >>=20 >> 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 !=3D NUMA_NO_NODE && nid !=3D = nid_request)) >> + list_add(&m->list, &huge_boot_pages[nid_request]); >> + else >> + list_add(&m->list, &huge_boot_pages[nid]); >=20 > 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. Thanks. >=20 > Rather than making alloc_bootmem_huge_page() bool (sorry my bad :)) we > can make it return -ENOMEM when memblock_alloc() fails, 0 if the page = is > not usable and 1 (i.e. number of allocated gigantic pages) if = everything > is fine. >=20 > The callers would need a bit of massage, but it still seems simpler to > me than adding them to the list and then walking that list. >=20 > --=20 > Sincerely yours, > Mike. >=20