From patchwork Mon Jun 12 21:04:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Vishal Moola (Oracle)" X-Patchwork-Id: 13277357 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 6A34BC88CBB for ; Mon, 12 Jun 2023 21:05:16 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8FC49940016; Mon, 12 Jun 2023 17:05:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 884B394000B; Mon, 12 Jun 2023 17:05:15 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B0B4940016; Mon, 12 Jun 2023 17:05: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 5BE5B94000B for ; Mon, 12 Jun 2023 17:05:15 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 35C5F1C79BA for ; Mon, 12 Jun 2023 21:05:15 +0000 (UTC) X-FDA: 80895326190.12.FFD892E Received: from mail-yw1-f180.google.com (mail-yw1-f180.google.com [209.85.128.180]) by imf09.hostedemail.com (Postfix) with ESMTP id 4A4E914001B for ; Mon, 12 Jun 2023 21:05:13 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=YrxPmjxN; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.180 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=1686603913; 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=EpDrDA23aZZSOuD9ECPgZVlXX9wPcibxiFG6a9Pg6kw=; b=NuRWaJMX+mX6ptvhnQ7tG4P+Y+u5xVXLj3VIGbYng86ETkc59BFKcx3xCA0W0XbkSujf6E eTDD4myNZbiXumFyWg33Le8vaOXE/wqNU9vN2/DfJlJ/4qAqFSa03DlGTFVOuRsjyUCjO6 t0BVjHISu41LhoqlRGcNI7/x5v75xm0= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=YrxPmjxN; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf09.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.180 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1686603913; a=rsa-sha256; cv=none; b=6O6RHXQR1RIsPXPG0qXk701uFGGIvAYvdU35PHK+sB4chLbNsDM4FM8b6h0HNMe94PnzSi Y+b/PUGs46vwvOGdcO2p4TLhcJZ3qYXk85KMkT/uDkbYovhO0XkXYJic86mI0R02ihztiR YZzaIu6C5ZhRmYBL3NKNwxbn2j9pv7Q= Received: by mail-yw1-f180.google.com with SMTP id 00721157ae682-56ce96063bcso37492997b3.1 for ; Mon, 12 Jun 2023 14:05:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686603912; x=1689195912; 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=EpDrDA23aZZSOuD9ECPgZVlXX9wPcibxiFG6a9Pg6kw=; b=YrxPmjxN/Qkfa39Za5HTgq4QQ3f9/zju1xoEkMHY76VWuya44wSbPKtXjzKY3v7sqU GBxsM+H0usX0mr3+rL1pflvYDpTa44gJOcWxVcOnDkRvcMNiHbLrpt96vvJ6FNwKJltW cMJPyFVQ/eSt9EDvrymbmWnro3jKR5HGdt4l2wI6AjCbDnCnt1cg4A0jjRLl9BCzyZ7N VzgyM4qBAMmkmToFHzJWSn2lcW28mUGQcMgbZJj1Lk3UeDxgd0pcGGp9/tqybVBUSS6z sfRYAsqcMK0gYJ/10nym3sY5+OJ+ZE83bX/QwPKBvH0660Lco3siIL8/QCwpR8viXQgt 6rfg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686603912; x=1689195912; 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=EpDrDA23aZZSOuD9ECPgZVlXX9wPcibxiFG6a9Pg6kw=; b=lFytRdMOkY8RTFz7O+J4QJsjUGIZcIGNHjwMLbQwFy4lUMYiLZQRm1wAlt8l/BKPZJ r1TNIT2+BFNSQ2Cne5bYvRXPxvqFThDkkkrWvL2DWbh4K8wN3yTnm1tSWidpuYlXsiHU JMTrng3bBJG1I4FxdMAoxQTAnTks7vQ6kqLuaWvhWoKJrdrdtz35XRG3Z/Vy/48zYLeA D5qhCyP8YqURa8Gltiblz7xihjMUtGKM4mZVDmfEw7MjfjLMjyp7b2v/ouCEjZbs5gf7 hpEHTvcbTbs7wvtmn2JJq+XYlK7mS87XZoRw2369VrMA33qfC//SoAff0kkulL1Nh0Pl +Bew== X-Gm-Message-State: AC+VfDwIJjOwQqLuAjpZOeKyrrW9EeotOwmoozSRPyvxE0AJ85kQuFdq 5KT/l9bxpxeQcm66MtlZL6s= X-Google-Smtp-Source: ACHHUZ4rEtwsIJS0u8/qiBl+7RQztIv/50rVsQeASCwgplg4IOIGaQtPyW+cRDHUBMrIJvgIE2xULQ== X-Received: by 2002:a81:4e4b:0:b0:569:e92f:72a with SMTP id c72-20020a814e4b000000b00569e92f072amr14103246ywb.16.1686603912361; Mon, 12 Jun 2023 14:05:12 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Jun 2023 14:05: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, Hugh Dickins , "Vishal Moola (Oracle)" Subject: [PATCH v4 13/34] mm: Create ptdesc equivalents for pgtable_{pte,pmd}_page_{ctor,dtor} Date: Mon, 12 Jun 2023 14:04:02 -0700 Message-Id: <20230612210423.18611-14-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-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 4A4E914001B X-Stat-Signature: xw6t9gof6i1gfkrwj88mywucosjd7yrx X-Rspam-User: X-HE-Tag: 1686603913-847302 X-HE-Meta: U2FsdGVkX1/jlqWzS5ZF2wKtuMpMfxLOSDANI0bafO01gZXFm780Gjq0IdZCmC/MFgmSqn7S07nKCwCxztOdME0sfIYfGP0rjHDfI2Sm6Q8T1lNeOlGRUXWFGGAQcNnyyoN3woqPm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bSrNKOxkOm5ZE9nmz6onbUYmyBw1ODhtKDwkHSoR/CrKnxZoXiIuYLkh6nIrY2ESB342GTYH3A6duC66QaJwHL927qCMNQuVU6JC/4uQlsOVlmcxDQhWyCf6C/Q0bqx4gZZPMmL6uwDFgADLZmLVH4kl+PIZ+4/kyWnjPmkc2koAmytQlyM6GOSV9tOgkU41uWXB3Xd3bMx4+Keb5f4mgo0v3g79PNYkHm3+mpjInrXwuv5kyPuKTcMXmPUdWEKlJuN7xIuKlwDnV4ySqw7JH2m8bbQmyRtUDSomzlqmkyV2Q8BN90eR8dIj09sPl5RA+tCsneMuMhPKGkqaslIX6BroRzztJAxVUmTWJU/1J/RWk= 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: Creates 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 a1af7983e1bd..dc211c43610b 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2886,20 +2886,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_table(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_table(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)); } #define pte_offset_map_lock(mm, pmd, address, ptlp) \ @@ -2981,20 +2995,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_table(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_table(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)); } /*