From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f200.google.com (mail-pf0-f200.google.com [209.85.192.200]) by kanga.kvack.org (Postfix) with ESMTP id D6AA66B0033 for ; Mon, 18 Dec 2017 11:19:05 -0500 (EST) Received: by mail-pf0-f200.google.com with SMTP id 3so12961289pfo.1 for ; Mon, 18 Dec 2017 08:19:05 -0800 (PST) Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id r9si9672383pfe.13.2017.12.18.08.19.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 18 Dec 2017 08:19:04 -0800 (PST) Date: Mon, 18 Dec 2017 08:19:02 -0800 From: Matthew Wilcox Subject: Re: [PATCH 2/8] mm: De-indent struct page Message-ID: <20171218161902.GA688@bombadil.infradead.org> References: <20171216164425.8703-1-willy@infradead.org> <20171216164425.8703-3-willy@infradead.org> <20171218153652.GC3876@dhcp22.suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20171218153652.GC3876@dhcp22.suse.cz> Sender: owner-linux-mm@kvack.org List-ID: To: Michal Hocko Cc: linux-mm@kvack.org, "Kirill A. Shutemov" , Christoph Lameter , Matthew Wilcox On Mon, Dec 18, 2017 at 04:36:52PM +0100, Michal Hocko wrote: > On Sat 16-12-17 08:44:19, Matthew Wilcox wrote: > > From: Matthew Wilcox > > > > I found the struct { union { struct { union { struct { } } } } } > > layout rather confusing. Fortunately, there is an easier way to write > > this. The innermost union is of four things which are the size of an > > int, so the ones which are used by slab/slob/slub can be pulled up > > two levels to be in the outermost union with 'counters'. That leaves > > us with struct { union { struct { atomic_t; atomic_t; } } } which > > has the same layout, but is easier to read. > > This is where the pahole output would be really helpeful. The patch > looks OK, I will double check with a fresh brain tomorrow (with the rest > of the series), though. I got Arnaldo to change the pahole output to make this easier. Here's the result: @@ -11,17 +11,15 @@ }; /* 16 8 */ union { long unsigned int counters; /* 24 8 */ + unsigned int active; /* 24 4 */ struct { - union { - atomic_t _mapcount; /* 24 4 */ - unsigned int active; /* 24 4 */ - struct { - unsigned int inuse:16; /* 24:16 4 */ - unsigned int objects:15; /* 24: 1 4 */ - unsigned int frozen:1; /* 24: 0 4 */ - }; /* 24 4 */ - int units; /* 24 4 */ - }; /* 24 4 */ + unsigned int inuse:16; /* 24:16 4 */ + unsigned int objects:15; /* 24: 1 4 */ + unsigned int frozen:1; /* 24: 0 4 */ + }; /* 24 4 */ + int units; /* 24 4 */ + struct { + atomic_t _mapcount; /* 24 4 */ atomic_t _refcount; /* 28 4 */ }; /* 24 8 */ }; /* 24 8 */ It's even more dramatic if you use diff -uw (ignore whitespace): @@ -11,9 +11,6 @@ }; /* 16 8 */ union { long unsigned int counters; /* 24 8 */ - struct { - union { - atomic_t _mapcount; /* 24 4 */ unsigned int active; /* 24 4 */ struct { unsigned int inuse:16; /* 24:16 4 */ @@ -21,7 +18,8 @@ unsigned int frozen:1; /* 24: 0 4 */ }; /* 24 4 */ int units; /* 24 4 */ - }; /* 24 4 */ + struct { + atomic_t _mapcount; /* 24 4 */ atomic_t _refcount; /* 28 4 */ }; /* 24 8 */ }; /* 24 8 */ -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org