Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751924AbdCMK1n (ORCPT ); Mon, 13 Mar 2017 06:27:43 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36480 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750993AbdCMK1f (ORCPT ); Mon, 13 Mar 2017 06:27:35 -0400 Subject: Re: [PATCH v2] statx: optimize copy of struct statx to userspace To: Andreas Dilger , Eric Biggers References: <20170311214555.941-1-ebiggers3@gmail.com> <20170312012411.GN29622@ZenIV.linux.org.uk> <20170312021655.GA593@zzz> <20170312022923.GQ29622@ZenIV.linux.org.uk> <20170312040206.GA3684@zzz> <20170312060148.GA1595@zzz> Cc: Al Viro , linux-fsdevel , David Howells , linux-kernel@vger.kernel.org, Eric Biggers From: Florian Weimer Message-ID: Date: Mon, 13 Mar 2017 11:27:32 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 13 Mar 2017 10:27:35 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1045 Lines: 22 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