From patchwork Thu Jun 22 20:57:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13289621 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 6222EEB64DA for ; Thu, 22 Jun 2023 20:58:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BB66B8D001A; Thu, 22 Jun 2023 16:58:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B67668D0001; Thu, 22 Jun 2023 16:58:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E0248D001A; Thu, 22 Jun 2023 16:58:48 -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 8F4008D0001 for ; Thu, 22 Jun 2023 16:58:48 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 60AA21C8C0F for ; Thu, 22 Jun 2023 20:58:48 +0000 (UTC) X-FDA: 80931597936.12.5C1F061 Received: from mail-yw1-f178.google.com (mail-yw1-f178.google.com [209.85.128.178]) by imf23.hostedemail.com (Postfix) with ESMTP id 8C8F8140016 for ; Thu, 22 Jun 2023 20:58:46 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=kdBMDjj5; spf=pass (imf23.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.178 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=1687467526; 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=hySW7brzBg7/Cj99gTTdUd3MvFvqZB/M9ynkCaO3FFc=; b=oOOEIrjZbrCTQ1UHizZ/e+3h3ZimZ3aLBaOHmT1EHVng5Ezz7hua4crIMuqCz3hdYnJfvj BCj91qYc9KTcpKnpn4vNkf+7pdw5Ikoa24Gx18m3gG047BpMd5KMl0BrD2GGLZfeM8UG/R Sp3VsuGVQzF6D8PvzKj0SvjtcJxsdRs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687467526; a=rsa-sha256; cv=none; b=InlqpXfHTf/KO2ZWAX+ZMqvpS37e2SIHZUhF8eVxyWlIUVX0dEwbNOcGyeI67SuYhAG0/M tXHjPeNQ2teLZ0wUKuQLfYrtrLLGrpnRXwDwCV4InLBkJpnHDySr5zHtyLH3//C4Z0ZayI 3VwuiQuh2Ur0Ra5dKEDVAtvN1AUnKPI= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=kdBMDjj5; spf=pass (imf23.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-yw1-f178.google.com with SMTP id 00721157ae682-57012b2973eso85136677b3.2 for ; Thu, 22 Jun 2023 13:58:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687467525; x=1690059525; 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=hySW7brzBg7/Cj99gTTdUd3MvFvqZB/M9ynkCaO3FFc=; b=kdBMDjj5wIp60ZYLcmWrdpMg4HGlypB71kW8hDPlIqh35A3b+v1T4Y1ydaWZz/xhee ZA5Wg86cVGIjXA/B7jKyd7KddQnHiyBrO7oSeao90//6ecohToH/3Eu0AvlHwhcP3OFV 2LpxjpRaH/c4lq6Z4eUITJ7RmwHPPRTtaIS3uYsOOd8x22FkyOEoLStjCJ6IEsjRHWMb 9n4Ph82ODGWg2AiQDJBhn0Lv8MIpG0JlDo4by6Q29EoMH8NyeBmUg+qti5r0raRohKmw K67ualO2cW/10KKjteAwcv5HaO3xkHdj+vI7ODmKcr0ceaF2dvSo3pCSjKcanq/h5Cgw ij4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687467525; x=1690059525; 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=hySW7brzBg7/Cj99gTTdUd3MvFvqZB/M9ynkCaO3FFc=; b=XZghfILvJ9HJA9Lu7r1SmOHuW0c5nLoeQ7MR2Fd6nef318dCYSG9008rzLETvauuD1 zI0XGfzjrOGwvd5ccQ81F7iKb1xT9y7k/0DB1kRBD4On/P15434qexg7b6T1HF186MLN bpBCxHiC/E+KbmPaYb/bXYrPurfXH/Jv8Ke4CqAndGkYCJSDlT2KT9oFhZVEGbbSnfri 7r6rEDvyAxKb1gsgq2eZ6l1Rawdl9J6Nb2wCwTEKVjfolrMRnQdMcT/I/1o5dErMDpvW 40ohx2a1VIgssFZqLRS1EJu4e7MXr2z65dqVG6iahkQ/fiIUsAfk5MgT0o61WWWkJHBF 2UwQ== X-Gm-Message-State: AC+VfDwuTUGK+R7Y4Efrs+HouhMFthJxQSUPdrkZBupHiTLJZDy+5QU2 +K7z+D9e9z8D+zc0D+cpios= X-Google-Smtp-Source: ACHHUZ57HMpnicW72R7dp4/5KYNv6JBaVpOvftGFkmzTzwziBVHjkWFtItA58L9caDWgi5cpht4WKg== X-Received: by 2002:a25:ced2:0:b0:bd5:8616:2579 with SMTP id x201-20020a25ced2000000b00bd586162579mr16452165ybe.36.1687467525581; Thu, 22 Jun 2023 13:58:45 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::36]) by smtp.googlemail.com with ESMTPSA id d18-20020a5b0c52000000b00bc501a1b062sm1684937ybr.42.2023.06.22.13.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 13:58:45 -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)" , Geert Uytterhoeven , Mike Rapoport Subject: [PATCH v5 24/33] m68k: Convert various functions to use ptdescs Date: Thu, 22 Jun 2023 13:57:36 -0700 Message-Id: <20230622205745.79707-25-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230622205745.79707-1-vishal.moola@gmail.com> References: <20230622205745.79707-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 8C8F8140016 X-Rspam-User: X-Stat-Signature: qpwj7zoznjp3ab19e9odib6sayfa63hi X-Rspamd-Server: rspam03 X-HE-Tag: 1687467526-927549 X-HE-Meta: U2FsdGVkX1+vBZkXlTvewf3rvZb/kvDHi4glKXn7U4biJxFhyTRZ+jkhtIcq9gqZiJD+K2Rd0/qK4XtoUIYYS1gzQe3eRgcX0gwS5YoBf2occnlnjK1vgRcR3oZhNTtiz/qxHfm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Wy0HIHKjmEwTF6kClW/A4EwRi0unUNyh6ceV+BxYKTeR3xdjD183qM240qdDR/gPrQzGmlyEyLyz80uo8Y3BMbdOaheV/T9MVQiRT1R1lU/X8n5hcM48yG300MY2HAYOoy0p/nesBIQbny9lAIR9mqmH6w1MbsROVSWLLRUgRx+e1zLGD6QtNI6nyt5bJCD1Ymi6V8fGL1TuMFm0cHhPZPVY3pbmVYTwplpl9RBOxyqNm7FCmCz7AOda9hdp3hIm3OcPzwh3o3xCPzFApuOTK2Lf7rTcMtTFJh2IF4ObNXuO5rkiF0ssVaYm7KXNBahcgrQ/Ewbkj7WjCBKGiSLJKzVAEfE4qgneL0DlUxnd4Cn363vIEHjL5GBzK0t9gQo= 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 | 43 ++++++++++++++-------------- arch/m68k/include/asm/sun3_pgalloc.h | 8 +++--- arch/m68k/mm/motorola.c | 4 +-- 3 files changed, 28 insertions(+), 27 deletions(-) diff --git a/arch/m68k/include/asm/mcf_pgalloc.h b/arch/m68k/include/asm/mcf_pgalloc.h index 5c2c0a864524..790ade4e778e 100644 --- a/arch/m68k/include/asm/mcf_pgalloc.h +++ b/arch/m68k/include/asm/mcf_pgalloc.h @@ -7,20 +7,20 @@ extern 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) { - 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) {