From nobody Fri Oct 3 18:01:16 2025 Received: from baidu.com (mx24.baidu.com [111.206.215.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 922003BB44 for ; Wed, 27 Aug 2025 04:13:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=111.206.215.185 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756268041; cv=none; b=ScjsTZoHlpqKcMcDjSsqm/HBbGl/YSmbTxRFpNlKPrDnWtyJYhTW78SrNr6CF5UzB4Mc2QOac4/QMLB266kD73oNmhNgTpm/kaJ6Cyvpn+Ezs/4AIf27b/Lgis0bN5Dv3C9bSnQuXaGBVmqNnSiZOI9Lo0pujsCYe2AzhEE5A8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756268041; c=relaxed/simple; bh=FwKGMJa1YOKpFW+ky8zIIrquwgW58xBTUeC+8VrZPms=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=NRknw042cpjbdsrqsDUTzT5Mv3Dt+L6ygbtRZnAePZCaEgMayUdMhtDiBtBAFZg4LapxCVE59CLm8Lp91SUWWj4Ii/Sd6s/xXdsLzP3MHp9/D19vOzMqcLffPSvzVqSjS++fKgc6xS4rl4yZG5gpSie0ntr1e28XPi6E2rdo8nI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com; spf=pass smtp.mailfrom=baidu.com; arc=none smtp.client-ip=111.206.215.185 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=baidu.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baidu.com From: "Li,Rongqing" To: David Hildenbrand , "muchun.song@linux.dev" , "osalvador@suse.de" , "akpm@linux-foundation.org" , "linux-mm@kvack.org" , "linux-kernel@vger.kernel.org" , "giorgitchankvetadze1997@gmail.com" CC: "Xu,Wenjie(ACG CCN)" Subject: RE: Re: [PATCH] mm/hugetlb: two-phase hugepage allocation when reservation is high Thread-Topic: Re: [PATCH] mm/hugetlb: two-phase hugepage allocation when reservation is high Thread-Index: AdwXCKQKyZG+t/+FSoO+KsNcdGLEBA== Date: Wed, 27 Aug 2025 04:12:48 +0000 Message-ID: <33c9676b1fda4cbaa42857787e03c7ec@baidu.com> Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-FEAS-Client-IP: 172.31.4.11 X-FE-Policy-ID: 52:10:53:SYSTEM =2E >=20 > Also, can't we fail lightly during the first attempt and dynamically deci= de if we > should do a second pase? >=20 Good idea, like below diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 753f99b..425a759 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -3589,6 +3589,7 @@ static unsigned long __init hugetlb_pages_alloc_boot(= struct hstate *h) unsigned long jiffies_start; unsigned long jiffies_end; + unsigned long remaining; job.thread_fn =3D hugetlb_pages_alloc_boot_node; job.start =3D 0; @@ -3620,6 +3621,18 @@ static unsigned long __init hugetlb_pages_alloc_boot= (struct hstate *h) jiffies_start =3D jiffies; padata_do_multithreaded(&job); + + if (h->nr_huge_pages !=3D h->max_huge_pages && hugetlb_vmemmap_opti= mizable(h)) { + remaining =3D h->max_huge_pages - h->nr_huge_pages; + /* vmemmap optimization can save about 1.6% (4/250) memory = */ + remaining =3D min(remaining, (h->nr_huge_pages * 4 / 250)); + + job.start =3D h->nr_huge_pages; + job.size =3D remaining; + job.min_chunk =3D remaining / hugepage_allocation_threads; + padata_do_multithreaded(&job); + } Thanks -Li > -- > Cheers >=20 > David / dhildenb