From patchwork Fri Jun 24 17:36:36 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Houghton X-Patchwork-Id: 12894930 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 3FF02CCA473 for ; Fri, 24 Jun 2022 17:37:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5DB758E0243; Fri, 24 Jun 2022 13:37:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4ED2E8E020E; Fri, 24 Jun 2022 13:37:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2CAA28E0243; Fri, 24 Jun 2022 13:37:19 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 104768E020E for ; Fri, 24 Jun 2022 13:37:19 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E1E2660A1A for ; Fri, 24 Jun 2022 17:37:18 +0000 (UTC) X-FDA: 79613835756.18.93FAE17 Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by imf23.hostedemail.com (Postfix) with ESMTP id 90593140002 for ; Fri, 24 Jun 2022 17:37:18 +0000 (UTC) Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-317765eb7ccso26892217b3.13 for ; Fri, 24 Jun 2022 10:37:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=/rA4FWSpYAR9L2sjJS2B0eCc4aGZeNFQ2hS7zEPXx88=; b=mjmAAKf/rdfFJdvjC9OXk41WB0xb48wdXBGxSuL0EQl9SkDoXcqxrY9GXlvPWLaEkg 8Hx1fw01wcTtT9K/GLcq3rroLEsW0zKCq/TUIz18NlMwdRcR1pA7Iaz2vn8ZlKAXcim1 wOaCTh2gfUTYSHpFrxRcxF2GTYKnhiAIuJO4LJxX4Vd8vg8DEaO1anDPe1vI6jmOnZyo xym6RDo4VAwtwvCcWa490l4s9zNK4x/xstjaksrlIYlIG61i/GAqmjnAH04jRi+sdL4m P8snVFmVGcbUsQWry1OYKwwBVkaqJWg10bFh2y6ecVXque/dyOxRMd1yJMz25o75f8Kd 6OwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=/rA4FWSpYAR9L2sjJS2B0eCc4aGZeNFQ2hS7zEPXx88=; b=jL96engpouxkPJpTM0jn2QhwaZqrL5LRjhOC3ENmO3mChfIpn6bvh+4PDQ4tQaRjPT qHJbnwFt0XVm3vLXwaOWl1snrgYzAdHat3NfvbYy3Dz8+M53hOWW+59KQvajRgCuEt37 PkWbCNRpIXlLZOaN4r9DecruL7ig4LKCdUVhdSQY3EYFxOJfdBXaepPv0kcuUoO0SpyK ksU017xKyPd27Yl/asVNzi/da0JTQsYnWDrf+tWvZqconva61R4JpGEV3BiXmSdzrq87 OvTGbdmHYX2qDBY71/Nsm1EyEW6FBBW8xH4NyBrnSJ5b1p8xDgBSsTUmFBB6fui2P/T4 H/UA== X-Gm-Message-State: AJIora8C9AqSjdrXCUvc44NmFc6Yf+Y1eloUyOKRCvjGCpyruosPq5qT vpKvZnANvw81sfMY7CfCCczjVCiPquhJvxL3 X-Google-Smtp-Source: AGRyM1t9tv0yjearXIr71+3GNqpFRDSr2edCHZwVgwQ6f0v6TT0Pfet2HMTd37UlieYMZq6c6zvogGIBBnnftS40 X-Received: from jthoughton.c.googlers.com ([fda3:e722:ac3:cc00:14:4d90:c0a8:2a4f]) (user=jthoughton job=sendgmr) by 2002:a25:b806:0:b0:663:d35d:8b8a with SMTP id v6-20020a25b806000000b00663d35d8b8amr282022ybj.69.1656092237926; Fri, 24 Jun 2022 10:37:17 -0700 (PDT) Date: Fri, 24 Jun 2022 17:36:36 +0000 In-Reply-To: <20220624173656.2033256-1-jthoughton@google.com> Message-Id: <20220624173656.2033256-7-jthoughton@google.com> Mime-Version: 1.0 References: <20220624173656.2033256-1-jthoughton@google.com> X-Mailer: git-send-email 2.37.0.rc0.161.g10f37bed90-goog Subject: [RFC PATCH 06/26] mm: make free_p?d_range functions public From: James Houghton To: Mike Kravetz , Muchun Song , Peter Xu Cc: 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, James Houghton ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1656092238; 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=/rA4FWSpYAR9L2sjJS2B0eCc4aGZeNFQ2hS7zEPXx88=; b=4yXBwtw5O9tK/D76DZr9cnxKy4BtbfmQ3G7CGk7rtuQagI7nXQ5kChF6RIN3GWYEK8cfLQ vb68M0mBLd6u2MSbYDgrZ0XLo9hzxrlDVnF4I+5Sw1EqgGw1lj2gEIYdiRNfUGESWSGf/I 1HI7CfBHatd5JSZ+H7u1Y4COhjxus84= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="mjmAAKf/"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of 3Tfa1YgoKCC4TdRYeQRdYXQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--jthoughton.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3Tfa1YgoKCC4TdRYeQRdYXQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--jthoughton.bounces.google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1656092238; a=rsa-sha256; cv=none; b=qnGes6+cDZCFEqTj3uUXVqe72tvRV0S9ipasCCpEg7Ff+GoS9jDVsN+UPyTk2gDbY0NZXY URZFi7XGe+DD6mVX/obhTny5YBHIJSmP9OWf3egqzoMUOcfADVf7C6l2EFcjDz2Qu31jxu 9uvtrcKspKZVQYk52jz0+KrAPfSp4J4= X-Rspamd-Queue-Id: 90593140002 Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=google.com header.s=20210112 header.b="mjmAAKf/"; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf23.hostedemail.com: domain of 3Tfa1YgoKCC4TdRYeQRdYXQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--jthoughton.bounces.google.com designates 209.85.128.202 as permitted sender) smtp.mailfrom=3Tfa1YgoKCC4TdRYeQRdYXQYYQVO.MYWVSXeh-WWUfKMU.YbQ@flex--jthoughton.bounces.google.com X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: kgrdjf6go8gr3cjaccxthr1hsbp1a3xg X-HE-Tag: 1656092238-259331 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: 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. Signed-off-by: James Houghton reviewed-by: manish.mishra@nutanix.com --- 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) {