From patchwork Mon Apr 17 20:50:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13214587 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 13777C88C95 for ; Mon, 17 Apr 2023 20:53:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B795C28000A; Mon, 17 Apr 2023 16:53:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B0389280005; Mon, 17 Apr 2023 16:53:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E09A28000A; Mon, 17 Apr 2023 16:53:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 72FD8280005 for ; Mon, 17 Apr 2023 16:53:27 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 46D801C659A for ; Mon, 17 Apr 2023 20:53:27 +0000 (UTC) X-FDA: 80692083654.15.7046F0E Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) by imf17.hostedemail.com (Postfix) with ESMTP id 5EB744000E for ; Mon, 17 Apr 2023 20:53:25 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=CQxyKkc2; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.181 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=1681764805; 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=uzUB7crKqn7Of69Iz0IiuKaVcaC8bpzNVtqjj02cJJs=; b=xEGrHsDJXEYZn5JgCIfAqaXQpW2ugVDYnba+SF4kTuWqj3CTBAGJVJGj/KDFZR72p9ZAL5 xjvPMbOtzS1s+sASzaZhC9coxTDaYup2MIraVrsoHTSCd2wN+97fJnRgJ5XIIbK2bxa3ug VHih6jcFUTtHkuIm31MATav2EwPcsNs= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=CQxyKkc2; spf=pass (imf17.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.181 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=1681764805; a=rsa-sha256; cv=none; b=Dr+/9k2w2ei/MbfL6sJGcGu2BZ+Mb2JUqYldfWdG7D5zR1gHxJj2Y5seldNFApYdkQXZ1a NQrZcDttv213AowKrAcAWbij/rkvXUaTPJVxbdenIqYiU22/BTLSWtAAGgq11lw5HDi/JM voTURwk+DIdXSpzRItqefagAs1lCCwk= Received: by mail-pl1-f181.google.com with SMTP id p8so27389183plk.9 for ; Mon, 17 Apr 2023 13:53:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681764804; x=1684356804; 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=uzUB7crKqn7Of69Iz0IiuKaVcaC8bpzNVtqjj02cJJs=; b=CQxyKkc21JMWEGZgaxo+DzkT7hmUe/EPeRLNy9307TK3NRBVO8qYFVHUBh0a+wrrFK REDRofZ4pQ77HB/xKTTnWP/BT1cyKC/pHZN9NhEm5iKL1tflp83IUSNn/z3JIjWng98Y 6RfpzxV5XfPWxGKOX4DdYV/wLmmlXNt332CwEYLgb9fOwCusASfTkzDGq48OmDuUGGpq tIsA4gMM5D4jkK0NC3tYS5RarJ0ZWQtkI1tM39+DRuLci+gK44bt1F+fDRaPwS3T5T9g S4uLRylS37AnplaeXGFnk7T6Qzad8RMawrqwBO6UKOhHtptnemCZZZWNN4xJh7uqqhEQ vrGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681764804; x=1684356804; 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=uzUB7crKqn7Of69Iz0IiuKaVcaC8bpzNVtqjj02cJJs=; b=HY+AdXPibTvqJigH0/utnhrTGfc4NglwTb5Z1DhyPmn4tGFDgeQ3O5m7GgeDbNwFqh 7AES1ViObBh3HGr/wi6AQmDmBrT53c7//N0EGq0beyMIw7iZWigFAHs4jAtpcxgdE8s2 icXM0OqPwHCq2Lj7igFOFE7L146hmEyMotvENBR4vFOpLFSy0Kmcjh6iGo2t2kI0H7Rr fRrxap2RxfBw/72O94XwzQ8ubpOwh8S1xIcE+oKeteiMzzUuEfyrVxxZIJpfeX6CA6QY a4bCbwmnfmKtP2hsdLI1yuzC2kIjd86zsGujonf/LJLvqZox1bP5o9Rk3Dazhr4ECdoG uz9A== X-Gm-Message-State: AAQBX9dSYf1J4JE96kfnxwfIm8PP0qGE8CuHA5OP+jctH5pzurpwbRcf GCX9jFIR4yRqpfHh6XRa+Btt0m42wXOabw== X-Google-Smtp-Source: AKy350avL9PdXaEjhmJuV1ybk5n54BLKq2822oDesoZKEo2GpNTKDMiGoy71eNPEPZjYfA/nM1qr3w== X-Received: by 2002:a17:90a:1286:b0:246:bb61:4a5b with SMTP id g6-20020a17090a128600b00246bb614a5bmr16053424pja.8.1681764804243; Mon, 17 Apr 2023 13:53:24 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::c139]) by smtp.googlemail.com with ESMTPSA id h7-20020a17090ac38700b0022335f1dae2sm7609707pjt.22.2023.04.17.13.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:53:23 -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, "Vishal Moola (Oracle)" Subject: [PATCH 28/33] riscv: Convert alloc_{pmd, pte}_late() to use ptdescs Date: Mon, 17 Apr 2023 13:50:43 -0700 Message-Id: <20230417205048.15870-29-vishal.moola@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417205048.15870-1-vishal.moola@gmail.com> References: <20230417205048.15870-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5EB744000E X-Stat-Signature: 4ftuqkf31hxepntts68fearqr8oqj59b X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1681764805-144710 X-HE-Meta: U2FsdGVkX18kroIy2aKfKwbSe24xWXm4/nmr3QltOHGRVWPCpU9T/Hl46vFvLHPrVqXKGjrs9kYuvvYaxOU9DtkIF94lV5aenePZ66kqRWpMQ0A+o3cWMtQngvowa35w5yd9IQyhkbhm6Dmzm/P3b2Wm4pZgJIPN/vuTaT3M7+MvwULjOKNSpHNNpOMwEZnO3ZmpeofrWwdtrQ3r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uENcrIy9Tu+K7HiTfONvEnuynxfjF4H3sRUcc6xHrNfHuUoNY04Vw5DH7QR6d8iEM1aLHg/QcW3D885b0PtLHVrubwXlljxZ5TEEV1eK2NzryZ1rvm1Obj6B6v979Fsd9kAIuKnxWikdkI6rSMahDBaX2WsyqcxCzot/YTIQPt6lEVGSe+7V/AbZoB1ohjjgGwnACxa0K+2O0coLhoWtN4RrTcJ7XFb+HcafpUR3wB8X55Ccy7lpbRWc0hpkd+LS04PNqxq2/US68Hxh4VW1QUO1jctb3uOZMkLmT9uudHg== 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 ptdesc_alloc() and ptdesc_address() instead to help standardize page tables further. 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..cb5536403bd8 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 { \ + ptdesc_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 0f14f4a8d179..2737cbc4ad12 100644 --- a/arch/riscv/mm/init.c +++ b/arch/riscv/mm/init.c @@ -346,12 +346,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(vaddr))); + struct ptdesc *ptdesc = ptdesc_alloc(GFP_KERNEL, 0); - return __pa(vaddr); + BUG_ON(!ptdesc || !ptdesc_pte_ctor(ptdesc)); + return __pa((pte_t *)ptdesc_address(ptdesc)); } static void __init create_pte_mapping(pte_t *ptep, @@ -429,12 +427,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(vaddr))); + struct ptdesc *ptdesc = ptdesc_alloc(GFP_KERNEL, 0); - return __pa(vaddr); + BUG_ON(!ptdesc || !ptdesc_pmd_ctor(ptdesc)); + return __pa((pmd_t *)ptdesc_address(ptdesc)); } static void __init create_pmd_mapping(pmd_t *pmdp,