From: Tulio Magno Quites Machado Filho <tuliom@ascii.art.br>
To: Matheus Castanho <msc@linux.ibm.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH v2 1/2] powerpc: Runtime selection between sc and scv for syscalls
Date: Wed, 30 Dec 2020 18:29:48 -0300 [thread overview]
Message-ID: <87o8ibx9rn.fsf@linux.ibm.com> (raw)
In-Reply-To: <20201203171528.83180-2-msc@linux.ibm.com>
Matheus Castanho via Libc-alpha <libc-alpha@sourceware.org> writes:
> Linux kernel v5.9 added support for system calls using the scv
> instruction for POWER9 and later. The new codepath provides better
> performance (see below) if compared to using sc. For the
> foreseeable future, both sc and scv mechanisms will co-exist, so this
> patch enables glibc to do a runtime check and use scv when it is
> available.
>
> Before issuing the system call to the kernel, we check hwcap2 in the TCB
> for PPC_FEATURE2_SCV to see if scv is supported by the kernel. If not,
> we fallback to sc and keep the old behavior.
>
> The kernel implements a different error return convention for scv, so
> when returning from a system call we need to handle the return value
> differently depending on the instruction we used to enter the kernel.
>
> For syscalls implemented in ASM, entry and exit are implemented by
> different macros (PSEUDO and PSEUDO_RET, resp.), which may be used in
> sequence (e.g. for templated syscalls) or with other instructions in
> between (e.g. clone). To avoid accessing the TCB a second time on
> PSEUDO_RET to check which instruction we used, the value read from
> hwcap2 is cached on a non-volatile register.
>
> This is not needed when using INTERNAL_SYSCALL macro, since entry and
> exit are bundled into the same inline asm directive.
>
> The dynamic loader may issue syscalls before the TCB has been setup
> so it always uses sc with no extra checks. For the static case, there
> is no compile-time way to determine if we are inside startup code,
> so we also check the value of the thread pointer before effectively
> accessing the TCB. For such situations in which the availability of
> scv cannot be determined, sc is always used.
>
> Support for scv in syscalls implemented in their own ASM file (clone and
> vfork) will be added later. For now simply use sc as before.
LGTM.
Pushed as 68ab82f56690ada86ac1e0c46bad06ba189a10ef.
Thanks!
--
Tulio Magno
next prev parent reply other threads:[~2020-12-30 21:29 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-03 17:15 [PATCH v2 0/2] powerpc: Add support for system call vectored Matheus Castanho
2020-12-03 17:15 ` [PATCH v2 1/2] powerpc: Runtime selection between sc and scv for syscalls Matheus Castanho
2020-12-10 17:28 ` Matheus Castanho
2020-12-10 18:07 ` Adhemerval Zanella
2020-12-30 21:29 ` Tulio Magno Quites Machado Filho [this message]
2020-12-03 17:15 ` [PATCH v2 2/2] powerpc: Use scv instruction on clone when available Matheus Castanho
2020-12-30 21:30 ` Tulio Magno Quites Machado Filho
2020-12-08 18:24 ` [PATCH v2 0/2] powerpc: Add support for system call vectored Lucas A. M. Magalhaes
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=87o8ibx9rn.fsf@linux.ibm.com \
--to=tuliom@ascii.art.br \
--cc=libc-alpha@sourceware.org \
--cc=msc@linux.ibm.com \
/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).