From: Alexander Lobakin <alobakin@pm.me>
To: Rich Felker <dalias@aerifal.cx>, musl@lists.openwall.com
Cc: Alexander Lobakin <alobakin@pm.me>
Subject: [musl] [PATCH 00/18] time64: always prefer time64 syscalls
Date: Sun, 27 Dec 2020 18:39:03 +0000 [thread overview]
Message-ID: <20201227183842.22030-1-alobakin@pm.me> (raw)
Since Linux 4.18, there's an option CONFIG_COMPAT_32BIT_TIME that
allows to ultimately test libc and userland programs if they are
using the latest available syscall variants, time64 variants in
particular.
With this option turned off, old time32 syscalls don't get compiled
at all. The same applies to some deprecated syscalls such as
nanosleep.
Unfortunately, on 32-bit systems Musl fails on this hardly with
at least non-working sleeps, signal and sockets. That's because
Musl currently uses time64 variants only as "fallbacks" when some
of the arguments exceeds 32-bit width.
Moreover, Musl currently prefers deprecated adjtimex over
clock_adjtime, ipc over semtimedop, nanosleep over clock_nanosleep
etc.
As for me, libc should always use the latest available syscalls,
especially when it comes to y2038, and get back to fallbacks only
in case of -ENOSYS (on older systems). Newer systems might just
don't get deprecated stuff compiled in, as it is with mentioned
Kconfig option.
BTW, code size savings from excluding deprecated syscalls are quite
nice (bloat-o-meter):
add/remove: 0/39 grow/shrink: 8/4 up/down: 3464/-10480 (-7016)
Function old new delta
sys_timerfd_settime 180 1604 +1424
sys_rt_sigtimedwait 236 884 +648
sys_timerfd_gettime 116 724 +608
sys_pselect6 128 356 +228
sys_timer_settime 256 472 +216
sys_timer_gettime 116 268 +152
sys_sched_rr_get_interval 108 260 +152
do_nanosleep.constprop 424 460 +36
sys_futimesat_time32 8 - -8
sys_clock_adjtime32 8 - -8
sys_adjtimex_time32 8 - -8
sys_utimes_time32 16 - -16
nanosleep_copyout 104 76 -28
poll_select_finish 600 564 -36
sock_gettstamp 524 480 -44
ksys_ipc 828 784 -44
sys_time32 80 - -80
put_old_itimerspec32 80 - -80
sys_sched_rr_get_interval_time32 108 - -108
sys_timerfd_gettime32 116 - -116
sys_timer_gettime32 116 - -116
__put_old_timespec32 124 - -124
sys_pselect6_time32 128 - -128
__do_sys_adjtimex_time32 144 - -144
sys_stime32 164 - -164
sys_timerfd_settime32 180 - -180
compat_ksys_semtimedop 188 - -188
sys_utime32 196 - -196
get_old_itimerspec32 204 - -204
sys_utimensat_time32 216 - -216
sys_clock_gettime32 224 - -224
sys_clock_getres_time32 232 - -232
sys_rt_sigtimedwait_time32 236 - -236
sys_clock_settime32 236 - -236
sys_ppoll_time32 244 - -244
do_timer_gettime 252 - -252
sys_timer_settime32 256 - -256
sys_recvmmsg_time32 256 - -256
sched_rr_get_interval 256 - -256
__do_sys_clock_adjtime32 260 - -260
sys_nanosleep_time32 276 - -276
do_compat_futimesat 300 - -300
put_old_timex32 316 - -316
do_pselect 316 - -316
do_timer_settime.part 320 - -320
sys_clock_nanosleep_time32 340 - -340
sys_futex_time32 480 - -480
get_old_timex32 480 - -480
do_sigtimedwait 696 - -696
do_timerfd_gettime 708 - -708
do_timerfd_settime 1560 - -1560
Total: Before=4538992, After=4531976, chg -0.15%
This set ensures that all 18 syscalls are being run as follows:
1. time64 variant.
2. -ENOSYS? time32 variant.
3. -ENOSYS again? Any old stuff (adjtimex, ipc, nanosleep).
With this set, all syscalls and userspace programs work as expected
with CONFIG_COMPAT_32BIT_TIME turned off, just by using time64
variants.
Tested on MIPS32R2 (OABI), Linux 5.11-rc1 (pre) + Musl latest git
snapshot.
Alexander Lobakin (18):
clock_gettime: prefer time64 variant if available
clock_settime: prefer time64 variant if available
clock_adjtime: try adjtimex at last
clock_getres: use time64 variant by default
clock_nanosleep: prefer time64 variant if available
timer_gettime: prefer time64 variant if available
timer_settime: prefer time64 variant if available
timerfd_gettime: prefer time64 variant if available
timerfd_settime: prefer time64 variant if available
utimensat: prefer time64 variant if available
pselect, select: prefer time64 variant of pselect6 if available
poll, ppoll: prefer time64 variant of ppoll if available
mq_timedsend: prefer time64 variant if available
mq_timedreceive: prefer time64 variant if available
semtimedop: prefer time64 variant of semtimedop if available
[rt_]sigtimedwait: prefer time64 variant if available
futex: prefer time64 variant if available
sched_rr_get_interval: use time64 variant if available
src/internal/pthread_impl.h | 22 +++++++++++++++++----
src/ipc/semtimedop.c | 20 +++++++++----------
src/linux/clock_adjtime.c | 12 ++++++-----
src/linux/ppoll.c | 8 +++-----
src/linux/timerfd.c | 11 +++--------
src/mq/mq_timedreceive.c | 6 ++----
src/mq/mq_timedsend.c | 6 ++----
src/sched/sched_rr_get_interval.c | 21 ++++++++++----------
src/select/poll.c | 23 +++++++++++++++++-----
src/select/pselect.c | 6 ++----
src/select/select.c | 22 +++++++++++----------
src/signal/sigtimedwait.c | 6 ++----
src/stat/utimensat.c | 6 ++----
src/thread/__timedwait.c | 6 ++----
src/thread/__wait.c | 4 ++--
src/thread/pthread_barrier_wait.c | 6 +++---
src/thread/pthread_cond_timedwait.c | 10 +++++-----
src/thread/pthread_mutex_timedlock.c | 8 +++-----
src/thread/pthread_mutex_trylock.c | 2 +-
src/thread/pthread_mutex_unlock.c | 2 +-
src/thread/pthread_mutexattr_setprotocol.c | 2 +-
src/time/clock_getres.c | 21 ++++++++++----------
src/time/clock_gettime.c | 4 +---
src/time/clock_nanosleep.c | 22 +++++++++++----------
src/time/clock_settime.c | 6 ++----
src/time/timer_gettime.c | 4 +---
src/time/timer_settime.c | 7 ++-----
27 files changed, 137 insertions(+), 136 deletions(-)
--
2.29.2
next reply other threads:[~2020-12-27 18:55 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-27 18:39 Alexander Lobakin [this message]
2020-12-27 18:40 ` [musl] [PATCH 01/18] clock_gettime: prefer time64 variant if available Alexander Lobakin
2020-12-27 18:40 ` [musl] [PATCH 02/18] clock_settime: " Alexander Lobakin
2020-12-27 18:41 ` [musl] [PATCH 03/18] clock_adjtime: try adjtimex at last Alexander Lobakin
2020-12-27 21:57 ` Rich Felker
2020-12-27 18:41 ` [musl] [PATCH 04/18] clock_getres: use time64 variant by default Alexander Lobakin
2020-12-27 18:41 ` [musl] [PATCH 05/18] clock_nanosleep: prefer time64 variant if available Alexander Lobakin
2020-12-27 18:41 ` [musl] [PATCH 06/18] timer_gettime: " Alexander Lobakin
2020-12-27 18:41 ` [musl] [PATCH 07/18] timer_settime: " Alexander Lobakin
2020-12-27 18:41 ` [musl] [PATCH 08/18] timerfd_gettime: " Alexander Lobakin
2020-12-27 18:41 ` [musl] [PATCH 09/18] timerfd_settime: " Alexander Lobakin
2020-12-27 18:41 ` [musl] [PATCH 10/18] utimensat: " Alexander Lobakin
2020-12-27 18:42 ` [musl] [PATCH 11/18] pselect, select: prefer time64 variant of pselect6 " Alexander Lobakin
2020-12-27 18:42 ` [musl] [PATCH 12/18] poll, ppoll: prefer time64 variant of ppoll " Alexander Lobakin
2020-12-27 18:42 ` [musl] [PATCH 13/18] mq_timedsend: prefer time64 variant " Alexander Lobakin
2020-12-27 18:42 ` [musl] [PATCH 14/18] mq_timedreceive: " Alexander Lobakin
2020-12-27 18:42 ` [musl] [PATCH 15/18] semtimedop: prefer time64 variant of semtimedop " Alexander Lobakin
2020-12-27 18:42 ` [musl] [PATCH 16/18] [rt_]sigtimedwait: prefer time64 variant " Alexander Lobakin
2020-12-27 18:42 ` [musl] [PATCH 17/18] futex: " Alexander Lobakin
2020-12-27 22:18 ` Rich Felker
2020-12-27 18:42 ` [musl] [PATCH 18/18] sched_rr_get_interval: use " Alexander Lobakin
2020-12-27 21:54 ` [musl] [PATCH 01/18] clock_gettime: prefer " Rich Felker
2020-12-27 21:52 ` [musl] [PATCH 00/18] time64: always prefer time64 syscalls Rich Felker
2020-12-28 11:11 ` Alexander Lobakin
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=20201227183842.22030-1-alobakin@pm.me \
--to=alobakin@pm.me \
--cc=dalias@aerifal.cx \
--cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
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 NNTP newsgroup(s).