From patchwork Mon Aug 7 23:05:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13345310 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 7A927C04FDF for ; Mon, 7 Aug 2023 23:06:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 200E794001F; Mon, 7 Aug 2023 19:06:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 113A6940008; Mon, 7 Aug 2023 19:06:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id ECCDD94001F; Mon, 7 Aug 2023 19:06:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id CEB48940008 for ; Mon, 7 Aug 2023 19:06:14 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id A55FF8025D for ; Mon, 7 Aug 2023 23:06:14 +0000 (UTC) X-FDA: 81098843868.19.AA01B7A Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) by imf09.hostedemail.com (Postfix) with ESMTP id C1CAD140010 for ; Mon, 7 Aug 2023 23:06:12 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=nS5J1UYk; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691449572; a=rsa-sha256; cv=none; b=5tfE/ryK35dBzkW7a2tyYZS+fVJGFJDAPPZ6wAgdh1aSHU1wnXudxR2BiCds6x8v0Hg6nz 0wj123VwA37+mtdV1lwVmD9SRqdZOemTAP0mYHa/aL57/DOY7DBHjKInjjMN7smnYDJvYe /xc0Kmx1WGDSKPd8VQg1JK2AAdlWr5w= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=nS5J1UYk; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1691449572; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=NpbBCMkwg1WbsmcEnKHREFultw/IY4tG3Jsqz6w0a8E=; b=j80LKnGlpqzdQ4pdQ+jIjvlLRNaA5Dj/p2pozuCgvwaaxWeIK20tOPI1gimaiTNy1DPwWq 7sDm8TV7ub9S/FiULzQYmX6RZq6VmAyfHtCFBdaHz9LkQSl/p1h22a9A/ZKpS9cF2Vv4/1 jemQ/6i1tgt7pKXc/o+wLErkM+Y4HfY= Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-d35a9d7a5bdso5116873276.0 for ; Mon, 07 Aug 2023 16:06:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691449572; x=1692054372; 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=NpbBCMkwg1WbsmcEnKHREFultw/IY4tG3Jsqz6w0a8E=; b=nS5J1UYk8f9msjmOJfcwkB8RnOSNZv60DefW2TDIHuOlvS9npGk8oT2LZd+SySl8sv g+gjV1veIOE2SNGvcFOMJ1pPimwLTZ7+pvFQ4bVBKr+eOsPpBFIPNto8klZeZdDlbFxo wkyNcA7u+kweH04q+BG4NvsUNaK7E9zibuZ01wwXmu5qj90Fw+mY1pf3xcSZWMeZa7wK aGRqh9CjWX7iCRUWp+ZrbhBol1e4MCC8JBlzqolLSWyg74wpF8elWEgkI2Vj4oenaGhD isx7MJZrX54CbrhbHsj99pEt0PqmBmGh9HnsD2DaWM5Gm6veS11IW5m9dzOKe44sU/M/ md6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691449572; x=1692054372; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=NpbBCMkwg1WbsmcEnKHREFultw/IY4tG3Jsqz6w0a8E=; b=hFBd+bBrtvofoWJEGyEsmFO4pbCGEnd1yuT19/3iD6tIFCm5h2Ipj94qMdcf28o7uu BerDm0iEpJvC747NwaLVhq35+DWgpNXC89hqaNQPmv2zXYHyc1x6r7rPkcJt3Tj3S7Yg eEc2xk6Q3Uel4LW2xiw9y3vEwKgQqpHaf5mnQ+bxa/LCU0CeedZhyFgP9z7uczPNym8J Mfpk5S00H1p5vM0bx7sJzw2iS3WwMN5v5Ym/hC0ef+7ne9BMi0oyQxuB7u5ez6pzCNbx mXapt93ldKpNWLAtsaCLjYPCmYpWk3qmeA66CPNultvjGQpjavdu+l8cWYV9MbOY5b/i AxKw== X-Gm-Message-State: AOJu0YzG4qOwSLk7JELFW9RV93iPYlCJJBE2hkepgUvCX12PS6TdVGRS t4T16Pi1zM1a1JRpUBHL4tKgHzx+je5dKQ== X-Google-Smtp-Source: AGHT+IHFLqgFAthROKM1yjg8aTn4QAXhjx425iARLy/TVdE1z6PZIG9RjSxWoTmqjhSqLQZr0gTMYg== X-Received: by 2002:a25:d24d:0:b0:d0a:127e:7478 with SMTP id j74-20020a25d24d000000b00d0a127e7478mr9478817ybg.44.1691449571835; Mon, 07 Aug 2023 16:06:11 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::16]) by smtp.googlemail.com with ESMTPSA id d190-20020a25cdc7000000b00d3596aca5bcsm2545203ybf.34.2023.08.07.16.06.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 16:06:11 -0700 (PDT) From: "Vishal Moola (Oracle)" To: Andrew Morton , Matthew Wilcox Cc: linux-mm@kvack.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-csky@vger.kernel.org, linux-hexagon@vger.kernel.org, loongarch@lists.linux.dev, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-openrisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-um@lists.infradead.org, xen-devel@lists.xenproject.org, kvm@vger.kernel.org, Hugh Dickins , "Vishal Moola (Oracle)" , Paul Walmsley , Palmer Dabbelt , Mike Rapoport Subject: [PATCH mm-unstable v9 26/31] riscv: Convert alloc_{pmd, pte}_late() to use ptdescs Date: Mon, 7 Aug 2023 16:05:08 -0700 Message-Id: <20230807230513.102486-27-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230807230513.102486-1-vishal.moola@gmail.com> References: <20230807230513.102486-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: C1CAD140010 X-Stat-Signature: oi54m5wc44eaz7x93r5s6bf4wjzbtzuw X-Rspam-User: X-HE-Tag: 1691449572-746346 X-HE-Meta: U2FsdGVkX18GepwLeaIFSpRMAUTBCI3eNuwi11RavyPbFT1nzv5J3PY0izHTxeevgW2xteOJ6oa06jiQZCTGnG4qJwwIUriD0DUH7po626J89W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DhowsIYJEUAgHMlMinEXhQ/ntIJhu7asziTj0lOjQz10ZnH07fq0D5IjZjSbW7bzRjQGNF7V5KLFTgl77XvCEuL3NKLIglRjuou+e+URZtn1QJNi4EFhxQptHcp+S9S1ep3U5AMApSED0k0foFa2fSUHvUFyr3L+nCGOCP3WVl8HpbOqLD71Q11slejczWX8+5uaPu01Sifazo1YqKh5SxZ2xhXZQTiIVsnRohUWLpFuaFCUQ8YfwWOTOKIcuPN5CcMCA5AcY8ikSM6iprf39mbTSyV803fkUsAyLrWd4GqRNh1uj14K56+4i4giF5e/XTcq7084k84aCMBBwa+aKg7U3bAiczP9M4gd0Kpvpy9cGD54TCQ8X/4Xmvaemmktjjavtzj4xZ4iLKF/9LkACldZyGnhpjQSyRR/md1/QFfTeg8rEH8sunooge/k42piC1Ay2OaJZkmcxnSIaE6XAwKbQyVBdaCI0HCu6fYda 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: As part of the conversions to replace pgtable constructor/destructors with ptdesc equivalents, convert various page table functions to use ptdescs. Some of the functions use the *get*page*() helper functions. Convert these to use pagetable_alloc() and ptdesc_address() instead to help standardize page tables further. Acked-by: Palmer Dabbelt Acked-by: Mike Rapoport (IBM) Signed-off-by: Vishal Moola (Oracle) --- arch/riscv/include/asm/pgalloc.h | 8 ++++---- arch/riscv/mm/init.c | 16 ++++++---------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/arch/riscv/include/asm/pgalloc.h b/arch/riscv/include/asm/pgalloc.h index 59dc12b5b7e8..d169a4f41a2e 100644 --- a/arch/riscv/include/asm/pgalloc.h +++ b/arch/riscv/include/asm/pgalloc.h @@ -153,10 +153,10 @@ static inline pgd_t *pgd_alloc(struct mm_struct *mm) #endif /* __PAGETABLE_PMD_FOLDED */ -#define __pte_free_tlb(tlb, pte, buf) \ -do { \ - pgtable_pte_page_dtor(pte); \ - tlb_remove_page((tlb), pte); \ +#define __pte_free_tlb(tlb, pte, buf) \ +do { \ + pagetable_pte_dtor(page_ptdesc(pte)); \ + tlb_remove_page_ptdesc((tlb), page_ptdesc(pte));\ } while (0) #endif /* CONFIG_MMU */ diff --git a/arch/riscv/mm/init.c b/arch/riscv/mm/init.c index 9ce504737d18..430a3d05a841 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -353,12 +353,10 @@ static inline phys_addr_t __init alloc_pte_fixmap(uintptr_t va) static phys_addr_t __init alloc_pte_late(uintptr_t va) { - unsigned long vaddr; - - vaddr = __get_free_page(GFP_KERNEL); - BUG_ON(!vaddr || !pgtable_pte_page_ctor(virt_to_page((void *)vaddr))); + struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL & ~__GFP_HIGHMEM, 0); - return __pa(vaddr); + BUG_ON(!ptdesc || !pagetable_pte_ctor(ptdesc)); + return __pa((pte_t *)ptdesc_address(ptdesc)); } static void __init create_pte_mapping(pte_t *ptep, @@ -436,12 +434,10 @@ static phys_addr_t __init alloc_pmd_fixmap(uintptr_t va) static phys_addr_t __init alloc_pmd_late(uintptr_t va) { - unsigned long vaddr; - - vaddr = __get_free_page(GFP_KERNEL); - BUG_ON(!vaddr || !pgtable_pmd_page_ctor(virt_to_page((void *)vaddr))); + struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL & ~__GFP_HIGHMEM, 0); - return __pa(vaddr); + BUG_ON(!ptdesc || !pagetable_pmd_ctor(ptdesc)); + return __pa((pmd_t *)ptdesc_address(ptdesc)); } static void __init create_pmd_mapping(pmd_t *pmdp,