From patchwork Mon Jul 31 17:03:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13335123 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 747FDC05052 for ; Mon, 31 Jul 2023 17:04:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 36FA0280074; Mon, 31 Jul 2023 13:04:27 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 2F8696B0185; Mon, 31 Jul 2023 13:04:27 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 198D4280074; Mon, 31 Jul 2023 13:04:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 067706B0184 for ; Mon, 31 Jul 2023 13:04:27 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 93A8B402F0 for ; Mon, 31 Jul 2023 17:04:25 +0000 (UTC) X-FDA: 81072530490.22.9B87617 Received: from mail-yb1-f172.google.com (mail-yb1-f172.google.com [209.85.219.172]) by imf25.hostedemail.com (Postfix) with ESMTP id 5CCFAA000A for ; Mon, 31 Jul 2023 17:04:22 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=SHsXJcCp; spf=pass (imf25.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.172 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=1690823063; 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=bAtPMRIqtsPsPo+3SsIXMGugkDL2ETx5u2L4pNwXY5VfRKh06CxmH6P7hh8PMfIinddScz 3qzlJ0iwZk1VC921dYfZaBgiIQGmBNEh7nrgiK9hURtKZcx0Ea8hxJGZEXCB/BSMlLv/UJ Mdk3j/XULZ60mLx+UtOCZZYRrFYbOTc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690823063; a=rsa-sha256; cv=none; b=6aTjPzaV717irb5kIEP9bDoSRVlb1BDUHmOlYDyK6Z6DV5yVfl9ciH5lSpBxNU88ApWZ6a 6etdo5e03TlGy0tLe2as9A644lPAWZebv4Rs8knC7xCj0eBhy7jCQEpnO7NqZNqBWgmUTj ZXPBMRQAyuR8f+VrvQ34UyYdCZO/XC4= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=SHsXJcCp; spf=pass (imf25.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.172 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-yb1-f172.google.com with SMTP id 3f1490d57ef6-d18566dc0c1so5048015276.0 for ; Mon, 31 Jul 2023 10:04:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690823062; x=1691427862; 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=SHsXJcCphZA5Q35Cm4n8w8dfqoRXj5UgYy95JNrPo0e5bckV50c6jH6lc7xhgkpfP3 LRpLcUVAnaJQDC2fy0cxRx/Sn5zDPk8HnSNMQ1nYTCeGYSjmp0NxEGU8+6AK0ydnCrXo B7huJXPBvLhjK9+NPSK/tK4mNxy6xmRWTGSAELwAb2C+WQkmM4czVeiClgF6xCu0dSVp valgcEUnr6tm5e6DmJ0wAnOlYJfOWUIH/75eKq+AUDCd7EFCR4LkmTx5JiojrlAh0iKl eJnCwnRGsblWEjcAQ70JqqSW1FXw0LcJDzZAr4AakE8Utv/Am0i5qwYjY31XRJqcgYKL 0oHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690823062; x=1691427862; 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=AZKyY3+uBYlcqkH76ZYzy2OSogEKvT2TGi8wl0lC3KB7+QUhjCU9lUzJsZaB1JXAQj VhsQXrFd4cqRh9Ccv8gEEgtyg7ZZfCitj5cmr8ocRV5kHlrNA9ILUk+sOZGWaqNFlxCI GDHoms5qkWomFgTTxoXlffI6Sdy5QeMUp80aXDyIm2NpBj7CFFZqbkmLOgvx4qyBOOpu aW8aGtWtkSkafb/8gf1pxLTTMFJ/gnJDQ+vx2m2VvSQDo9JV9KepLB/lvLuzDwhkp1O1 B6KbDCRNVeLqCCKN0iyC7ekCXhHZp4wleeztWQl8U7xJXdRJwD2CLJEQLyPNcMvD1fKG t1Rg== X-Gm-Message-State: ABy/qLbKNGVY+kUCOWpNDF+F/CYX2f9QH0lw1FK81kwbSE6sN9gqmxzD ubsdWX9DXn8gnfjjEkBIzQE= X-Google-Smtp-Source: APBJJlEK1MlTqpIOoxn7Ar4pWAsbFPg2CXwhdETyczjwWIQSRY3cc8fD4iPGtAg+uKqG+zuVrd170A== X-Received: by 2002:a25:ad4f:0:b0:d13:80a0:b428 with SMTP id l15-20020a25ad4f000000b00d1380a0b428mr10830361ybe.3.1690823062269; Mon, 31 Jul 2023 10:04:22 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 10:04:22 -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 v8 22/31] m68k: Convert various functions to use ptdescs Date: Mon, 31 Jul 2023 10:03:23 -0700 Message-Id: <20230731170332.69404-23-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-Stat-Signature: ubfrm4fga6cmxwcarsa76nngbgsp47zg X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 5CCFAA000A X-Rspam-User: X-HE-Tag: 1690823062-202087 X-HE-Meta: U2FsdGVkX19zil5w7NYOMV/rhBG6h0620ruH1jMQxBfSbJaWWNpGlpRaMfKi8hzSqzw7LhsSGJVkTgioFmySylSTHjJ3C8qSJ5m7LMouWuo9u30ToxgF7mzS+vvBnSfYHu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/wp2XKLDNj1ACDpUdVIaoRfmru6E3pidNn6xbAy5Vhh3LtsL2//qknMv5VwRi0Lupnl+TrhD/HRz6ynhHNkkB558igN4LVsZjZPHtghPzSFv4PnFqVCTqzQb6Mzy2QJW7tsBfMm5JK9iwMDyiZSMdVTyqcpkbhJ0HUv4fmVWH4k8pS8sNwrwSzc37SKguq6ny2EzeXaG9bbQtmsEoHwF01PawHL3Tnvjmoxcn0to0lrkS31v2kMlmZv1HJG2bcLx9nOMWTpgw3HDIesph5baJ8KGPZilw8xohaL8G/BzjNmHuD/kueZa7u1enY5jfo0EWMbaynBsnRXi1pc39pssj2Yr6NDuXwfpc/eSh62vrYQBmUbKpR8nFUNI1XF3D5a+AHrQ7lHQYNnIgE+N+OjN58mgoAbL/QxCn/c3ah7WLQDrnEpuInVRVUCWE0wE/vdrBdW3Q== 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) {