[all-commits] [llvm/llvm-project] 6e25ea: [libc] Implement pthread_attr_[gs]etschedpolicy (#...
Pavel Labath via All-commits
all-commits at lists.llvm.org
Fri Sep 11 01:55:10 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 6e25eaedeee9ee4845565514dce823988ac7f23c
https://github.com/llvm/llvm-project/commit/6e25eaedeee9ee4845565514dce823988ac7f23c
Author: Pavel Labath <pavel at labath.sk>
Date: 2026-09-11 (Fri, 11 Sep 2026)
Changed paths:
M libc/config/linux/aarch64/entrypoints.txt
M libc/config/linux/riscv/entrypoints.txt
M libc/config/linux/x86_64/entrypoints.txt
M libc/include/llvm-libc-types/pthread_attr_t.h
M libc/include/pthread.yaml
M libc/src/pthread/CMakeLists.txt
A libc/src/pthread/pthread_attr_getschedpolicy.cpp
A libc/src/pthread/pthread_attr_getschedpolicy.h
M libc/src/pthread/pthread_attr_init.cpp
A libc/src/pthread/pthread_attr_setschedpolicy.cpp
A libc/src/pthread/pthread_attr_setschedpolicy.h
M libc/test/src/pthread/CMakeLists.txt
M libc/test/src/pthread/pthread_attr_test.cpp
Log Message:
-----------
[libc] Implement pthread_attr_[gs]etschedpolicy (#222682)
This patch implements pthread_attr_setschedpolicy and
pthread_attr_getschedpolicy.
This commit only operates on the pthread_attr_t object. It does not
attempt to install the scheduling policy when creating a new thread. I'm
leaving that for a separate patch as it requires a moderately
complicated startup dance to ensure that the scheduling policy takes
effect before the startup code runs.
The validation of inputs in pthread_attr_setschedpolicy is an
interesting question. Glibc accepts only policies explicitly declared in
POSIX, while other implementations let the user pass anything, and rely
on the kernel to validate the arguments. Interestingly, even glibc does
not validate the arguments in pthread_setschedparam.
For llvm-libc, I chose not to validate the arguments either. This is
*mostly* consistent with POSIX, which says (emphasis mine):
> The supported values of policy shall *include* SCHED_FIFO, SCHED_RR,
and
> SCHED_OTHER, which are defined in the <sched.h> header.
I say mostly, because the spec does say we should return ENOTSUP if "an
attempt was made to set the attribute to an unsupported value", but I'm
not sure that's worthwhile, as it means we would need to update our list
of supported policies whenever the kernel adds a new one (and anyway, we
cannot be sure that our understanding of supported policies matches what
the running kernel actually supports).
Assisted-by: Gemini
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list