From patchwork Tue Jun 27 03:14:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13293840 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 8ABCDC001DB for ; Tue, 27 Jun 2023 03:16:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 997BB8D0006; Mon, 26 Jun 2023 23:15:59 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 91FC68E0002; Mon, 26 Jun 2023 23:15:59 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 799B38D000B; Mon, 26 Jun 2023 23:15:59 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 640E18D0006 for ; Mon, 26 Jun 2023 23:15:59 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2D7781406BB for ; Tue, 27 Jun 2023 03:15:59 +0000 (UTC) X-FDA: 80947063638.28.3B26930 Received: from mail-yw1-f170.google.com (mail-yw1-f170.google.com [209.85.128.170]) by imf30.hostedemail.com (Postfix) with ESMTP id 5659D80005 for ; Tue, 27 Jun 2023 03:15:57 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=lEtqmrwI; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf30.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.170 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=1687835757; 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=pBiyp2dfMpzV+NvCt1JbKOh6Ic1GEYp83948mVxRzoc=; b=S7MwJlK7hYUYZ/OxVGkxRDIJvuZwB6MrGwg1fUXsa+mr2AYlFJG+pZ9VcpBiUFADaN/nOC rjpaAzrRkCYDDT65dHJNJPY7tPNhS5ql56+UM1G60lqXS5biKzNev1amCP3HOo3LORuyLk UYXVsVMbdnHCypOBfHarfzCabxUcSmI= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=lEtqmrwI; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf30.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.170 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687835757; a=rsa-sha256; cv=none; b=JYcS5znn39tX4z7sRdvOwisqe/oL4SqsxjdABO+z7QjBwe9QKMHLpmcNoGDnc6MClw9+9W sliHN8TmSwz7pmD/7+4SiRm/yLBlEZt+iQdtDk6fycomYRxac0/qA/s2zslGLgqgVC2X/f HW8MkCeNGFl+w/6n21XbcBmqA6vPeZc= Received: by mail-yw1-f170.google.com with SMTP id 00721157ae682-56ffd7d7fedso42552217b3.2 for ; Mon, 26 Jun 2023 20:15:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687835756; x=1690427756; 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=pBiyp2dfMpzV+NvCt1JbKOh6Ic1GEYp83948mVxRzoc=; b=lEtqmrwI3pH1F9NhuLSu+lhrJuJBeaNoc0B/a+jtRpylRNiz6lnVYqwXFylSaxIlSS fal5MuqlLO46M8tgspmd3hSeZZQkHzVCiF/enKflZ1M3hEbA15QMn0yHyWiDxK+YUgaZ GWFcNw4Uez0C21+p6DRUZFT6brtk9p0VoxgHF26jewVOVnyhkSQ3DRQfrpXYXTkzJvdt UKT9r8byFkYtRNMun/mKCKgBDEtBv/scAQyWpgjFy69JlQUU0QN5ljLcHnq80rGO/875 /+CaEkKEPeM1zZ6Ui2wCINBbaXnsdbhwpMR3GV5pLj1s7PximB5Gycu9naEXtrlwl71V d+Sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687835756; x=1690427756; 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=pBiyp2dfMpzV+NvCt1JbKOh6Ic1GEYp83948mVxRzoc=; b=XkKvZg7+QzjdbcZg6ucW2NSNwNyg7UFYAajYkGYD7xDfbCD+JtCGJ+XOL+UNMArNgJ lQkzKkWMcg07RjwRcaTyR02I/adpYHwhWlIkdMGYBe6MJFGNYn3tQP4AaiEPEcLz1wgj SkSgm60bGQfUvM6+R9A/oxblryOsgHHnR1yhU9m+tIC4SHaP+veDxVbecxBonaSsu4cn x0FfATJIct0M5vRRCcS75d2EEm8lcyv+wqevhMH9ylOC8Ai3NeGjc8fORrpEoPpweCbj XnO7EMYk6TtEMTvGYDK1IPz5IZppe5I3l9BLyDwgM4JvUUF8kL/KwJ7z0D5YVEpC1kER /0mA== X-Gm-Message-State: AC+VfDxSwNnud0BC3uX0v3FdLyirUKIxvwaT/ypF015acj+pkAW1U0wS e7zbTGG8u9u3uY2RsEbQLv8= X-Google-Smtp-Source: ACHHUZ6AsPEMPaYNwMvJ9C/uUytKifTWfNOxJlUh8Y26CFwkBAjPl8zEubY5Kzi6Ted2kFoKwje9oQ== X-Received: by 2002:a0d:e24c:0:b0:56c:fc62:a5a2 with SMTP id l73-20020a0de24c000000b0056cfc62a5a2mr32690358ywe.7.1687835756402; Mon, 26 Jun 2023 20:15:56 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::16]) by smtp.googlemail.com with ESMTPSA id s4-20020a0dd004000000b0057399b3bd26sm1614798ywd.33.2023.06.26.20.15.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 20:15:56 -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)" , Huacai Chen , Mike Rapoport Subject: [PATCH v6 23/33] loongarch: Convert various functions to use ptdescs Date: Mon, 26 Jun 2023 20:14:21 -0700 Message-Id: <20230627031431.29653-24-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230627031431.29653-1-vishal.moola@gmail.com> References: <20230627031431.29653-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5659D80005 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: wwknfamcg8tfejcspajgcun3wwomj7mq X-HE-Tag: 1687835757-134330 X-HE-Meta: U2FsdGVkX19F776keCMGM5T234dN0MtsaQYX9Dj39iQGKb3jNzw70XXnOypGXJgAwrA9zoJ1UVKk7MK+fI46oq/eoju6C0/qNboVDja50vjCySPtoJIP/I3hPcn3fHDz3VqaKBuM8/D0JC36r0UoFYg/TvLOqNXcFdYQNn0C7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tLl8TG8CW9oNPp+nxKmGlkyDcg4HBiI0e5GKfyK6K36yoKudhbkh1Ct0ZMeOfoFzK22Q4dTglUvQC11/A1VLE5SZ9IMoB9hKXpPxiSSFS+Jtm30rT8yjjv7fxHkPzpzqruKmK4e/VlcfOpPtMGyJ1yhoYUHpP0halQU/mKOlu3WjnDl6ZsX9ei/zTn/lQ6ekK+EpsOpsNC5iAwk2MkjAP0h6L09F08NPK9UQEA0a2i7bBhgucDiMSeWFkcTv9EjZYce1SWFEzqPEEJiLWZyyDQeSM3DTLTrsKfBKdW0WzLHcSsZ47UydHb6iOHEvu3UpoPwzthjTiAMuRRW9QvnMBXvWfN/KUeTBB8eg7xW1akT/ey2jt+ll8WkQBzsecBvijDwMDRaJo6jecDk55K69yo5UI81Zk3Q+L 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/loongarch/include/asm/pgalloc.h | 27 +++++++++++++++------------ arch/loongarch/mm/pgtable.c | 7 ++++--- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/arch/loongarch/include/asm/pgalloc.h b/arch/loongarch/include/asm/pgalloc.h index af1d1e4a6965..23f5b1107246 100644 --- a/arch/loongarch/include/asm/pgalloc.h +++ b/arch/loongarch/include/asm/pgalloc.h @@ -45,9 +45,9 @@ extern void pagetable_init(void); extern pgd_t *pgd_alloc(struct mm_struct *mm); #define __pte_free_tlb(tlb, pte, address) \ -do { \ - pgtable_pte_page_dtor(pte); \ - tlb_remove_page((tlb), pte); \ +do { \ + pagetable_pte_dtor(page_ptdesc(pte)); \ + tlb_remove_page_ptdesc((tlb), page_ptdesc(pte)); \ } while (0) #ifndef __PAGETABLE_PMD_FOLDED @@ -55,18 +55,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_page(GFP_KERNEL_ACCOUNT); - if (!pg) + ptdesc = pagetable_alloc(GFP_KERNEL_ACCOUNT, 0); + if (!ptdesc) return NULL; - if (!pgtable_pmd_page_ctor(pg)) { - __free_page(pg); + 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; } @@ -80,10 +80,13 @@ 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, 0); - pud = (pud_t *) __get_free_page(GFP_KERNEL); - if (pud) - pud_init(pud); + if (!ptdesc) + return NULL; + pud = ptdesc_address(ptdesc); + + pud_init(pud); return pud; } diff --git a/arch/loongarch/mm/pgtable.c b/arch/loongarch/mm/pgtable.c index 36a6dc0148ae..5bd102b51f7c 100644 --- a/arch/loongarch/mm/pgtable.c +++ b/arch/loongarch/mm/pgtable.c @@ -11,10 +11,11 @@ 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, 0); - ret = (pgd_t *) __get_free_page(GFP_KERNEL); - if (ret) { + if (ptdesc) { + ret = (pgd_t *)ptdesc_address(ptdesc); init = pgd_offset(&init_mm, 0UL); pgd_init(ret); memcpy(ret + USER_PTRS_PER_PGD, init + USER_PTRS_PER_PGD,