public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Noah Goldstein <goldstein.w.n@gmail.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Cc: Florian Weimer <fw@deneb.enyo.de>,
	 Noah Goldstein via Libc-alpha <libc-alpha@sourceware.org>,
	hjl.tools@gmail.com, carlos@systemhalted.org
Subject: Re: [PATCH v1 1/2] x86: Implement sched_yield syscall for x86 only.
Date: Thu, 8 Jun 2023 12:39:32 -0500	[thread overview]
Message-ID: <CAFUsyfK=G6Gs8c5jrU4-2ROsBB04_c3sV1CtvUG=fuvaNS=h+Q@mail.gmail.com> (raw)
In-Reply-To: <51ab6d92-6f27-52bf-c70c-c45c478a3299@linaro.org>

On Thu, Jun 8, 2023 at 7:08 AM Adhemerval Zanella Netto
<adhemerval.zanella@linaro.org> wrote:
>
>
>
> On 08/06/23 08:43, Florian Weimer wrote:
> > * Noah Goldstein via Libc-alpha:
> >
> >> We slightly optimize it by using `vzeroall` before the actual syscall.
> >> This returns the SSE, AVX, and ZMM_HI256 xsave/xrstor states to the
> >> init-state which allows the imminent context switch to skip
> >> saving/restoring those states.
> >
> > Surely there is a better way to implement this, enabling something
> > similar for all system calls issued by libc on the kernel side?  It
> > changes userspace ABI, so it has to be opt-in.  Maybe it could be an
> > additional flag in the system call number, indicating that it is safe
> > to zap the vector state if it is beneficial.
It seems like a much bigger change than is needed.
>
> Agree, trying to implement it on userland seems really hacky.  It means
> to potentially override and/or add an ifunc variant to any syscall that
> can potentially trigger a context switch; besides adding arch-specific
> implementation for something the kernel already has the information
> (so it can rewrite the syscall entrypoint depending of the ISA).

I don't think we need/want this for every syscall. Only the syscalls
where there is a high probability of a proper ctx switch and the calling
process going back to the schedule loop.
Otherwise the kernel generally just takes care to not touch vector registers
and doesn't bother with the save/restore.

  reply	other threads:[~2023-06-08 17:39 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-08  9:00 Noah Goldstein
2023-06-08  9:00 ` [PATCH v1 2/2] x86: Implement clock_nanosleep{_time64} " Noah Goldstein
2023-06-08 10:13 ` [PATCH v1 1/2] x86: Implement sched_yield " Gabriel Ravier
2023-06-08 17:43   ` Noah Goldstein
2023-06-08 11:43 ` Florian Weimer
2023-06-08 12:08   ` Adhemerval Zanella Netto
2023-06-08 17:39     ` Noah Goldstein [this message]
2023-06-08 18:26       ` Zack Weinberg
2023-06-08 19:41         ` Florian Weimer
2023-06-08 19:53           ` Noah Goldstein
2023-06-08 20:22             ` Zack Weinberg
2023-06-08 20:38               ` Noah Goldstein
2023-06-08 20:44                 ` Zack Weinberg
2023-06-08 21:06                   ` Noah Goldstein
2023-06-08 21:25                     ` Florian Weimer
2023-06-09  5:59                       ` Zack Weinberg
2023-06-10  1:11                         ` Noah Goldstein
2023-06-10  2:07                           ` Gabriel Ravier
2023-06-10  4:59                             ` Noah Goldstein

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='CAFUsyfK=G6Gs8c5jrU4-2ROsBB04_c3sV1CtvUG=fuvaNS=h+Q@mail.gmail.com' \
    --to=goldstein.w.n@gmail.com \
    --cc=adhemerval.zanella@linaro.org \
    --cc=carlos@systemhalted.org \
    --cc=fw@deneb.enyo.de \
    --cc=hjl.tools@gmail.com \
    --cc=libc-alpha@sourceware.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).