From patchwork Mon Jul 31 17:03:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13335286 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 29D79C001DE for ; Mon, 31 Jul 2023 17:10:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B898F280081; Mon, 31 Jul 2023 13:10:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B396528007A; Mon, 31 Jul 2023 13:10:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A0162280081; Mon, 31 Jul 2023 13:10:32 -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 912BB28007A for ; Mon, 31 Jul 2023 13:10:32 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 5E730120B51 for ; Mon, 31 Jul 2023 17:10:32 +0000 (UTC) X-FDA: 81072545904.06.020D32A Received: from mail-oa1-f43.google.com (mail-oa1-f43.google.com [209.85.160.43]) by imf12.hostedemail.com (Postfix) with ESMTP id 3BC7A40005 for ; Mon, 31 Jul 2023 17:10:30 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="L/L7zvA1"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.160.43 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690823430; a=rsa-sha256; cv=none; b=R6Bg0UaI9hwKLQ0phXj/b0aF77mPDRlBd00nGDbTnVYAwn/Q5dtB0RiaPt5l6h4RHiR5hW MGs8hg5i93H9Cg3IMy/noeFEHUBskuHDEoRX5AeZgvSwzIt7wfeVjc7O0E9SMUu/WgyZch yp/bevh9UkQwvgdXeb/NUL7PE4TWYsI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="L/L7zvA1"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf12.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.160.43 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=1690823430; 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=SAhmPkA/GpQ47QH28uSJ5R3865OUJLAREcdtnZSTz+OU+6lZ2DevMop3SlhzrnX62QOSVM awkd1njTDCnWzvfqYLPGav7qQre5LKLlVQoByJPvVGv0yc9ok3mO4ZCz5C0mg5hlZrWH2W tXAAZkT8xGS/+Aed3X/VLzAXJiSaEQU= Received: by mail-oa1-f43.google.com with SMTP id 586e51a60fabf-1ba5cda3530so3597696fac.3 for ; Mon, 31 Jul 2023 10:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690823429; x=1691428229; 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=L/L7zvA11LcRdD1cN1MMKXDyF33EZjb+UtaPx6sqMQxbQxkvH2GrlKxyu1w2PvN7i5 1AezWCH3S9obCTgfc/F6j3DrCPczdpxt5KHtbYnPPF5gg1D7B1fRKe1214jKxrYBAQMY v7dxEEKg6bFi7TOnwOpj/crnBTGxG2kA3Sw1SWBk51+/u3CbxU90FdyToCTE/bxLYZ5I Lw4QMdrucKhLXZJ0nAS2+qCqWiOXTDBD+569jA3oTXBERdcem/hLewLCsahrTdspLBpV e7IEX3yQCzM7MhGxf/ODfw063S34i+rKfZt+uFhLOrEJV3b142JHE6Cl+lTtbGa6iBnW H7pQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690823429; x=1691428229; 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=lTIE8Lei3Md1G1aUM2UgcTob/71qs2s+dqcCV5yHU4jVYC9jGLnz0vB4yOAgRIdtYK zKlZW9z6yxbX9wZBmIYTX6fG2iYZkwL/vCnFnJyCnU6gG4ASH6xLkn/X9doG9yaQSxPN 32tDoLg8gbfoH9vJtyTXHfC5LwR7+L7l5wN5jYr8Fj3AEaTkEQchLXOPXhEnjQfDU+YH Vdb38SfDU9QBm1KOuB8X24zyavtHrMZ0Ieh/ND9kWfxYvdRcVtlgOwRRDyM6YOhawOgj V/oE/mbM7F4TsBTW9H3W0BwqriW+UUMe1yZTOBhYdJaWGforb+JKcZW5OIQDGXCCM4rI 1RkQ== X-Gm-Message-State: ABy/qLYcXPoB5PudFGD4vCkCpCHhteDQScZlSK7Y+cz8aBmZgJ+RIsgJ e+RP+QP/lJx8GU7KNXrOSHItBkPntcZjYw== X-Google-Smtp-Source: APBJJlFeS2ogl3m5ezZAcTbxwtfQRoXWWYsAvuudazx+JhR2l/mtz06faRF9RklP+vg5BWBteq8aEQ== X-Received: by 2002:a25:d18e:0:b0:d07:d88b:4843 with SMTP id i136-20020a25d18e000000b00d07d88b4843mr7628126ybg.20.1690823060256; Mon, 31 Jul 2023 10:04:20 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 10:04:20 -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 v8 21/31] loongarch: Convert various functions to use ptdescs Date: Mon, 31 Jul 2023 10:03:22 -0700 Message-Id: <20230731170332.69404-22-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: 3BC7A40005 X-Stat-Signature: j1nemm6ihyxm3npcks48aicwdjp8y1d8 X-HE-Tag: 1690823430-925611 X-HE-Meta: U2FsdGVkX1+IrfQTyzYSrsh4Y/kVy55PQPZb9yH8Ga+Hm7MRHf9Elea12Z8JfpWFjQZIJDNWEvkqHHnJTuR0xrhDsHA3mzyC4Km3+3d3fCpylBiy2BZvai0U3IFnzvRKKN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W+flRsADHbleALa/dKMBjwlsLYc8vdo2Zf395aubD6NuG7TZg//IVja7qx/Iazf67k4TzIqBQRSg5D9BXbdTomqJT2XLwK0gfGFNxv/bN10rSmoNvKqu/zjk8NPblLK2pSdy94gYsOPd7UiJECfsEXiC9hmVcWk9uOfsblgZcNo0KEI1O2beC+yUljc7PcuLQ2qCdtN/7nV8QQ3OasLybpQ5REI3yn2gzEfcbqNQ75lw0+S/2FqqRDuaSRIJfC/iMKNJwNflZcErHXNVhRyG/l9sgKuX9DL3Ru9bG5yZdsfM6NThWcTT8jHNaGp9f7fv4d5/8UUnT2yASngvwpiIZU+Lc4Vo9WxhfGb3XoVFCQfzsI3Arwwe0hM54DMO3f93LG7KED/iwQ== 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,