netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@infradead.org>
To: Eric Dumazet <edumazet@google.com>
Cc: Christoph Lameter <cl@linux.com>,
	Dmitry Vyukov <dvyukov@google.com>,
	Eric Dumazet <eric.dumazet@gmail.com>,
	Andrey Ryabinin <aryabinin@virtuozzo.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Theodore Ts'o <tytso@mit.edu>,
	jack@suse.com, linux-ext4@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	Jozsef Kadlecsik <kadlec@blackhole.kfki.hu>,
	Florian Westphal <fw@strlen.de>,
	David Miller <davem@davemloft.net>,
	netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	netdev <netdev@vger.kernel.org>,
	Gerrit Renker <gerrit@erg.abdn.ac.uk>,
	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
Subject: Misuse of constructors
Date: Wed, 1 Aug 2018 08:51:36 -0700	[thread overview]
Message-ID: <20180801155136.GB4039@bombadil.infradead.org> (raw)
In-Reply-To: <CANn89i+KtwtLvSw1c=Ux8okKP+XyMxzYbuKhYb2qhYeMw=NTzg@mail.gmail.com>

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()).

  reply	other threads:[~2018-08-01 15:51 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-31 17:01 SLAB_TYPESAFE_BY_RCU without constructors (was Re: [PATCH v4 13/17] khwasan: add hooks implementation) Andrey Ryabinin
2018-07-31 17:09 ` Florian Westphal
2018-07-31 17:32   ` Eric Dumazet
2018-07-31 17:36 ` Christopher Lameter
2018-07-31 17:41   ` Eric Dumazet
2018-07-31 17:51     ` Dmitry Vyukov
2018-07-31 18:16       ` Eric Dumazet
2018-07-31 17:49   ` Linus Torvalds
2018-07-31 18:51     ` Linus Torvalds
2018-08-01  8:46       ` Dmitry Vyukov
2018-08-01  9:10         ` Dmitry Vyukov
2018-08-01 10:35           ` Florian Westphal
2018-08-01 10:41             ` Dmitry Vyukov
2018-08-01 11:40               ` Florian Westphal
2018-08-01 12:38                 ` Dmitry Vyukov
2018-08-01 13:46                   ` Florian Westphal
2018-08-01 13:52                     ` Dmitry Vyukov
2018-08-06 20:20         ` Jan Kara
2018-08-01  9:03       ` Andrey Ryabinin
2018-08-01 10:23         ` Eric Dumazet
2018-08-01 10:34           ` Dmitry Vyukov
2018-08-01 11:28             ` Eric Dumazet
2018-08-01 11:35               ` Dmitry Vyukov
2018-08-01 15:15                 ` Christopher Lameter
2018-08-01 15:37                   ` Eric Dumazet
2018-08-01 15:51                     ` Matthew Wilcox [this message]
2018-08-01 15:53                     ` Dmitry Vyukov
2018-08-01 16:22                     ` Christopher Lameter
2018-08-01 16:25                       ` Eric Dumazet
2018-08-01 16:47                         ` Dmitry Vyukov
2018-08-01 17:18                           ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180801155136.GB4039@bombadil.infradead.org \
    --to=willy@infradead.org \
    --cc=airlied@linux.ie \
    --cc=aryabinin@virtuozzo.com \
    --cc=cl@linux.com \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=dccp@vger.kernel.org \
    --cc=dvyukov@google.com \
    --cc=edumazet@google.com \
    --cc=eric.dumazet@gmail.com \
    --cc=fw@strlen.de \
    --cc=gerrit@erg.abdn.ac.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=intel-gfx@lists.freedesktop \
    --cc=jack@suse.com \
    --cc=jani.nikula@linux.intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=kadlec@blackhole.kfki.hu \
    --cc=linux-ext4@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=rodrigo.vivi@intel.com \
    --cc=torvalds@linux-foundation.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).