From patchwork Mon May 1 19:28:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13228030 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 0A300C7EE33 for ; Mon, 1 May 2023 19:29:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3222828001B; Mon, 1 May 2023 15:29:20 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2D2B3280002; Mon, 1 May 2023 15:29:20 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1728328001B; Mon, 1 May 2023 15:29:20 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 0791A280002 for ; Mon, 1 May 2023 15:29:20 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id D415C1A0818 for ; Mon, 1 May 2023 19:29:19 +0000 (UTC) X-FDA: 80742674838.25.F69AA3B Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by imf03.hostedemail.com (Postfix) with ESMTP id 1F54F20015 for ; Mon, 1 May 2023 19:29:17 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=QOhINfLs; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.172 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=1682969358; 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=l1ckLKbyzk3TycCfORfJ/TBkh9kewWK+wgbsmWovkLc=; b=CJdGMXSq03r8qzLYnCXRljVqzWmBdyKzDpMClpSYneWHK1ehnTaUGstZBhaSSPbCU/scUj bYR8tKgK7wt2dxF9HbL2D2pQs0ntrIE8ftZx/4QtPrWT610KVB1UusQRrUrKlfm5F/ysbM 4sRxCbFZmNqNQFy6wON0ks6ta2h61L0= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=QOhINfLs; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.172 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=1682969358; a=rsa-sha256; cv=none; b=ij0wyIgz2D4AhiUMEmFxunPGkf1h5lt5wfrKtwx/6IGBHo2YAOccK+iR+xEPGZocvOCPnX E3jzsTq7WD3wjaxxD1wP/c1p+GVbTRhGl9QXOH8DyKR0Y5rCsJc4ABv4Zv0wvdv8Mab2sj NxYSXf2ArdcFCgYLCbsvmtZ/x+rpAIc= Received: by mail-pl1-f172.google.com with SMTP id d9443c01a7336-1aafa41116fso8346175ad.1 for ; Mon, 01 May 2023 12:29:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682969357; x=1685561357; 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=l1ckLKbyzk3TycCfORfJ/TBkh9kewWK+wgbsmWovkLc=; b=QOhINfLsJScPCSo/IfeyIyqWMqeIs48D8yaoqlS6ttjMbmNZXsD0pl2iRSwsAXqRrv zUUJOXK9c/ejP/aK8PhIumKGyTM6wx4FMhZyB9B20DcTQunSql+VvjSwHErAI8TxAw4R Y99zvhqhTYwxHGbhjSdsPxRy9B+yD0izY9vTuFFo+4wz8Jz2C37zAT+8c8EYp2fDz24U oGrB6CUieeF0SbwTG14XhJhloKyt3nzbHvCyZJJU6u4aL5aKMUavEI+jK4qMtp6ZB84A TmLf+lTqOkVGEF+wZ1coiBesyT5OIE5Gk6hWNsWKJwTKVv0S28KrIjiosst3fU+17ZhU 2bkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682969357; x=1685561357; 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=l1ckLKbyzk3TycCfORfJ/TBkh9kewWK+wgbsmWovkLc=; b=P11aIZrZBE9tI9nTbVu4u1R7TSmS5gMYlDtXZTDI8aYZ76G10ZKcCZT/H9GokCd8t8 x8QDKJE1Fl9kSgn9y14qJ9/+ZpcFg4Bk6x9lE8dgxZiOIl40+Es+CiZxXcTRf/Ai0mV5 udgO+1fNwo6qGkN1393VInnzOdWU53NDETnvWGifB0Oclb9TQc00gGoQgLX7tQN0UBoK TnvzHaGyPq8V+ZPjCjJEb8k23JbgOqLqH9N5IYTdMvX89ZLqkSrGDP8LtP4Bq45ucZbW AXjJGjjpjkrdOCkySKxLaqBWEnKbYQH4eFbP82GcsUatDNWkE6wKzBuWv1LH38wUyQie Ha2A== X-Gm-Message-State: AC+VfDxv8rVuXLORaK0Byh5d3hQ6qKwvNaUxZbTd2Cl5K/PqkWtbM281 SyBZn8EZKRTfGPGsvBjzKRE= X-Google-Smtp-Source: ACHHUZ5ad9gvhcfa1XbL+pCFsXQ41wyEuU00A0VqKiT0180mGKgTi8tTwjBbR7r20yn6kHE8l0iQaQ== X-Received: by 2002:a17:902:ce91:b0:1aa:ef83:34be with SMTP id f17-20020a170902ce9100b001aaef8334bemr6350222plg.47.1682969356855; Mon, 01 May 2023 12:29:16 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::9a2c]) by smtp.googlemail.com with ESMTPSA id u8-20020a170902bf4800b0019c13d032d8sm18175622pls.253.2023.05.01.12.29.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 12:29:16 -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)" , Paul Walmsley Subject: [PATCH v2 29/34] riscv: Convert alloc_{pmd, pte}_late() to use ptdescs Date: Mon, 1 May 2023 12:28:24 -0700 Message-Id: <20230501192829.17086-30-vishal.moola@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501192829.17086-1-vishal.moola@gmail.com> References: <20230501192829.17086-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 1F54F20015 X-Stat-Signature: rfnkgkayakuztqffo6whoe4w4gmsqgxp X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1682969357-232988 X-HE-Meta: U2FsdGVkX1+D01zm05/PuIS09kLxq6uTrPnbP+dLfHCcA1asIVw7ag4iY+yofjCziA1F01xyKrLwEx3fXYAZmCfFTTr8n9EeSmH92kYfKJC2uEFzvf9v+f1XSalgJs5HDf1rDSYG8e8C8AiTgwsM/yAxW3YQg3LzzgmGUMoZs2ymnlEogv4jXdnzZOt+t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QQLanD1nQXHRCVjfHin/UDnb7PQ5Hf5ZZHbmf5Tl/PSP7VqRXRR41Hop6YI6hqcyr7ezzSb/qzskiWSgyHcdRXM+zEHWCJIH24aFmkYC7e8x8A8FZka2mWKiDrCIciecTu0Uf1B4XOiZEBiFFgthpRiQIRSLm/MULTPgERVaXRg1GFzfClsZP2EWyLlI9BwJ0rvWUb1HdilcsjnKLqIcWQMv+3Yk5426CZ7gP6ghsCc5KlV1Sp8scQ8ir3hUFKpLZDcO40bypGlxdkLGqCJMoprRYeht1Sog6kxHFMxwPhHIV8yrcFX0Ec= 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) Acked-by: Palmer Dabbelt --- 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 eb8173a91ce3..8f1982664687 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(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, @@ -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(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,