From nobody Thu Apr 2 19:17:23 2026 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A63541AB6F1 for ; Thu, 12 Feb 2026 00:37:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770856650; cv=none; b=ShJz3+2k9WbHqdLQWKLfPY1bhLPK3UtnhKEML6mJIeDLsezLz+rxkBhOGmK62CpSC5wzNSQ6ObmsP1fpY63sZOJppBCGzxZB+O9uM2gIMSw/IZlbIyzNxJ5sK/SeEZTEzPctUi4CvqdEm8nXUrJ0efWTyz9qeNovmfHfkeqXq/Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1770856650; c=relaxed/simple; bh=LM4IDRwtUxJyRCp0kUE1qgZT5L1HEBFTk6wT4AL7YaM=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=sSVpQZTAX/BRbnku0LAOmNj/s1dUIgXkjCB5MdBGulEDJeK4WYr3AHsgsegi02L46LDRqZ/VZ/qTinpQY5ODnA7tyrLLcf+etYShhjwkoAl3f6YLkcrYOVGmc7BR4s/QF9jb3BYGlQ+p/evOv0EpXMfIOGLdTBbO1M7Y7XgaAXY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=lWwt34gR; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--ackerleytng.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="lWwt34gR" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-35464d7c539so5892067a91.0 for ; Wed, 11 Feb 2026 16:37:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1770856648; x=1771461448; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=2JnA227LuyuHWxtahECJXUZ4BvkZ1hdR9r/VpPR8oGw=; b=lWwt34gRcEoQKHR52f7m0mprMvta85z7Kl+YRjoeQuFli12rq3Z6JuvgWq1WcZGldL JL4p6Q+ltNTwhEqpJW8S0ate+1RH4GQNSXXoaMOl3ixfSEtkrTiRK9L6K9yTFtJGDFwz CNXEeb0lK6PQvmS7IExlAh3IwMhezAszqM6Qbu1PSB3JmB/deMckSKigsD1pzif3P8/G Sqe2ylvlkh3Yv0erQBk1OU5rPBSHK4YewDlD5D00SMc917VLPu0OQRbuuYqU1+yeJnC6 UFcY0BbQYqxZfoEJjlzSgen5wIw57Lm3oAV6idIoMWdvkYR86WTZXAtM23mI1fc5/yNk V6yA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770856648; x=1771461448; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=2JnA227LuyuHWxtahECJXUZ4BvkZ1hdR9r/VpPR8oGw=; b=wD3gBp2K4yczCVjSRqroZkmtE66uW1bzK6Ug2fLQPOYa/rzFHDF2ZswyLtw+12EJZh GbtgaqywoXbnmkH5ESf0R2Kh7hGRRaoaWtpL7C2h4JaN39rIFmw4MvL9Cv1pFtU0qqIN FJf8SnbtMYP+lBdKIkH7crjNI+GhzD/TbFN0P+TAZ0DM5vHLyGN9Dbh+3dQrq2F1DpHj 4hDYIK/sKS6Hns2WMp0/bXzrklLQ7yPbp1Hhw/18f2KopkJ7P1g54yNYT9cRJz5m6xnk w8q9wnCo+BFj71sQYPg8qTNbakZ4iW8r1Qbtip2WZXytdCSMoth3DeagC9tpOrv8VO/q Zx4g== X-Forwarded-Encrypted: i=1; AJvYcCXeBOHsLdq3Q1HPEYlcwWD6+VJ4Wtp6QE3UA47CV+GFPVjn86US7erupfy2veGUxq/5pG2/whOFRRPc4lE=@vger.kernel.org X-Gm-Message-State: AOJu0YxnR1bvtDvsav8RVkIn9SbiYU9rOH0Pn1hy360MfQYrqLJnjF6E BEWPaIaIRk8OTV2WrwqZk4Yb4OuYD+VVNJklmf/sdbO8n63WwrYKnPEFomVAsUavMW1R2FPCQgo 0MFPi23poRUN+fDngraIoOCHROQ== X-Received: from pgbdo14.prod.google.com ([2002:a05:6a02:e8e:b0:c6c:9940:fac3]) (user=ackerleytng job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a21:495:b0:38d:ebdc:3546 with SMTP id adf61e73a8af0-39448477cb9mr923997637.6.1770856647927; Wed, 11 Feb 2026 16:37:27 -0800 (PST) Date: Wed, 11 Feb 2026 16:37:12 -0800 In-Reply-To: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: X-Mailer: git-send-email 2.53.0.310.g728cabbaf7-goog Message-ID: Subject: [RFC PATCH v1 1/7] mm: hugetlb: Consolidate interpretation of gbl_chg within alloc_hugetlb_folio() From: Ackerley Tng To: akpm@linux-foundation.org, dan.j.williams@intel.com, david@kernel.org, fvdl@google.com, hannes@cmpxchg.org, jgg@nvidia.com, jiaqiyan@google.com, jthoughton@google.com, kalyazin@amazon.com, mhocko@kernel.org, michael.roth@amd.com, muchun.song@linux.dev, osalvador@suse.de, pasha.tatashin@soleen.com, pbonzini@redhat.com, peterx@redhat.com, pratyush@kernel.org, rick.p.edgecombe@intel.com, rientjes@google.com, roman.gushchin@linux.dev, seanjc@google.com, shakeel.butt@linux.dev, shivankg@amd.com, vannapurve@google.com, yan.y.zhao@intel.com Cc: ackerleytng@google.com, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Previously, gbl_chg was passed from alloc_hugetlb_folio() into dequeue_hugetlb_folio_vma(), leaking the concept of gbl_chg into dequeue_hugetlb_folio_vma(). This patch consolidates the interpretation of gbl_chg into alloc_hugetlb_folio(), also renaming dequeue_hugetlb_folio_vma() to dequeue_hugetlb_folio() so dequeue_hugetlb_folio() can just focus on dequeuing a folio. No functional change intended. Signed-off-by: Ackerley Tng Reviewed-by: James Houghton Reviewed-by: Joshua Hahn --- mm/hugetlb.c | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/mm/hugetlb.c b/mm/hugetlb.c index a1832da0f6236..fd067bd394ee0 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c @@ -1380,7 +1380,7 @@ static unsigned long available_huge_pages(struct hsta= te *h) =20 static struct folio *dequeue_hugetlb_folio_vma(struct hstate *h, struct vm_area_struct *vma, - unsigned long address, long gbl_chg) + unsigned long address) { struct folio *folio =3D NULL; struct mempolicy *mpol; @@ -1388,13 +1388,6 @@ static struct folio *dequeue_hugetlb_folio_vma(struc= t hstate *h, nodemask_t *nodemask; int nid; =20 - /* - * gbl_chg=3D=3D1 means the allocation requires a new page that was not - * reserved before. Making sure there's at least one free page. - */ - if (gbl_chg && !available_huge_pages(h)) - goto err; - gfp_mask =3D htlb_alloc_mask(h); nid =3D huge_node(vma, address, gfp_mask, &mpol, &nodemask); =20 @@ -1412,9 +1405,6 @@ static struct folio *dequeue_hugetlb_folio_vma(struct= hstate *h, =20 mpol_cond_put(mpol); return folio; - -err: - return NULL; } =20 #ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE @@ -2962,12 +2952,16 @@ struct folio *alloc_hugetlb_folio(struct vm_area_st= ruct *vma, goto out_uncharge_cgroup_reservation; =20 spin_lock_irq(&hugetlb_lock); + /* - * glb_chg is passed to indicate whether or not a page must be taken - * from the global free pool (global change). gbl_chg =3D=3D 0 indicates - * a reservation exists for the allocation. + * gbl_chg =3D=3D 0 indicates a reservation exists for the allocation - so + * try dequeuing a page. If there are available_huge_pages(), try using + * them! */ - folio =3D dequeue_hugetlb_folio_vma(h, vma, addr, gbl_chg); + folio =3D NULL; + if (!gbl_chg || available_huge_pages(h)) + folio =3D dequeue_hugetlb_folio_vma(h, vma, addr); + if (!folio) { spin_unlock_irq(&hugetlb_lock); folio =3D alloc_buddy_hugetlb_folio_with_mpol(h, vma, addr); --=20 2.53.0.310.g728cabbaf7-goog