From patchwork Mon May 1 19:28:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13227933 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 4DB34C77B73 for ; Mon, 1 May 2023 19:29:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C4B4628000D; Mon, 1 May 2023 15:28:56 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BD3DE28000C; Mon, 1 May 2023 15:28:56 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A747D28000D; Mon, 1 May 2023 15:28:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 9432D28000C for ; Mon, 1 May 2023 15:28:56 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id EACAB160824 for ; Mon, 1 May 2023 19:28:55 +0000 (UTC) X-FDA: 80742673830.10.BDCC879 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) by imf13.hostedemail.com (Postfix) with ESMTP id 2E64320018 for ; Mon, 1 May 2023 19:28:54 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=B5BQ0PUP; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.175 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=1682969334; 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=ZNft63XW9H/x5zK6HuCJK1zZ20bn1woHqcJTdinQF34=; b=5FH1nh+G5WyU11Oo87ffvJUkJsT5g/rNqBLRIiE+56h4V4qkYJsHWp/dN8N5J2vxb43COk 98UU0ndVinsrZ51YQcR3BCcM9hAeAFt1LFLQi0lqznIVqs9iu/gF6nmMniHd9172jPLl+w XvKp+rroGy185pdqOy4Ok2RfmZt8yZY= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=B5BQ0PUP; spf=pass (imf13.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.175 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=1682969334; a=rsa-sha256; cv=none; b=znhpK8lYJxX22BuMnbYaEaNE6UPSyQKxvXRDAn/Dk4DeIjaFiTKFNvBrnpGk95i645nPxs BUTlqB3ZVlu4zEIHUw64VlkKWAxcO6Jr5Uc9xARsj3pnMF+3yFwM5m+gDdK91QG163n40W im1SfdVA14CIT7zQB4OFX7tWNE28Crw= Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-1aad55244b7so19088465ad.2 for ; Mon, 01 May 2023 12:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682969333; x=1685561333; 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=ZNft63XW9H/x5zK6HuCJK1zZ20bn1woHqcJTdinQF34=; b=B5BQ0PUPuJOe03g2Zj4SmcYFdZoHhvQEhjHjXIrDV/cPLgWmHOnGLph27PMtDy+gUk vrb8aMyrjxs7+rH+bt4rcFQy1jeum2KTcgeZne4eID9YQx0p8xFIvsQDPlXa9T02F5bm XDuuEHyhAFLF/N4HXmu9lHkWjBlAxtCK794Vd1UTAVcPxs1s/UJDMyYjBVgG5TX0KFIE Ex1W8v+MyjG1XFcX2NmMKnrKsIeNEQB+OMbajwZPymWFDvUYoyj1bmkkKVL9eBJZnPmo n2i7pNy6eK/amTh+JnM4F05ImhBvIH/eExR134Xtgm68Uv7no3ItCNvBtZlMVAsp6dYE 5mrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682969333; x=1685561333; 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=ZNft63XW9H/x5zK6HuCJK1zZ20bn1woHqcJTdinQF34=; b=J9yiFCpKRamHOj+4+9qfj9l3/6ZR2j4n4f9UrEl7ZDDw+mrfWleDrceQ5G4mvoQk4i Alpuzhf7w5qdbz/y6ZTLgWH0Q5zqv/SgUWfHx4gLOj3nm5GgFDK8EknulSORU8TtAc16 7YdsXo5fBv7e26iwZzDKayOp9vh6AMLI6ZdJoq7+k7W7I9sW/z3VlHkdmO1ygCB1mxIB GZRv+IZCkZG/lV0gmoy/Hv8Cs1SrhEI+aprh60/Dt0RPNggbPou2HvUJ7UtBdx3qn9oS Cr1NcPHcVt/h22xvRqAS7UsUtItceSjZlNnJb75I42RzL2lgUvMTTe8HCxaOgfFDHppy 1Sug== X-Gm-Message-State: AC+VfDwulpI1IO6Te5zoD5IGR0ijVKam83xmPDQoAE2WA24IZud12Jpn MRM3cG9UGOxew75Mrd609Ao= X-Google-Smtp-Source: ACHHUZ5/VRaG2onpIf15XR/3p6i4VphUhlpU8l14iUMmxT/o+LeZ6COrGbtS8DM/yhDOMNorlLAd2g== X-Received: by 2002:a17:902:d48b:b0:1a6:ef75:3c53 with SMTP id c11-20020a170902d48b00b001a6ef753c53mr18457119plg.11.1682969333517; Mon, 01 May 2023 12:28:53 -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.28.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 12:28: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, "Vishal Moola (Oracle)" Subject: [PATCH v2 14/34] powerpc: Convert various functions to use ptdescs Date: Mon, 1 May 2023 12:28:09 -0700 Message-Id: <20230501192829.17086-15-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-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2E64320018 X-Stat-Signature: ywqg1xdapxh8e8xts68dfmdcqrkzx3nh X-HE-Tag: 1682969334-751515 X-HE-Meta: U2FsdGVkX19jd5Wnl0oHhAT9TWkZW6c4a0dqwn0sq/UAWqgwNjvUYuBLJO45CFZPkW3j/s8gY9sn+QJ8bQoYpkiBEk8pc+si6xppLc84oEpuuiVMEG8p+PM+OWkMqpqyg7Q868o3c6pHtwZXGNUYsLNg8Q4A06Q/ufhZp6uGPAe67UVTIUIKo2eHZ2rPTNT4LWhSubTRzW0fApiCYy8D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xfyzyyxwIditsvXaUt0/UOmYH72UNQVvjkhs4O4dbEY6YAoYPVR+j3pMwHbC3jQdxaeCn058SelXJTSkQS0xQRucZUQ5Po/2G9Pm7e/Frx5UOSZIczi04ygc5Htf5MmRYAZXt9yf+NR41AQ3D9olLjodZuFsdRRi26C6E1GNmhraVmILknwkYRZfg6tlAPlXqyoyHAKAmlOf2lRLejNnXWyjY6y1MdjjsdGvgqlIZELUkqAk7R+nVHVzLyhnjXenkCMwhclgk6/YXU6ntyshvd4j+148 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: In order to split struct ptdesc from struct page, convert various functions to use ptdescs. Signed-off-by: Vishal Moola (Oracle) --- arch/powerpc/mm/book3s64/mmu_context.c | 10 +++--- arch/powerpc/mm/book3s64/pgtable.c | 32 +++++++++--------- arch/powerpc/mm/pgtable-frag.c | 46 +++++++++++++------------- 3 files changed, 44 insertions(+), 44 deletions(-) diff --git a/arch/powerpc/mm/book3s64/mmu_context.c b/arch/powerpc/mm/book3s64/mmu_context.c index c766e4c26e42..b22ad2839897 100644 --- a/arch/powerpc/mm/book3s64/mmu_context.c +++ b/arch/powerpc/mm/book3s64/mmu_context.c @@ -246,15 +246,15 @@ static void destroy_contexts(mm_context_t *ctx) static void pmd_frag_destroy(void *pmd_frag) { int count; - struct page *page; + struct ptdesc *ptdesc; - page = virt_to_page(pmd_frag); + ptdesc = virt_to_ptdesc(pmd_frag); /* drop all the pending references */ count = ((unsigned long)pmd_frag & ~PAGE_MASK) >> PMD_FRAG_SIZE_SHIFT; /* We allow PTE_FRAG_NR fragments from a PTE page */ - if (atomic_sub_and_test(PMD_FRAG_NR - count, &page->pt_frag_refcount)) { - pgtable_pmd_page_dtor(page); - __free_page(page); + if (atomic_sub_and_test(PMD_FRAG_NR - count, &ptdesc->pt_frag_refcount)) { + ptdesc_pmd_dtor(ptdesc); + ptdesc_free(ptdesc); } } diff --git a/arch/powerpc/mm/book3s64/pgtable.c b/arch/powerpc/mm/book3s64/pgtable.c index 85c84e89e3ea..da46e3efc66c 100644 --- a/arch/powerpc/mm/book3s64/pgtable.c +++ b/arch/powerpc/mm/book3s64/pgtable.c @@ -306,22 +306,22 @@ static pmd_t *get_pmd_from_cache(struct mm_struct *mm) static pmd_t *__alloc_for_pmdcache(struct mm_struct *mm) { void *ret = NULL; - struct page *page; + struct ptdesc *ptdesc; gfp_t gfp = GFP_KERNEL_ACCOUNT | __GFP_ZERO; if (mm == &init_mm) gfp &= ~__GFP_ACCOUNT; - page = alloc_page(gfp); - if (!page) + ptdesc = ptdesc_alloc(gfp, 0); + if (!ptdesc) return NULL; - if (!pgtable_pmd_page_ctor(page)) { - __free_pages(page, 0); + if (!ptdesc_pmd_ctor(ptdesc)) { + ptdesc_free(ptdesc); return NULL; } - atomic_set(&page->pt_frag_refcount, 1); + atomic_set(&ptdesc->pt_frag_refcount, 1); - ret = page_address(page); + ret = ptdesc_address(ptdesc); /* * if we support only one fragment just return the * allocated page. @@ -331,12 +331,12 @@ static pmd_t *__alloc_for_pmdcache(struct mm_struct *mm) spin_lock(&mm->page_table_lock); /* - * If we find pgtable_page set, we return + * If we find ptdesc_page set, we return * the allocated page with single fragment * count. */ if (likely(!mm->context.pmd_frag)) { - atomic_set(&page->pt_frag_refcount, PMD_FRAG_NR); + atomic_set(&ptdesc->pt_frag_refcount, PMD_FRAG_NR); mm->context.pmd_frag = ret + PMD_FRAG_SIZE; } spin_unlock(&mm->page_table_lock); @@ -357,15 +357,15 @@ pmd_t *pmd_fragment_alloc(struct mm_struct *mm, unsigned long vmaddr) void pmd_fragment_free(unsigned long *pmd) { - struct page *page = virt_to_page(pmd); + struct ptdesc *ptdesc = virt_to_ptdesc(pmd); - if (PageReserved(page)) - return free_reserved_page(page); + if (ptdesc_is_reserved(ptdesc)) + return free_reserved_ptdesc(ptdesc); - BUG_ON(atomic_read(&page->pt_frag_refcount) <= 0); - if (atomic_dec_and_test(&page->pt_frag_refcount)) { - pgtable_pmd_page_dtor(page); - __free_page(page); + BUG_ON(atomic_read(&ptdesc->pt_frag_refcount) <= 0); + if (atomic_dec_and_test(&ptdesc->pt_frag_refcount)) { + ptdesc_pmd_dtor(ptdesc); + ptdesc_free(ptdesc); } } diff --git a/arch/powerpc/mm/pgtable-frag.c b/arch/powerpc/mm/pgtable-frag.c index 20652daa1d7e..b53e18fab74a 100644 --- a/arch/powerpc/mm/pgtable-frag.c +++ b/arch/powerpc/mm/pgtable-frag.c @@ -18,15 +18,15 @@ void pte_frag_destroy(void *pte_frag) { int count; - struct page *page; + struct ptdesc *ptdesc; - page = virt_to_page(pte_frag); + ptdesc = virt_to_ptdesc(pte_frag); /* drop all the pending references */ count = ((unsigned long)pte_frag & ~PAGE_MASK) >> PTE_FRAG_SIZE_SHIFT; /* We allow PTE_FRAG_NR fragments from a PTE page */ - if (atomic_sub_and_test(PTE_FRAG_NR - count, &page->pt_frag_refcount)) { - pgtable_pte_page_dtor(page); - __free_page(page); + if (atomic_sub_and_test(PTE_FRAG_NR - count, &ptdesc->pt_frag_refcount)) { + ptdesc_pte_dtor(ptdesc); + ptdesc_free(ptdesc); } } @@ -55,25 +55,25 @@ static pte_t *get_pte_from_cache(struct mm_struct *mm) static pte_t *__alloc_for_ptecache(struct mm_struct *mm, int kernel) { void *ret = NULL; - struct page *page; + struct ptdesc *ptdesc; if (!kernel) { - page = alloc_page(PGALLOC_GFP | __GFP_ACCOUNT); - if (!page) + ptdesc = ptdesc_alloc(PGALLOC_GFP | __GFP_ACCOUNT, 0); + if (!ptdesc) return NULL; - if (!pgtable_pte_page_ctor(page)) { - __free_page(page); + if (!ptdesc_pte_ctor(ptdesc)) { + ptdesc_free(ptdesc); return NULL; } } else { - page = alloc_page(PGALLOC_GFP); - if (!page) + ptdesc = ptdesc_alloc(PGALLOC_GFP, 0); + if (!ptdesc) return NULL; } - atomic_set(&page->pt_frag_refcount, 1); + atomic_set(&ptdesc->pt_frag_refcount, 1); - ret = page_address(page); + ret = ptdesc_address(ptdesc); /* * if we support only one fragment just return the * allocated page. @@ -82,12 +82,12 @@ static pte_t *__alloc_for_ptecache(struct mm_struct *mm, int kernel) return ret; spin_lock(&mm->page_table_lock); /* - * If we find pgtable_page set, we return + * If we find ptdesc_page set, we return * the allocated page with single fragment * count. */ if (likely(!pte_frag_get(&mm->context))) { - atomic_set(&page->pt_frag_refcount, PTE_FRAG_NR); + atomic_set(&ptdesc->pt_frag_refcount, PTE_FRAG_NR); pte_frag_set(&mm->context, ret + PTE_FRAG_SIZE); } spin_unlock(&mm->page_table_lock); @@ -108,15 +108,15 @@ pte_t *pte_fragment_alloc(struct mm_struct *mm, int kernel) void pte_fragment_free(unsigned long *table, int kernel) { - struct page *page = virt_to_page(table); + struct ptdesc *ptdesc = virt_to_ptdesc(table); - if (PageReserved(page)) - return free_reserved_page(page); + if (ptdesc_is_reserved(ptdesc)) + return free_reserved_ptdesc(ptdesc); - BUG_ON(atomic_read(&page->pt_frag_refcount) <= 0); - if (atomic_dec_and_test(&page->pt_frag_refcount)) { + BUG_ON(atomic_read(&ptdesc->pt_frag_refcount) <= 0); + if (atomic_dec_and_test(&ptdesc->pt_frag_refcount)) { if (!kernel) - pgtable_pte_page_dtor(page); - __free_page(page); + ptdesc_pte_dtor(ptdesc); + ptdesc_free(ptdesc); } }