From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f50.google.com (mail-ot1-f50.google.com [209.85.210.50]) (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 73720306B21 for ; Wed, 25 Feb 2026 20:27:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.50 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772051227; cv=none; b=UGijTzTI3Osz/cSXzO4NIoneq4Lx6wFhsmG2A0Td/YUSUxDmbqpEDMJRzpEiVRn2/3LiK40a+BXh2oEXBGa+eFGdQ/T52nfBbB1KsnBjoheS6TUqrd84RZ9N+Gud4sy7mDTyGLV2+kz0tkEiaujTLKCyidTIFtf3YIyWswxauzY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772051227; c=relaxed/simple; bh=uQ5ODX6Ec6bUxHv4xNuvgLmwIhwEhBrFm24dfHVZiWw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kf9O9vbC/kCfvMLtFJxvn5kbVuMlJZ5DEseNMGnrtZZn9zbmZz1W7L2rdPqliQW3Q68fmqf6tk4lzTwPtr2EybH5CcEo07CO9tIaQX9hfjWKhNsBBmhxxxR3eGPE19Lkrg4QvbjIIK+BjGa3av8lQmvxLIxqNC9BNmXJ+Qc2p9E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nVJFmv7+; arc=none smtp.client-ip=209.85.210.50 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nVJFmv7+" Received: by mail-ot1-f50.google.com with SMTP id 46e09a7af769-7d4bd4db87aso6270a34.2 for ; Wed, 25 Feb 2026 12:27:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1772051224; x=1772656024; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EnoCZpEnsiZT/nYZfVWRoHJkjSlEny21hV+TMR2IO+k=; b=nVJFmv7+kU5hG6NS+CZUn9TF+MHgSNOB/IFg8QlTD9P6+ZpWfxRf57ra9RD9DArXwk tjXyl4WdguH1HHXZcmCW7UEp5hHWbSadPVpbRs/EpDn/bKxJ91Um19Gk7WmG4EgS118w jJxqhxE/t246Sc4WbUDBBHdK7+7fNcEs7eXtlWgaqR4eDinqBuRBxqw/cU9u6Vk1osO4 kDqnwqDY7C8sTb4k9NyXHu+9EhG8wOzi6FBGNaKPtv4KBgFHOb+/kIDCFAELMCAtcVw8 z4Vi0AKLqI+DKQ3JCuZKrH0YifTuQjBHlIJjE7ksI/ykQaCVwV1puU/DbfKhM0k+ys+0 lYXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772051224; x=1772656024; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=EnoCZpEnsiZT/nYZfVWRoHJkjSlEny21hV+TMR2IO+k=; b=AYYnPCrelMLcLSEOJJlj0cZfWcIRkAVmF3lkfhrQMCc5ZZxkGDaMiCdw/xOTt84LTe 2HVuGHteRgO9SWYVrtPZOjO7cfpdulMyK+zFrIyvwucqzh6lMgf9R426GWIP0I+UoZXT xxtEWw8EV1qNxwCxJ5EDdesgIN8hShZUsvQVh7PdCjBZAx/tKOsc8TcR/UG0eHiJESWQ bDPc5U1lPHYu4ZCfG16kfeRlA/m9xxd7ApmdpguAGPEOOMRd2HTk+fP/q0GmcIV+j3Xx H8ToBSI1dYqpYPicUGU/i/x0snscB4oY73S1gGOBuIyOOEnvoS+KM4AV4ilKU72qRq57 XSpw== X-Forwarded-Encrypted: i=1; AJvYcCWzcCNiQlv4Wtqhuw+Ve6Hum11nOBiYRyYekQE4Hf5puM5hmf4VwBAuNEFfv3KKgDIoWc7ejUG6IHW2iqk=@vger.kernel.org X-Gm-Message-State: AOJu0YyEFJ1B/uSxjDQd53YKVHPwaXxqkOtIWG90dnfFn72yJGUjRcx5 ItlOlOCdf4Tzu4baZkwiKhvfofmsBevfqd7NhIFnk7lfJTxkV6aNisj7 X-Gm-Gg: ATEYQzxyyR6EbkRm7SMj5/E6A/go9Ihng7Gx2qtOK/zOyivP3ftseHq/K0ogL+is7mU CTfinyc6k4yqWEb+B4mKzA75QkbdUom5SQInp4t9uTJUr5afhjVWXK0ckr3J/f6cyrmnlS4LPQk UIdBhQSpbtKMT1RJvV633YY6ZkKiYE3GHJo0Lq8dXHLJuFN4QIVY7SvCVL+hZDHbt78wjuzrNya 80POLMIaLirWfAbr5/c2sM/Y6xHfHHsgYRubSLbVRpH1vnp0tgF0doG0sViRhGxhuMGXLcBdepk TI9rNtblMHa4v8Ji6q31FiCuYheAjrXH7X0SJJy4GvV8Wl5lRSDTd4SWvttHsDpaopNeZJeUSRr C7yBGXCUFA90tKEeVk8l6A8AEEwG50S2Ftj1f6Egi2ivT+cCG+4seRmwK4/D4iDZztCbkAJw3Pz 4m8kk2UiAn3YTorqs4g8gH X-Received: by 2002:a05:6830:6c07:b0:7cf:e4a1:8b6b with SMTP id 46e09a7af769-7d52bdf6e7fmr9810731a34.4.1772051224348; Wed, 25 Feb 2026 12:27:04 -0800 (PST) Received: from localhost ([2a03:2880:10ff:2::]) by smtp.gmail.com with ESMTPSA id 46e09a7af769-7d58644edf0sm8089a34.2.2026.02.25.12.27.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 25 Feb 2026 12:27:02 -0800 (PST) From: Joshua Hahn To: Ackerley Tng Cc: 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, cgroups@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: Re: [RFC PATCH v1 1/7] mm: hugetlb: Consolidate interpretation of gbl_chg within alloc_hugetlb_folio() Date: Wed, 25 Feb 2026 12:27:00 -0800 Message-ID: <20260225202701.4104505-1-joshua.hahnjy@gmail.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit On Wed, 11 Feb 2026 16:37:12 -0800 Ackerley Tng wrote: > 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 Makes sense to me, this seems like a reasonable semantic change even without factoring out hugetlb_alloc_folio. Thank you! 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 hstate *h) > > 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 = NULL; > struct mempolicy *mpol; > @@ -1388,13 +1388,6 @@ static struct folio *dequeue_hugetlb_folio_vma(struct hstate *h, > nodemask_t *nodemask; > int nid; > > - /* > - * gbl_chg==1 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 = htlb_alloc_mask(h); > nid = huge_node(vma, address, gfp_mask, &mpol, &nodemask); > > @@ -1412,9 +1405,6 @@ static struct folio *dequeue_hugetlb_folio_vma(struct hstate *h, > > mpol_cond_put(mpol); > return folio; > - > -err: > - return NULL; > } > > #ifdef CONFIG_ARCH_HAS_GIGANTIC_PAGE > @@ -2962,12 +2952,16 @@ struct folio *alloc_hugetlb_folio(struct vm_area_struct *vma, > goto out_uncharge_cgroup_reservation; > > 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 == 0 indicates > - * a reservation exists for the allocation. > + * gbl_chg == 0 indicates a reservation exists for the allocation - so > + * try dequeuing a page. If there are available_huge_pages(), try using > + * them! > */ > - folio = dequeue_hugetlb_folio_vma(h, vma, addr, gbl_chg); > + folio = NULL; > + if (!gbl_chg || available_huge_pages(h)) > + folio = dequeue_hugetlb_folio_vma(h, vma, addr); > + > if (!folio) { > spin_unlock_irq(&hugetlb_lock); > folio = alloc_buddy_hugetlb_folio_with_mpol(h, vma, addr); > -- > 2.53.0.310.g728cabbaf7-goog > >