From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pl0-f69.google.com (mail-pl0-f69.google.com [209.85.160.69]) by kanga.kvack.org (Postfix) with ESMTP id B980A6B000A for ; Wed, 1 Aug 2018 11:52:47 -0400 (EDT) Received: by mail-pl0-f69.google.com with SMTP id m2-v6so13867070plt.14 for ; Wed, 01 Aug 2018 08:52:47 -0700 (PDT) Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:e::133]) by mx.google.com with ESMTPS id 196-v6si16499218pgg.588.2018.08.01.08.52.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Aug 2018 08:52:46 -0700 (PDT) Date: Wed, 1 Aug 2018 08:51:36 -0700 From: Matthew Wilcox Subject: Misuse of constructors Message-ID: <20180801155136.GB4039@bombadil.infradead.org> References: <01000164f169bc6b-c73a8353-d7d9-47ec-a782-90aadcb86bfb-000000@email.amazonses.com> <30ee6c72-dc90-275a-8e23-54221f393cb0@virtuozzo.com> <01000164f60f3f12-b1253c6e-ee57-49fc-aed8-0944ab4fd7a2-000000@email.amazonses.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: owner-linux-mm@kvack.org List-ID: To: Eric Dumazet Cc: Christoph Lameter , Dmitry Vyukov , Eric Dumazet , Andrey Ryabinin , Linus Torvalds , Theodore Ts'o , jack@suse.com, linux-ext4@vger.kernel.org, Greg Kroah-Hartman , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , David Miller , netfilter-devel@vger.kernel.org, coreteam@netfilter.org, netdev , Gerrit Renker , dccp@vger.kernel.org, jani.nikula@linux.intel.com, joonas.lahtinen@linux.intel.com, rodrigo.vivi@intel.com, airlied@linux.ie, intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Alexey Kuznetsov , Hideaki YOSHIFUJI , Ursula Braun , linux-s390@vger.kernel.org, LKML , Andrew Morton , linux-mm , Andrey Konovalov , linux-fsdevel@vger.kernel.org On Wed, Aug 01, 2018 at 08:37:07AM -0700, Eric Dumazet wrote: > The idea of having a ctor() would only be a win if all the fields that > can be initialized in the ctor are contiguous and fill an integral > number of cache lines. Let's state it more generally: Having a ctor is only a win if it allows the user to avoid reading or writing a significant number of cachelines. For example, the radix tree node occupies nine cachelines (576 bytes). The typical user will touch two of those cacheliens (the header and the cacheline which contains the slot of interest). That's seven cachelines which don't even need to be read, let alone written. I think filesystems are particularly prone to this antipattern of initialising some of their inode with a ctor and the remainder at alloc_inode() time (compare the locations of the struct members touched by inode_init_always() and inode_init_once()).