From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A8F2C3ABB2 for ; Wed, 28 May 2025 08:55:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D0F426B0089; Wed, 28 May 2025 04:55:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CC01A6B008A; Wed, 28 May 2025 04:55:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BAEAE6B008C; Wed, 28 May 2025 04:55:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9D0636B0089 for ; Wed, 28 May 2025 04:55:30 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 18BCCE7DA3 for ; Wed, 28 May 2025 08:55:30 +0000 (UTC) X-FDA: 83491708020.15.9B5E0DD Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.9]) by imf28.hostedemail.com (Postfix) with ESMTP id 3E157C0005 for ; Wed, 28 May 2025 08:55:27 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="Kb9z1b/B"; spf=none (imf28.hostedemail.com: domain of binbin.wu@linux.intel.com has no SPF policy when checking 192.198.163.9) smtp.mailfrom=binbin.wu@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1748422527; h=from:from:sender: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:dkim-signature; bh=pDnlvzn/mwkSoAKxlHuRWXypjxP19COPjGlYUeLHq90=; b=ohun9WYj8hmzFHJEBLmO6UCuC+cPP0JOvPrakj546E1OHoBMBSj44+BgZxjRqnXF9fx/IQ 2t2jVtMucyjiVjQg5E+aRmK1W3LohoaDy4eTFlSJdvCXBnf9Lf1zH89Ank8WLSZGRLm/6R 5GK3Bp/6SGZ/iiwX8VxdHQXTg18lJC4= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=intel.com header.s=Intel header.b="Kb9z1b/B"; spf=none (imf28.hostedemail.com: domain of binbin.wu@linux.intel.com has no SPF policy when checking 192.198.163.9) smtp.mailfrom=binbin.wu@linux.intel.com; dmarc=pass (policy=none) header.from=intel.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1748422527; a=rsa-sha256; cv=none; b=1TMrq5feut1dQ49YcfUPwwp86H0IAeBwLaJxASRBUDKc2LM/AiPgwQC5ElggMFwt7xVTQa xTpYNc9ay+MzycErWVI0+VxdF5VI0bODgaqRm1xRawx8redlga+dn9+wYeYhGbzfoqTkeV 1THOgv1IwsLqp+ukE9KTta560f/wuvs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1748422527; x=1779958527; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=o/IBf/bL4uUQfqfko7CVRmw6Pl3VESZqBWXrtTbKLHg=; b=Kb9z1b/Be7vgBgT3nxMLgZpNH8w24y1kZKjH8ruWxRf9AM7HXq2Anijl sVkd8YQY7m6eX7a4HKw7bmtdJd3gyIUSpBClWkOpvyNkJyApu1Mp6NVqt C9dJU+NHnyH2n+LBY2OGveyuDtLF14bfLZU/34FmTY8p+Woi2f/ix8Xzg LCUNaF8hLATTy3X1KYrW+vJPm6kTu6CsAt/JrigfPbrXBiDYZeL4yinOl mmyy3GxTcgVS7uPwIR+YosvI5eutfl4NH10WHiKc5gWUuzQh3yJS2Y9r0 dkZqYmZgAI8ic8vGwSEAdmszwirTE6Ma7RARTCGF2adOTEmX+7Xk3xDfc Q==; X-CSE-ConnectionGUID: zgpngWKaSqKe2YOevjPUvQ== X-CSE-MsgGUID: ekS+/AmASy2ceYRxwrMIYA== X-IronPort-AV: E=McAfee;i="6700,10204,11446"; a="61098603" X-IronPort-AV: E=Sophos;i="6.15,320,1739865600"; d="scan'208";a="61098603" Received: from fmviesa002.fm.intel.com ([10.60.135.142]) by fmvoesa103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 01:55:26 -0700 X-CSE-ConnectionGUID: 1yTLA9bhTNGc1WfrftagLg== X-CSE-MsgGUID: YJGTweprTPmbgT0LpLaE6Q== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,320,1739865600"; d="scan'208";a="166357521" Received: from unknown (HELO [10.238.3.95]) ([10.238.3.95]) by fmviesa002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 May 2025 01:55:08 -0700 Message-ID: Date: Wed, 28 May 2025 16:55:05 +0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC PATCH v2 16/51] mm: hugetlb: Consolidate interpretation of gbl_chg within alloc_hugetlb_folio() To: Ackerley Tng Cc: kvm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, x86@kernel.org, linux-fsdevel@vger.kernel.org, aik@amd.com, ajones@ventanamicro.com, akpm@linux-foundation.org, amoorthy@google.com, anthony.yznaga@oracle.com, anup@brainfault.org, aou@eecs.berkeley.edu, bfoster@redhat.com, brauner@kernel.org, catalin.marinas@arm.com, chao.p.peng@intel.com, chenhuacai@kernel.org, dave.hansen@intel.com, david@redhat.com, dmatlack@google.com, dwmw@amazon.co.uk, erdemaktas@google.com, fan.du@intel.com, fvdl@google.com, graf@amazon.com, haibo1.xu@intel.com, hch@infradead.org, hughd@google.com, ira.weiny@intel.com, isaku.yamahata@intel.com, jack@suse.cz, james.morse@arm.com, jarkko@kernel.org, jgg@ziepe.ca, jgowans@amazon.com, jhubbard@nvidia.com, jroedel@suse.de, jthoughton@google.com, jun.miao@intel.com, kai.huang@intel.com, keirf@google.com, kent.overstreet@linux.dev, kirill.shutemov@intel.com, liam.merwick@oracle.com, maciej.wieczor-retman@intel.com, mail@maciej.szmigiero.name, maz@kernel.org, mic@digikod.net, michael.roth@amd.com, mpe@ellerman.id.au, muchun.song@linux.dev, nikunj@amd.com, nsaenz@amazon.es, oliver.upton@linux.dev, palmer@dabbelt.com, pankaj.gupta@amd.com, paul.walmsley@sifive.com, pbonzini@redhat.com, pdurrant@amazon.co.uk, peterx@redhat.com, pgonda@google.com, pvorel@suse.cz, qperret@google.com, quic_cvanscha@quicinc.com, quic_eberman@quicinc.com, quic_mnalajal@quicinc.com, quic_pderrin@quicinc.com, quic_pheragu@quicinc.com, quic_svaddagi@quicinc.com, quic_tsoni@quicinc.com, richard.weiyang@gmail.com, rick.p.edgecombe@intel.com, rientjes@google.com, roypat@amazon.co.uk, rppt@kernel.org, seanjc@google.com, shuah@kernel.org, steven.price@arm.com, steven.sistare@oracle.com, suzuki.poulose@arm.com, tabba@google.com, thomas.lendacky@amd.com, usama.arif@bytedance.com, vannapurve@google.com, vbabka@suse.cz, viro@zeniv.linux.org.uk, vkuznets@redhat.com, wei.w.wang@intel.com, will@kernel.org, willy@infradead.org, xiaoyao.li@intel.com, yan.y.zhao@intel.com, yilun.xu@intel.com, yuzenghui@huawei.com, zhiquan1.li@intel.com References: <8548af334e01401a776aae37a0e9f30f9ffbba8c.1747264138.git.ackerleytng@google.com> Content-Language: en-US From: Binbin Wu In-Reply-To: <8548af334e01401a776aae37a0e9f30f9ffbba8c.1747264138.git.ackerleytng@google.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 3E157C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D7 mlXPXPE+92BDc4YcZ/v4YIp23rL4652aZPqHBk4QUhGVQfiSQiyRHyvyUdf9+R9U8w0H+0nvjTOdlku8Dyjki/eyQYDbhnL6/lOAcuRJ5VEj5Lrg5f7keiPkrx8+6tsraQpNL2jtLswUvZGcgkCwYcYy9UukQ0Xj0dirAyiSY9qnzzBV9p5RTMl0Ud5m38nvendgF7py6Ogtxz1fhAK+dDZ5mSHQiKG8kz3/oVqke7WeX7c2ZcU7o4nDQ4s4saVRziVur7VoyombLHzaNwoovHrxMSjpmBGM0iZfad14FDNe4qGQraE+4dd6aHFTgkKAkK6g+To9hXDTMP3iz9GM5ap5iU89qLbh5XmP5U9iL6e8tqSejyYyROhpZf+gpHfcLUe5K X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 5/15/2025 7:41 AM, 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. > > Change-Id: I31bf48af2400b6e13b44d03c8be22ce1a9092a9c > Signed-off-by: Ackerley Tng > --- > mm/hugetlb.c | 28 +++++++++++----------------- > 1 file changed, 11 insertions(+), 17 deletions(-) > > diff --git a/mm/hugetlb.c b/mm/hugetlb.c > index 6ea1be71aa42..b843e869496f 100644 > --- a/mm/hugetlb.c > +++ b/mm/hugetlb.c > @@ -1364,9 +1364,9 @@ static unsigned long available_huge_pages(struct hstate *h) > return h->free_huge_pages - h->resv_huge_pages; > } > > -static struct folio *dequeue_hugetlb_folio_vma(struct hstate *h, > - struct vm_area_struct *vma, > - unsigned long address, long gbl_chg) > +static struct folio *dequeue_hugetlb_folio(struct hstate *h, > + struct vm_area_struct *vma, > + unsigned long address) The rename seems not needed in this patch, since the function still takes vma and uses it. May be better to move the rename to a later patch. > { > struct folio *folio = NULL; > struct mempolicy *mpol; > @@ -1374,13 +1374,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); > > @@ -1398,9 +1391,6 @@ static struct folio *dequeue_hugetlb_folio_vma(struct hstate *h, > > mpol_cond_put(mpol); > return folio; > - > -err: > - return NULL; > } > > /* > @@ -3074,12 +3064,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(h, vma, addr); > + > if (!folio) { > spin_unlock_irq(&hugetlb_lock); > folio = alloc_buddy_hugetlb_folio_with_mpol(h, vma, addr);