From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Matheus Castanho <msc@linux.ibm.com>,
GNU C Library <libc-alpha@sourceware.org>
Subject: Re: semtimedop, powerpc, time64 and older kernels
Date: Wed, 30 Sep 2020 16:12:42 -0300 [thread overview]
Message-ID: <7b907046-152a-d057-c01d-2d0a80f83931@linaro.org> (raw)
In-Reply-To: <490fc1e6-fd80-c5e5-0d0f-603fed44d4b6@linux.ibm.com>
On 30/09/2020 15:29, Matheus Castanho wrote:
> Also, looks like my email client messed up the diff *sigh*. I'm sending
> a proper patch attached this time.
>
> --
> Matheus Castanho
>
> From 1c0a497a3f986bc6980581c9eab482ccf7bb190f Mon Sep 17 00:00:00 2001
> From: Matheus Castanho <msc@linux.ibm.com>
> Date: Wed, 30 Sep 2020 14:22:18 -0300
> Subject: [PATCH] sysvipc: Fix semtimedop for Linux < 5.1
>
> Kernels older than 5.1 will fail with ENOSYS when calling
> semtimedop_time64 syscall in __semtimedop_time64. Just like for
> !__ASSUME_TIME64_SYSCALLS, we should fallback to using the old mechanism
> in such cases.
> ---
> sysdeps/unix/sysv/linux/semtimedop.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/sysdeps/unix/sysv/linux/semtimedop.c b/sysdeps/unix/sysv/linux/semtimedop.c
> index a9ad922ee2..510fea1852 100644
> --- a/sysdeps/unix/sysv/linux/semtimedop.c
> +++ b/sysdeps/unix/sysv/linux/semtimedop.c
> @@ -32,7 +32,7 @@ __semtimedop64 (int semid, struct sembuf *sops, size_t nsops,
> int r = INLINE_SYSCALL_CALL (semtimedop_time64, semid, sops, nsops,
> timeout);
>
> -#ifndef __ASSUME_TIME64_SYSCALLS
> +#if !(defined __ASSUME_TIME64_SYSCALLS) || __LINUX_KERNEL_VERSION < 0x050100
> if (r == 0 || errno != ENOSYS)
> return r;
>
> --
> 2.26.2
Thanks for catching it and although it fixes the regression, we have
kernel-features.h exactly to avoid using __LINUX_KERNEL_VERSION through the
implementations. Also this is sub-optimal since it forces semtimeopd issues
__NR_semtimeop and then __NR_ipc on powerpc64 and we have
__ASSUME_DIRECT_SYSVIPC_SYSCALLS exactly to avoid this strategy of handling
ENOSYS for newer syscalls and thus slowing it down the implementation on
older kernels (--enable-kernel exists exactly to get rid of this older kernel
support).
I forgot that powerpc64 and s390x used the older multiplexed __NR_ipc and
kernel v5.1 decided to add proper __NR_semtimedop (and it was in fact handled
by 720e9541f5d919). I think a better fix is the one below, since it:
1. Issues __NR_semtimeop_time64 iff it is defined (32-bit architectures).
2. Issues __NR_semtimeop otherwise iff glibc is configured for a kernel that
supports it (for powerpc64 it will only for --enable-kernel=5.1).
Otherwise it will use only 3.
3. Issues __NR_ipc with IPCOP_semtimedop.
For powerpc64 it will issue either __NR_ipc (default) or __NR_semtimeop
(--enable-kernel=5.1), while for powerpc it will use either
__NR_semtimeop_time64 and fallback to __NR_ipc or just issue
__NR_semtimeop_time64.
I am running some regressions before commit it.
---
diff --git a/sysdeps/unix/sysv/linux/semtimedop.c b/sysdeps/unix/sysv/linux/semtimedop.c
index a9ad922ee2..29647f8ccd 100644
--- a/sysdeps/unix/sysv/linux/semtimedop.c
+++ b/sysdeps/unix/sysv/linux/semtimedop.c
@@ -26,11 +26,15 @@ int
__semtimedop64 (int semid, struct sembuf *sops, size_t nsops,
const struct __timespec64 *timeout)
{
-#ifndef __NR_semtimedop_time64
-# define __NR_semtimedop_time64 __NR_semtimedop
+ int r;
+#if defined __NR_semtimedop_time64
+ r = INLINE_SYSCALL_CALL (semtimedop_time64, semid, sops, nsops, timeout);
+#elif defined __ASSUME_DIRECT_SYSVIPC_SYSCALLS && defined __NR_semtimedop
+ r = INLINE_SYSCALL_CALL (semtimedop, semid, sops, nsops, timeout);
+#else
+ r = INLINE_SYSCALL_CALL (ipc, IPCOP_semtimedop, semid,
+ SEMTIMEDOP_IPC_ARGS (nsops, sops, timeout));
#endif
- int r = INLINE_SYSCALL_CALL (semtimedop_time64, semid, sops, nsops,
- timeout);
#ifndef __ASSUME_TIME64_SYSCALLS
if (r == 0 || errno != ENOSYS)
next prev parent reply other threads:[~2020-09-30 19:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-30 18:01 Matheus Castanho
2020-09-30 18:29 ` Matheus Castanho
2020-09-30 18:45 ` Andreas Schwab
2020-09-30 19:12 ` Adhemerval Zanella [this message]
2020-09-30 20:45 ` Matheus Castanho
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=7b907046-152a-d057-c01d-2d0a80f83931@linaro.org \
--to=adhemerval.zanella@linaro.org \
--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).