From patchwork Thu Jun 22 20:57:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13289609 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 C12FEEB64DA for ; Thu, 22 Jun 2023 20:58:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 65F0C8D000F; Thu, 22 Jun 2023 16:58:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 636ED8D0001; Thu, 22 Jun 2023 16:58:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B15D8D000F; Thu, 22 Jun 2023 16:58:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3BBED8D0001 for ; Thu, 22 Jun 2023 16:58:24 -0400 (EDT) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id D51CA140740 for ; Thu, 22 Jun 2023 20:58:23 +0000 (UTC) X-FDA: 80931596886.11.67390BE Received: from mail-ot1-f53.google.com (mail-ot1-f53.google.com [209.85.210.53]) by imf24.hostedemail.com (Postfix) with ESMTP id E1B69180010 for ; Thu, 22 Jun 2023 20:58:21 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=RozEvIvV; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.53 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=1687467501; 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=RnNdr5PDFTKJu1h5zX1p1xVUKJvhUfKvVUh/w7ZbrdI=; b=n2L8VnWXkfiuZ/X/+8EmbA5mSchRbR/9PqWrlDHv2eGFt2w2vt0X/7DyZeiplUwguE879X BebWBllq/XYh9ZYbCu2VPO7RJv9rwpk9Dqxn/bUr6GremZeQXJ1xA6lulVJAUc4hFUBWlB tWVknwEh6o+XCOonWI8kWvv0zO+Mfv4= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=RozEvIvV; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.53 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687467501; a=rsa-sha256; cv=none; b=R0QdXEL2IFUDAnw32IUzfTg0/jKez1cX6uGHPoaHMXqpp+Qo2heBBss4i1JmMM5rey32cl fH0INty1/naXxJjOTKDVD7tcIJnGkwJgpDbmd/sJgu1TmB/3Ni7She5wZvLS0XdpF5IH/u F5IvDwKNH6k6daadHhNFy029y5H3Cpc= Received: by mail-ot1-f53.google.com with SMTP id 46e09a7af769-6b5cf23b9fcso5138a34.0 for ; Thu, 22 Jun 2023 13:58:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687467501; x=1690059501; 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=RnNdr5PDFTKJu1h5zX1p1xVUKJvhUfKvVUh/w7ZbrdI=; b=RozEvIvVOP2VqVYYMWGzDNL6CpsXTnGXlp/+8t0w3BlD0JmgE5T0sEFoPJ6ld3NgrT bo4deZV9iKOusMQ4leLcL/PwL7QvpCQol+1I1GDFuH17XhvWiV9F9j1adtGOARy9Hha6 3RGKMSONQqhzWt/kDmWTnPMrNJ63EExn/gif2mwqScqJ0/yA9eOZVrNV6N0d1si+/PRm WBpjPrumaScaXS+oAuKW5qjU1zlQ2w0x0jfPY5Gm7PSjCaEQ+p7K8a/NRyFlUYxCrD6N J99EeDDjbETqur6Uq9P5kOnzRuhiB5K690PgOVUOJzS9Q8J6CLKu6wMbAbv6pVzbEVQk Y9LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687467501; x=1690059501; 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=RnNdr5PDFTKJu1h5zX1p1xVUKJvhUfKvVUh/w7ZbrdI=; b=Sik9J22GHeL20+a92gXXg/TO62t44NQUilNawtI+Fjq4iYEhYjO+KVNCUDNeAPmPtj Cpgkc85qToYbuIj12qfVmXgUzmfaIssud0erjndoWqnTeoOXLURyi+klIdY6GVqS0RHe il9fibSaYdukAjWmpSZH6C+J0YgRiCt+p5OCk1sTJSra7DYcNVAgcovj4bk+675l7Z19 7Ocs1LTXRr1p/nIcn5mu8+UddFizwpcTWRM7tQGxsO+Ch4I7Sjh8G/1+/bTFI1vbQHt7 b5sLDVcAD3OZQsRHciLHfq2oA2PvbM/z4ot1PmC7Q03lVa9mVqqcMF/elBdJSkVA0Mxb Okzg== X-Gm-Message-State: AC+VfDwNGQ/7OC5YjzyFLzFEV5iBodNUBzBE3gaXjNlm7BB+8zMqem+2 Nr+56o2bDxUkL3Xl2fOdjXs= X-Google-Smtp-Source: ACHHUZ69lonjyuyFM3x/i0CqMLsv9C2vXMWoj4oQ2M7sud29qozQJHPP5PISfmTicbDCzcNZpP0hng== X-Received: by 2002:a05:6358:c114:b0:12b:cdd6:9661 with SMTP id fh20-20020a056358c11400b0012bcdd69661mr14337984rwb.13.1687467500803; Thu, 22 Jun 2023 13:58:20 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::36]) by smtp.googlemail.com with ESMTPSA id d18-20020a5b0c52000000b00bc501a1b062sm1684937ybr.42.2023.06.22.13.58.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 13:58:20 -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 Subject: [PATCH v5 12/33] mm: Create ptdesc equivalents for pgtable_{pte,pmd}_page_{ctor,dtor} Date: Thu, 22 Jun 2023 13:57:24 -0700 Message-Id: <20230622205745.79707-13-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230622205745.79707-1-vishal.moola@gmail.com> References: <20230622205745.79707-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: E1B69180010 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: umtwoatrru5jh8ycdfg45oa689r5erg7 X-HE-Tag: 1687467501-595947 X-HE-Meta: U2FsdGVkX1+yQAJiwQqUadJ3Rf+Sm3sNWIO6VGsFpu0RdEkFCR1vEDoC0H4lvenlJVcprDJ4V7uif8pvOshM30P4Sc0M6sG105e/qbdHaRXEOlZa8/rVZGSuFI7I+Y+pK9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X9fC2PU6e/2H8RUdGJc3n4dHcXpmEI6Gft7aGpjRZmYQNLs8HH12XhOnX/dW/mLE+GPQzh/75r2Da5dYaex/HPy/gcnkjI2R47Czri6nr1dKkcxzxjFSFFdaUGLY/JwJCwUy0KLzFE7put30hC5RaqM4WjK1KGOPRK0NJ+laK4OCn+74Uype65XbeKnli+Rf7FhiKiaDc1DWVqt5J+dQRc4RQ0bCcECleInLg94+MphLwAUxh42faisNYTEBsDEnvaoOAL7rzTDrtBnd4Ff9Yi5UBP9UIFfIaJiUQu+Rv8Ucn8ZUglDBBagCmXWRra/El1ZfkA2FNHCoMrIBeinEyJZMEuRXTHuCKiaWJLxY58hftzMYK8H26s7SQYBWaXV+OBWsKLAeHZ1CN9qKPFcEhPvrNITUFDcF0QEY= 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: Create pagetable_pte_ctor(), pagetable_pmd_ctor(), pagetable_pte_dtor(), and pagetable_pmd_dtor() and make the original pgtable constructor/destructors wrappers. Signed-off-by: Vishal Moola (Oracle) Acked-by: Mike Rapoport (IBM) --- include/linux/mm.h | 56 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/include/linux/mm.h b/include/linux/mm.h index 69e6d6696c44..356e79984cf9 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2859,20 +2859,34 @@ static inline bool ptlock_init(struct ptdesc *ptdesc) { return true; } static inline void ptlock_free(struct ptdesc *ptdesc) {} #endif /* USE_SPLIT_PTE_PTLOCKS */ -static inline bool pgtable_pte_page_ctor(struct page *page) +static inline bool pagetable_pte_ctor(struct ptdesc *ptdesc) { - if (!ptlock_init(page_ptdesc(page))) + struct folio *folio = ptdesc_folio(ptdesc); + + if (!ptlock_init(ptdesc)) return false; - __SetPageTable(page); - inc_lruvec_page_state(page, NR_PAGETABLE); + __folio_set_pgtable(folio); + lruvec_stat_add_folio(folio, NR_PAGETABLE); return true; } +static inline bool pgtable_pte_page_ctor(struct page *page) +{ + return pagetable_pte_ctor(page_ptdesc(page)); +} + +static inline void pagetable_pte_dtor(struct ptdesc *ptdesc) +{ + struct folio *folio = ptdesc_folio(ptdesc); + + ptlock_free(ptdesc); + __folio_clear_pgtable(folio); + lruvec_stat_sub_folio(folio, NR_PAGETABLE); +} + static inline void pgtable_pte_page_dtor(struct page *page) { - ptlock_free(page_ptdesc(page)); - __ClearPageTable(page); - dec_lruvec_page_state(page, NR_PAGETABLE); + pagetable_pte_dtor(page_ptdesc(page)); } pte_t *__pte_offset_map(pmd_t *pmd, unsigned long addr, pmd_t *pmdvalp); @@ -2965,20 +2979,34 @@ static inline spinlock_t *pmd_lock(struct mm_struct *mm, pmd_t *pmd) return ptl; } -static inline bool pgtable_pmd_page_ctor(struct page *page) +static inline bool pagetable_pmd_ctor(struct ptdesc *ptdesc) { - if (!pmd_ptlock_init(page_ptdesc(page))) + struct folio *folio = ptdesc_folio(ptdesc); + + if (!pmd_ptlock_init(ptdesc)) return false; - __SetPageTable(page); - inc_lruvec_page_state(page, NR_PAGETABLE); + __folio_set_pgtable(folio); + lruvec_stat_add_folio(folio, NR_PAGETABLE); return true; } +static inline bool pgtable_pmd_page_ctor(struct page *page) +{ + return pagetable_pmd_ctor(page_ptdesc(page)); +} + +static inline void pagetable_pmd_dtor(struct ptdesc *ptdesc) +{ + struct folio *folio = ptdesc_folio(ptdesc); + + pmd_ptlock_free(ptdesc); + __folio_clear_pgtable(folio); + lruvec_stat_sub_folio(folio, NR_PAGETABLE); +} + static inline void pgtable_pmd_page_dtor(struct page *page) { - pmd_ptlock_free(page_ptdesc(page)); - __ClearPageTable(page); - dec_lruvec_page_state(page, NR_PAGETABLE); + pagetable_pmd_dtor(page_ptdesc(page)); } /*