From patchwork Fri May 18 19:45:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Wilcox X-Patchwork-Id: 10411977 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 E0436602C2 for ; Fri, 18 May 2018 19:45:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CEECD286AA for ; Fri, 18 May 2018 19:45:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C385828A4F; Fri, 18 May 2018 19:45:38 +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 1FECB286AA for ; Fri, 18 May 2018 19:45:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5A2BC6B0668; Fri, 18 May 2018 15:45:26 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4B5836B0665; Fri, 18 May 2018 15:45:26 -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 131D46B0662; Fri, 18 May 2018 15:45:26 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from mail-pf0-f199.google.com (mail-pf0-f199.google.com [209.85.192.199]) by kanga.kvack.org (Postfix) with ESMTP id AEF9E6B0662 for ; Fri, 18 May 2018 15:45:25 -0400 (EDT) Received: by mail-pf0-f199.google.com with SMTP id e3-v6so5290422pfe.15 for ; Fri, 18 May 2018 12:45:25 -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=sp2WVcc1sSo7LvGC7f/lZyiGf5ULs93gmxdZAPNSkvU=; b=aayfvAy/BWzxf7eWhflIu0PsrAfVF8ta0x5Y8PPRPiYpS5oiBniHV9MjecvOC9GRly 6+MqRbpfmU9BHo+bJBAGAx0O3impaAsI867Nr2E8qQLRbIAG2d3t8/R8NhZ1/OyeC6zd /BjBI+xS8JyCUbJJH/bDwIL4a4XrtJkodJN0X0xihwhtV2VPzjodLgmB4jyJ8v8MMt2B DLjCg+/aQzKVmjGDDq0sRQKcE3VcchEHrF3cwKqHFCGAMZDxzEEU5d7VV3JWt0/ajodF VAPhnpgyPATqQLzLmcK0N7ra2SJewaubC/42mGfmX1bXCYW/707m9o808EOItfIr19d6 h/vw== X-Gm-Message-State: ALKqPwfSwzcUNTRN6kyhCHzbLwDLqkxZ+A+VVhdJ21DB0DFHhylPVSjE yhuBUoc/W7qA4CShMRS4tTOe7JV83bQRxm7hTr6vOc3Uqg80/T92JKIFQ7ub8sovUNiLF9Tj2rs CFvJhD3wg+kD1y2LIpYL+GS5Xn+66bb4AS63xJyCUG6zVoF8gtUO4B1kSNTntBAqQ9Q== X-Received: by 2002:a17:902:1566:: with SMTP id b35-v6mr10894079plh.107.1526672725409; Fri, 18 May 2018 12:45:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqHfhpKPstdCKJp4vT8yPAvbVJF8/LvFFdYZT2jCACL4QDgrRuFEj5/GFn4Pj40/QitEuvl X-Received: by 2002:a17:902:1566:: with SMTP id b35-v6mr10894010plh.107.1526672723568; Fri, 18 May 2018 12:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526672723; cv=none; d=google.com; s=arc-20160816; b=JYfAQuqGzLsYGH8mFtkKqeB4vcXio1dM7LXXrPlzLgiriWJqUwocEe5gQ+k1c7hCM+ Wgqm6C8NfBgUXFIpGGxkbCA7YqC+vj01ri6RSpgYf5m0r6avEWLcGVuDK5qa88QOHlMC 5+gu2abBBl/c8HLRiWohNe9j2ogYe9wazvZONLqFfy8ETvRMStPQjEld/7d1V5yVNei4 4ikbzb03QjM71WINDRrmUgutkJLwVK8jy5KupS78gZBNv+E8aqnS6fEz//BUg/td/fvu 5ruzDuq4vyfxaMkvzmeAA2VpMLHnKz5Oz8N7hbLXxhQhdQ5XokiUIezE466edEP9C1ms Ppig== 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=sp2WVcc1sSo7LvGC7f/lZyiGf5ULs93gmxdZAPNSkvU=; b=gE9ZWADE6yJXiAKeKfW8dGil1PnpxAtesi29UI4f4RpFhvg4n5JiZb3OWxEUlJyV3w I4pxwLatcCGMy+fglL5924nvCDGMeEeeJBVCqi2gcyHJEvGkO7PN+LuIgP/UCcZu3uwU 6JliW085PVZ/YlDWFqgmsk0BRwpCX56oidFTdyPU0bOdJkGAcSu9SDHAWD+wWW05pN7f YYbXC3/lhj7jSXPiYyp+qmJxIqpDRNN7qTX21jR8+3/EFjoLuiSmVy6Y/00X+Uh/k/mE BkN0fLYC6eJudjih900r9WGYP5mlH4CEgqJeJ0GNYAI+t+OjwfSln57BMx5+BxMnYSt3 NVUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=YcqIvHeu; 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 q137-v6si8456752pfc.68.2018.05.18.12.45.23 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 May 2018 12:45: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=YcqIvHeu; 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=sp2WVcc1sSo7LvGC7f/lZyiGf5ULs93gmxdZAPNSkvU=; b=YcqIvHeuCnpyHkgV2nGl6Op8X scK6uPMsUnQRbDPjzhEXWzBKWRQQsNKzKW42D39SoFt0/Ji/jvTrx7bHnNjeA1JTQMP5cNbUnRoJh SqFj3EJJgvk6gKJz2zUwnbzozrtk3bEYI4l6xAOqCHd9IcJp0LJpBnpc4ucuvvnMC+gcO7Ss3TM4u 5GrxFug0on+AO6fdN7kRF0ZRy7i0/9e5cX6TM+5wVGaKLVB13rTVIF7PVHS7AckcO18HR6DM3TjO6 DptbsAvi20orapX9h3HWgXPBoQa3gn2R5xlZlQVSkhZ2R/kcZoyNW+uZxoQlEM2AfVx/3dyqrw740 73Tpw7JuQ==; Received: from willy by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJlJa-00010w-P8; Fri, 18 May 2018 19:45: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 v6 07/17] mm: Combine first three unions in struct page Date: Fri, 18 May 2018 12:45:09 -0700 Message-Id: <20180518194519.3820-8-willy@infradead.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180518194519.3820-1-willy@infradead.org> References: <20180518194519.3820-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; }; };