From patchwork Mon Jul 31 17:03:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13335112 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 96FFFC07E8D for ; Mon, 31 Jul 2023 17:04:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5BA4B6B0177; Mon, 31 Jul 2023 13:04:09 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 4F47D6B0178; Mon, 31 Jul 2023 13:04:09 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2D11228006F; Mon, 31 Jul 2023 13:04:09 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 1B32C6B0177 for ; Mon, 31 Jul 2023 13:04:09 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 0783340BBD for ; Mon, 31 Jul 2023 17:04:08 +0000 (UTC) X-FDA: 81072529776.14.2DBBD08 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by imf06.hostedemail.com (Postfix) with ESMTP id 209B4180046 for ; Mon, 31 Jul 2023 17:04:00 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=WsnCjEuF; spf=pass (imf06.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.178 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=1690823041; 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=GM8s3dDlKIn9bcZ3Rv1fAyQJ11tvy15JiujAITQGQIU=; b=mXdFupG8SUDeui69kLZ3ZWdycMRh8Uu+H7QZkdqsDzKkpgi2FDn7wMQDwfPLlhvAVLxMQF 6BfvlPQUpWgt96KpFxS5FpU5RDzYBfmZ8AGbMmhDLJ2jKGhvek6Y2FDMTyMCGkcBuuTEMi /6Tc1/qj/miaeumKdaVPNv/zvv64eh0= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690823041; a=rsa-sha256; cv=none; b=ExMwWJnV1h/r1qW2c++nqbJ6WD/kukUEkZpR/rGuVVyi5JWZPK34vRfuq6I8g5+QOq+IiL N9erHhhf6u2XTyxnO6+jKtPM1o6maXgCgjgO+1VAxNnW4bYsnT4ujrl7QPv6BpRyP+35TX WylGv3kZu16DyczbGOys8F1IFdY48KA= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=WsnCjEuF; spf=pass (imf06.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.178 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-yb1-f178.google.com with SMTP id 3f1490d57ef6-ca4a6e11f55so3743643276.1 for ; Mon, 31 Jul 2023 10:04:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690823040; x=1691427840; 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=GM8s3dDlKIn9bcZ3Rv1fAyQJ11tvy15JiujAITQGQIU=; b=WsnCjEuFun6IuHpPh6Ck/rBg4AZLbVHEs2jk+7TEc5kPbUlyDbLU82vMQ8hYNiUbEV KmukkQXHlnalx2MRwxX9OA1ED5qQ+cRzMsv/rlYCU41nnUNJeib6/uXFu8sMt236/2Ud yhZAMNcebKfkSv6mc59ZybiKh0RsfAPQpPnm2pft2DHqmzXA9/C0fNB/u3wlBocoiSJC LtpkvTvVemtPOevOsyRiBPGxBKIgXaumZpQx0YFqajcNPkaTnpsizZKv1A3XIPWZnK5y p/CzUaAjAQ1JZb9e9DygJrxewNU/aZAjuX8qYUs6cV2yG2QRoeh00nb4O3A983HwtiRJ fbTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690823040; x=1691427840; 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=GM8s3dDlKIn9bcZ3Rv1fAyQJ11tvy15JiujAITQGQIU=; b=dgmL5FBzLuARR//HiUcrKpGdWax9IDJ1Fy+Lmfmau43atSo9EpvJI5HGzVPjF4aPAe SdFw0dgMVq9Njuso+OpvtCsyzOkijRPuAF6A4fWpfzZi4KhOlAnMggTU+e1Og9zwvfbo yEsl+JvRuI2CmZJ5f/0XljAZoW8PJT5cmXNLzzCzrUbKBRNu22R+4EyE62Mh0rVhNa+o 70vSNGHoKuHJTgo4PCXCzZcKTTEBxLMM1JcKSZ2llADsiYsw8RVuGSdqx96lpU55eRkY YcyzQh34A60ov+ZFunBw134k4+H3p5rkrmzwez2L8ldjeeUoB6yfGOoVo22GekPgvJm6 LcfA== X-Gm-Message-State: ABy/qLZOobf0XoTqD32JRHPE+X46ZT5Yrxtu7wMhZI/x96MUWVI1LAy+ wFHreF0WQHH6LHg9J1R8fNo= X-Google-Smtp-Source: APBJJlHch/jSJCdVVtDWb1WClZ5gGKwbX6GY1zRRfwmE6xAtgRg67mCRvfprsxzmmxwehzomhr3VNg== X-Received: by 2002:a25:c7d1:0:b0:d08:20f1:f7cd with SMTP id w200-20020a25c7d1000000b00d0820f1f7cdmr8274869ybe.16.1690823039767; Mon, 31 Jul 2023 10:03:59 -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.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 10:03:59 -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 mm-unstable v8 11/31] mm: Create ptdesc equivalents for pgtable_{pte,pmd}_page_{ctor,dtor} Date: Mon, 31 Jul 2023 10:03:12 -0700 Message-Id: <20230731170332.69404-12-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-Stat-Signature: 56tzsnrg4zigxnezi7mk546b6xisz3bu X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 209B4180046 X-Rspam-User: X-HE-Tag: 1690823040-124469 X-HE-Meta: U2FsdGVkX18WF7G7RN2nlqDhSzqPce/FwYReH65H2lZRNUgHLKgFJ8KwxGXgGAR/nG2EevHsxItIt8oYHyeLiVao6mQmMEqHVbJjRV+L9P2zROJfjtejjGd/8s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iWBETsKAjGWM2JYz9ggCPcu24LSMdIbAHa2YmmyJgois5v395OaG1Nv6qQGFEGx+XzWRLI1LCL6vsfB0//xAuHpWxMYNmz/BQEAfmLHK+9eO9kwWPGwzgv7UZwkDxLcE1fHO+39q3cjVbAx+a4cbCAh9F6UKA2n30AapiP4wuKJw1cu78a1mNA+TY91wqqYgL3Aud+Iffk62jRKD1z/iEbMa4TwbKtbJj8Oe3Tm1+ANq6Kdp+hluR1qWOLP7NUr0M/Eu5KHxik8/QDPTYUnt1IaiwJWEQ1l738k/q64/AUPU2gV2IJIfWZdUoX9txq2Ng/TjSSMuxItpgGuxavqmd7IHkopJRy0ZidkpjQHHHFdVrQAmCCqPhVZjb+z394PgKZLU51hpg5ZrH2/RVN9XTiNTeQCTtLOvHKEI2MICYT17lHNMNzg= 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 ffddae95af78..bd3d99d81984 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2902,20 +2902,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); @@ -3013,20 +3027,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)); } /*