From patchwork Tue Jul 25 04:20:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13325733 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 E4B6FC001DF for ; Tue, 25 Jul 2023 04:21:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7651E900005; Tue, 25 Jul 2023 00:21:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 71555900002; Tue, 25 Jul 2023 00:21:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DE87900005; Tue, 25 Jul 2023 00:21:55 -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 48B7D900002 for ; Tue, 25 Jul 2023 00:21:55 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1FC3CC040E for ; Tue, 25 Jul 2023 04:21:55 +0000 (UTC) X-FDA: 81048836190.13.D368DA5 Received: from mail-yb1-f181.google.com (mail-yb1-f181.google.com [209.85.219.181]) by imf21.hostedemail.com (Postfix) with ESMTP id BC0821C000B for ; Tue, 25 Jul 2023 04:21:52 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=M6jRKuiv; spf=pass (imf21.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.181 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690258912; a=rsa-sha256; cv=none; b=5TgjIh6fmjjKUMcNHM1qhvEvPWlYVqfZ2hKBk6HeexL4hmOTYeoC/B/bdycfOtXnudUoHz 2q1MgSp0BXRfENzDUZ2AKhPPVGON220sxezv597F58mmvNHPSdTaxymYVMvC4Hus/2oND3 UB9FXs/t66EkFxXnJEvoMNsvaNMi4+k= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=M6jRKuiv; spf=pass (imf21.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.181 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690258912; 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=F9pjqRMMdsvb9IhOLmwsQMetaTQ+QgB6dMglfNdI9IpSWC4gcn8LuIAG63UzlpMK+hFZIJ JPqPO8FzprSxvgYfnsiMn9zF+yYYN7q5sHX7WYYj1GV1YwsSDfO0lBWSLhnVA1tJl/p7gp oTFiC6+RhQ0Po4KtFUXBGu/c6m8geZg= Received: by mail-yb1-f181.google.com with SMTP id 3f1490d57ef6-d08658c7713so3153908276.3 for ; Mon, 24 Jul 2023 21:21:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690258912; x=1690863712; 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=M6jRKuivh8zjiemd5A6uxigxJohHpad42drXAXZPo/WrWX/VH06lIJBZPBsy6q5WUU sx0lJdOkpQ0kaLkBOuxv3JTr0MrJ9mxzZ+UUwF+trvlZXj+IJfJxZEoLsbjBtENoOnKp r4LPLa1pA9aLy86FefeD5kRctnKeFj9h3GxRlhN5hCXqNjunVSlk6MQa/3J7EWf+g7LP GgIUvItIu349rIBsGC+5p4KYn28jcwcdvYVyudYGHQ4Rpe+/D34t/jp9N4BHJAtnbKCw qFN4cKxe4NHkjK6LRf9V/I6F5RMPandO1u3QcQV36zYYu50WN177HZ6ueUgU7U2rKCNZ UtKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690258912; x=1690863712; 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=hRA/RG5vyEYPV9TKzWsytuneSP+AWmUGQbLDt2QWRHwCK2Ee9JEL3VwtpRbpcsmqCj DGjZjgu/CP6YC+udsMbodRRDGYAeLaurE24L2NYlDMdbcjgjBW7LRAM+Nn3cuLdTicbF Jw//m/hEV1uXi7G9TMF37E0SGIQmEuRYih8WEIaJA627boqT/l9jznIXr7dBTS+vK8Jy J8+QbuUv7B5VOPdyfjOgypu5QO9q/DqKbwKii1h25TfHOpCLbyebDR1BBT08qxvunEI1 UuaruV+4opzvqmopBtQnoiJpq1FABgqvCHNj8wDQBAfWVo4SPtBXawZ1cz2aoIWng66a lZdw== X-Gm-Message-State: ABy/qLanpS8ymWQAtO0Dvz6f7n9v3qXmFtawbdihrliUrMqb4nX0cl6d em+iS7I4+MzidMmpbkJm7Cc= X-Google-Smtp-Source: APBJJlHmWGng2mD7r+HORvYbViNahHExZyfg9AnaCMkhuF9zAe2z+T72MtBm8rxbTIBepY55dKGlDw== X-Received: by 2002:a25:2547:0:b0:d0b:f845:c831 with SMTP id l68-20020a252547000000b00d0bf845c831mr5748800ybl.13.1690258911713; Mon, 24 Jul 2023 21:21:51 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::16]) by smtp.googlemail.com with ESMTPSA id h9-20020a25b189000000b00d0db687ef48sm1175540ybj.61.2023.07.24.21.21.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 21:21:51 -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 v7 21/31] loongarch: Convert various functions to use ptdescs Date: Mon, 24 Jul 2023 21:20:41 -0700 Message-Id: <20230725042051.36691-22-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230725042051.36691-1-vishal.moola@gmail.com> References: <20230725042051.36691-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: BC0821C000B X-Stat-Signature: 6a3roawsiqb94jhr3bdi8raxohdp3ea8 X-Rspam-User: X-HE-Tag: 1690258912-464728 X-HE-Meta: U2FsdGVkX182h8odw5uzktF/VrsSsMEb5wRmVu4SoHrNdK6w+N6TcxpBVgXsjE0xXV91b19nSaOGRP6OCoW/I4kdD8jBtA3uHRMpUAFsw3y72PjuSyufs5wmbgqWF0rH6O97NmQgKx+yXUG8EW3mG1+WJfHYcF0MSn06kGuxCtWzMIRl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dro5gJTCxkus24z8hEr2HQdNRTnaYN2W8U9+gneCdru7rYPLTPxNGJcGYHDfSjhaIKOIzfsm29piHYK8ADmcbTISCksWRvO7cjR748G4H48mRckO1uhY+9XeydZrIdVjNbmSeccvCD3dLCv9C/72E8gYlkeW8oT+GBiqKE05x7QfDARv71hvHgs9SF+E2jMGdwkcnw6q3pqzWES57Q9Sw8wWHn7lZe1Pvuxtg9w2mV0lUTQFWPtQQ/+pkPnB0i0JMnNDIAbJIsSsvXNMMbMkxmFnyuEMsv7pVyLURdBHrYu5GofLGb6Pw7U4KiND+goxmbSQ== 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,