From patchwork Mon May 1 19:28:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13227932 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 1A1FEC7EE21 for ; Mon, 1 May 2023 19:28:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8F334280001; Mon, 1 May 2023 15:28:55 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 877F128000C; Mon, 1 May 2023 15:28:55 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7161F280001; Mon, 1 May 2023 15:28:55 -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 5C25428000C for ; Mon, 1 May 2023 15:28:55 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 362E6AD4EE for ; Mon, 1 May 2023 19:28:55 +0000 (UTC) X-FDA: 80742673830.12.1BA3C30 Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf08.hostedemail.com (Postfix) with ESMTP id 5427516001A for ; Mon, 1 May 2023 19:28:53 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=YU74FvpH; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.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=1682969333; 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=L/HbzXYZlFs8Glr3mCgcQ6yZjaq6zFAfxmTJm9brDXY=; b=YAmpGRkAz1Sobz2CEJSdMXdbF6eMPKQ+I72yFyorzTKz4wvlqxtUclLgaB/WsBBJ2Bjuew p4gDILyxCrd5C5b21vO9miAISSozCg70kOhuIQpu9AM1F8YnvYBVJ5P+V/PalTV9SDS4WE n96/XVZ3m1bhYP+iD9w4xrghlmO/APM= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=YU74FvpH; spf=pass (imf08.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.178 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=1682969333; a=rsa-sha256; cv=none; b=vIJ9iV9ohxfikiEihHCVBTFSjAv7y433foXDwun+alBZiImIg3VQvb+N7M0b+lMLvtXkWe 2sZq4nZfs4tH1fZQvB0zNUxo7tAEIwGpAmM1hqdphSyIaQlY3Y1KApcFfvyhyJQIMQ1zS3 UNKlTz7Ht5DvvOks+Aq8fWUIg1+Ymx0= Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-64115eef620so29038013b3a.1 for ; Mon, 01 May 2023 12:28:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682969332; x=1685561332; 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=L/HbzXYZlFs8Glr3mCgcQ6yZjaq6zFAfxmTJm9brDXY=; b=YU74FvpHQCK1VqAuVX8r2BjduNpUerOh1yATlR8mKQ/tJLpS2WI1LKB7NUnPZev+ku rfgntGzBluAMKuHfK/jms2NgctRzUuZHcxtFDuNiPPeXkbQ7Z48v/aLnoLGhmcKi5okk NTHNilz0HthKY/XHg97rKwZvMnLAYPI7U1eBqYo3DUIS7zYhW0tg5v9W5kNg2nZAJHx+ 0W0xkqlDIUsVkMuesra65fGttpYRxCYfqsHDDsc8zlGh06W2A2UnpmXTtrAlRE/I54n/ 9b61gxsFscmWDNDgpJxss4pOhFtz/pn5R4Qs2mfASivX3bx3H5gbzbMc69UUOvWi91zv pr8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682969332; x=1685561332; 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=L/HbzXYZlFs8Glr3mCgcQ6yZjaq6zFAfxmTJm9brDXY=; b=Dk+sOfzXMbrCfupOviAFTeXCPn0Js5tzNiThXHQMlGxSRLqSA4uBx8nuhZBE73F4f9 HIyvptf7exhQb2EldRND0oQealARg3+R7Gkoz5+LlqSO0dIw4zi+41bG8c2aPixuz8Yn In4lKlEO/GVVblmrzAthThFmkO3DGg/CqesJbZ+7LXYYZPZj9ZzpT/t6Rk987NPP3TRl i8q8P3kR2xb9QUGdA/QpMgE1Hsm7pfzK1UUNO4hSnnVPID0QTzdcbzbcM6cZAymgBVje 2UN/Xtvzh/8FTDDqp1zINLSLYdW2zSdhpnQ9llrgdyu7b0OkXWr2utbNealBBmcoqfkv /bzQ== X-Gm-Message-State: AC+VfDybodSv9sftVfnBvWWeL1iQ8tSUV6mSC+xzmZfaPj2Rh5EQNOoY nkicL4VdA0kzEm9z1fnKfMI= X-Google-Smtp-Source: ACHHUZ5tlVMWyUaJdG9fqFVZnpLPEvgTINU205p9ECnUgFr/jtV6hdVvJcRfvr33OgCYwfP6dTnMLg== X-Received: by 2002:a17:902:c94f:b0:19a:727e:d4f3 with SMTP id i15-20020a170902c94f00b0019a727ed4f3mr22987004pla.5.1682969332204; Mon, 01 May 2023 12:28:52 -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.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 12:28:51 -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 13/34] mm: Create ptdesc equivalents for pgtable_{pte,pmd}_page_{ctor,dtor} Date: Mon, 1 May 2023 12:28:08 -0700 Message-Id: <20230501192829.17086-14-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-Stat-Signature: 8fi7xm9s4q5kc13oedc3aba6x47iakct X-Rspam-User: X-Rspamd-Queue-Id: 5427516001A X-Rspamd-Server: rspam06 X-HE-Tag: 1682969333-608462 X-HE-Meta: U2FsdGVkX1/g8aAPptgaO5DbFwO3/7btMoVSaMJwdvsVA9uASfgwWabNHsp3ZzEukygk3KFIs6FCwXEIZMqOL2Hmv+pTxoocmVk8K+/q6YNtR5ri60J2IikPEWP1pMtAGBoKXM0VyiZGq24WhDGXIP1jiKs1cqffexOe374wk0KDl89u6OgWGcDIQqTxrf8I+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cEIwUHZgQdDoBP/KHaQJjkY/p1THj3OiUDTbQOY7jioBkIpOOGZML9yDM0ZSkUkRQz3ibxEcx5k6K+4jsJf4CFLvA9SZAdmqUNdLSxcpjyNhU+gqwYlmEvIWJKVmcikswg9kxzsNGTdDvgHpkLndk2WfEVoFpvdKHC5DXOW2gYjIxeCakeq2KZ4wUG/+bVJrPY+rhkQxzRlMhRfgaAaBjk79wpyrmVJ0SqwIIns1xOv++TwcGRPQ97gak+slFNgYHzQUtm92TV289aLggDL8NWENVVw= 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 ptdesc_pte_ctor(), ptdesc_pmd_ctor(), ptdesc_pte_dtor(), and ptdesc_pmd_dtor() and make the original pgtable constructor/destructors wrappers. Signed-off-by: Vishal Moola (Oracle) --- 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 58c911341a33..dc61aeca9077 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h @@ -2847,20 +2847,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 ptdesc_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 ptdesc_pte_ctor(page_ptdesc(page)); +} + +static inline void ptdesc_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); + ptdesc_pte_dtor(page_ptdesc(page)); } #define pte_offset_map_lock(mm, pmd, address, ptlp) \ @@ -2942,20 +2956,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 ptdesc_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 ptdesc_pmd_ctor(page_ptdesc(page)); +} + +static inline void ptdesc_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); + ptdesc_pmd_dtor(page_ptdesc(page)); } /*