From patchwork Tue Jun 27 03:14:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13293720 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 B0A5FEB64DC for ; Tue, 27 Jun 2023 03:15:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 43F678D0007; Mon, 26 Jun 2023 23:15:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3EF4A8D0001; Mon, 26 Jun 2023 23:15:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 291A88D0007; Mon, 26 Jun 2023 23:15:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 1BA638D0001 for ; Mon, 26 Jun 2023 23:15:17 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id EAFF71408BA for ; Tue, 27 Jun 2023 03:15:16 +0000 (UTC) X-FDA: 80947061832.05.B17DDD8 Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) by imf15.hostedemail.com (Postfix) with ESMTP id 29E5EA001A for ; Tue, 27 Jun 2023 03:15:14 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="YbS6It5/"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.173 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=1687835715; 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=g10wkISUfh+NWh/zmhT9FX+m3ZttfvdTUqPKBonJP24=; b=BHyeawmBzr3DdGDOUAS82Wr2tjCDTFr6Eg4iiicNcvKg25z63pFUEsWriRKmquYxsw0UFp SB6bCcPyDT9AoVCF6hMdynX04OV3E5+vzcWKE+u9W9JhlBtenOr2QvAjvLdDOaL6mH0lVH H6+NtCIeofQEFsZJ3W7I64yInB1uoVo= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b="YbS6It5/"; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf15.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.173 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687835715; a=rsa-sha256; cv=none; b=bxwQRtzBY13qhpcsZCKbjbxFUkPkqWkTo41UiZDP1SHC5tVlpoZ84VEMEE8T2gAcprPG2m 3UmBnfYYSA5dyTN79/x0WiSIV84O6V90+dXHJmcBk7mBTGhxMzfOJoeDlC9WF1zm2c4CMX IoWAtPEqRI89ySAZoX9ZOhNkKcS9P+Q= Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-5700b37da3fso32873577b3.1 for ; Mon, 26 Jun 2023 20:15:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687835714; x=1690427714; 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=g10wkISUfh+NWh/zmhT9FX+m3ZttfvdTUqPKBonJP24=; b=YbS6It5/jG4gj9GV1WnqlWfE48J9CdnxNvOxOEYb2jkpFBwkcijgogv5/2FTyBYSJu izIlhC4BKNDwS5s1e4kK9kflroiGbN+V3CM6t7L2EFgtcSkg+ReKLemBNYF5Y3oVXg4d FUK6TJROlYVwfl34r2gL5piZl88lZtnh5mJi4W6rFRki4guA/8D+KKFrkkfHcSu1EJOJ fncA5E4mKOaGZV6UHnLSf+mughQQ2/sG6vdU9OT//BnRvDPbrV7dVSZuLKiGxg9g4JB4 L4rqAG2yhTX1HWLW8k7KKi4wHWH5luhyXPrJQJ+E2hOyRozoqBZDlMJstEk3Y4X/0/Xj 8nVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687835714; x=1690427714; 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=g10wkISUfh+NWh/zmhT9FX+m3ZttfvdTUqPKBonJP24=; b=PeqArqWSEQpYD7eu+HD6GQvO55rn5hAxAtIf0w4zxytUrCmSflghLEP03WQ0nq5QBw whOKUmyg72YjcCNMKrWz4BQkuocuB0qK+wCYubELoJg2jiJJ21D1f19XoqwZTkRocBL9 iE5dvOAsLujAz9MFeoU5s0fv1Ta5sRie0yhTzYWc0i1UfUs+q4/XepFWcHheuhrGjOgs qh2Zoa+D0vFSuju50DptwWwsGOWXlJOZeLxMup3ky8v353HXkTrPw6Dwbre26qtmdvEd oofPLu7cQj+5Wz6rLHKz7iZI3cMkAM4xk9AD9WyOmrzSSl6GY1Ew+ZOCcdWHGveRFJx3 RHCg== X-Gm-Message-State: AC+VfDwiMI7vXnvnEUVC4YGayluZqpcFo8tOcQs7ZRbOErFCmt2nrvDB rjmA/gzkFRNGVXyDKRZcLy4= X-Google-Smtp-Source: ACHHUZ4trddfgXzjmNYnvfIX3UyOWVfVwt64/0k1X+1Ib62f54dPN/U9UUyskS0pcHiYwtqCWDYcTQ== X-Received: by 2002:a81:4e44:0:b0:56f:ff55:2b74 with SMTP id c65-20020a814e44000000b0056fff552b74mr21585770ywb.37.1687835714203; Mon, 26 Jun 2023 20:15:14 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::16]) by smtp.googlemail.com with ESMTPSA id s4-20020a0dd004000000b0057399b3bd26sm1614798ywd.33.2023.06.26.20.15.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Jun 2023 20:15:13 -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 v6 03/33] pgtable: Create struct ptdesc Date: Mon, 26 Jun 2023 20:14:01 -0700 Message-Id: <20230627031431.29653-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230627031431.29653-1-vishal.moola@gmail.com> References: <20230627031431.29653-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 29E5EA001A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: kk5b8c5wkdzmewqmjrdoyu59hifk74pt X-HE-Tag: 1687835714-919877 X-HE-Meta: U2FsdGVkX1+bdsY9+bAeMMZFhxI1iS26okC5s1IiEzdIbNyxcAJ+yZbcReoYnm6XuTBZ7TtLL868bD118bTivJlB7ER9Ce+aKfuUToSzB+eYoC+njrva09TuLQQksm+ZKVOxDl6fk6TEfa1zBmlh/cr7SK3COEW/FmIoqf6DwwYwO7p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ChPUlh/0ybff8Tiimiqa66q0X2jRPbX6xTjcsNWqNA6Oj05IDwjwtWz3Hr5KCjW1oC0vJURTFgF6fG9HWEY86bLI04yfn7Da+Advv/oiApwgAxhuTi891YBJgY1qewrbKPZUc5SgtPe1ykqXJJam6//JP84s4rX8Q8oMHV4+zh0WS7bHGYgLsP9Fc1gEJ/jEDWMkURUDZ+heJnysu+HDynd0sJNeuLzTN4610yLkn00pr1UgkKq3VPA3AFrRSKluQwSln8oLCGhxWumadboq0fRwD1sJySDk2y78CK96BsAsrH2MJacXBnOlrsCW9KDN3fwg9zNfQ== 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) Acked-by: Mike Rapoport (IBM) --- include/linux/pgtable.h | 68 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 5063b482e34f..d46cb709ce08 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -987,6 +987,74 @@ 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_rcu_head: For freeing page table pages. + * @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. + * @__page_type: Same as page->page_type. Unused for page tables. + * @_refcount: Same as page refcount. Used for s390 page tables. + * @pt_memcg_data: Memcg data. Tracked for page tables here. + * + * 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 rcu_head pt_rcu_head; + 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; + }; + + union { + unsigned long _pt_pad_2; +#if ALLOC_SPLIT_PTLOCKS + spinlock_t *ptl; +#else + spinlock_t ptl; +#endif + }; + unsigned int __page_type; + atomic_t _refcount; +#ifdef CONFIG_MEMCG + unsigned long pt_memcg_data; +#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); +TABLE_MATCH(rcu_head, pt_rcu_head); +#ifdef CONFIG_MEMCG +TABLE_MATCH(memcg_data, pt_memcg_data); +#endif +#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.