From patchwork Mon May 1 19:28:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13227945 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 E512EC77B73 for ; Mon, 1 May 2023 19:29:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5BB6A280018; Mon, 1 May 2023 15:29:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F486280002; Mon, 1 May 2023 15:29:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D0F3280018; Mon, 1 May 2023 15:29:15 -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 1DFE7280002 for ; Mon, 1 May 2023 15:29:15 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id E59D11C706C for ; Mon, 1 May 2023 19:29:14 +0000 (UTC) X-FDA: 80742674628.08.E5491F7 Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) by imf22.hostedemail.com (Postfix) with ESMTP id 209F3C0013 for ; Mon, 1 May 2023 19:29:12 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=bIC3wiMr; spf=pass (imf22.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.170 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=1682969353; 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=kyicI3UFSJTH3R33HGjLFGEyUDrTPXlIkqJCgIfzdrc=; b=CbTjAdjUrb+sH1SZQYx1lFK9BfLNZ5u0uHHucPz/IGcwo6UNr5NnSe1SHQ33MKKGRHxqfB 26tmmHI+clx4AjrgrB3Hrv/jgUWH+U/1P87IYjboBg6PC5l0qiWT12JcMrILTFO5kvzCOV od5rKQvQUgknic/w9r/CqF93CNkRmX4= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=bIC3wiMr; spf=pass (imf22.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.170 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=1682969353; a=rsa-sha256; cv=none; b=1Iva0lGmc0qRgrJiZAjG+9rZXQhKipwIjtKcdNOmaLE61wTa/MTGF9RxYwMJ4fEf0Amc4J kOeUbCptZVGp3uPYUudJLjEcGA26o+6S2G8KpUe3Sy4aj/GjsDJzezPZwMJjzgBkf26p+Q EZl7QXUoGP6Z1jm871PjTe6YIdjDhvU= Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1a6ebc66ca4so21091485ad.3 for ; Mon, 01 May 2023 12:29:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682969352; x=1685561352; 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=kyicI3UFSJTH3R33HGjLFGEyUDrTPXlIkqJCgIfzdrc=; b=bIC3wiMrkZ043YRG29tisEfS2j+UeOAsmyII3EDzrldtjEb8icghvzgUTYdQYM4doj vdu0JKDKQcL03t0/j67MJsK3EMdVvlx3Lc/9NrJJJYh+5KdPrYzRKBiHtTGqpBRhkA5a ZboUsEenHMS9VrUn3gKI66CrCL9Z8GCruZLIMyl89zj2oR4Tg7uJGI/BsPQUk9uXq4w7 IEqVWzOt4YqC8i9AxlAbu1JP49n5XnekAOLER4FSWBBd0M0ka47bttpu+oGYYPDkowKQ ep35YwloCTCGYeII4Pobz7D0t4NcJCq50AMppyxrvfN/Wt0IBRqMUSxoDgh1JHSYp5Pm g50g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682969352; x=1685561352; 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=kyicI3UFSJTH3R33HGjLFGEyUDrTPXlIkqJCgIfzdrc=; b=YxcWqlS0/ynq4FHzgW91+Mw7Gipm5ha8Vd2EfbnJDL6GqOS4uZSY/mQeVWdi+7cwMy 0hWIoTzP3vgyKMADEq5n39HoGl2NdLs0dJWq3gzhUm6MKIA+6IvELqnWTK/w3HNWcwGF oBLUJvxWb72Wko/UtLmIAoJim7bYBeNCiIvGNrK5lq6BSAdQnmUGzYQgsOzJxLMa0peh LFe2e1mBWllqlNNqWzl+8NRi8moNR+qg+Flk0YfpE8GYahXjTQcnR0AGGnstGrftRTAY D4nLwb446rHq5htYhCsnzcrLO+aLPJ678/09IK0L4jz4V283sq6hUy/naVyygzLB1uRw O8Og== X-Gm-Message-State: AC+VfDx+Ms2t13kB4vgT0JGEIqePc/3JAFQF8AlarHI0FLES/27NJ/dM F3gkGxQiZZxn47LJq6GfV4w= X-Google-Smtp-Source: ACHHUZ6JGwiASceIv2N+eQzagLfWHlR6lj5LsM9PIBmbvfqlnJYs1oK6NLyKl7E/zGC8k10AZHOifw== X-Received: by 2002:a17:902:ea0b:b0:1a6:3b9c:7fea with SMTP id s11-20020a170902ea0b00b001a63b9c7feamr19311944plg.36.1682969351902; Mon, 01 May 2023 12:29:11 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::9a2c]) by smtp.googlemail.com with ESMTPSA id u8-20020a170902bf4800b0019c13d032d8sm18175622pls.253.2023.05.01.12.29.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 12:29:11 -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, "Vishal Moola (Oracle)" , Thomas Bogendoerfer Subject: [PATCH v2 26/34] mips: Convert various functions to use ptdescs Date: Mon, 1 May 2023 12:28:21 -0700 Message-Id: <20230501192829.17086-27-vishal.moola@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501192829.17086-1-vishal.moola@gmail.com> References: <20230501192829.17086-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 209F3C0013 X-Stat-Signature: ze8jmsf6tnfro93apm96bfzrrsconiec X-Rspam-User: X-Rspamd-Server: rspam08 X-HE-Tag: 1682969352-477165 X-HE-Meta: U2FsdGVkX1/wzIO/hoYLDID/wr6n7WRLJWvXqq8v32to4T9z3bG+OQs5CMKB/3iRlfYQnRWIxEwxyzbspe/Yy/AblT02pqxnmXjaRVl/c4/mRFUVMGLChHBOWAJCY45yJ9a0mJAYr3bHziyzyQl5/p1U6VU20/nPCG5Swbh7Y5G3lXN6NcBIwgvoOQUyJGVuVzAst1GxtmpIJ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UPuemvO2MBHe+PmgxpyZskALbt3qLswApGoV3D7jyMUohVTZhosbeqP1SiMglDBarD71lG+6xU9tQ7Z1YBM1WjibIxfTy70hG5XcWcxxRQh+koS9wvmb6uPtPYKcoNlZil4yuzCyvQQwoX8vPES/4Vmt6Mi7nV9gH1wJen644N/R/HMDhskz5stwllo4GAUI5fnP1ziL25Tcx0LfEK+VHEAZF1sX6f30cDLKlUv+TIGgmA== 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 ptdesc_alloc() and ptdesc_address() instead to help standardize page tables further. Signed-off-by: Vishal Moola (Oracle) --- arch/mips/include/asm/pgalloc.h | 31 +++++++++++++++++-------------- arch/mips/mm/pgtable.c | 7 ++++--- 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/arch/mips/include/asm/pgalloc.h b/arch/mips/include/asm/pgalloc.h index f72e737dda21..7f7cc3140b27 100644 --- a/arch/mips/include/asm/pgalloc.h +++ b/arch/mips/include/asm/pgalloc.h @@ -51,13 +51,13 @@ extern pgd_t *pgd_alloc(struct mm_struct *mm); static inline void pgd_free(struct mm_struct *mm, pgd_t *pgd) { - free_pages((unsigned long)pgd, PGD_TABLE_ORDER); + ptdesc_free(virt_to_ptdesc(pgd)); } -#define __pte_free_tlb(tlb,pte,address) \ -do { \ - pgtable_pte_page_dtor(pte); \ - tlb_remove_page((tlb), pte); \ +#define __pte_free_tlb(tlb, pte, address) \ +do { \ + ptdesc_pte_dtor(page_ptdesc(pte)); \ + tlb_remove_page_ptdesc((tlb), page_ptdesc(pte)); \ } while (0) #ifndef __PAGETABLE_PMD_FOLDED @@ -65,18 +65,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_pages(GFP_KERNEL_ACCOUNT, PMD_TABLE_ORDER); - if (!pg) + ptdesc = ptdesc_alloc(GFP_KERNEL_ACCOUNT, PMD_TABLE_ORDER); + if (!ptdesc) return NULL; - if (!pgtable_pmd_page_ctor(pg)) { - __free_pages(pg, PMD_TABLE_ORDER); + if (!ptdesc_pmd_ctor(ptdesc)) { + ptdesc_free(ptdesc); return NULL; } - pmd = (pmd_t *)page_address(pg); + pmd = (pmd_t *)ptdesc_address(ptdesc); pmd_init(pmd); return pmd; } @@ -90,10 +90,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 = ptdesc_alloc(GFP_KERNEL, PUD_TABLE_ORDER); - pud = (pud_t *) __get_free_pages(GFP_KERNEL, PUD_TABLE_ORDER); - if (pud) - pud_init(pud); + if (!ptdesc) + return NULL; + pud = (pud_t *)ptdesc_address(ptdesc); + + pud_init(pud); return pud; } diff --git a/arch/mips/mm/pgtable.c b/arch/mips/mm/pgtable.c index b13314be5d0e..d626db9ac224 100644 --- a/arch/mips/mm/pgtable.c +++ b/arch/mips/mm/pgtable.c @@ -10,10 +10,11 @@ pgd_t *pgd_alloc(struct mm_struct *mm) { - pgd_t *ret, *init; + pgd_t *init, *ret = NULL; + struct ptdesc *ptdesc = ptdesc_alloc(GFP_KERNEL, PGD_TABLE_ORDER); - ret = (pgd_t *) __get_free_pages(GFP_KERNEL, PGD_TABLE_ORDER); - 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,