From patchwork Mon May 1 19:27:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13227923 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 483C3C77B73 for ; Mon, 1 May 2023 19:28:44 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C236F280003; Mon, 1 May 2023 15:28:43 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BA9B9280001; Mon, 1 May 2023 15:28:43 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A2400280003; Mon, 1 May 2023 15:28:43 -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 93A48280001 for ; Mon, 1 May 2023 15:28:43 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 48123160286 for ; Mon, 1 May 2023 19:28:43 +0000 (UTC) X-FDA: 80742673326.26.2D45307 Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by imf20.hostedemail.com (Postfix) with ESMTP id 721DC1C0016 for ; Mon, 1 May 2023 19:28:41 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=BSfSX498; spf=pass (imf20.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.169 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=1682969321; 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=B0Od9Inc5y6h3dSbsHmdGR20xSLs7HxIKZ/fFcl7OHg=; b=ZRdDLJtRVEZR4M7v3NB8zAwJvf8QXMbtc3NSuos+OLsfeJhoM9IPScm7gfbhqOJTetcXMZ scC7zyw0VIpM6tUgKADB7GP+oje3itKbMISXqJrl8Sr/BJbQu9iTNDR01m3w+9gciE4qS2 HXJI8O+sm8HuAcJJ1qITN1xumcpiSPw= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=BSfSX498; spf=pass (imf20.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.210.169 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=1682969321; a=rsa-sha256; cv=none; b=RZFOY5kFz0ocBYZASCIKcgwGygVXAQe3vmSHWoHD5vrXj//3nMNRGh1FuG/bfIbumF19bI 2rQO/gO01ZcN9H1eLIjHtiRFDlWa71mg0Mh1GFx77tzh2wi4oRRe/nWOO5QMuD3a1/wSzx napNvsN4Dy3kEcz46lmmyoUqaHievuU= Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-63b5c4c76aaso2032684b3a.2 for ; Mon, 01 May 2023 12:28:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682969320; x=1685561320; 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=B0Od9Inc5y6h3dSbsHmdGR20xSLs7HxIKZ/fFcl7OHg=; b=BSfSX498+nRsOwkOZCv/c3TfiIzHvFrBHqOPXzZnUzdOTpraA1SFYJQ7S9OlNSy+oo SgKJwDZ3qC6C//XEAcYljRcEjgHnyeaNoyhEAyOx7Ys6/3k09Ik8CgCQWIiXukHyuWI8 JqooqMgdLQ1gpcR/L/mcYK+KZEjEg+InGInQqZs8g+xQwi3fiMtnPj+o8uf54dHCG0nD x8PpX8tpE3nfYMsr6vBPGSrBk7IqcdW9rAQJxVfKMF33+mjDorfNig4J/P1XioZbWwxD uXByeI5tsaD8qrYP2W7mncKrp6aQydR1tjw1T6sz0jLjo8cvDXE3/58iahOtRXOU+sGT jXsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682969320; x=1685561320; 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=B0Od9Inc5y6h3dSbsHmdGR20xSLs7HxIKZ/fFcl7OHg=; b=Bwny+Uf2U5EIL+k5k3XLbF2Xmca1jWU2FzbTm5i0F9Z8k5MHpdKP5ya702YHFQK+yo 9gTI9PgR9+WuV77aibs0MJT+yiC7IWLUHo4SZ8S4/nkKV4t4puIY4d/rPja0wyd9jOW/ 7b+VqIUryZTCfHy0tZcbn8Q3VDx1XTxUgfqQaHPmPA+AZ6PEk8xe+6nGL3oR5xQVYfYb KzsJyTZjZLTcWlCQVUmWfUIXctjVw4vgqzFryEWJTwhX+YEgwcKjpsJJTZhDF3lpZl+S vQ2b7yZq+xWDip3VhlTZZPMTTq1rJjE1U2DeGVvhaHTeMdJftgit3mnSBdvw+aUhQQ9v /tqA== X-Gm-Message-State: AC+VfDx8EqVXDonQnpIwtCzEoJG8IxtfK6CoHF9eeYpXo8fMQCwpEH7+ La6QVT5HN17kQSY9pT8XGXw= X-Google-Smtp-Source: ACHHUZ5c/2Ko6MMnlJILdIHFSiqsi7woH2pp9LXJUwyBETBH//ZWHg6e+tUlm1aX3nzTckKQE2QL/Q== X-Received: by 2002:a17:902:d2cf:b0:1aa:ffe1:de13 with SMTP id n15-20020a170902d2cf00b001aaffe1de13mr2810716plc.5.1682969320162; Mon, 01 May 2023 12:28:40 -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.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 May 2023 12:28:39 -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 04/34] pgtable: Create struct ptdesc Date: Mon, 1 May 2023 12:27:59 -0700 Message-Id: <20230501192829.17086-5-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: kozxrf1zm9pawj374eqny88pjg1qpmqy X-Rspam-User: X-Rspamd-Queue-Id: 721DC1C0016 X-Rspamd-Server: rspam06 X-HE-Tag: 1682969321-959432 X-HE-Meta: U2FsdGVkX18dGaFwbofyve2sXED3LB80jjQnqgIU1qCMtSjsnpJCS/1p1J/BUKv0ahXdx5ZUqY5+GSTcUV5MQXTYIssIndj7xo2EoTgktsWLNQiJocGM0ZzEgxKJ1Lg4/SnonZbU6QHres69X1FZTaamm4XSOW8zvpjZaFZ+tQEphj++UQcKptVrDMlc5rRbebbqcJ3tb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JY/EcgkFzY0/CWyOIGB0Q16+H/frgIQwR24YMe4vA61Cx3QghalkOyEKD/677imIlsGQNlfY/zqmxqST1gdUCyeu5XpAslwOGZvGFRjc36V/WKf6VudQSp26Loo64XwtELDePPwydFanNbIFs+x7OzUby4oo7aFjWOAmS1E06JbKzhWQsXUsdsmtmXmdMnVFr5AkMg+1mZvsi8Yblm6UvJicsOOkpacikn81yDvp1/WQ== 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: Currently, page table information is stored within struct page. As part of simplifying struct page, create struct ptdesc for page table information. Signed-off-by: Vishal Moola (Oracle) --- include/linux/pgtable.h | 52 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 023918666dd4..5e0f51308724 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -989,6 +989,58 @@ static inline void ptep_modify_prot_commit(struct vm_area_struct *vma, #endif /* __HAVE_ARCH_PTEP_MODIFY_PROT_TRANSACTION */ #endif /* CONFIG_MMU */ + +/** + * struct ptdesc - Memory descriptor for page tables. + * @__page_flags: Same as page flags. Unused for page tables. + * @pt_list: List of used page tables. Used for s390 and x86. + * @_pt_pad_1: Padding that aliases with page's compound head. + * @pmd_huge_pte: Protected by ptdesc->ptl, used for THPs. + * @_pt_s390_gaddr: Aliases with page's mapping. Used for s390 gmap only. + * @pt_mm: Used for x86 pgds. + * @pt_frag_refcount: For fragmented page table tracking. Powerpc and s390 only. + * @ptl: Lock for the page table. + * + * This struct overlays struct page for now. Do not modify without a good + * understanding of the issues. + */ +struct ptdesc { + unsigned long __page_flags; + + union { + struct list_head pt_list; + struct { + unsigned long _pt_pad_1; + pgtable_t pmd_huge_pte; + }; + }; + unsigned long _pt_s390_gaddr; + + union { + struct mm_struct *pt_mm; + atomic_t pt_frag_refcount; + unsigned long index; + }; + +#if ALLOC_SPLIT_PTLOCKS + spinlock_t *ptl; +#else + spinlock_t ptl; +#endif +}; + +#define TABLE_MATCH(pg, pt) \ + static_assert(offsetof(struct page, pg) == offsetof(struct ptdesc, pt)) +TABLE_MATCH(flags, __page_flags); +TABLE_MATCH(compound_head, pt_list); +TABLE_MATCH(compound_head, _pt_pad_1); +TABLE_MATCH(pmd_huge_pte, pmd_huge_pte); +TABLE_MATCH(mapping, _pt_s390_gaddr); +TABLE_MATCH(pt_mm, pt_mm); +TABLE_MATCH(ptl, ptl); +#undef TABLE_MATCH +static_assert(sizeof(struct ptdesc) <= sizeof(struct page)); + /* * No-op macros that just return the current protection value. Defined here * because these macros can be used even if CONFIG_MMU is not defined.