From patchwork Mon Aug 7 23:05:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13345305 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 376B2C001B0 for ; Mon, 7 Aug 2023 23:06:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 384F394001A; Mon, 7 Aug 2023 19:06:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2C273940008; Mon, 7 Aug 2023 19:06:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EF5A694001A; Mon, 7 Aug 2023 19:06:04 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id DCF3C940008 for ; Mon, 7 Aug 2023 19:06:04 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id D8203C06F0 for ; Mon, 7 Aug 2023 23:06:03 +0000 (UTC) X-FDA: 81098843406.23.1BFD15C Received: from mail-yb1-f173.google.com (mail-yb1-f173.google.com [209.85.219.173]) by imf24.hostedemail.com (Postfix) with ESMTP id 1267C180005 for ; Mon, 7 Aug 2023 23:06:01 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=KaA5Xf0Z; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.173 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=1691449562; 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=VD2saKmHCgP979K/4Ur2DZD5lv+pCsAy+26MDZ4lRXE=; b=qT2KpSaibNi/inRbyJWqQS7ensZOd+HWux6KZHZbjdKvrD74ji4xlr7ir3Kcpq+JI9b9at EuxDjuPmN2uaFPHSZYYv6W5GE62u6/++faHDaeNb//WZdmY+RoGPjTm821fcZ3UA+zXltb Z7vEm4J5AWsDoqOiscoXQTQRMAWEXGQ= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=KaA5Xf0Z; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.173 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691449562; a=rsa-sha256; cv=none; b=i6Jz+Y6Wo7cEvnnzZIz80nSFOg2pNAETnp6V8xKMKiWt7iAqjzURvSYQmBwARcSluFOHPG sCO/aQhPvpR99UUDsWbSnHf6aOYN7JsKHWAJRr9AL5QaY7ErB6GMnzmLbX3SZWk9LrXKwQ /qQ/y4juqXw3826ApgRjzlv4s/DdJhI= Received: by mail-yb1-f173.google.com with SMTP id 3f1490d57ef6-bc379e4c1cbso5465423276.2 for ; Mon, 07 Aug 2023 16:06:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691449561; x=1692054361; 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=VD2saKmHCgP979K/4Ur2DZD5lv+pCsAy+26MDZ4lRXE=; b=KaA5Xf0Zq7VankK3QOvVnhKCvDQA0idGZ5r/QtBaYpBUZhM7IUDDnipX0Mck9NuTr6 FMzfUiWHWV61utAYtiNJjvsmZyQrjEGqV1vWWuYtjGooZk9wKA6pHj8JXiEh77Vd66gm gq9wCdtohtsBXI+QiM0g5DM3RYb5yVm35tcAKNI7nQZaFVODWjyuyXisRnjCevekbcDp QweW3qBvEiOtjGdP8+KO+Ai79xaww40f8oFcpzIoZ31G0t7vkt4E3RfT7Asw6Y6mNUmW 4v5tgaFeOHT3yezqwQ6Pv7HkjczS8wtW/o3vWALkNkC7/L83lM6ERIvU0onlnalg95pZ XQOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691449561; x=1692054361; 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=VD2saKmHCgP979K/4Ur2DZD5lv+pCsAy+26MDZ4lRXE=; b=V3VX+C+wZd9emYutdJJ0SXX3xVtbf7IJOsnlZQ0qZu6yH+BE0vx6KCa4I53yeqCPs9 8Plx6gw3gtvjJz9wV6fvN4DHlOIz7hnJm0owWpzVIBCIgwP1azWBnUuX6CURBIMJD0eF zUXDe/0YxG+JqlUSm6LwEeB0PqfIT8Ck7zxdHUCN9U3qKv3nQT3WBqZiE8RER5r8AnRZ hwH24RoQLDJu3Hr54OvgSCFGeImgik8ipDR42dF9eEkdRW5/t3IQtpWn1c4hyTQzZaiN IvFx5hJu/6RHjoZqkDZQlSoVEVOm5REvVHpqqSVmhAIrx+GiMsNuuNXeWjhF9WUAYob6 Ix4g== X-Gm-Message-State: AOJu0YxGm7OiHVHbwYU4oqE/v8SQfl1i1COL5nOyIzsxXSENYKlTOMDr W7sFrsZT1ifcvt0I+5vRoWU= X-Google-Smtp-Source: AGHT+IGT7jcZ858GNZbGv2ymKyHkNCq6k2xr+zx9+OdmxVuwoAhnOKduGJp0I6ObmWSEyVKiLNM8sw== X-Received: by 2002:a25:8210:0:b0:d39:fa2f:8b63 with SMTP id q16-20020a258210000000b00d39fa2f8b63mr13670853ybk.25.1691449561057; Mon, 07 Aug 2023 16:06:01 -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.05.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 16:06:00 -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 mm-unstable v9 21/31] loongarch: Convert various functions to use ptdescs Date: Mon, 7 Aug 2023 16:05:03 -0700 Message-Id: <20230807230513.102486-22-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-Rspamd-Queue-Id: 1267C180005 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 3gr4p4yn977zabikmb1f6b9o9yhdpct6 X-HE-Tag: 1691449561-937266 X-HE-Meta: U2FsdGVkX1+X0PGiD7UsTFfsVsQj8fBKFNcGdEKd6Kqrz32t+0Rw0gwDWItzhvX1YFkZOEirkQ93trMMb7te7g7/dXxap11gXJOXAwgtndytE5g4X+BjAXxaeMAI5BIWBggxAUA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LtQhC16PPfzQFFnqIZ57/WKiK4bZ4Y0RRG431qXLF8q9PNzmGslg7Ak8+OOe29F0253a5dXeNwgoMcmQ8KabBZ1PpSMZuxyBm1EB4BhIP9yn0bhod8UF8G7vecKljPd2nLvwyS1Vul4B9EDvV9QBY8vrr2OpyzzDkTkRywAgFzJIQnAiNiZ3CsnIe7EWjSU0cBFXGXm35e7ji1+b+UsGBltowxfk6cLsSEYz4ipsHtOxzZGDCfav0W3S8O0xKjit0tmrWkS1UINNi1SDcKoNLt6WdN6sr8ypa4MBWwh+d8QKgbVN6obMluF0aB//zBZj/TbpaLLTQA8HXcBObcH68WoHBLi6VCCKJwa0EKz9OeFEH8mY/wzE0mA== 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/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 1260cf30e3ee..b14343e211b6 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,