From patchwork Mon Jun 12 21:04:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13277369 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 840A2C7EE43 for ; Mon, 12 Jun 2023 21:05:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0BE2394001E; Mon, 12 Jun 2023 17:05:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 070D594001D; Mon, 12 Jun 2023 17:05:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E532D94001E; Mon, 12 Jun 2023 17:05:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id C872894001D for ; Mon, 12 Jun 2023 17:05:39 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 954DEA030A for ; Mon, 12 Jun 2023 21:05:39 +0000 (UTC) X-FDA: 80895327198.08.2CC5B2C Received: from mail-yw1-f169.google.com (mail-yw1-f169.google.com [209.85.128.169]) by imf09.hostedemail.com (Postfix) with ESMTP id CCF9C14001D for ; Mon, 12 Jun 2023 21:05:37 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=QRoyvLYE; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.169 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=1686603937; 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=YznDncwA9GAqykzg54RX0MBNzB2zliFPfcggpr0Eh4s=; b=hLFVp7SIs6L8sFt6a7MBWBD6KknXfBoQy5bGwI23YWRccr0C7ojlMGnjVXWYSV9xQuWc/Z 4WuRbDqn9aFGfCP7sRtwTjd9V613iQfjCjrHl5hJahatmzFCWrfBaT/ZMw8EQQ39fvcDNJ AxBx1B138ayaNUAD+d5gR531IsJOsQY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686603937; a=rsa-sha256; cv=none; b=IHfxZ7kdeNdgbQ73UUQmUBHQXGN+hZEqieZZdtL97nQJpwVxvYKm3bXPLNuArCMxvz29Fe Ba7lez+v5brP2vEtK7QPdK3NbmSWfIc2iB4c1/RgQrgeAfWHBb0BXdGfGEWzCxX8n+IUFF K3gKgmB2uoPL9FGUL0QeanVrIKf5/EY= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=QRoyvLYE; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.169 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-yw1-f169.google.com with SMTP id 00721157ae682-56d304e5f83so13125787b3.2 for ; Mon, 12 Jun 2023 14:05:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686603937; x=1689195937; 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=YznDncwA9GAqykzg54RX0MBNzB2zliFPfcggpr0Eh4s=; b=QRoyvLYEgxL/2kCjPdtGz5QAOI77H8loVEKJnu5DXjBhTeuZzXSW3sH87LjUK8GXq+ Ni0/ms01raOgbTyNhkKSK5xptFnCpOw51bCuMschp5irMPmkXquXQTS+FYmXtEVbn5yM l55Cew9WZd/PGf5LMSokC+rcq8ZKIRncx7ECXqQGG+tKKnAOMwOtO9dyfKSmSCaex2iX 2NivJzP5rq2hVV/YjxU2wV6J9nj+kvJCVEu9BAqcy2HzczmnbJeIkP/KaaT6YTF9TAWb AjjacshjGjPtqwSZWAawzFFfrAAsEWLFLRmKLAa65IfKQVb6IUHRo6JGUNBf25tg/BiS TUvQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686603937; x=1689195937; 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=YznDncwA9GAqykzg54RX0MBNzB2zliFPfcggpr0Eh4s=; b=Sf3VOr7qTvKXKK5BRWPosT345ZTodp4Yjhv6J1Jv0mVkGzj8ax5oTIvCJfIZET/BKN PcEutTXaTefLLIt9fCTX+5ENey7pe2xr5VLAV/ZuD0t84N/+gllDdQNMVidThHp8Cv7A wT0GY5XVhpiDfxy4KqM4I/+ex+HkKCV0POli/5GY9p/S0J+/s9FQJ1GNVOA2DRuM7hfH Wkp1xQfWix0h78CFABZ34MLCBsYZTHwCzrbstSwkCa0h71XuW2JwcrBrTxZsLf6qkz6E kzXBu9QC9a9qrdKEb17jshTujPETptdaIS/4idZvpnZzpRUelU0zv5bl1W4DthNlesgz HwFA== X-Gm-Message-State: AC+VfDyT81WCoB4pRn1NqyPxO/37oKFtX4DzcyeSL4FdND/K1h2NkpYR 8BfDhCDf4+sjm6woDxpeFv4= X-Google-Smtp-Source: ACHHUZ6CPRZy4B1gHWQwGyL1jpWh6RHuanx0k7sKCLWXZpcFJmn4wjrQVTLXrK9+FDMtZqXPjFpwgg== X-Received: by 2002:a0d:cb4e:0:b0:56c:f32d:1753 with SMTP id n75-20020a0dcb4e000000b0056cf32d1753mr9075881ywd.44.1686603936731; Mon, 12 Jun 2023 14:05:36 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::16]) by smtp.googlemail.com with ESMTPSA id s125-20020a817783000000b00569eb609458sm2757115ywc.81.2023.06.12.14.05.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 14:05:36 -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 Subject: [PATCH v4 25/34] m68k: Convert various functions to use ptdescs Date: Mon, 12 Jun 2023 14:04:14 -0700 Message-Id: <20230612210423.18611-26-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230612210423.18611-1-vishal.moola@gmail.com> References: <20230612210423.18611-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Stat-Signature: 3wnmzgrujmxji1frb49yjjgg1p9p9i4p X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: CCF9C14001D X-Rspam-User: X-HE-Tag: 1686603937-29603 X-HE-Meta: U2FsdGVkX19JMAhJtTBLayHRZa69HDoGubVVJp77Kw+03YzFTzqRGWxJ0WFVbCWUUIg0aSIG2hOUVIrOYKQtEHjEYCxUQjwlstFQ+DteAtrPtgovtjkJRRJW8PK2yv92AUvtwnv0caReGKJBiFRtJTSQNhWal1YByzIAnesmt12/EgB6UcPtpqi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q8g+T1cDayqBSnmOphr5pQ56KSK9RftvFnjFEOGv5cd2lFP+WhRB1w93DhMaLUfjDKgPW/4RcBOuG9kDzCEUOH7YtszCRP2hUoqjMn2mYlpu036LYyp7X9nU6jCDfEYYWmBfGmcG8cujzx4b//F0wwVp2CMGb+3wj7mvoCVZdTp1U7qD5IkxEclg8yizWrnYRjM2iQn7ppENPUlPETXo85DwJAsiiniaPfMcz6YiQxCXDcGOzGlfudpSrTmOtbubg== 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: Geert Uytterhoeven Acked-by: Mike Rapoport (IBM) --- arch/m68k/include/asm/mcf_pgalloc.h | 41 ++++++++++++++-------------- arch/m68k/include/asm/sun3_pgalloc.h | 8 +++--- arch/m68k/mm/motorola.c | 4 +-- 3 files changed, 27 insertions(+), 26 deletions(-) diff --git a/arch/m68k/include/asm/mcf_pgalloc.h b/arch/m68k/include/asm/mcf_pgalloc.h index 5c2c0a864524..857949ac9431 100644 --- a/arch/m68k/include/asm/mcf_pgalloc.h +++ b/arch/m68k/include/asm/mcf_pgalloc.h @@ -7,20 +7,19 @@ 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, 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 +34,36 @@ 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, 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); + pagetable_clear(pte); 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 +74,18 @@ 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, 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) {