From patchwork Tue Jul 25 04:20:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13325736 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 D8C10C41513 for ; Tue, 25 Jul 2023 04:21:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D59FD900006; Tue, 25 Jul 2023 00:21:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D302F900002; Tue, 25 Jul 2023 00:21:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BF777900006; Tue, 25 Jul 2023 00:21:56 -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 B0588900002 for ; Tue, 25 Jul 2023 00:21:56 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8C3A280818 for ; Tue, 25 Jul 2023 04:21:56 +0000 (UTC) X-FDA: 81048836232.03.9FB5114 Received: from mail-yb1-f169.google.com (mail-yb1-f169.google.com [209.85.219.169]) by imf11.hostedemail.com (Postfix) with ESMTP id C691E40007 for ; Tue, 25 Jul 2023 04:21:54 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=PXib1Cao; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.169 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=1690258914; 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=PAg5qbCpsu4QeXC2CiYcNVSx9jEaugPagVbNncebk84=; b=EWm5/RxZ/aKtO2zSCmVjeK4LdSS/08s0qG/oFP0kpYay56bJhP2Ev0IPvxquicED6UkVaE ncVrFLrEWb+zAJeIcw+CSMkJep3jDIwTRl/8ZO/i45RDsd36kX/QFxi0mjVXR0J64KIsAG aTC6kmb/HC0OnXK9uijRntM+4suSrVo= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=PXib1Cao; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf11.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.169 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690258914; a=rsa-sha256; cv=none; b=t1k+HXQG08ZJ6PerG4Oy9hsoRXDi22DxZP2YRz0psbO1ycziUt95/alchu7HJqUkRIdOpY kT0vsE60VQN/d13U1HX2+7v8tmOlIc8q9VSscO9kO/qqYPEI6OmNFkWVq8RabdQZsyhVrY i6stWAs1cPIewwBa1e3YLVKoFvE9wRQ= Received: by mail-yb1-f169.google.com with SMTP id 3f1490d57ef6-d16639e16e6so691892276.3 for ; Mon, 24 Jul 2023 21:21:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690258914; x=1690863714; 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=PAg5qbCpsu4QeXC2CiYcNVSx9jEaugPagVbNncebk84=; b=PXib1CaoeptK69/6qIILztnTaPIyTv5YQR6TlThXrcj/XpnovRKNC9dRvmGTlMVJ+Y 8clpfWi14Fbd16+bMMcIRSu1RjPFhxm0HGFSqSbVNLXv71Rm3nby7GTQmmhFhxR6Fe4W a+uFGPq1sDojuKpfGHqkLm54qltGyV31LmZTGF+k48o1qYH0m7DJawnWKwrZ6fgwSg9U SkV3boxZmuDGmlSDQsQA0yQXTmRpMU2gDvzpay51JFwtkFxUR2TcnLVayYqi4qXpl0OW +6iL34M/ESeTyP1F7hG3vKsG74iuD4sY6ImSrnr2BOLiIrK5HdmfLQg1v5h+YsRalPF6 ymFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690258914; x=1690863714; 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=PAg5qbCpsu4QeXC2CiYcNVSx9jEaugPagVbNncebk84=; b=i1a6nj6AyJWlZVNrPH7OBVoEdrpdmsj6d3OCB2Ydk9DY2lJUoi1QYlvAIET/RnEiQ3 FSfi5Etox54l/jD0mim2bcA1ge6FzbD/cmGJ7zx+9A8DxuvWIu8g79kdCKmHQ5V0ZDaY Q1YkV2r/Y2PAivuw2F/ccL+8fW/HMXmSDQB8aVt15zJCeHFIx2BbqAXGVGLosVCyo73l dxSKZJ81CgS7EEaqBjid2Kw3f0+2eQLF5ifZEprkAWdnE69+N6f82IvQ72iwkTQmppHF 2IHTsPX020P7NbLPktQJBm2Q/3eJRs3hIJcm+V5EMfQp9pDqg90P4lq8yX3Il4YXeCeG SrjA== X-Gm-Message-State: ABy/qLaeNy3wL8qvoMM9JHi1BSqQrKL4KksEay1JthO7lSt1hwiY4RHn t/9CWwNDBaWdsA1QB55I7s720ZC1a8wlTg== X-Google-Smtp-Source: APBJJlHF/0iqvuKN3GeuQCQLqa/Csn12p4p6+Y/7f8hKrU53tH/yWNA7sehk6j4tDPYcgh4VwiCADg== X-Received: by 2002:a25:d57:0:b0:d06:7064:5209 with SMTP id 84-20020a250d57000000b00d0670645209mr6311982ybn.22.1690258913820; Mon, 24 Jul 2023 21:21:53 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 24 Jul 2023 21:21:53 -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)" , Mike Rapoport , Geert Uytterhoeven Subject: [PATCH mm-unstable v7 22/31] m68k: Convert various functions to use ptdescs Date: Mon, 24 Jul 2023 21:20:42 -0700 Message-Id: <20230725042051.36691-23-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: rspam09 X-Rspamd-Queue-Id: C691E40007 X-Stat-Signature: g787xbc96iakedf5he3oznss98goewqf X-Rspam-User: X-HE-Tag: 1690258914-558882 X-HE-Meta: U2FsdGVkX1+cVmyhB59Dc+Pv8Avkk7tmCZcTGejBxIIZtT0WDecZlr5SL2uPqzXtlcRMWwq0GKnGfAorsBX7i6OGUmxi6UZBjWCwyNYCq3uSPYFz8jaijV3oEVoO1fpM/LrnORgtXxBsggZHh1ImWnzpma0hsOTyS+zaII8UmFdlGH2j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zfsaCBT4I3HrlJ588nm/T7H0mMQWT31aAbRS9DLTk0NiR2w378poiea5o0Q7URyoJIXOEyIXAMCuUJccHd/rfE0VGnSee/bsIUUjBbxqTTkMo7Xj5D1hfcoey9c/HlTsl/XXi0/2mzudbxC86Ssm+YS1n1QqzYzDdKYMnwIL5+YlL8DYN8OAppbx6slScQEAV0/qeQzMABuM1XAUM2oDg2RJWobv1G9OFKVWjJXYNxS1a+oMeSsCjjFMYJInBdTiiz5PBzTng/Zqr2GPjS/FEBLRE+EhjZ08w7jOdgo1E9ihgRe99qJXOpAr3Jef56tyhDOOSG/wJlaVbCzNxszuwSnwDSp2dtZYmVkF6Zc4hDMc7nK0FQxuCMCz8VjVgF/uOgWQElDjVHnUTA== 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) Acked-by: Geert Uytterhoeven --- arch/m68k/include/asm/mcf_pgalloc.h | 47 ++++++++++++++-------------- arch/m68k/include/asm/sun3_pgalloc.h | 8 ++--- arch/m68k/mm/motorola.c | 4 +-- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/arch/m68k/include/asm/mcf_pgalloc.h b/arch/m68k/include/asm/mcf_pgalloc.h index 5c2c0a864524..302c5bf67179 100644 --- a/arch/m68k/include/asm/mcf_pgalloc.h +++ b/arch/m68k/include/asm/mcf_pgalloc.h @@ -5,22 +5,22 @@ #include #include -extern inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) +static inline void pte_free_kernel(struct mm_struct *mm, pte_t *pte) { - free_page((unsigned long) pte); + pagetable_free(virt_to_ptdesc(pte)); } extern const char bad_pmd_string[]; -extern inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm) +static inline pte_t *pte_alloc_one_kernel(struct mm_struct *mm) { - unsigned long page = __get_free_page(GFP_DMA); + struct ptdesc *ptdesc = pagetable_alloc((GFP_DMA | __GFP_ZERO) & + ~__GFP_HIGHMEM, 0); - if (!page) + if (!ptdesc) return NULL; - memset((void *)page, 0, PAGE_SIZE); - return (pte_t *) (page); + return ptdesc_address(ptdesc); } extern inline pmd_t *pmd_alloc_kernel(pgd_t *pgd, unsigned long address) @@ -35,36 +35,34 @@ extern inline pmd_t *pmd_alloc_kernel(pgd_t *pgd, unsigned long address) static inline void __pte_free_tlb(struct mmu_gather *tlb, pgtable_t pgtable, unsigned long address) { - struct page *page = virt_to_page(pgtable); + struct ptdesc *ptdesc = virt_to_ptdesc(pgtable); - pgtable_pte_page_dtor(page); - __free_page(page); + pagetable_pte_dtor(ptdesc); + pagetable_free(ptdesc); } static inline pgtable_t pte_alloc_one(struct mm_struct *mm) { - struct page *page = alloc_pages(GFP_DMA, 0); + struct ptdesc *ptdesc = pagetable_alloc(GFP_DMA | __GFP_ZERO, 0); pte_t *pte; - if (!page) + if (!ptdesc) return NULL; - if (!pgtable_pte_page_ctor(page)) { - __free_page(page); + if (!pagetable_pte_ctor(ptdesc)) { + pagetable_free(ptdesc); return NULL; } - pte = page_address(page); - clear_page(pte); - + pte = ptdesc_address(ptdesc); return pte; } static inline void pte_free(struct mm_struct *mm, pgtable_t pgtable) { - struct page *page = virt_to_page(pgtable); + struct ptdesc *ptdesc = virt_to_ptdesc(pgtable); - pgtable_pte_page_dtor(page); - __free_page(page); + pagetable_pte_dtor(ptdesc); + pagetable_free(ptdesc); } /* @@ -75,16 +73,19 @@ static inline void pte_free(struct mm_struct *mm, pgtable_t pgtable) static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) { - free_page((unsigned long) pgd); + pagetable_free(virt_to_ptdesc(pgd)); } static inline pgd_t *pgd_alloc(struct mm_struct *mm) { pgd_t *new_pgd; + struct ptdesc *ptdesc = pagetable_alloc((GFP_DMA | __GFP_NOWARN) & + ~__GFP_HIGHMEM, 0); - new_pgd = (pgd_t *)__get_free_page(GFP_DMA | __GFP_NOWARN); - if (!new_pgd) + if (!ptdesc) return NULL; + new_pgd = ptdesc_address(ptdesc); + memcpy(new_pgd, swapper_pg_dir, PTRS_PER_PGD * sizeof(pgd_t)); memset(new_pgd, 0, PAGE_OFFSET >> PGDIR_SHIFT); return new_pgd; diff --git a/arch/m68k/include/asm/sun3_pgalloc.h b/arch/m68k/include/asm/sun3_pgalloc.h index 198036aff519..ff48573db2c0 100644 --- a/arch/m68k/include/asm/sun3_pgalloc.h +++ b/arch/m68k/include/asm/sun3_pgalloc.h @@ -17,10 +17,10 @@ extern const char bad_pmd_string[]; -#define __pte_free_tlb(tlb,pte,addr) \ -do { \ - pgtable_pte_page_dtor(pte); \ - tlb_remove_page((tlb), pte); \ +#define __pte_free_tlb(tlb, pte, addr) \ +do { \ + pagetable_pte_dtor(page_ptdesc(pte)); \ + tlb_remove_page_ptdesc((tlb), page_ptdesc(pte)); \ } while (0) static inline void pmd_populate_kernel(struct mm_struct *mm, pmd_t *pmd, pte_t *pte) diff --git a/arch/m68k/mm/motorola.c b/arch/m68k/mm/motorola.c index c75984e2d86b..594575a0780c 100644 --- a/arch/m68k/mm/motorola.c +++ b/arch/m68k/mm/motorola.c @@ -161,7 +161,7 @@ void *get_pointer_table(int type) * m68k doesn't have SPLIT_PTE_PTLOCKS for not having * SMP. */ - pgtable_pte_page_ctor(virt_to_page(page)); + pagetable_pte_ctor(virt_to_ptdesc(page)); } mmu_page_ctor(page); @@ -201,7 +201,7 @@ int free_pointer_table(void *table, int type) list_del(dp); mmu_page_dtor((void *)page); if (type == TABLE_PTE) - pgtable_pte_page_dtor(virt_to_page((void *)page)); + pagetable_pte_dtor(virt_to_ptdesc((void *)page)); free_page (page); return 1; } else if (ptable_list[type].next != dp) {