From patchwork Mon Aug 7 23:04:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13345286 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 93E14C001DF for ; Mon, 7 Aug 2023 23:05:26 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9C4E28D0001; Mon, 7 Aug 2023 19:05:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 97768900002; Mon, 7 Aug 2023 19:05:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7EE148D0006; Mon, 7 Aug 2023 19:05:25 -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 70DEA8D0001 for ; Mon, 7 Aug 2023 19:05:25 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 4E605A0B12 for ; Mon, 7 Aug 2023 23:05:25 +0000 (UTC) X-FDA: 81098841810.29.147EB4C Received: from mail-yb1-f176.google.com (mail-yb1-f176.google.com [209.85.219.176]) by imf24.hostedemail.com (Postfix) with ESMTP id 78D6C18000B for ; Mon, 7 Aug 2023 23:05:23 +0000 (UTC) Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=oFwky5a0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.176 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=1691449523; 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=a34f21esV50lWBersDNDqmppsx1/6ilmHOTavl/xl8o=; b=IfnWIFMgpLlxc8vI/CkaEiwtnIeNTAjVZByclGf7jT1JfLQRToGSB2ks/41XbkccUFlOWJ p2357LaHARAcXyt0b2oSZDIsbIDNBCtRkO82x1JzdAQKtqaYNVl0vqEpo14Hsnsse3yU2Y bbrGgODt/TDjhtFP7b+VIwvMvMoYOqg= ARC-Authentication-Results: i=1; imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=oFwky5a0; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.219.176 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691449523; a=rsa-sha256; cv=none; b=vVDRvj+QEGxbf8QGRHM7InV+FdWgK7UQL2aoubHtc34HlLbbjbkNmydQZX9SxJymYiZD0Y Xi1swP3A3vONekXiNb/pxhhDkU8sgvsHwLA25lrvZPRtnQoG02dF6dn741K9zNea5tnZo1 +B79lJmYyjizjla2gugx9kFoYjCCakM= Received: by mail-yb1-f176.google.com with SMTP id 3f1490d57ef6-d5869d9651aso722674276.2 for ; Mon, 07 Aug 2023 16:05:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691449522; x=1692054322; 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=a34f21esV50lWBersDNDqmppsx1/6ilmHOTavl/xl8o=; b=oFwky5a0u6RDMZneanUwrrMHlk718vp357up6yt/zwnqVYFChL1rvBLlof3lNCzIMa fNsEK2lTF1AVBptjZ1CNiCZUzihavKETKYN9gVvYQI6adZVOr5WVilhYnG1hRIdUadMS rZHYG0cY0MgC9spT/xtrGp0Z9RSAR89ub11+qTFSD/NHXR1SOhgGi5SO3dghfFZLOejg KputLo/y59tBrGZ+oHkk/Miwz+ltthb0+dR9j85/GLscklo1srlDZt2wotLowv37n6A5 LO+9uJnrNQ6hj9u600MpE0S2h1+9c+75UpIga0Og5F4xShPF0bPK2EhAmwZTlcxr2oZQ 4pBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691449522; x=1692054322; 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=a34f21esV50lWBersDNDqmppsx1/6ilmHOTavl/xl8o=; b=eV6ohadCRc0+8MHPUORNukER15MjxMX9KTbg/eANrtdO2fBe1WkrUh8KPxRApv5I+M TDaRDvo5IcugcqKhv8OUhEUNrR85/JX52Knfu4kcC626egUnfv65JEx+EcFW3vYMkzGU Zl02TGJdtoVqck98ZjhIJIcGm2rnsQqIUdRzhUgI8xU1dSHq4PxlP7FjzKMsgcxcxwVb 7W1vwzm0AFpxHFUDLZFnT2f6I7bPAQd8IsdfYYa3y3IaTf3aJHtHNGn78qJPt5n17a4R zJ43mRFw8lw0nUrN9RVjHSFVe9dTEobOJqfxWOn04tTuq4gAKtBhTWRKn0GgHQqHwKL3 nYpA== X-Gm-Message-State: AOJu0YxNi9DGyvLq7JFMs31p5Pb7C/ss7rBAv0OO4g/0InL0SFLTzL/3 ywTWgO1G+WW2rAAPsN4Rh00= X-Google-Smtp-Source: AGHT+IHp9NHIhzlo/URxP7pkQYxSTPvQNJLHOzpXCbXbudXygK+XnGEho5KZf1Qzac+pXhrvkYZIBg== X-Received: by 2002:a25:320c:0:b0:d4b:64ac:a4f7 with SMTP id y12-20020a25320c000000b00d4b64aca4f7mr9519366yby.62.1691449522393; Mon, 07 Aug 2023 16:05:22 -0700 (PDT) Received: from unknowna0e70b2ca394.attlocal.net ([2600:1700:2f7d:1800::16]) by smtp.googlemail.com with ESMTPSA id d190-20020a25cdc7000000b00d3596aca5bcsm2545203ybf.34.2023.08.07.16.05.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 16:05:22 -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 v9 02/31] pgtable: create struct ptdesc Date: Mon, 7 Aug 2023 16:04:44 -0700 Message-Id: <20230807230513.102486-3-vishal.moola@gmail.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230807230513.102486-1-vishal.moola@gmail.com> References: <20230807230513.102486-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 78D6C18000B X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: 4d415zcumy9a577jfpqhnbq4zy6zq6x9 X-HE-Tag: 1691449523-270476 X-HE-Meta: U2FsdGVkX1/HStTZTuzrg1AYC+G1xKTU4MUp63Xnl/Ds6DPjOBoqHqY/I7tRX+IQlcAGhMa71J3oIn54iWYwHFcKXl0434ckfhL1MDcARvCwuLMa6L2nd9yObIbym3Qu8/5+BZb0ljF9+9YXyK38lF3YMschGzfmmBYxkI+Tg+s8OWn8rwiXdg7Ex8CyX19gK7KqgizKm30/KV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opeZzD0ZLih5pl+niNdpSyYzbm96WzWGflrCWEtowQZjfHVSozmnUlZnMryc7vtjRNRsH9nuqm5a1VCccMM57WawY8evnj2jUei7Mi5ZOZnT52w9jK9UApF49Sq3gkFTfET2SZpubUcHsdHXexJT69ndkhrxtGHtgBqfvxiycaA+0C85kjILb/zPmM7rzdOvtgm9zFI7lGe+vKmtWuYCWbbgrRt9GT3pm8iBpM2AP+ejeB2hxI17rYeQFrI3ri+D+BURBXRKUCU7vo7NT0g0CBMwTpDE8Kfll0Xh8D28tFF9E66CFQ== 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/mm_types.h | 70 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 18c8c3d793b0..cb47438ae17f 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -397,6 +397,76 @@ FOLIO_MATCH(flags, _flags_2); FOLIO_MATCH(compound_head, _head_2); #undef FOLIO_MATCH +/** + * 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)); + /* * Used for sizing the vmemmap region on some architectures */