From patchwork Fri May 4 18:33:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10381345 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 19F4860353 for ; Fri, 4 May 2018 18:59:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09F5B29598 for ; Fri, 4 May 2018 18:59:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F29F129597; Fri, 4 May 2018 18:59:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E623D2957C for ; Fri, 4 May 2018 18:59:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7C6A76B0276; Fri, 4 May 2018 14:33:37 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 6EBA06B027C; Fri, 4 May 2018 14:33:37 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 562B76B0275; Fri, 4 May 2018 14:33:37 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pg0-f70.google.com (mail-pg0-f70.google.com [74.125.83.70]) by kanga.kvack.org (Postfix) with ESMTP id 005506B0275 for ; Fri, 4 May 2018 14:33:37 -0400 (EDT) Received: by mail-pg0-f70.google.com with SMTP id 127-v6so14199464pge.10 for ; Fri, 04 May 2018 11:33:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:dkim-signature:from:to:cc:subject:date :message-id:in-reply-to:references; bh=WViRD4Wc5jFIBPybgKCAGG+BQXTxifioMpZ+h9xXVkA=; b=f6vNglhIkUw71/Q3CC2erTn8c22w4xW7PURKaU7eRpGGPfyBaovB4u7+asA0RsSMAy BliC8JqbS99/Z7Vz3+LHOHeP99NRDarUXcGgSM8nz7WXW61XY/WcVsdrrmFa4bKdisLe uiyp6iF6Y1UX+lDyHY/NfjniPaVNbLr1X9PaAFQzOsq/aG6ONcT2wWNPkmCdLJv4A6sl l67ACltdcd8zInQ5m0+6idZSa00MJ6sUJMSsOAfVqOiqchAw0gFF32IGIYH2U3flfGL5 WH23h1y1/D4QCLcR4kd40ZjJI0DjkQYUI5XvHY1iloPwqeouPjqxVDjpQeopiMqh/7am KmVg== X-Gm-Message-State: ALQs6tDPkjTHl5dsnIJpz/ugEQMH+ZLmt7gJVv5cpI3d0Dt6MqqKymqg KMj4SqvWsJIWb4gyTB4gOezpMmFSx2q0gh7YgWRX1tZ7Sr7aktKfcQ+h7p7qNEETMLuWUfwnGtG k+aulkfA3ynNP3TJEbsol1X8VWiXZ6L/IX4A7S+46hjariTmxa0lKYht7G0OZzqMP7g== X-Received: by 2002:a65:5a07:: with SMTP id y7-v6mr23195496pgs.15.1525458816677; Fri, 04 May 2018 11:33:36 -0700 (PDT) X-Google-Smtp-Source: AB8JxZp7GxhhC2dpyYbbLv3p2MORJf9c5Pe1KGNhAixNj9SlYLRkBVPiIt9ZupYhPv3y6CG6JLQs X-Received: by 2002:a65:5a07:: with SMTP id y7-v6mr23195053pgs.15.1525458803561; Fri, 04 May 2018 11:33:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525458803; cv=none; d=google.com; s=arc-20160816; b=fIbbu5VvIZ3d8h00LIF8TY5BizWnGVBe4LPJ8jUZ40h4mnOOdKw6XwomylBhnFBo7z 0gf95OKHJHZARaH3EirNILodijUVQ9c9bxoUqUEAkhBVUIESCoPmhBq8a8j/pxDVndMf UHdtdlFLBjKVjFC6R4+l4/Gw0QKdRzp6BswOdxnzIX1lFZ/r4AjgI6bB1syshEI1RP75 xIjpDhje/Xy7+rz73X1b3MeGwytHSiOAoJWXCcICI8xGUIysXSIqAtOYH8C1YL5yfUJB uouONwQaLDyv//L7E0YUA3875v2hX/gMZb6mJOcB9a+zGzLvslCArUcFjeA9SsAVAl7M V0XA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=WViRD4Wc5jFIBPybgKCAGG+BQXTxifioMpZ+h9xXVkA=; b=tKsvDXDsA4RXhmZXZiNC7LsonNRuHOuPIwNvjqJ66JLAkwJpZ3qlWyQF4+4vYGYLm5 BNApVgpBgSqit0hF4XrfBZXYpQLdxDsWPTC52hBsjZwq5flU469wkCUOui8rgLqPw7nU Nyu9+LaxXuGU8rRuJL4hEhwQRoPeidFFPyUqpjYO9CsyssQXP5kRWOu+LztziA/+Nkck XM9YIE375QFDpCRgaALL743o4tRnZ1qx7eAD0O55iD+ZDhoHqsOaIa2nT7F+ebFzwDdo 3Q/0vvepmudZHbBW49SQkFVSbcMDz26txdTAZVYHQWDLjgtCj++DlHGdjB8m7NwL/Ad8 jgfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=JY3CAuUT; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id q9-v6si13192521pgt.5.2018.05.04.11.33.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 11:33:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) client-ip=2607:7c80:54:e::133; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=JY3CAuUT; spf=pass (google.com: best guess record for domain of willy@infradead.org designates 2607:7c80:54:e::133 as permitted sender) smtp.mailfrom=willy@infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=WViRD4Wc5jFIBPybgKCAGG+BQXTxifioMpZ+h9xXVkA=; b=JY3CAuUTT5/3C0VRpCAHpEpRp 2MTZIAYaeTtHkC2IhHNKbMxKgDhL8DDr2/uC4KJglK9JonB8gFt07GaxfWJYE6aS/l3Pn19eph9qB d70JD+UexZH6sj8RROpHh9plriii45uCRzvUcg+JbXuCKGA2D55NhKvvITAX9CW4RqeR1nJupysEG zaSUSttSXHk+YmWTsRr3pYTnS3k5oKCn/i5vf59z9JfXc6nGz7N8w1Nj3Uw4FG9ZepI4+vUL2YoKt uj16OLNB/kNPcocrUqJVIiDbRiPXeWSphxWyXdaigef9B/1u2IXzFNJVDrrc7w2fqs7xzTux4vW0J yNezSnwOw==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fEfWE-0003m6-JV; Fri, 04 May 2018 18:33:22 +0000 From: Matthew Wilcox To: linux-mm@kvack.org Cc: Matthew Wilcox , Andrew Morton , "Kirill A . Shutemov" , Christoph Lameter , Lai Jiangshan , Pekka Enberg , Vlastimil Babka , Dave Hansen , =?UTF-8?q?J=C3=A9r=C3=B4me=20Glisse?= Subject: [PATCH v5 07/17] mm: Combine first three unions in struct page Date: Fri, 4 May 2018 11:33:08 -0700 Message-Id: <20180504183318.14415-8-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504183318.14415-1-willy@infradead.org> References: <20180504183318.14415-1-willy@infradead.org> 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: X-Virus-Scanned: ClamAV using ClamSMTP From: Matthew Wilcox By combining these three one-word unions into one three-word union, we make it easier for users to add their own multi-word fields to struct page, as well as making it obvious that SLUB needs to keep its double-word alignment for its freelist & counters. No field moves position; verified with pahole. Signed-off-by: Matthew Wilcox Acked-by: Kirill A. Shutemov Acked-by: Vlastimil Babka --- include/linux/mm_types.h | 66 ++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 33 deletions(-) diff --git a/include/linux/mm_types.h b/include/linux/mm_types.h index 9828cd170251..629a7b568ed7 100644 --- a/include/linux/mm_types.h +++ b/include/linux/mm_types.h @@ -70,46 +70,46 @@ struct hmm; #endif struct page { - /* First double word block */ unsigned long flags; /* Atomic flags, some possibly * updated asynchronously */ + /* Three words (12/24 bytes) are available in this union. */ union { - /* See page-flags.h for the definition of PAGE_MAPPING_FLAGS */ - struct address_space *mapping; - - struct kmem_cache *slab_cache; /* SL[AU]B: Pointer to slab */ + struct { /* Page cache and anonymous pages */ + /* See page-flags.h for PAGE_MAPPING_FLAGS */ + struct address_space *mapping; + pgoff_t index; /* Our offset within mapping. */ + /** + * @private: Mapping-private opaque data. + * Usually used for buffer_heads if PagePrivate. + * Used for swp_entry_t if PageSwapCache. + * Indicates order in the buddy system if PageBuddy. + */ + unsigned long private; + }; + struct { /* slab, slob and slub */ + struct kmem_cache *slab_cache; /* not slob */ + /* Double-word boundary */ + void *freelist; /* first free object */ + union { + void *s_mem; /* slab: first object */ + unsigned long counters; /* SLUB */ + struct { /* SLUB */ + unsigned inuse:16; + unsigned objects:15; + unsigned frozen:1; + }; + }; + }; atomic_t compound_mapcount; /* first tail page */ - /* page_deferred_list().next -- second tail page */ - }; - - /* Second double word */ - union { - pgoff_t index; /* Our offset within mapping. */ - void *freelist; /* sl[aou]b first free object */ - /* page_deferred_list().prev -- second tail page */ - }; - - union { - /* - * Mapping-private opaque data: - * Usually used for buffer_heads if PagePrivate - * Used for swp_entry_t if PageSwapCache - * Indicates order in the buddy system if PageBuddy - */ - unsigned long private; -#if USE_SPLIT_PTE_PTLOCKS + struct list_head deferred_list; /* second tail page */ + struct { /* Page table pages */ + unsigned long _pt_pad_2; /* mapping */ + unsigned long _pt_pad_3; #if ALLOC_SPLIT_PTLOCKS - spinlock_t *ptl; + spinlock_t *ptl; #else - spinlock_t ptl; -#endif + spinlock_t ptl; #endif - void *s_mem; /* slab first object */ - unsigned long counters; /* SLUB */ - struct { /* SLUB */ - unsigned inuse:16; - unsigned objects:15; - unsigned frozen:1; }; };