From patchwork Mon Jun 12 21:04:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13277370 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 E5AB6C88CBA for ; Mon, 12 Jun 2023 21:05:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8D4FA94001F; Mon, 12 Jun 2023 17:05:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 884CA94001D; Mon, 12 Jun 2023 17:05:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B1D094001F; Mon, 12 Jun 2023 17:05:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 54BA694001D for ; Mon, 12 Jun 2023 17:05:41 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 2E97E14033B for ; Mon, 12 Jun 2023 21:05:41 +0000 (UTC) X-FDA: 80895327282.26.BD489D0 Received: from mail-yw1-f175.google.com (mail-yw1-f175.google.com [209.85.128.175]) by imf23.hostedemail.com (Postfix) with ESMTP id 3B4FE140006 for ; Mon, 12 Jun 2023 21:05:39 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="hFoqvf/V"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.175 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686603939; a=rsa-sha256; cv=none; b=NZHsZchr7E/YjUQ8U2g6sjEN6EK9xjiJ+QMuEaw/8CfW/6LA4RBlGVf5Hi48v3Byr31GpT slohRt9H+5WVxdC5iiBLEalOp+HMnZ0GVjhq00Uktav4ZHnr9HY/6oflj7BfC6mQ7kS/S7 7kdCj2UB+Wku2e6D6QXHyrEV0dJVxxU= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="hFoqvf/V"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf23.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.175 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=1686603939; 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=x0T5hRMJMhyAQcr70NSN00ZodxImAvN36JhDkpGUyhY=; b=f5BWYuZtdvIcI9c++mP9ojiKVrQxnl47avxQapVLAghC+sed94V3u0hPnA/zOXexguSV47 ovAJcfiShgGir3DKlTXoIMZ0PC/mqzH9lVABF676J5V7A7t4xvv4SoTW8nkfASbBVN7Bdy H7oGHO5Qdoj/CYq9vlmKAgu/BETcl1o= Received: by mail-yw1-f175.google.com with SMTP id 00721157ae682-56d17a5d786so19490547b3.1 for ; Mon, 12 Jun 2023 14:05:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686603939; x=1689195939; 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=x0T5hRMJMhyAQcr70NSN00ZodxImAvN36JhDkpGUyhY=; b=hFoqvf/V9d8VqdB1r7rkRWq3dicIimOQySgVHkIAvwFL0Mu8+p1N/1GXYk20QCUvFC OBvHXqLIwjKUW/Cg2L8TmdMFxaZ6erl8dDsxPeG4KHBkNdpNt+SDRM/fp02BIXhlhRFh zXyh4Ur2o3sR1wLNSv+RjLnPdgEzgFATa4g2Xg+LDMcjUjKcFkx+ifp4/8Lyr5+rSxVP +jDDkF8+0sKN+s4pK+Y7LtIDDsq1fD/1mjzcxIj0x+6U6FJXpEaUQtkvK0KHsh7xRlWs 1TqkCn6ISt1EZJ2kze1cJk8ZhVzPLe93moWp6KpJkfCGbbls5KNPHYDQvJaFIhhqzRGm 8czw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686603939; x=1689195939; 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=x0T5hRMJMhyAQcr70NSN00ZodxImAvN36JhDkpGUyhY=; b=BJwG5Zo17yRiE9jflpbyLrm4vtlULGv+sSJRkcvy3ozslVrPvsjqkLmG0Bvpz2BCVR shHlgdK5/0i3ogWQim9yJumJAFA0fvEM8Qi1RRUHjv/wfJTgG3mrR4sUIupkhe67zGhy uRvZJiRahOt4AOtBRp4wPdXIs4qVfLZnkwfRRDzo8RQmJxBH+cp2cn8OpeOfN0J8lk0b 0lCzpGXU4INPq7yJPKWLvotBJI9G4NYPAoA1CdPUNvNdaZgcJLaIm8lx9nj7E/Y24MJi y8XUBgdcWylI9yyd5/mleecius7k+ucNXtL0/+eljk6oVkB9T1T6xOVNs4hC7GNVchw7 UdFg== X-Gm-Message-State: AC+VfDxAX+MVZojYxdPcc4f1stkg+jd/jSobuup5WDHCddTIcV8qIZtT MTgGAtu1wE3iiqZoieaoUBk= X-Google-Smtp-Source: ACHHUZ7R4s+2aZ6dyK9NB/h4GJ1OeGFjhnSrFQqFV2mTnMsc5RahC9DLUvZ1Ug17YsYVh0NwNxMgmQ== X-Received: by 2002:a0d:e2c7:0:b0:56c:f6cd:7b55 with SMTP id l190-20020a0de2c7000000b0056cf6cd7b55mr7964257ywe.6.1686603938725; Mon, 12 Jun 2023 14:05:38 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::16]) by smtp.googlemail.com with ESMTPSA id s125-20020a817783000000b00569eb609458sm2757115ywc.81.2023.06.12.14.05.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 14:05:38 -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 Subject: [PATCH v4 26/34] mips: Convert various functions to use ptdescs Date: Mon, 12 Jun 2023 14:04:15 -0700 Message-Id: <20230612210423.18611-27-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230612210423.18611-1-vishal.moola@gmail.com> References: <20230612210423.18611-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3B4FE140006 X-Stat-Signature: 8yu57szyz6a8sjkzitknrcbruj9fg4jr X-HE-Tag: 1686603939-963749 X-HE-Meta: U2FsdGVkX1+ohN6n8AZlMDw8G5v4lXjlPdpDBDyDstwmGpgKdEWUMsAeWf2MH4+rgYo9E5z1keT1m6ji1wWNED/NnoKYqAD20N9ySNIcvERbTin2xs1dBIil+QhkGNJAoV7bHFlTMbCS48N4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ck+U/BtvQRTLT7GwGiU50MAmmP0kCk11PaZXgjV+lJGbClAzt/ynBjfGllyJzkU9v9Qlp4+k0fmg32wZ6yhL1Im8c+oP5eZoPVd/j2eOrDxq8Z7n55EDnq79hX4Tgqv+tjnOYHIJz10h5E0axMH3KqVDvQ84TbWUZF23rAflciNp1KPAi2+2fI0UEg72MK52mJUGOqPnhXWxZaqvfaQiBDkAkVhTKfeEXriwxKVB6P3+X3N0DP7Fp3H/oXUfyUEY06dM3jfxAX3AAvjr7TRwwgMhTbZcjAq1ZBAz/ZOr3C0GdkpWfWuaNmcKqkKmvB9w== 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 | 31 +++++++++++++++++-------------- arch/mips/mm/pgtable.c | 7 ++++--- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h index f72e737dda21..6940e5536664 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,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, 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..729258ff4e3b 100644 --- a/arch/mips/mm/pgtable.c +++ b/arch/mips/mm/pgtable.c @@ -10,10 +10,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, 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,