mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Andreas Dilger <adilger@dilger.ca>, Eric Biggers <ebiggers3@gmail.com>
Cc: Al Viro <viro@ZenIV.linux.org.uk>,
	linux-fsdevel <linux-fsdevel@vger.kernel.org>,
	David Howells <dhowells@redhat.com>,
	linux-kernel@vger.kernel.org, Eric Biggers <ebiggers@google.com>
Subject: Re: [PATCH v2] statx: optimize copy of struct statx to userspace
Date: Mon, 13 Mar 2017 11:27:32 +0100	[thread overview]
Message-ID: <dbbe9bca-15c5-5d3f-92f0-80cc69ec7768@redhat.com> (raw)
In-Reply-To: <F7337E43-D0B7-4196-8BB9-8E292C582C3B@dilger.ca>

On 03/13/2017 05:34 AM, Andreas Dilger wrote:
> Not that it is a huge deal either way, but I'd think it is harder for the
> compiler to optimize across a function call boundary like memset() vs. a
> struct initialization in the same function where it can see that all but
> a few of the fields are being overwritten immediately before they are used.

GCC treats memset as a function call only if options such as 
-ffreestanding or -fno-builtin are enabled, or if memset is redefined in 
a header file.  Does the kernel do this?

> I don't think the designated initializer is any less clear to the reader
> that the struct is zeroed out compared to using memset().  Possibly the
> best compromise is to use a designated initializer that specifies all of
> the known fields, and leaves it to the compiler to initialize unset fields
> or padding.

GCC will not always initialize padding if you specify a designated 
initializer because padding values are unspeficied and their value does 
not matter from a language point of view.

Thanks,
Florian

  reply	other threads:[~2017-03-13 10:27 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-11 21:45 Eric Biggers
2017-03-12  1:24 ` Al Viro
2017-03-12  2:16   ` Eric Biggers
2017-03-12  2:29     ` Al Viro
2017-03-12  4:02       ` Eric Biggers
2017-03-12  6:01         ` Eric Biggers
2017-03-13  4:34           ` Andreas Dilger
2017-03-13 10:27             ` Florian Weimer [this message]
2017-03-13 18:11               ` Eric Biggers

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=dbbe9bca-15c5-5d3f-92f0-80cc69ec7768@redhat.com \
    --to=fweimer@redhat.com \
    --cc=adilger@dilger.ca \
    --cc=dhowells@redhat.com \
    --cc=ebiggers3@gmail.com \
    --cc=ebiggers@google.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@ZenIV.linux.org.uk \
    /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

Powered by JetHome