Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933399AbdCLECU (ORCPT ); Sat, 11 Mar 2017 23:02:20 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:33591 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755666AbdCLECK (ORCPT ); Sat, 11 Mar 2017 23:02:10 -0500 Date: Sat, 11 Mar 2017 20:02:06 -0800 From: Eric Biggers To: Al Viro Cc: linux-fsdevel@vger.kernel.org, David Howells , linux-kernel@vger.kernel.org, Eric Biggers Subject: Re: [PATCH v2] statx: optimize copy of struct statx to userspace Message-ID: <20170312040206.GA3684@zzz> References: <20170311214555.941-1-ebiggers3@gmail.com> <20170312012411.GN29622@ZenIV.linux.org.uk> <20170312021655.GA593@zzz> <20170312022923.GQ29622@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170312022923.GQ29622@ZenIV.linux.org.uk> User-Agent: Mutt/1.8.0 (2017-02-23) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1071 Lines: 21 On Sun, Mar 12, 2017 at 02:29:27AM +0000, Al Viro wrote: > > Oh, I agree that multiple __put_user() are wrong; I also agree that bulk copy is > the right approach (when we get the unsafe stuff right, we can revisit that, but > I suspect that on quite a few architectures a bulk copy will still give better > time, no matter what). > > > If padding is a concern at all (AFAICS it's not actually an issue now with > > struct statx, but people tend to have different opinions on how careful they > > want to be with padding), then I think we'll just have to start by memsetting > > the whole struct to 0. > > My point is simply that it's worth a comment in that code. Okay, thanks. I'll add a comment about the padding assumption, and I think I'll take the suggestion to use a designated initializer. Then at least all *fields* get initialized by default. And if in the future someone wants to conditionally initialize fields, then they can use ?: or they can do it after the initializer. Either way, at least they won't be able to forget to zero some field. - Eric