From patchwork Mon Jul 31 17:03: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: 13335124 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 ED1E3C001DC for ; Mon, 31 Jul 2023 17:04:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C6F8D280075; Mon, 31 Jul 2023 13:04:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BF8E66B0185; Mon, 31 Jul 2023 13:04:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A98E66B0186; Mon, 31 Jul 2023 13:04:27 -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 9A4B36B0184 for ; Mon, 31 Jul 2023 13:04:27 -0400 (EDT) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 74E66140B41 for ; Mon, 31 Jul 2023 17:04:27 +0000 (UTC) X-FDA: 81072530574.16.69714EE Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) by imf29.hostedemail.com (Postfix) with ESMTP id 780BA120035 for ; Mon, 31 Jul 2023 17:04:25 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=UQMFQ0r4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.166.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690823065; a=rsa-sha256; cv=none; b=GWhaWooQZx5MQ1oI9M0m+l5tTLZ9h2JkVh5Bo9mIipVgc6ip23xV8MNMgjFJUGRosvMG1t 8ApzjAamIrOWgPJP2dYVXg9WPxUDLhAExBw+diZVtji5fLerRfqq2gVVWh7LK0C3j+NZRZ pT5pv3tARgEZmqyf6cL3DpIExHi/4jk= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=UQMFQ0r4; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf29.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.166.179 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690823065; 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=Z2eVDlXL8alglJUGVXcc8JA7ix0brgT+4DYqdXjkOuM=; b=fZVIo706hHxiG7x0dGuGAhme+0+6kQ3ex+yZY/kVVILDxeig/UBSkQtgcdxO+C2DK8cHuq pWH/pivxwJC4qJ4yyDKBY/QanQwYGUR/WrkMMrIZJJnE+r0HGK+F0FGWinx3shFINepN/g t7UyKnws0MOctgX2o1uCeZ/I7LsnNi4= Received: by mail-il1-f179.google.com with SMTP id e9e14a558f8ab-3491516c4aeso4951565ab.1 for ; Mon, 31 Jul 2023 10:04:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690823064; x=1691427864; 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=Z2eVDlXL8alglJUGVXcc8JA7ix0brgT+4DYqdXjkOuM=; b=UQMFQ0r4Q5WPDgBqHxt98e/7rMdzo/EpmwOe+r7kVkn3hiopHSDbWlcbl5oUHK5iIf MEr4ea890R+sJP/eAUogbkn4iWG+9UMyn5afkOFV0PrV0pq/LpKVZxDpJGv509y94xGw hLI4HOjNYVUd1nDexzxomwE2YqUnNF1NoyuArVYtjoOeqdYPeQHR5JxR2RSbP4U9P+Tn EAeRXMlzA2BnCRlADTS23mT/QfJ1wsL2dS3bX8pvVfdD0qkUAvCOMkcifg576YKQRwd3 ZfJGkC7UmIJC4v8PHFpL2Jz1mt7kK3WgxCHNDNZXpdMKgiKnSf1XJCiXOu4fHHWiZceQ 1gJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690823064; x=1691427864; 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=Z2eVDlXL8alglJUGVXcc8JA7ix0brgT+4DYqdXjkOuM=; b=XC3VzVBJOH9u8jhWgR62oJyynyYX2c09aMaZ/gauQmaDf0V8yckfaGIA/rR4KHocmp ECEyCyWCCn6ZsoT5n7nGgT1gMUujV18qY7rlGvIDazTJiiDuXYAqHh5GLGXyCI6CCHex PY4ettckzcBUsgsjXChueFMSlDlSt75OqNo9AcLg9c4cC4Frj0Mxw8GJvkVdEFrkDg/U fwhQs1XNRnTDK2okIc17LV2yMQ9xi4rxSW7EygCKP/v3IrF4t3RYEiapcIcv69KWtEvN RgMDWTZju/H0Syxp0uVWSPVKxx2VQvEhnoE3GDC+4UbTjk5vkndLI7lJ7uzMO76lCgGl +faw== X-Gm-Message-State: ABy/qLauOF7gv32f3h3PvRn+jqyGn4bpXoRYhO0yNtOxGYJmgIjMY9Y0 1i607meyc/vv4eVSgZ45B4o= X-Google-Smtp-Source: APBJJlEWWd7SGavQpR/ZisDPXe2n2lSwd0LXy0L6znKYOT3kkqP+7NMXZkXm3S5oeNu3Zj7rrKqKrw== X-Received: by 2002:a05:6e02:170d:b0:346:24c2:4f87 with SMTP id u13-20020a056e02170d00b0034624c24f87mr10569413ill.32.1690823064428; Mon, 31 Jul 2023 10:04:24 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::16]) by smtp.googlemail.com with ESMTPSA id x31-20020a25ac9f000000b00c832ad2e2eesm2511833ybi.60.2023.07.31.10.04.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 10:04:24 -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)" , Thomas Bogendoerfer , Mike Rapoport Subject: [PATCH mm-unstable v8 23/31] mips: Convert various functions to use ptdescs Date: Mon, 31 Jul 2023 10:03:24 -0700 Message-Id: <20230731170332.69404-24-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230731170332.69404-1-vishal.moola@gmail.com> References: <20230731170332.69404-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 780BA120035 X-Stat-Signature: of5r4i7h1yuzoxxx3d6nfj55xkjc4quw X-HE-Tag: 1690823065-455219 X-HE-Meta: U2FsdGVkX18TD+sas5tN9BH252LDIoFhqhkTHEyFyVy2Enx0qt+RRG3x164XreQnkfIkFh1VUB6ILnYXt57fb+3ZfqxAdy/Z+piLxQmq3RmwEi+YiHpPxrzt0xh4hZjaQZ4e1xibTY/07UXbmksJ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YKYhn3HkiWFau1V2GlbyjwmMEuQd8oPm6PQjZy3ecc4bhjP+DEMKZhF8IfgeiNct0JNottpg1YwUddHmPLuChEkJVj+yn3hit+0l1r6k4mpLap4z+EL6cH45g2wK0EHXh9PqkRhBKCSjXsC3jjVcT0V5gqSxTNxxCxqzyNmJn7EIox/WGwLYxAqrrrft0Ye9FBH+6qBHUK7I0plDD+1z1+4oX+Uex9sLEfAYt3mPMuUQL42DkZVfZ/AW6ydRuANsqh5iQ5xJGhBJvBl1xt9f0qMe8/YOHxBvMpEftHcdo4xkCre8pYzHfKA3Xnp2oc+2gmvIQKRlZ/YyJ3mafpHkamWeuIriP22K98d1BDrL5LhXkxoaqQ== 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. Signed-off-by: Vishal Moola (Oracle) Acked-by: Mike Rapoport (IBM) --- arch/mips/include/asm/pgalloc.h | 32 ++++++++++++++++++-------------- arch/mips/mm/pgtable.c | 8 +++++--- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h index f72e737dda21..40e40a7eb94a 100644 --- a/arch/mips/include/asm/pgalloc.h +++ b/arch/mips/include/asm/pgalloc.h @@ -51,13 +51,13 @@ extern pgd_t *pgd_alloc(struct mm_struct *mm); static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) { - free_pages((unsigned long)pgd, PGD_TABLE_ORDER); + pagetable_free(virt_to_ptdesc(pgd)); } -#define __pte_free_tlb(tlb,pte,address) \ -do { \ - pgtable_pte_page_dtor(pte); \ - tlb_remove_page((tlb), pte); \ +#define __pte_free_tlb(tlb, pte, address) \ +do { \ + pagetable_pte_dtor(page_ptdesc(pte)); \ + tlb_remove_page_ptdesc((tlb), page_ptdesc(pte)); \ } while (0) #ifndef __PAGETABLE_PMD_FOLDED @@ -65,18 +65,18 @@ do { \ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) { pmd_t *pmd; - struct page *pg; + struct ptdesc *ptdesc; - pg = alloc_pages(GFP_KERNEL_ACCOUNT, PMD_TABLE_ORDER); - if (!pg) + ptdesc = pagetable_alloc(GFP_KERNEL_ACCOUNT, PMD_TABLE_ORDER); + if (!ptdesc) return NULL; - if (!pgtable_pmd_page_ctor(pg)) { - __free_pages(pg, PMD_TABLE_ORDER); + if (!pagetable_pmd_ctor(ptdesc)) { + pagetable_free(ptdesc); return NULL; } - pmd = (pmd_t *)page_address(pg); + pmd = ptdesc_address(ptdesc); pmd_init(pmd); return pmd; } @@ -90,10 +90,14 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) static inline pud_t *pud_alloc_one(struct mm_struct *mm, unsigned long address) { pud_t *pud; + struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL & ~__GFP_HIGHMEM, + PUD_TABLE_ORDER); - pud = (pud_t *) __get_free_pages(GFP_KERNEL, PUD_TABLE_ORDER); - if (pud) - pud_init(pud); + if (!ptdesc) + return NULL; + pud = ptdesc_address(ptdesc); + + pud_init(pud); return pud; } diff --git a/arch/mips/mm/pgtable.c b/arch/mips/mm/pgtable.c index b13314be5d0e..1506e458040d 100644 --- a/arch/mips/mm/pgtable.c +++ b/arch/mips/mm/pgtable.c @@ -10,10 +10,12 @@ pgd_t *pgd_alloc(struct mm_struct *mm) { - pgd_t *ret, *init; + pgd_t *init, *ret = NULL; + struct ptdesc *ptdesc = pagetable_alloc(GFP_KERNEL & ~__GFP_HIGHMEM, + PGD_TABLE_ORDER); - ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_TABLE_ORDER); - if (ret) { + if (ptdesc) { + ret = ptdesc_address(ptdesc); init = pgd_offset(&init_mm, 0UL); pgd_init(ret); memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,