From patchwork Mon Aug 7 23:05:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13345307 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 8F9A7C07E8E for ; Mon, 7 Aug 2023 23:06:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C9C194001C; Mon, 7 Aug 2023 19:06:08 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 753DF940008; Mon, 7 Aug 2023 19:06:08 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 556CC94001C; Mon, 7 Aug 2023 19:06:08 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 39BD7940008 for ; Mon, 7 Aug 2023 19:06:08 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 188381402D8 for ; Mon, 7 Aug 2023 23:06:08 +0000 (UTC) X-FDA: 81098843616.08.C48A7E0 Received: from mail-yb1-f182.google.com (mail-yb1-f182.google.com [209.85.219.182]) by imf02.hostedemail.com (Postfix) with ESMTP id 422BB8001D for ; Mon, 7 Aug 2023 23:06:06 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=UEUmdRWy; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.182 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=1691449566; 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=SCvcoKWLGx6gAjym9VWVFszZElqPM/KxU0nQCUs9lhU=; b=ixmSkTYY2EMGjtE+I+VOcd6mTPCTzvQIqidQakUf7jnDVdMBhjpbkdAGg2x0c9wGQ11CDH noGIIAQzoyAQcuf7Cbz2qUii7l0RvuIzjowcL5mNcM26IwqRGhmTr7peIjk93LyckzQ8g8 7J1oVFiwIxVfJNX1ohdvu6qJyiRw+W8= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=UEUmdRWy; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf02.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.182 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691449566; a=rsa-sha256; cv=none; b=G9z2Getcl//n+6/Fs+6TmCq4USMhXYNqK7L3fedNZ7LZUu9RQ3NeSrzuCaNB1QzL+2EMXl aufkfY2/BrRblyw7FyA4PAjsdVTa+AOr8ZVmwBfsT0VWBc/RMQBec2W3b3iyDax3R/dw+N xM9oyzU9+oGAnx/QHYf693dVpHe7+Ng= Received: by mail-yb1-f182.google.com with SMTP id 3f1490d57ef6-d13e0bfbbcfso7271414276.0 for ; Mon, 07 Aug 2023 16:06:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691449565; x=1692054365; 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=SCvcoKWLGx6gAjym9VWVFszZElqPM/KxU0nQCUs9lhU=; b=UEUmdRWyflXklFyhNX736vuEaqgiuaE747b2iDMdbsntaDVnz91uxqlH5BcdgyOH5x uvJaTvPkpQGN9akIqApZ8zKHvLZguej6njtjOnVMX/cM5jmsFezl/LYYVYVkbeho4b0z HHNTILzp+Xc4v6kzsuUo73oAPiN0CJazQDUAwcPLlet/lIEFQgMVrv8B24qA6Hz5wjkw b8w6Ifa5zhm6L11dsVrnJ9eA4XJTM6QxI5QWilhFcSjtgNKdoGywloLoSOAO6BZpBMSb 8CiRrKjceUBw/RGFjWiyE5TzR9GZJ5T3ThAn9ujnfgeZbAfe+0n8PqgNKPCIQtpGYCsJ QRzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691449565; x=1692054365; 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=SCvcoKWLGx6gAjym9VWVFszZElqPM/KxU0nQCUs9lhU=; b=FCpY5gyispcCvhK0rSChFmaDUTvI6WhoY8G72R01xkM2ZoScmbzM/pt2W55U3VpZP/ omKm1fuIcdrvEKSXvoOnN0YENqidkGjIBle6jKzwmtcBcF9S370vcsheI2be6Ahw+BfW qz2w9W20CgLBBN3o6GR7GHe5F8DLeKFi+xSkSOabB5VMg7865YCGs+QvvcZJ8AXFfm6M eDb047XWAjFEnG9vMgZwwk2D8jLTi3916L/BpVZoXoB9NBX/PsxEh1AShog8OtfsDe38 nI9hBbN2iiX06aGVC2DJcV6WLiIA/ICyp1gWkwuPOCvCpB6gCpmPsCBiv/fc08xRDjRE do3w== X-Gm-Message-State: AOJu0YxUWRsRMiE8WrjREk03uxiJOYLiUPioQo3lvhuB7LtBsJafeqV5 zoADPqwhE/+cAQFk8KoWBH0= X-Google-Smtp-Source: AGHT+IEqzmUPQsWPkdBtUj3V9QXK122J73o4hp/g5UvHeQgKIN7qrVubtY48PFSpogl4MBW4UXPeVQ== X-Received: by 2002:a25:944:0:b0:cb4:6167:a69c with SMTP id u4-20020a250944000000b00cb46167a69cmr9868214ybm.8.1691449565251; Mon, 07 Aug 2023 16:06:05 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 16:06:04 -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 v9 23/31] mips: Convert various functions to use ptdescs Date: Mon, 7 Aug 2023 16:05:05 -0700 Message-Id: <20230807230513.102486-24-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-Rspam-User: X-Stat-Signature: 15pco3rgzo834npnbfyz5bzhfni36dym X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 422BB8001D X-HE-Tag: 1691449566-378980 X-HE-Meta: U2FsdGVkX1/o7KDK7deg9y5p1L3tJD5S66/Ki6EIUbcy2f/bF/3yy2YtFIaHFEl50FuMAvJIWmmdmSCvFIQ39SVh7YOkgeMWzG9jMRLYyekpezUtr408hG2atrhGT2HvgtOvrqnGbjFjUmnLZHWnokffjvHN1oi19pDyFAb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nemRcdnaYlYJdXBcTChbhlxLIgzCvQSCQSW4mYn+XZs+nXrEn+Eu4Z7i2w435NWUKaHJCvCRb6ObbKk2ifN/ZI/Xj9ugHQ9naSCtreEuJO1QQ+94i9R65/+CsF8kM9Fs5j+HkV0gVczP7qw7LbO1nwGyYNQwLLwQyS28O8ZOpDKwCSIfrBa5EgK2npubzm2M8QHxwhtrCCsB7NTTScy5B8ujB8kArPuAc/JsM42qDMy/jr3+XAaH+dLBPOI6/0qeF3bNYfz9+lzkg/qSumWP/IykH8H+Hz4ScotlpAMM1ESX4BO3B33E6otZ0VPubOrjCZaOObXfmi0C36diLiIsD3DCw== 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: Mike Rapoport (IBM) Signed-off-by: Vishal Moola (Oracle) --- 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,