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 78C43C43334 for ; Tue, 12 Jul 2022 20:52:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EF3CB9400D2; Tue, 12 Jul 2022 16:52:21 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EA42C940063; Tue, 12 Jul 2022 16:52:21 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D92E69400D2; Tue, 12 Jul 2022 16:52:21 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CB6FB940063 for ; Tue, 12 Jul 2022 16:52:21 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 98FEF34F98 for ; Tue, 12 Jul 2022 20:52:21 +0000 (UTC) X-FDA: 79679645682.14.599C35C Received: from mail-lf1-f50.google.com (mail-lf1-f50.google.com [209.85.167.50]) by imf10.hostedemail.com (Postfix) with ESMTP id 40DCAC0064 for ; Tue, 12 Jul 2022 20:52:21 +0000 (UTC) Received: by mail-lf1-f50.google.com with SMTP id e28so12348708lfj.4 for ; Tue, 12 Jul 2022 13:52:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iz3LrBt6Ku3myI5IwwlOusoVA0/X3ThdIo77BcqKEIY=; b=TvNekszX27wYHpN0/ZUw28oRMTdMI3ObkgaeKYJs55ORez5/V/UFePB6/aa7leY3F8 Q2+OIT5QhqRY2mYJlnSn+sa3+Wom5ByQ7sHv5CH7fS77fKadZaNnvENGGE0isTfyRhmI eo/mBtgsAUI3Kg1RbGK1ocfcgg0GuTJAJdkcImTBGgRke+/+PWoHsidMPI/meUedaNKZ T89TObUdphEW2tB1mI/HAG6diFljiJ8Lt08Pa1tkf0B0OHGkC0//cspqEYq4YNnrIaVm K/WnNicP2YGDzbMBvzni/FwGhA3HQNR3QypCrcPxgkqTqL6P+JGGGUGNuks1OSXYO0CT 8aWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iz3LrBt6Ku3myI5IwwlOusoVA0/X3ThdIo77BcqKEIY=; b=OELuG84W+4oaIKGm1GwaVdcwDttOif1iXeNDqXdVomCThF1IfmyNEDQLobsjWrk/pc 3Kc4EZ34DA0uDNKIeCJYpK8MgkYiWKEFM183mUcxwii1XOWsP+CPG35ZsZFw9PB53XuX 6Ajn7QCv5cwrb+gGprqO0c3dBuHDnug8kvKkRiT2du95I5n36A2oUxwM6J9GPM5iK9Js Da0FhQMeuHnNF6FddPZK+KlML0ATCzmYfCjz7HHoEQV1Fy6LNK2TGdEdPZLFwYBO9tLv p+q4mXJYWYON5eObcpUaTMhc9uxmHylygwBVcN39wpEJPW5rAw1nhC3g4f3IoDiZxGG/ uv9A== X-Gm-Message-State: AJIora9gvpYWAajWyRCV2Aoe55ysBNCSKf53MxFssoEAdMJPDp7eu4Tq 94BX3xELSzt+9U0o4ZEHTYkzkCZbMCwHUE7TdPKOcQ== X-Google-Smtp-Source: AGRyM1tLpvyWd82tlSu90Ie0vUUnPmmjMdRdN7kOuJSQxjdEpGJ2aV8pRsQaQLXnt40GsSJHL2g5MiFaOEf1Eq0GxBs= X-Received: by 2002:a05:6512:3f14:b0:47d:e011:f19b with SMTP id y20-20020a0565123f1400b0047de011f19bmr15571994lfa.427.1657659139495; Tue, 12 Jul 2022 13:52:19 -0700 (PDT) MIME-Version: 1.0 References: <20220624173656.2033256-1-jthoughton@google.com> <20220624173656.2033256-7-jthoughton@google.com> In-Reply-To: From: James Houghton Date: Tue, 12 Jul 2022 13:52:08 -0700 Message-ID: Subject: Re: [RFC PATCH 06/26] mm: make free_p?d_range functions public To: Mike Kravetz Cc: Muchun Song , Peter Xu , David Hildenbrand , David Rientjes , Axel Rasmussen , Mina Almasry , Jue Wang , Manish Mishra , "Dr . David Alan Gilbert" , linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1657659141; a=rsa-sha256; cv=none; b=zhtadaFjPLdcfnC7w/r+1yzmAY8oWCGB/HEySUweeu5XlyONmv2VsU2HJ5Dd9SPaAroRYQ lb3zpkL6G2lzDsyJYUda2Xl06olYwjbbi+YoBtyENlDbgBBMnJJfrDPDIOnd4bbdDUPpYl UH6LU/l7mcIaJFkjxwisrTnbzn4ZuNo= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=TvNekszX; spf=pass (imf10.hostedemail.com: domain of jthoughton@google.com designates 209.85.167.50 as permitted sender) smtp.mailfrom=jthoughton@google.com; dmarc=pass (policy=reject) header.from=google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1657659141; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=iz3LrBt6Ku3myI5IwwlOusoVA0/X3ThdIo77BcqKEIY=; b=KO2b8fCWHCzguS4DgHAF1RTnImVBKVBn2kdEsjFN2w/4yldQTugQfZCXSc7GLsehKBAmuU swMDqiqND6b81+XqXFphabTaIXmoCHoynVacqikZEYEciMx6bUekAs272OlzDdCnSwILKz nUl5ZhCQjy5tYU6CySmUxnkq090EBrk= X-Rspamd-Queue-Id: 40DCAC0064 Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b=TvNekszX; spf=pass (imf10.hostedemail.com: domain of jthoughton@google.com designates 209.85.167.50 as permitted sender) smtp.mailfrom=jthoughton@google.com; dmarc=pass (policy=reject) header.from=google.com X-Rspamd-Server: rspam02 X-Rspam-User: X-Stat-Signature: y8c1wjracfc81cnuy1mcsnqanw7ghot1 X-HE-Tag: 1657659141-937856 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: On Tue, Jun 28, 2022 at 1:35 PM Mike Kravetz wrote: > > On 06/24/22 17:36, James Houghton wrote: > > This makes them usable for HugeTLB page table freeing operations. > > After HugeTLB high-granularity mapping, the page table for a HugeTLB VMA > > can get more complex, and these functions handle freeing page tables > > generally. > > > > Hmmmm? > > free_pgd_range is not generally called directly for hugetlb mappings. > There is a wrapper hugetlb_free_pgd_range which can have architecture > specific implementations. It makes me wonder if these lower level > routines can be directly used on hugetlb mappings. My 'guess' is that any > such details will be hidden in the callers. Suspect this will become clear > in later patches. Thanks for pointing out hugetlb_free_pgd_range. I think I'll need to change how freeing HugeTLB HGM PTEs is written, because as written, we don't do any architecture-specific things. I think I have a good idea for what I need to do, probably something like this: make `hugetlb_free_range` overridable, and then provide an implementation for it for all the architectures that HAVE_ARCH_HUGETLB_FREE_PGD_RANGE. Making the regular `free_p?d_range` functions public *does* help with implementing the regular/general `hugetlb_free_range` function though, so I think this commit is still useful. - James > -- > Mike Kravetz > > > Signed-off-by: James Houghton > > --- > > include/linux/mm.h | 7 +++++++ > > mm/memory.c | 8 ++++---- > > 2 files changed, 11 insertions(+), 4 deletions(-) > > > > diff --git a/include/linux/mm.h b/include/linux/mm.h > > index bc8f326be0ce..07f5da512147 100644 > > --- a/include/linux/mm.h > > +++ b/include/linux/mm.h > > @@ -1847,6 +1847,13 @@ void unmap_vmas(struct mmu_gather *tlb, struct vm_area_struct *start_vma, > > > > struct mmu_notifier_range; > > > > +void free_pte_range(struct mmu_gather *tlb, pmd_t *pmd, unsigned long addr); > > +void free_pmd_range(struct mmu_gather *tlb, pud_t *pud, unsigned long addr, > > + unsigned long end, unsigned long floor, unsigned long ceiling); > > +void free_pud_range(struct mmu_gather *tlb, p4d_t *p4d, unsigned long addr, > > + unsigned long end, unsigned long floor, unsigned long ceiling); > > +void free_p4d_range(struct mmu_gather *tlb, pgd_t *pgd, unsigned long addr, > > + unsigned long end, unsigned long floor, unsigned long ceiling); > > void free_pgd_range(struct mmu_gather *tlb, unsigned long addr, > > unsigned long end, unsigned long floor, unsigned long ceiling); > > int > > diff --git a/mm/memory.c b/mm/memory.c > > index 7a089145cad4..bb3b9b5b94fb 100644 > > --- a/mm/memory.c > > +++ b/mm/memory.c > > @@ -227,7 +227,7 @@ static void check_sync_rss_stat(struct task_struct *task) > > * Note: this doesn't free the actual pages themselves. That > > * has been handled earlier when unmapping all the memory regions. > > */ > > -static void free_pte_range(struct mmu_gather *tlb, pmd_t *pmd, > > +void free_pte_range(struct mmu_gather *tlb, pmd_t *pmd, > > unsigned long addr) > > { > > pgtable_t token = pmd_pgtable(*pmd); > > @@ -236,7 +236,7 @@ static void free_pte_range(struct mmu_gather *tlb, pmd_t *pmd, > > mm_dec_nr_ptes(tlb->mm); > > } > > > > -static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud, > > +inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud, > > unsigned long addr, unsigned long end, > > unsigned long floor, unsigned long ceiling) > > { > > @@ -270,7 +270,7 @@ static inline void free_pmd_range(struct mmu_gather *tlb, pud_t *pud, > > mm_dec_nr_pmds(tlb->mm); > > } > > > > -static inline void free_pud_range(struct mmu_gather *tlb, p4d_t *p4d, > > +inline void free_pud_range(struct mmu_gather *tlb, p4d_t *p4d, > > unsigned long addr, unsigned long end, > > unsigned long floor, unsigned long ceiling) > > { > > @@ -304,7 +304,7 @@ static inline void free_pud_range(struct mmu_gather *tlb, p4d_t *p4d, > > mm_dec_nr_puds(tlb->mm); > > } > > > > -static inline void free_p4d_range(struct mmu_gather *tlb, pgd_t *pgd, > > +inline void free_p4d_range(struct mmu_gather *tlb, pgd_t *pgd, > > unsigned long addr, unsigned long end, > > unsigned long floor, unsigned long ceiling) > > { > > -- > > 2.37.0.rc0.161.g10f37bed90-goog > >