From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936160AbdCXVIq (ORCPT ); Fri, 24 Mar 2017 17:08:46 -0400 Received: from mail-pg0-f67.google.com ([74.125.83.67]:35549 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756475AbdCXVIe (ORCPT ); Fri, 24 Mar 2017 17:08:34 -0400 Date: Fri, 24 Mar 2017 14:08:26 -0700 From: Eric Biggers To: David Howells Cc: linux-fsdevel@vger.kernel.org, Al Viro , linux-kernel@vger.kernel.org, Eric Biggers Subject: Re: [PATCH v4] statx: optimize copy of struct statx to userspace Message-ID: <20170324210826.GB4986@gmail.com> References: <20170313222836.105526-1-ebiggers3@gmail.com> <3434.1489664501@warthog.procyon.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3434.1489664501@warthog.procyon.org.uk> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 16, 2017 at 11:41:41AM +0000, David Howells wrote: > Eric Biggers wrote: > > > stat() instead initializes its struct on the stack and copies it to > > userspace with a single call to copy_to_user(). This turns out to be > > much faster, and changing statx to do this makes it almost as fast as > > stat: > > I wonder if we actually need to copy __spare2 at the end. We could define any > future values added in there to be unset/undefined if the respective bits are > not set. > > I would prefer it to be cleaner, however, and clear the unused space. > > Another thought is does it make sense to rearrange struct kstat to mirror > the first part of struct statx so that this can be memcpy'd? > > David Not clearing __spare2 would effectively turn every new bit into specifying an "extension of the buffer", and there would be no way for the kernel to provide a "fabricated" value for any new field. I don't think it's the right choice. Also I don't think it makes sense to rearrange struct kstat to match struct statx, because that would bring details of the syscall ABI down into places it shouldn't be. Also, struct kstat is used to hold information for both stat() and statx(). It doesn't make sense to optimize statx() at the expense of stat() yet because almost everything will still be using stat() in the near-term. - Eric