From patchwork Mon Jul 31 17:03:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13335104 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 B3924C001DE for ; Mon, 31 Jul 2023 17:03:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F4D26B0168; Mon, 31 Jul 2023 13:03:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 47E656B0169; Mon, 31 Jul 2023 13:03:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2AAA66B016A; Mon, 31 Jul 2023 13:03:51 -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 181C26B0168 for ; Mon, 31 Jul 2023 13:03:51 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CB55A1C8C55 for ; Mon, 31 Jul 2023 17:03:50 +0000 (UTC) X-FDA: 81072529020.29.DFF0997 Received: from mail-oi1-f175.google.com (mail-oi1-f175.google.com [209.85.167.175]) by imf05.hostedemail.com (Postfix) with ESMTP id 04786100014 for ; Mon, 31 Jul 2023 17:03:42 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=U7jETlvh; spf=pass (imf05.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.167.175 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=1690823023; a=rsa-sha256; cv=none; b=ET6N0DalW/g2We2n220UXRy17SVQXtwSISRFAHYZEoLfkumkSvWLvoHW47R5s51iPEwWcD RtBGAMWXOvmyK6QzhHeG99zbPinNPd3qtwHQcl7JGcvTRowZGXLKx9K4px/2rI7IZrF8EW mYWCZ4jBq2vs3t2SI03JwdJw0fjO4tQ= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=U7jETlvh; spf=pass (imf05.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.167.175 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=1690823023; 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=Z39OytypuZQhWkFCV+z6u8l5O5ZgTP/vsQXKA5JsO6g=; b=OHfApBJdJ3RZ+6dMbSmrTM3YtUyJSBkLSW0qBzq/c4UF6JiY2v8u6MWq4aINx1IiCWhWqe KU+EAQExlwL60gkSrmWSl6PIB2XxQLlbE5a+LXjYSINTs+4NtHS5JHRj2mjS7M96IS1doy 37WO1P4srhb6f9NUsY8acMvxdWYijH0= Received: by mail-oi1-f175.google.com with SMTP id 5614622812f47-3a426e70575so2742159b6e.0 for ; Mon, 31 Jul 2023 10:03:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1690823022; x=1691427822; 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=Z39OytypuZQhWkFCV+z6u8l5O5ZgTP/vsQXKA5JsO6g=; b=U7jETlvh8mqc3055+tBC6M+9Gy8R7REEMm1ZwKGc87m0rGDIJvgZcQ22vsmsinFtgt YTQlnuPzwi5zjdD+hLDWvxB/bmYZ8keXNmrVzrv6YRz6eCv0CI9nx19KksxH7KprzagR irj90f/wH/tTIxD8sQn1Ka9sOZ4dPOYQtK8h3N0b0riSaIJ2B+2YXCtlZtVEkrPg3Bbm Ojw5AwhfC3mD3DUjG5dFAv5YKIY2ngXsFAsSD6uydkdJ8uV+q2q9uUnnFZIrFIqfANGz oTPiE5dBvTDG/Pv3tzLP875t1DoqUqRhJ+2aPTfRbOK8xixubum5W0ZiIgU8cUKgztEJ 6Kvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690823022; x=1691427822; 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=Z39OytypuZQhWkFCV+z6u8l5O5ZgTP/vsQXKA5JsO6g=; b=G/tct7LcoySVSkjYYj5lxP8j1HVHSLgdYgHj22wBNueh9R6shDB04F58L/MD/8bGWC giiRWke5zejx3ARicOU86hrsbkhWKlPVi3FixmENcCQkbv7fFkbT0k/EP+WOHzK/cJ2H jvpXNgxgyB8FMEedpAA5k7ko7PhqN8Jv9QnHIYQ4hGOczNbBsnQ1YvA+QxQ94JB2O4l/ ZoeMaxVR3X72GYhzE75NbGxor2eo8N2z3T1VEDvuW5xYA69hOi/gjZvj5/w7m+7IRYNk lMHuaxGwFfiDgAnTgqokb4wIKJ4D2Gg7uI4kl3mKwEwRl5PxVP/afEhsJO9uK4novp/q 8JdA== X-Gm-Message-State: ABy/qLY2+SjUjYzkScClOjR6ykHSyQSEIpjFxIiR+64zaB/JhYiVF59u FM/ryk1vpDKYJXe9NYoqFc8= X-Google-Smtp-Source: APBJJlHO94ah80UzwDXxBX9kkXsVAL3mPuWGcSVwu/SHGxcgeWhtI+EazxMnc09xov2z5IkvLaxhhA== X-Received: by 2002:a05:6808:13c1:b0:3a3:7612:28cd with SMTP id d1-20020a05680813c100b003a3761228cdmr11096736oiw.28.1690823021788; Mon, 31 Jul 2023 10:03:41 -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.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 31 Jul 2023 10:03:41 -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 02/31] pgtable: Create struct ptdesc Date: Mon, 31 Jul 2023 10:03:03 -0700 Message-Id: <20230731170332.69404-3-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-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 04786100014 X-Stat-Signature: uzjuratfzh6ferfn7rbq1gieo6y87k8t X-Rspam-User: X-HE-Tag: 1690823022-550384 X-HE-Meta: U2FsdGVkX1940Id+HQvMOqFyp9ITBXXvXevPfgCPiOluhGJBavLaJPNEcJBQc459aHw56JEqpdPbirrZUTaNwYythOeja87C3wbLFVjkCYLPsGd88B6FB8W/GUF/LrGA8p0D1t2rF4pm2o+LsAT2a2NxGzoDMNX6/9LPdZIpR7dXG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yS+alwkGZaJa2y27+Y4QrdtYs/lKIVKzYJR6ODjEoCaD4wVfLSmcx3lA4i6x++lGmffoCHQrAAGr774QFK5XU3rgJuOsXLtwcvfKftiXLBwUY6a8pGZjGoqXzJIsNtu9HU1a4YfIiAWNV+OWOF0ZdGqPTfuIqHOxdVmr7Mi/Jw9N5fcDH3dJYZFPywzB6fsYB0K+pBoypDCAh7LvxmHpoCY+aj0IS+xUuHgoITTzi3Bk7k3M2htB5squMPpvkYlg9QN/iu9PsFaDHmo6LYqz371sGMtp15zCkpsqn5J+Byca9bLGmUFRMjIXQMTPtrspEDbWzMg== 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 | 71 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 5f36c055794b..1f92514d54b0 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -993,6 +993,77 @@ 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. + * @__page_mapping: Aliases with page->mapping. Unused for page tables. + * @pt_mm: Used for x86 pgds. + * @pt_frag_refcount: For fragmented page table tracking. Powerpc and s390 only. + * @_pt_pad_2: Padding to ensure proper alignment. + * @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 __page_mapping; + + 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, __page_mapping); +TABLE_MATCH(pt_mm, pt_mm); +TABLE_MATCH(ptl, ptl); +TABLE_MATCH(rcu_head, pt_rcu_head); +TABLE_MATCH(page_type, __page_type); +TABLE_MATCH(_refcount, _refcount); +#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.