[PATCH 0/3] Add the sched_setattr, sched_getattr functions

enh enh@google.com
Thu Sep 5 20:29:03 GMT 2024


On Thu, Sep 5, 2024 at 3:51 PM Carlos O'Donell <carlos@redhat.com> wrote:
>
> On 9/5/24 2:33 PM, Florian Weimer wrote:
> > These are straightforward system call wrappers.  Like the existing
> > sched_* scheduler policy functions, sched_setattr interacts poorly with
> > PTHREAD_PRIO_PROTECT mutexes.
>
> As noted by Jopseh Myers in 2015, these interfaces should have had wrappers
> a long time ago following:
> https://sourceware.org/glibc/wiki/Consensus#WIP:_Kernel_syscalls_wrappers
>
> I think these APIs meet the goals outlined there, modulo their poor interaction
> with the pthread_* APIs, which is something that can be improved over time.

do you trust upstream not to break source compatibility again? there
have already been two different versions of this struct with the same
name. or are you just assuming that next time they do it, userspace
has a struct sched_attr_2?

(this -- and the fact that glibc hadn't taken a position -- is why i'd
been avoiding doing anything in bionic.)

btw, from my [machine-readable seccomp] notes, here's a couple of
other similarly old syscalls glibc's missing:

# Since Linux 4.3, not in glibc. Probed for and conditionally used by ART.
int membarrier(int, int) all
int userfaultfd(int) all

oddly musl does have a <sys/membarrier.h> with the former, but i don't
think anyone has the latter yet.

> Without theses APIs the SCHED_DEADLINE support in the kernel has be manually
> added to things chatr.
>
> > Documentation mostly refers to the manual pages.
> >
> > Tested on i686-linux-gnu, x86_64-linux-gnu.  Built with
> > build-many-glibcs.py.
> >
> > Thanks,
> > Florian
> >
> > Florian Weimer (3):
> >   manual: Extract the @manpageurl{func,sec} macro
> >   Linux: Add the sched_setattr and sched_getattr functions
> >   Linux: Add missing scheduler constants to <sched.h>
> >
> >  NEWS                                          |   3 +
> >  manual/macros.texi                            |   7 +-
> >  manual/resource.texi                          | 103 +++++++++++++++++
> >  sysdeps/unix/sysv/linux/Makefile              |  13 +++
> >  sysdeps/unix/sysv/linux/Versions              |   4 +
> >  sysdeps/unix/sysv/linux/aarch64/libc.abilist  |   2 +
> >  sysdeps/unix/sysv/linux/alpha/libc.abilist    |   2 +
> >  sysdeps/unix/sysv/linux/arc/libc.abilist      |   2 +
> >  sysdeps/unix/sysv/linux/arm/be/libc.abilist   |   2 +
> >  sysdeps/unix/sysv/linux/arm/le/libc.abilist   |   2 +
> >  sysdeps/unix/sysv/linux/bits/sched.h          |  58 +++++++++-
> >  sysdeps/unix/sysv/linux/csky/libc.abilist     |   2 +
> >  sysdeps/unix/sysv/linux/hppa/libc.abilist     |   2 +
> >  sysdeps/unix/sysv/linux/i386/libc.abilist     |   2 +
> >  .../sysv/linux/loongarch/lp64/libc.abilist    |   2 +
> >  .../sysv/linux/m68k/coldfire/libc.abilist     |   2 +
> >  .../unix/sysv/linux/m68k/m680x0/libc.abilist  |   2 +
> >  .../sysv/linux/microblaze/be/libc.abilist     |   2 +
> >  .../sysv/linux/microblaze/le/libc.abilist     |   2 +
> >  .../sysv/linux/mips/mips32/fpu/libc.abilist   |   2 +
> >  .../sysv/linux/mips/mips32/nofpu/libc.abilist |   2 +
> >  .../sysv/linux/mips/mips64/n32/libc.abilist   |   2 +
> >  .../sysv/linux/mips/mips64/n64/libc.abilist   |   2 +
> >  sysdeps/unix/sysv/linux/nios2/libc.abilist    |   2 +
> >  sysdeps/unix/sysv/linux/or1k/libc.abilist     |   2 +
> >  .../linux/powerpc/powerpc32/fpu/libc.abilist  |   2 +
> >  .../powerpc/powerpc32/nofpu/libc.abilist      |   2 +
> >  .../linux/powerpc/powerpc64/be/libc.abilist   |   2 +
> >  .../linux/powerpc/powerpc64/le/libc.abilist   |   2 +
> >  .../unix/sysv/linux/riscv/rv32/libc.abilist   |   2 +
> >  .../unix/sysv/linux/riscv/rv64/libc.abilist   |   2 +
> >  .../unix/sysv/linux/s390/s390-32/libc.abilist |   2 +
> >  .../unix/sysv/linux/s390/s390-64/libc.abilist |   2 +
> >  sysdeps/unix/sysv/linux/sched_getattr.c       |  27 +++++
> >  sysdeps/unix/sysv/linux/sched_setattr.c       |  26 +++++
> >  sysdeps/unix/sysv/linux/sh/be/libc.abilist    |   2 +
> >  sysdeps/unix/sysv/linux/sh/le/libc.abilist    |   2 +
> >  .../sysv/linux/sparc/sparc32/libc.abilist     |   2 +
> >  .../sysv/linux/sparc/sparc64/libc.abilist     |   2 +
> >  sysdeps/unix/sysv/linux/tst-sched-consts.py   |  56 +++++++++
> >  sysdeps/unix/sysv/linux/tst-sched_setattr.c   | 106 ++++++++++++++++++
> >  .../unix/sysv/linux/x86_64/64/libc.abilist    |   2 +
> >  .../unix/sysv/linux/x86_64/x32/libc.abilist   |   2 +
> >  43 files changed, 465 insertions(+), 4 deletions(-)
> >  create mode 100644 sysdeps/unix/sysv/linux/sched_getattr.c
> >  create mode 100644 sysdeps/unix/sysv/linux/sched_setattr.c
> >  create mode 100644 sysdeps/unix/sysv/linux/tst-sched-consts.py
> >  create mode 100644 sysdeps/unix/sysv/linux/tst-sched_setattr.c
> >
> >
> > base-commit: 3e4a01870ef9605ccf6475215a4b32aa86d5d206
>
> --
> Cheers,
> Carlos.
>


More information about the Libc-alpha mailing list