From patchwork Mon Jul 31 17:03:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13335117 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 D0354C0729B for ; Mon, 31 Jul 2023 17:04:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7B54E28006F; Mon, 31 Jul 2023 13:04:16 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 764FD6B0180; Mon, 31 Jul 2023 13:04:16 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5698328006F; Mon, 31 Jul 2023 13:04:16 -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 41CC86B0180 for ; Mon, 31 Jul 2023 13:04:16 -0400 (EDT) Received: from smtpin20.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id F1B03C01AD for ; Mon, 31 Jul 2023 17:04:15 +0000 (UTC) X-FDA: 81072530112.20.052CCA8 Received: from mail-oi1-f169.google.com (mail-oi1-f169.google.com [209.85.167.169]) by imf03.hostedemail.com (Postfix) with ESMTP id 0DBDB20085 for ; Mon, 31 Jul 2023 17:04:02 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=b+RH2hQL; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.167.169 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690823043; a=rsa-sha256; cv=none; b=qJ/QV2W6ltKFOtRk80o4cf4WXZ9Ds6w2FLDzm1qRLb2sqtg8NGCLDKw49e2RqiE1mWCq/C q6JTWNyOX/sUyRNP15CGck5258JUdA2lqxkTmJx2hwxb1Ke9eXK9xxaP2eqgMpNQAgVc2N murHY3fCJyuZmYgy4aEvavFBsX+d590= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=b+RH2hQL; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.167.169 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690823043; 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=9sW6ZvuXfbFTHYep83+z5KceXKUDE808r1Cv8/pw/I4=; b=7NlhrIGiexe0SCFoerkE8iHwVW/tIOQsX+qZ4PsPFW3BrR7LqLDhxpWHtW90PkO2q4/LG7 VcwVoGqXuINzcrERvadC5lFWD8ZxpY7XWa0G5U+cEGsstzPY0J4pQ1TtoqkUR3jFbHaelB vMqjv3f9R54+7WnotDz6/PaTG3av7dw= Received: by mail-oi1-f169.google.com with SMTP id 5614622812f47-3a6f87b2993so2241813b6e.3 for ; Mon, 31 Jul 2023 10:04:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690823042; x=1691427842; 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=9sW6ZvuXfbFTHYep83+z5KceXKUDE808r1Cv8/pw/I4=; b=b+RH2hQLs0PrVwmTtZEtfUeHXjshu4ts0OsC/tTRMBNL2mI6FVIeJ+HO2sJc9CHbAN CYuYEUlC05IcPjkCqLxNke2EK1ijZ05jv63DReY0r2tPeNGvUBJekr+gcoNL1dz8PJ26 /cA4AkNpz6v8HN3tbVp4xFy5RCmhWYIIra7v2cEeHbXn3sfQnBhgAc2yuX2m6lE/+9mA 9y/jmAUWLmB4o1mWve3z/4oUJYIlqq3nVkrOrqW86WuABmDsL4jvWbVffSny/K6W7B5Z rXA6KtaxPm6aezMEUN+nLjZwW5J7C1GsPuTnmHV2MzYNOQ2wNdnkfwDaXHstMJLOGYKi Q3BA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690823042; x=1691427842; 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=9sW6ZvuXfbFTHYep83+z5KceXKUDE808r1Cv8/pw/I4=; b=aFA1XV6HyeqbabZ2TkG7cC4Oxjets1yJpeD9+fyvTSYmHmxV6w7tGvht9wzYiEAUKE DSDu2B/+llduMfvzVxxA+ici+E71JauRW38QnBNpXwjmrBQ5uJH5It3whJRYJlAJ1J68 qY9rT9MIuq0a7I4GgrNfxjO3toHMVSjAcQD7Ji+GxexJCpVUQeRkHSPBBM0CJuitk/OK 05nBFhDD5FffgClqSQJmEARRw/1GC/0j7gikCfjZsShi7qA6P84gMayDBJMpb7KkAQZr 5NUvkKmmVBUe//Yanlk8YL/4UTvVyNXv6ulcaZs+LSTIoiJX53T5z099PsV0or+QObd0 So8A== X-Gm-Message-State: ABy/qLY3roVgG6z14RjPvQWElWHS1lUvbIzys2YJ4mjWT47lpMfqrz2S x9i0YAecn+/PiYMBGD82Wew= X-Google-Smtp-Source: APBJJlEBdh+xsvh+Bo5hWO3RkW2wDNeEPqSCLaQ2ijqegBPt3AxvxjSwU8QAdn957rZPqKKKWtbDqg== X-Received: by 2002:a05:6808:b26:b0:3a3:aedd:6b21 with SMTP id t6-20020a0568080b2600b003a3aedd6b21mr10745132oij.39.1690823041847; Mon, 31 Jul 2023 10:04:01 -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.03.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 10:04:01 -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)" , Christophe Leroy , Mike Rapoport Subject: [PATCH mm-unstable v8 12/31] powerpc: Convert various functions to use ptdescs Date: Mon, 31 Jul 2023 10:03:13 -0700 Message-Id: <20230731170332.69404-13-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-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 0DBDB20085 X-Stat-Signature: btbxfwoyrjoxa5a5hu1pgf6p6wubf3bf X-HE-Tag: 1690823042-471348 X-HE-Meta: U2FsdGVkX1+JOTPKTBMDAF9GKsZR2eCvT7J5b8twJ4SSKErLHRNj3Qa4PnGClCs7sktZYy+usPuoE1siOcM1wWr8FgSuUmMiw81lVldsBeJ2CTjf2puwm86DuSdmxuqCK0rbsxHM5aLc0viKqJ6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ZYstl34t+gApEJAjgBNYHYQZPEcU+cObLPIaDGEQ5EU+jWY49be3GOIF6b2OYodAWnAYO0pFEeCdUy9GqfggW37RSflOKXgkcuxOppp0QuUKpZ/4yJmolMYMPIoY4154nCynJUbOKxEG5C1BpaVRkxPh6udxKVqgA9LOGKjbRmwOQa7JJ97CceEF6R+JctbQ1KewkR0ZVCIrtIP9bjYPErDD8Zj1vhkV+960xSrwntwbLpkz3BVFxI1EizWEDbAOHzgYrOgupfp5Y+Mt2GVhwrg3gMscNCzqrpUsp004V2dAaz0WdngLK00ebjN3+xmGUctSLM7OObP1TOe0YMSgSqtWpiFK4Z67vnhU6orkwIUL+Hqrktg== 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) Acked-by: Mike Rapoport (IBM) --- arch/powerpc/mm/book3s64/mmu_context.c | 10 ++--- arch/powerpc/mm/book3s64/pgtable.c | 32 +++++++------- arch/powerpc/mm/pgtable-frag.c | 58 +++++++++++++------------- 3 files changed, 50 insertions(+), 50 deletions(-) diff --git a/arch/powerpc/mm/book3s64/mmu_context.c b/arch/powerpc/mm/book3s64/mmu_context.c index c766e4c26e42..1715b07c630c 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)) { + pagetable_pmd_dtor(ptdesc); + pagetable_free(ptdesc); } } diff --git a/arch/powerpc/mm/book3s64/pgtable.c b/arch/powerpc/mm/book3s64/pgtable.c index 85c84e89e3ea..1212deeabe15 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 = pagetable_alloc(gfp, 0); + if (!ptdesc) return NULL; - if (!pgtable_pmd_page_ctor(page)) { - __free_pages(page, 0); + if (!pagetable_pmd_ctor(ptdesc)) { + pagetable_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 (pagetable_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)) { + pagetable_pmd_dtor(ptdesc); + pagetable_free(ptdesc); } } diff --git a/arch/powerpc/mm/pgtable-frag.c b/arch/powerpc/mm/pgtable-frag.c index 0c6b68130025..8c31802f97e8 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)) { + pagetable_pte_dtor(ptdesc); + pagetable_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 = pagetable_alloc(PGALLOC_GFP | __GFP_ACCOUNT, 0); + if (!ptdesc) return NULL; - if (!pgtable_pte_page_ctor(page)) { - __free_page(page); + if (!pagetable_pte_ctor(ptdesc)) { + pagetable_free(ptdesc); return NULL; } } else { - page = alloc_page(PGALLOC_GFP); - if (!page) + ptdesc = pagetable_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,28 +108,28 @@ pte_t *pte_fragment_alloc(struct mm_struct *mm, int kernel) static void pte_free_now(struct rcu_head *head) { - struct page *page; + struct ptdesc *ptdesc; - page = container_of(head, struct page, rcu_head); - pgtable_pte_page_dtor(page); - __free_page(page); + ptdesc = container_of(head, struct ptdesc, pt_rcu_head); + pagetable_pte_dtor(ptdesc); + pagetable_free(ptdesc); } 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 (pagetable_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) - __free_page(page); - else if (TestClearPageActive(page)) - call_rcu(&page->rcu_head, pte_free_now); + pagetable_free(ptdesc); + else if (folio_test_clear_active(ptdesc_folio(ptdesc))) + call_rcu(&ptdesc->pt_rcu_head, pte_free_now); else - pte_free_now(&page->rcu_head); + pte_free_now(&ptdesc->pt_rcu_head); } }