From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from brightrain.aerifal.cx (brightrain.aerifal.cx [216.12.86.13]) by sourceware.org (Postfix) with ESMTPS id BE17E385843E for ; Tue, 5 Sep 2023 21:42:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BE17E385843E Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=libc.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=libc.org Date: Tue, 5 Sep 2023 17:42:43 -0400 From: Rich Felker To: Linus Torvalds Cc: Adhemerval Zanella Netto , Mateusz Guzik , Andreas Schwab , Mateusz Guzik via Libc-alpha Subject: Re: fstat(2) penalized by using newfstatat(6, "", buf, AT_EMPTY_PATH) Message-ID: <20230905214242.GJ20403@brightrain.aerifal.cx> References: <680b330d-6ef3-adc5-9ba6-cf74dd53e422@linaro.org> <6d0e4e9e-ab69-0c73-bb9d-ce344b4a043b@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Tue, Sep 05, 2023 at 10:45:17AM -0700, Linus Torvalds wrote: > On Tue, 5 Sept 2023 at 10:28, Adhemerval Zanella Netto > wrote: > > > > I think we can still make it in a generic way, stat family would use more > > syscall (which some filters might complain) but it should be ok: > > Ugh. That patch of yours certainly seems to avoid the kernel overhead > (where that "fetch a byte from user space just to check it is '\0'" is > much more expensive than it is in user space), but why does glibc do > that whole "turn fstat() into fstatat(), and then turn it back again"? > > It seems just stupid. If the user asked for 'fstat()', just give the > user 'fstat()'. We do it in musl, but we also do the "turn it back again" in userspace. musl's __fstatat_kstat checks if AT_EMPTY_PATH is set, and if so, calls SYS_fstat. I don't see why glibc couldn't do the same. However, we don't do this, and this does not seem to be possible, in the case where statx has to be used (32-bit archs). Is there an analogous issue for statx? Rich