* [LTP] [PATCH] lapi/sched: Fix sched_getattr/setattr fallback definitions
@ 2026-09-01 22:45 Wake Liu via ltp
2026-09-01 23:05 ` [LTP] " linuxtestproject.agent
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Wake Liu via ltp @ 2026-09-01 22:45 UTC (permalink / raw)
To: ltp; +Cc: Wake Liu
Commit c48700d8cdbe ("sched_attr: Do not define for glibc >= 2.41")
guarded the definitions of struct sched_attr, sched_setattr(), and
sched_getattr() under "#ifndef SCHED_ATTR_SIZE_VER0" to avoid conflicts
when glibc >= 2.41 provides these definitions.
However, SCHED_ATTR_SIZE_VER0 is a standard Linux kernel UAPI macro
defined in <linux/sched/types.h>. When headers include the kernel types
(such as on Android Bionic, musl, or older glibc with kernel headers),
SCHED_ATTR_SIZE_VER0 is defined even though libc does not provide the
sched_setattr() or sched_getattr() functions. This causes the fallback
syscall wrappers to be omitted, leading to unresolved symbol errors.
Add autotools checks for sched_getattr, sched_setattr, and
struct sched_attr. Guard the fallback functions with
HAVE_SCHED_GETATTR and HAVE_SCHED_SETATTR, and remove const from
sched_setattr's attr parameter to match the kernel and libc signatures.
Fixes: c48700d8cdbe ("sched_attr: Do not define for glibc >= 2.41")
Signed-off-by: Wake Liu <wakel@google.com>
---
configure.ac | 3 +++
include/lapi/sched.h | 16 ++++++++++------
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/configure.ac b/configure.ac
index 19fc5e1b8..8aa3ff539 100644
--- a/configure.ac
+++ b/configure.ac
@@ -155,7 +155,9 @@ AC_CHECK_FUNCS_ONCE([ \
rand_r \
recvmmsg \
renameat2 \
+ sched_getattr \
sched_getcpu \
+ sched_setattr \
sendmmsg \
sethostid \
setns \
@@ -199,6 +201,7 @@ AC_CHECK_DECLS([TCA_PEDIT_PARMS_EX, TCA_PEDIT_KEYS_EX, TCA_PEDIT_KEY_EX,
AC_CHECK_TYPES([struct acct_v3],,,[#include <sys/acct.h>])
AC_CHECK_TYPES([struct af_alg_iv, struct sockaddr_alg],,,[# include <linux/if_alg.h>])
AC_CHECK_TYPES([struct clone_args],,,[#include <sched.h>])
+AC_CHECK_TYPES([struct sched_attr],,,[#include <sched.h>])
AC_CHECK_TYPES([struct fanotify_event_info_fid, struct fanotify_event_info_error,
struct fanotify_event_info_header, struct fanotify_event_info_pidfd,
struct fanotify_event_info_range],,,[#include <sys/fanotify.h>])
diff --git a/include/lapi/sched.h b/include/lapi/sched.h
index 05b322c1c..d835537e7 100644
--- a/include/lapi/sched.h
+++ b/include/lapi/sched.h
@@ -14,8 +14,8 @@
#include "config.h"
#include "lapi/syscalls.h"
-/* sched_attr is not defined in glibc < 2.41 */
#ifndef SCHED_ATTR_SIZE_VER0
+# ifndef HAVE_STRUCT_SCHED_ATTR
struct sched_attr {
uint32_t size;
@@ -33,20 +33,24 @@ struct sched_attr {
uint64_t sched_deadline;
uint64_t sched_period;
};
+# endif
+# define SCHED_ATTR_SIZE_VER0 48 /* sizeof first published struct */
+#endif
-static inline int sched_setattr(pid_t pid, const struct sched_attr *attr,
- unsigned int flags)
+#ifndef HAVE_SCHED_SETATTR
+static inline int sched_setattr(pid_t pid, struct sched_attr *attr,
+ unsigned int flags)
{
return syscall(__NR_sched_setattr, pid, attr, flags);
}
+#endif
+#ifndef HAVE_SCHED_GETATTR
static inline int sched_getattr(pid_t pid, struct sched_attr *attr,
- unsigned int size, unsigned int flags)
+ unsigned int size, unsigned int flags)
{
return syscall(__NR_sched_getattr, pid, attr, size, flags);
}
-
-# define SCHED_ATTR_SIZE_VER0 48 /* sizeof first published struct */
#endif
struct clone_args_minimal {
--
2.55.0.966.g6673acef38-goog
--
Mailing list info: https://lists.linux.it/listinfo/ltp
^ permalink raw reply related [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-09-04 10:41 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-01 22:45 [LTP] [PATCH] lapi/sched: Fix sched_getattr/setattr fallback definitions Wake Liu via ltp
2026-09-01 23:05 ` [LTP] " linuxtestproject.agent
2026-09-04 8:57 ` [LTP] [PATCH] " Andrea Cervesato via ltp
2026-09-04 10:41 ` Andrea Cervesato via ltp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox