[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20180801155136.GB4039@bombadil.infradead.org>
Date: Wed, 1 Aug 2018 08:51:36 -0700
From: Matthew Wilcox <willy@...radead.org>
To: Eric Dumazet <edumazet@...gle.com>
Cc: Christoph Lameter <cl@...ux.com>,
Dmitry Vyukov <dvyukov@...gle.com>,
Eric Dumazet <eric.dumazet@...il.com>,
Andrey Ryabinin <aryabinin@...tuozzo.com>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Theodore Ts'o <tytso@....edu>, jack@...e.com,
linux-ext4@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Pablo Neira Ayuso <pablo@...filter.org>,
Jozsef Kadlecsik <kadlec@...ckhole.kfki.hu>,
Florian Westphal <fw@...len.de>,
David Miller <davem@...emloft.net>,
netfilter-devel@...r.kernel.org, coreteam@...filter.org,
netdev <netdev@...r.kernel.org>,
Gerrit Renker <gerrit@....abdn.ac.uk>, dccp@...r.kernel.org,
jani.nikula@...ux.intel.com, joonas.lahtinen@...ux.intel.com,
rodrigo.vivi@...el.com, airlied@...ux.ie,
intel-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
Alexey Kuznetsov <kuznet@....inr.ac.ru>,
Hideaki YOSHIFUJI <yoshfuji@...ux-ipv6.org>,
Ursula Braun <ubraun@...ux.ibm.com>,
linux-s390@...r.kernel.org, LKML <linux-kernel@...r.kernel.org>,
Andrew Morton <akpm@...ux-foundation.org>,
linux-mm <linux-mm@...ck.org>,
Andrey Konovalov <andreyknvl@...gle.com>,
linux-fsdevel@...r.kernel.org
Subject: Misuse of constructors
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()).
Powered by blists - more mailing lists