public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Mateusz Guzik <mjguzik@gmail.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Andreas Schwab <schwab@suse.de>, Rich Felker <dalias@libc.org>,
	 Mateusz Guzik via Libc-alpha <libc-alpha@sourceware.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: fstat(2) penalized by using newfstatat(6, "", buf, AT_EMPTY_PATH)
Date: Tue, 5 Sep 2023 15:14:43 +0200	[thread overview]
Message-ID: <CAGudoHF1pLbO4+1ucqct2kEqNEkyqCPeX7uDsYRE82tVVX6cmQ@mail.gmail.com> (raw)
In-Reply-To: <680b330d-6ef3-adc5-9ba6-cf74dd53e422@linaro.org>

On 9/5/23, Adhemerval Zanella Netto <adhemerval.zanella@linaro.org> wrote:
> If I understand correctly, the issue seems to be the usage of a empty string
>
> sentinel ("") to indicate the argument it not really used (which trigger
> all
> the SMAP issues since kernel will always try to copy the argument from
> userland).  This also means on x86_64 you will also have this performance
> penalty on syscalls that use AT_EMPTY_PATH (i.e, execveat,
> name_to_handle_at,
> open_tree, faccessat, etc.).  I really think it would better fixed in the
> kernel instead of adding extra constraints for the userland.
>

I completely agree this is a problem going way past fstat.

One could be tempted to allow NULL with the flag, but that wont work
-- I know of code out there which checks for statx availability by
deliberately passing a NULL path. I would not be shocked if there was
more of the sort and passing the AT_EMPTY_PATH flag on top.

I am considering proposing a new flag which combined with NULL path
would indicate there is only a fd lookup to perform -- fuly backwards
compatible and avoiding the problem. Then syscalls could start
supporting it over time as people get around to it.

However, the fstab stub in glibc does not have to suffer it regardless
of what happens with the above.

-- 
Mateusz Guzik <mjguzik gmail.com>

  reply	other threads:[~2023-09-05 13:14 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 [this message]
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

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=CAGudoHF1pLbO4+1ucqct2kEqNEkyqCPeX7uDsYRE82tVVX6cmQ@mail.gmail.com \
    --to=mjguzik@gmail.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=dalias@libc.org \
    --cc=libc-alpha@sourceware.org \
    --cc=schwab@suse.de \
    --cc=torvalds@linux-foundation.org \
    /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).