From: Linus Torvalds <torvalds@linux-foundation.org>
To: Mateusz Guzik <mjguzik@gmail.com>
Cc: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
Andreas Schwab <schwab@suse.de>, Rich Felker <dalias@libc.org>,
Mateusz Guzik via Libc-alpha <libc-alpha@sourceware.org>
Subject: Re: fstat(2) penalized by using newfstatat(6, "", buf, AT_EMPTY_PATH)
Date: Tue, 5 Sep 2023 10:29:42 -0700 [thread overview]
Message-ID: <CAHk-=wg_6CYB0qDQ9eDfjZSsqzgKcF2ZMd2DObfeFc_N-PxUjg@mail.gmail.com> (raw)
In-Reply-To: <CAGudoHF1pLbO4+1ucqct2kEqNEkyqCPeX7uDsYRE82tVVX6cmQ@mail.gmail.com>
On Tue, 5 Sept 2023 at 06:14, Mateusz Guzik <mjguzik@gmail.com> wrote:
>
> I completely agree this is a problem going way past fstat.
Realistically, fstatat() is likely the only case that matters from any
performance angle because it's the only one likely to be used a lot in
real loads.
Sure, there are other "at" system calls, but they just aren't
important from a performance angle.
I don't think we've ever seen 'fchown/fchmod()' be a major performance
issue, and if it was, the cost is elsewhere (ie the writeback of the
changed inode), so if glibc were to translate it to
'fchownat/fchmodat()' with AT_EMPTY_PATH, it really wouldn't matter.
In contrast, there are tons of loads where 'fstat()' is a noticeable
part of the load, because the "open+fstat" pattern is simply
fundamental Unix code. So converting it to 'fstatat()' is simply
*bad*.
Right now the kernel does even more than it needs to do (ie it does
the whole pathname handling, because I certainly didn't expect
AT_EMPTY_PATH to be a *hot* path), but as Mateusz says, even with that
all short-circuited (we have a trivial patch to do just that), just
the cost of checking "is it actually empty" is noticeable because of
the security boundary issue.
Linus
prev parent reply other threads:[~2023-09-05 17:30 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-04 9:55 Mateusz Guzik
2023-09-04 10:08 ` Andreas Schwab
2023-09-04 10:11 ` Mateusz Guzik
2023-09-05 13:01 ` Adhemerval Zanella Netto
2023-09-05 13:14 ` Mateusz Guzik
2023-09-05 17:28 ` Adhemerval Zanella Netto
2023-09-05 17:45 ` Linus Torvalds
2023-09-05 18:22 ` Adhemerval Zanella Netto
2023-09-05 19:16 ` Adhemerval Zanella Netto
2023-09-05 19:21 ` Linus Torvalds
2023-09-05 21:42 ` Rich Felker
2023-09-05 21:46 ` Mateusz Guzik
2023-09-05 17:29 ` Linus Torvalds [this message]
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='CAHk-=wg_6CYB0qDQ9eDfjZSsqzgKcF2ZMd2DObfeFc_N-PxUjg@mail.gmail.com' \
--to=torvalds@linux-foundation.org \
--cc=adhemerval.zanella@linaro.org \
--cc=dalias@libc.org \
--cc=libc-alpha@sourceware.org \
--cc=mjguzik@gmail.com \
--cc=schwab@suse.de \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).