From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6EEE12066D4 for ; Fri, 10 Jan 2025 06:24:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736490252; cv=none; b=o9stQkYbrk2w1ExY34UB1U+NMrX+S2Au15i5IurkvAFf3b1GE7AJ531zJDRnUEMDxhpBNWWfxL5xV0WC01Q7bGn51dGhzi1gCdWBbmRH+nW3AjBtbeQOaOPO/nvB7Qoc6SceTk6n9EjNqXSkhz1qcEUUZ+YdpDupd4oZU7U57VQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736490252; c=relaxed/simple; bh=dCODRaBrJ5sji+fH9+tSgVssGi5YVIGFZTkfydyahv8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=iPM06rlB9HdOweTAReZi22KsEFjPBpcbpAS1dJK3AIeJMT/eceKWqIiyXSRp4I8+jIBn7BNkjE0XSRuk3zmCDToDgAZUmop5LMRTWWk7VSS2HVCLcSFgV+AUUJqICW+baVvGZ2yfHmJXFecMZ7+GpQnZe8Mv3dDrcJOPxDG9tfg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 113601477; Thu, 9 Jan 2025 22:24:29 -0800 (PST) Received: from [10.162.42.21] (K4MQJ0H1H2.blr.arm.com [10.162.42.21]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 64D7C3F673; Thu, 9 Jan 2025 22:23:49 -0800 (PST) Message-ID: Date: Fri, 10 Jan 2025 11:53:46 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [RFC 06/11] khugepaged: generalize alloc_charge_folio for mTHP support To: Nico Pache , linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: ryan.roberts@arm.com, anshuman.khandual@arm.com, catalin.marinas@arm.com, cl@gentwo.org, vbabka@suse.cz, mhocko@suse.com, apopple@nvidia.com, dave.hansen@linux.intel.com, will@kernel.org, baohua@kernel.org, jack@suse.cz, srivatsa@csail.mit.edu, haowenchao22@gmail.com, hughd@google.com, aneesh.kumar@kernel.org, yang@os.amperecomputing.com, peterx@redhat.com, ioworker0@gmail.com, wangkefeng.wang@huawei.com, ziy@nvidia.com, jglisse@google.com, surenb@google.com, vishal.moola@gmail.com, zokeefe@google.com, zhengqi.arch@bytedance.com, jhubbard@nvidia.com, 21cnbao@gmail.com, willy@infradead.org, kirill.shutemov@linux.intel.com, david@redhat.com, aarcange@redhat.com, raquini@redhat.com, sunnanyong@huawei.com, usamaarif642@gmail.com, audra@redhat.com, akpm@linux-foundation.org References: <20250108233128.14484-1-npache@redhat.com> <20250108233128.14484-7-npache@redhat.com> Content-Language: en-US From: Dev Jain In-Reply-To: <20250108233128.14484-7-npache@redhat.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 09/01/25 5:01 am, Nico Pache wrote: > alloc_charge_folio allocates the new folio for the khugepaged collapse. > Generalize the order of the folio allocations to support future mTHP > collapsing. > > No functional changes in this patch. > > Signed-off-by: Nico Pache > --- > mm/khugepaged.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/mm/khugepaged.c b/mm/khugepaged.c > index e2e6ca9265ab..6daf3a943a1a 100644 > --- a/mm/khugepaged.c > +++ b/mm/khugepaged.c > @@ -1070,14 +1070,14 @@ static int __collapse_huge_page_swapin(struct mm_struct *mm, > } > > static int alloc_charge_folio(struct folio **foliop, struct mm_struct *mm, > - struct collapse_control *cc) > + struct collapse_control *cc, int order) > { > gfp_t gfp = (cc->is_khugepaged ? alloc_hugepage_khugepaged_gfpmask() : > GFP_TRANSHUGE); > int node = khugepaged_find_target_node(cc); > struct folio *folio; > > - folio = __folio_alloc(gfp, HPAGE_PMD_ORDER, node, &cc->alloc_nmask); > + folio = __folio_alloc(gfp, order, node, &cc->alloc_nmask); > if (!folio) { > *foliop = NULL; > count_vm_event(THP_COLLAPSE_ALLOC_FAILED); > @@ -1121,7 +1121,7 @@ static int collapse_huge_page(struct mm_struct *mm, unsigned long address, > */ > mmap_read_unlock(mm); > > - result = alloc_charge_folio(&folio, mm, cc); > + result = alloc_charge_folio(&folio, mm, cc, HPAGE_PMD_ORDER); > if (result != SCAN_SUCCEED) > goto out_nolock; > > @@ -1834,7 +1834,7 @@ static int collapse_file(struct mm_struct *mm, unsigned long addr, > VM_BUG_ON(!IS_ENABLED(CONFIG_READ_ONLY_THP_FOR_FS) && !is_shmem); > VM_BUG_ON(start & (HPAGE_PMD_NR - 1)); > > - result = alloc_charge_folio(&new_folio, mm, cc); > + result = alloc_charge_folio(&new_folio, mm, cc, HPAGE_PMD_ORDER); > if (result != SCAN_SUCCEED) > goto out; > I guess we will need stat updation like I did in my patch.