From patchwork Thu Jun 22 20:57:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13289600 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 26E91EB64DC for ; Thu, 22 Jun 2023 20:58:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B68E98D0006; Thu, 22 Jun 2023 16:58:05 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B18ED8D0001; Thu, 22 Jun 2023 16:58:05 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 859CF8D0006; Thu, 22 Jun 2023 16:58:05 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 773088D0001 for ; Thu, 22 Jun 2023 16:58:05 -0400 (EDT) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3CA6D140151 for ; Thu, 22 Jun 2023 20:58:05 +0000 (UTC) X-FDA: 80931596130.22.AB8FA79 Received: from mail-yw1-f172.google.com (mail-yw1-f172.google.com [209.85.128.172]) by imf01.hostedemail.com (Postfix) with ESMTP id 69FDC4001A for ; Thu, 22 Jun 2023 20:58:03 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=pU1rNku+; spf=pass (imf01.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.172 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=1687467483; 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=ISCF0EoL2+dOXGl/co4T/8nL9MZo/swzituaeX6cBZlT1WQBgCzrEWT8+ZdJwrkqjv/Yz0 SxVtcvhlLjgfFuEEzoCQVOnV+eiGgx4tde3gRggs5BINMnzdj3PCtPUMp6ifynIwr2HOw1 MiLydbZ38UzZaDmSccM30D2FoC4cDf8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1687467483; a=rsa-sha256; cv=none; b=58hDg7SpnqhXkycFrKktf+BY03kFmWg3B7qeLgJ7sr1AOEy4tga6hR1B6sXPU6d4IPQBE4 q31XGZkjCAed7N8P5C2yiVy7L09MkjTuvW1ng34Vm4XmYWkAPHervBa8Z+oCn7DaoFELNi +H8UYnyaMxckxg+pEZq271vN/bDzq9s= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=pU1rNku+; spf=pass (imf01.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.128.172 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-yw1-f172.google.com with SMTP id 00721157ae682-561b7729a12so16637457b3.1 for ; Thu, 22 Jun 2023 13:58:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687467482; x=1690059482; 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=pU1rNku+EwfuvvAUFkFumH3vBy2yB8eY8b9rmQMddlJoc9QhOnRcokyjWDtIUPPy9P MyE7phtpnefNxvysKqFF1dCChREaY4VAw7Hj9WJFlZFrzpk6eifBId3wubz0Vyh/S2pn 8/Y3zkVGHHKKYxzZzu8HCxLQTltPQvJHitS9QsbrsAUgPjueiuuK933isxWF/RQdLHvt zcy+Qct09qmvfH+KRctZzkT+vvZGDQDyiysBgsbHpUxND18HRJm9vVFEK6S0KHOtgU7u IRCWYGiDuX3Hydg/OjrZHIGz2lGmohOF8cCd3deLunhE1oH3PJ2GTuP2PJzlmW5OQRrp EAKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687467482; x=1690059482; 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=f5Tgo4sYfQ7vXGAMJj54YCSCUnJKYJEQb1yv0xoAk7QudPYtS8K9DWqeMtDzPaRbzX jKLs0Zc2Rs64AJoj9iV0CTOpPMehyYbsm0065tOQgvhsaShXN41+VpxUH8r5vGAaHXxN RXjHeMZQ24y4XW1sC15z1TyjS6h3rzv/VyoMtJ/2dDlwhpCxLet/sZH2xviJI8fmpqs4 I5T6osK5nxtDSl+hcEdWC1TXYwLTqjOUEu1jS+ks3Skoh7x/KZEmU43z8GYNcW/YlzlO GoIor514eAq5CM0bJ5CYswYqLJOwZ6Mazz9Y4yKPLRLC20TS+s6rSjAhfzTJk50tdY7B E3UQ== X-Gm-Message-State: AC+VfDxcXnh8jtxd2DF71X5/r5rQK2UehLY6lc5Zb2bBle7L6nDOyPMf OLZii0mpSf0Y9V/F8TJ7ToE= X-Google-Smtp-Source: ACHHUZ77fWcfFpcqNU9K3kqcEPsqSpbWa/fmZ/3pFZFyzvd1rtc51te7WicHxIwYc2YzOzHNnZEaEA== X-Received: by 2002:a25:2f85:0:b0:bd5:eeb4:55be with SMTP id v127-20020a252f85000000b00bd5eeb455bemr19092596ybv.0.1687467482307; Thu, 22 Jun 2023 13:58:02 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::36]) by smtp.googlemail.com with ESMTPSA id d18-20020a5b0c52000000b00bc501a1b062sm1684937ybr.42.2023.06.22.13.58.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jun 2023 13:58:02 -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 v5 03/33] pgtable: Create struct ptdesc Date: Thu, 22 Jun 2023 13:57:15 -0700 Message-Id: <20230622205745.79707-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230622205745.79707-1-vishal.moola@gmail.com> References: <20230622205745.79707-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 69FDC4001A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: p7hzfqbiqk7t39c4b6pr1o7dsoya5ye3 X-HE-Tag: 1687467483-651804 X-HE-Meta: U2FsdGVkX18tliEjxYpvTWG+YhRldy0XObB3Fvo6JF0KN+A7SoyfxkmU9fdC0fFoLcRAPz/DvpxOr46Hs415EWz0D/G0bbogVSkseyC0+VcGVlmDcZN6QUBQgMDOpswQHPc7suKMLqipGVhvkb+a666jUKsnUycFf7QT8X0I+BEQyYyZjg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Eg9fCtZjDc5Ea4BW8DO57RX3EcY6NVvBBU6/B97uuJ+fBLiRz/Wy+vZ6gGk21ylAcLo57f805Y52hNDNw/TBjwlgpjaPvH9YTGX092eFHZu4QCZ8pbdzQvlZQEQ1qMFBqWIGQl/1NW+4mJ3bU05Wd22ZscBrVT7vwIEf2igIoZ8DU89unGmrGxB5xePXhKZybb19trohzsEems4yoOH2Tt7eg3qYt0hOPdvNjRwuO8hrBYfqfdxHQu8PMbpyoQwJRu8TJRnvPYfIrkvbBfDqMqc4LlWndFOiGdnnCXU4aFx0h82Kw6Zr4okOuijit4XDtz3+Fx/i+vGW1Ogdy6Pc0g== 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.