From patchwork Mon Apr 17 20:50:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vishal Moola X-Patchwork-Id: 13214562 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 AF669C7EE2C for ; Mon, 17 Apr 2023 20:52:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9F3D7900002; Mon, 17 Apr 2023 16:52:52 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9A3618E0002; Mon, 17 Apr 2023 16:52:52 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7F5C8900002; Mon, 17 Apr 2023 16:52:52 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6F24B8E0002 for ; Mon, 17 Apr 2023 16:52:52 -0400 (EDT) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3FFAFC0562 for ; Mon, 17 Apr 2023 20:52:52 +0000 (UTC) X-FDA: 80692082184.10.2D4DD6C Received: from mail-pl1-f174.google.com (mail-pl1-f174.google.com [209.85.214.174]) by imf01.hostedemail.com (Postfix) with ESMTP id 76D1240010 for ; Mon, 17 Apr 2023 20:52:50 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=hr7pEt7A; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.174 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=1681764770; 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=ds3IS9TWlY4iXOF1Vygr3Q/N2fJxO0/Dzlxnv3cq6/0=; b=xJ5AgI6W3dBwlOTwacYfNuaqQeiC6WC8KXFQuu4xawQY8R9RgdlLcT/xuMGnaW/bMw0sUH bDyd5OUyaRM57vw6Atp1EG4QbwHKkis2RWHAk6yl2uM/ZF+3y3wonpv5fR7sn1PJiFQVho Ei4Dby1wVkAqBljFa9iwuVEdQyehzAI= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=gmail.com header.s=20221208 header.b=hr7pEt7A; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf01.hostedemail.com: domain of vishal.moola@gmail.com designates 209.85.214.174 as permitted sender) smtp.mailfrom=vishal.moola@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681764770; a=rsa-sha256; cv=none; b=IthICwpkbqJhki/D2GG/9QXRdIknwAIjM9+Rsexbdt3jDgihPSrXwKnnGMzVke/3U4u1b4 Pu6sVAoCVkxEMLlOpvmpXDZMLOGoNyk043+o/oZcv9SXwb+pinHSZ3HX9ffXdluXEjw67Z QRpfF6CutjQNIYkcOMNm0vHajbKhpBI= Received: by mail-pl1-f174.google.com with SMTP id p8so27386562plk.9 for ; Mon, 17 Apr 2023 13:52:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1681764769; x=1684356769; 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=ds3IS9TWlY4iXOF1Vygr3Q/N2fJxO0/Dzlxnv3cq6/0=; b=hr7pEt7A7XcPfK4WHrNDJyXTyW/f522/QxHB9K2NM6BmG8KnIlcSk7Prak06XFsubX Sjsu1MPagS5Ajy0wM6nwYZFly4hHrr9DYIrVTEdELHRdfsGo64oEk7qD+41S/NMObi8y l8A2tz8IWZ1X+Du4Mg5V1agW+uGCUPtQdgx1HioQtiEf01hZXw902OFYpkixEmc4936W rbvY3hq0N/ZSHnXC+KGydT6+ZrTUjCaNrxKIoD5OlWamJ5QPi1l2Tt7uz8xTA1Fp0QB2 97/hz5zZCcVfwzgfNZP+zBkRfPzWu3gB3ojY6/LKA9XIpl4tn1OEejbLEhRl9E9QH4p3 YC/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681764769; x=1684356769; 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=ds3IS9TWlY4iXOF1Vygr3Q/N2fJxO0/Dzlxnv3cq6/0=; b=iqPLa605BYlldQO32eQaBu4VilwEZGfjB28i1fDT/2+w3eNyzCS0B0X4FgiqZc8kbZ f/TbpwTxCKCID94RUQnz1KnYxS+yUeSDDwBjZAolEuvMFFH8VZcO94dDCr/bQTKnbnp1 BHi1gP6o7+Jj1lE9SAyBMEKV+g4st+FojrvqLEzo1y24fnNCyNCCXXQJ9FHECEdiQq1z dpUZnXdJ3apJXN6X463RG2cZMPbNGDkniAm+X2YD406eJFra24EESiixLHJ/lsLEyqWc +DFkMKleJdSthU5OPdXNf1/J4qaA8+BfJVhi1kcT/ugfNZqu62Sq5dnihpr9djKoUldd CpgQ== X-Gm-Message-State: AAQBX9evcVxrGaXPSYZEmF0vCXst6HFpO5HtpiPEPhIMYPxwc2VZcBPF V79duAWkA7+AuZ7WCSCqrlk= X-Google-Smtp-Source: AKy350bKOtS2RU5+UPauyBEeUGcMLqfRctd5dndnPm3bZbQM5N2yHnkL/dVsnC5V83h9pYCSEFQOHw== X-Received: by 2002:a05:6a20:6595:b0:eb:ad6a:ccf4 with SMTP id p21-20020a056a20659500b000ebad6accf4mr15296929pzh.18.1681764769281; Mon, 17 Apr 2023 13:52:49 -0700 (PDT) Received: from fedora.hsd1.ca.comcast.net ([2601:644:937f:7f20::c139]) by smtp.googlemail.com with ESMTPSA id h7-20020a17090ac38700b0022335f1dae2sm7609707pjt.22.2023.04.17.13.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Apr 2023 13:52:49 -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 03/33] pgtable: Create struct ptdesc Date: Mon, 17 Apr 2023 13:50:18 -0700 Message-Id: <20230417205048.15870-4-vishal.moola@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230417205048.15870-1-vishal.moola@gmail.com> References: <20230417205048.15870-1-vishal.moola@gmail.com> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 76D1240010 X-Stat-Signature: iun4orphywsapp75d154meai1s1rf5d3 X-HE-Tag: 1681764770-455821 X-HE-Meta: U2FsdGVkX19OAQcBF1pf56AQGiUacsNhiKMNgRqTLKDb5ljcITpcH5CyA/01eP8SL76aab+7jPNb4X6kuPiOB8hwIuV0aLgFoBb80Y4c5AVwnvG/+/o0kA1h9lcbKBkuxJ9eUkMtGJ8NaXIWvfc13aHl9aBVpb/q8bSg9p+ZkfbOfJ84/L55Sx2AemHaCgZ6Yr+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Ea+Ob+OWNbkSSF0qC6f1cp9AzVXiu+EPAatbXPniumzVyAg/L0vz/RFmA0ZYy/wS5fXIXYiuBpNiVLuLttJ12u2uuoa7ShR4AQmefRqGRaZUd7UeEGBXUWduyfLojyd9IBuOmMSZgXhijv+yPuYwJLDUikA14V2LqP7sX0EKzd5avkNzS+7yxi4BueTtUl5ANy9sWtY/SW7UTCYmkuTbhQn6UtXNwSuCXiXKbVo7De+PQgnsy7JTB4dOqOK5HN1g= 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 | 50 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/include/linux/pgtable.h b/include/linux/pgtable.h index 023918666dd4..7cc6ea057ee9 100644 --- a/include/linux/pgtable.h +++ b/include/linux/pgtable.h @@ -47,6 +47,56 @@ #define pmd_pgtable(pmd) pmd_page(pmd) #endif +/** + * 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; + }; + +#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(mapping, _pt_s390_gaddr); +TABLE_MATCH(pmd_huge_pte, pmd_huge_pte); +TABLE_MATCH(pt_mm, pt_mm); +TABLE_MATCH(ptl, ptl); +#undef TABLE_MATCH +static_assert(sizeof(struct ptdesc) <= sizeof(struct page)); + /* * A page table page can be thought of an array like this: pXd_t[PTRS_PER_PxD] *