Overwrite target for x86_64_v2

Add /usr/lib64/lp64d to ricv64
This commit is contained in:
Eduard Abdullin 2025-08-08 01:34:55 +00:00 committed by root
commit f4a9441531
14 changed files with 1621 additions and 2 deletions

27
glibc-RHEL-107861-1.patch Normal file
View File

@ -0,0 +1,27 @@
commit a07e000e82cb71238259e674529c37c12dc7d423
Author: DJ Delorie <dj@redhat.com>
Date: Fri May 10 17:34:29 2024 -0400
manual: add dup3
Reviewed-by: Florian Weimer <fweimer@redhat.com>
diff --git a/manual/llio.texi b/manual/llio.texi
index a65230d612eba7bf..513ba9e8859b8e6e 100644
--- a/manual/llio.texi
+++ b/manual/llio.texi
@@ -3443,6 +3443,14 @@ middle of calling @code{dup2} at which @var{new} is closed and not yet a
duplicate of @var{old}.
@end deftypefun
+@deftypefun int dup3 (int @var{old}, int @var{new}, int @var{flags})
+@standards{Linux, unistd.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+This function is the same as @code{dup2} but creates the new
+descriptor as if it had been opened with flags @var{flags}. The only
+allowed flag is @code{O_CLOEXEC}.
+@end deftypefun
+
@deftypevr Macro int F_DUPFD
@standards{POSIX.1, fcntl.h}
This macro is used as the @var{command} argument to @code{fcntl}, to

348
glibc-RHEL-107861-2.patch Normal file
View File

@ -0,0 +1,348 @@
commit 6c0be74305745c8f78bcfb69442c8c379459d99b
Author: DJ Delorie <dj@redhat.com>
Date: Mon Jul 8 17:52:15 2024 -0400
manual: add syscalls
The purpose of this patch is to add some system calls that (1) aren't
otherwise documented, and (2) are merely redirected to the kernel, so
can refer to their documentation; and define a standard way of doing
so in the future. A more detailed explaination of how system calls
are wrapped is added along with reference to the Linux Man-Pages
project.
Default version of man-pages is in configure.ac but can be overridden
by --with-man-pages=X.Y
Reviewed-by: Alejandro Colomar <alx@kernel.org>
Conflicts:
configure (skip unrelated configure changes, due to autoconf
call)
diff --git a/config.make.in b/config.make.in
index 55e8b7563b961dfc..36096881b7af4574 100644
--- a/config.make.in
+++ b/config.make.in
@@ -91,6 +91,7 @@ use-nscd = @use_nscd@
build-hardcoded-path-in-tests= @hardcoded_path_in_tests@
build-pt-chown = @build_pt_chown@
pthread-in-libc = @pthread_in_libc@
+man-pages-version = @man_pages_version@
# Build tools.
CC = @CC@
diff --git a/configure b/configure
index 432e40a59295cffd..c25b93dd0b317e4e 100755
--- a/configure
+++ b/configure
@@ -706,6 +706,7 @@ force_install
bindnow
hardcoded_path_in_tests
enable_timezone_tools
+man_pages_version
rtld_early_cflags
extra_nonshared_cflags
sysheaders
@@ -787,6 +788,7 @@ with_headers
with_nonshared_cflags
with_rtld_early_cflags
with_timeoutfactor
+with_man_pages
enable_sanity_checks
enable_shared
enable_profile
@@ -1509,6 +1511,8 @@ Optional Packages:
build early initialization with additional CFLAGS
--with-timeoutfactor=NUM
specify an integer to scale the timeout
+ --with-man-pages=VERSION
+ tie manual to a specific man-pages version
--with-cpu=CPU select code for CPU variant
Some influential environment variables:
@@ -4374,6 +4378,17 @@ fi
printf "%s\n" "#define TIMEOUTFACTOR $timeoutfactor" >>confdefs.h
+man_pages_version=6.9.1
+
+
+# Check whether --with-man-pages was given.
+if test ${with_man_pages+y}
+then :
+ withval=$with_man_pages; man_pages_version=$withval
+fi
+
+
+
# Check whether --enable-sanity-checks was given.
if test ${enable_sanity_checks+y}
then :
diff --git a/configure.ac b/configure.ac
index bdc385d03c3dc7f5..f00fc36f387af09d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -168,6 +168,15 @@ AC_ARG_WITH([timeoutfactor],
[timeoutfactor=1])
AC_DEFINE_UNQUOTED(TIMEOUTFACTOR, $timeoutfactor)
+man_pages_version=6.9.1
+
+AC_ARG_WITH([man-pages],
+ AS_HELP_STRING([--with-man-pages=VERSION],
+ [tie manual to a specific man-pages version]),
+ [man_pages_version=$withval],
+ [])
+AC_SUBST(man_pages_version)
+
AC_ARG_ENABLE([sanity-checks],
AS_HELP_STRING([--disable-sanity-checks],
[really do not use threads (should not be used except in special situations) @<:@default=yes@:>@]),
diff --git a/manual/Makefile b/manual/Makefile
index b5fda4a7ae07a785..a6c05db540d6c1da 100644
--- a/manual/Makefile
+++ b/manual/Makefile
@@ -117,6 +117,7 @@ $(objpfx)stamp-pkgvers: $(common-objpfx)config.make
echo "@set PKGVERSION_DEFAULT" >> $(objpfx)pkgvers-tmp; \
fi
echo "@set REPORT_BUGS_TO $(REPORT_BUGS_TEXI)" >> $(objpfx)pkgvers-tmp
+ echo "@set man_pages_version $(man-pages-version)" >> $(objpfx)pkgvers-tmp; \
echo "@end ifclear" >> $(objpfx)pkgvers-tmp
$(move-if-change) $(objpfx)pkgvers-tmp $(objpfx)pkgvers.texi
touch $@
diff --git a/manual/intro.texi b/manual/intro.texi
index ff43c5a7fbb969a0..879c1b38d9b73a46 100644
--- a/manual/intro.texi
+++ b/manual/intro.texi
@@ -85,6 +85,7 @@ standards each function or symbol comes from.
* Berkeley Unix:: BSD and SunOS.
* SVID:: The System V Interface Description.
* XPG:: The X/Open Portability Guide.
+* Linux Kernel:: The Linux kernel.
@end menu
@node ISO C, POSIX, , Standards and Portability
@@ -941,7 +942,7 @@ inter-process communication and shared memory, the @code{hsearch} and
@code{drand48} families of functions, @code{fmtmsg} and several of the
mathematical functions.
-@node XPG, , SVID, Standards and Portability
+@node XPG, Linux Kernel, SVID, Standards and Portability
@subsection XPG (The X/Open Portability Guide)
The X/Open Portability Guide, published by the X/Open Company, Ltd., is
@@ -960,6 +961,20 @@ fulfilling the XPG standard with the Unix extensions is a
precondition for getting the Unix brand chances are good that the
functionality is available on commercial systems.
+@node Linux Kernel, , XPG, Standards and Portability
+@subsection Linux (The Linux Kernel)
+
+@Theglibc{} includes by reference the Linux man-pages
+@value{man_pages_version} documentation to document the listed
+syscalls for the Linux kernel. For reference purposes only the latest
+@uref{https://www.kernel.org/doc/man-pages/,Linux man-pages Project}
+documentation can be accessed from the
+@uref{https://www.kernel.org,Linux kernel} website. Where the syscall
+has more specific documentation in this manual that more specific
+documentation is considered authoritative.
+
+Additional details on the Linux system call interface can be found in
+@xref{System Calls}.
@node Using the Library, Roadmap to the Manual, Standards and Portability, Introduction
@section Using the Library
diff --git a/manual/llio.texi b/manual/llio.texi
index 513ba9e8859b8e6e..17fe1181d5cc2cef 100644
--- a/manual/llio.texi
+++ b/manual/llio.texi
@@ -65,6 +65,7 @@ directly.)
* Interrupt Input:: Getting an asynchronous signal when
input arrives.
* IOCTLs:: Generic I/O Control operations.
+* Other Low-Level I/O APIs:: Other low-level-I/O-related functions.
@end menu
@@ -2242,6 +2243,8 @@ file descriptor, or until the timeout period expires.
There is another example showing the use of @code{select} to multiplex
input from multiple sockets in @ref{Server Example}.
+For an alternate interface to this functionality, see @code{poll}
+(@pxref{Other Low-Level I/O APIs}).
@node Synchronizing I/O
@section Synchronizing I/O operations
@@ -3325,7 +3328,9 @@ require additional arguments to be supplied. These additional arguments
and the return value and error conditions are given in the detailed
descriptions of the individual commands.
-Briefly, here is a list of what the various commands are.
+Briefly, here is a list of what the various commands are. For an
+exhaustive list of kernel-specific options, please see @xref{System
+Calls}.
@vtable @code
@item F_DUPFD
@@ -4661,5 +4666,28 @@ Most IOCTLs are OS-specific and/or only used in special system utilities,
and are thus beyond the scope of this document. For an example of the use
of an IOCTL, see @ref{Out-of-Band Data}.
-@c FIXME this is undocumented:
-@c dup3
+@node Other Low-Level I/O APIs
+@section Other low-level-I/O-related functions
+
+@deftp {Data Type} {struct pollfd}
+@standards{POSIX.1,poll.h}
+@end deftp
+
+@deftp {Data Type} {struct epoll_event}
+@standards{Linux,sys/epoll.h}
+@end deftp
+
+@deftypefun int poll (struct pollfd *@var{fds}, nfds_t @var{nfds}, int @var{timeout})
+
+@manpagefunctionstub{poll,2}
+@end deftypefun
+
+@deftypefun int epoll_create(int @var{size})
+
+@manpagefunctionstub{epoll_create,2}
+@end deftypefun
+
+@deftypefun int epoll_wait(int @var{epfd}, struct epoll_event *@var{events}, int @var{maxevents}, int @var{timeout})
+
+@manpagefunctionstub{epoll_wait,2}
+@end deftypefun
diff --git a/manual/macros.texi b/manual/macros.texi
index 4a2e22f4730d2390..579da3fb81e59da0 100644
--- a/manual/macros.texi
+++ b/manual/macros.texi
@@ -282,4 +282,11 @@ cwd\comments\
@macro standardsx {element, standard, header}
@end macro
+@macro manpagefunctionstub {func,sec}
+This documentation is a stub. For additional information on this
+function, consult the manual page
+@url{https://man7.org/linux/man-pages/man\sec\/\func\.\sec\.html}.
+@xref{Linux Kernel}.
+@end macro
+
@end ifclear
diff --git a/manual/socket.texi b/manual/socket.texi
index f0e35d9e13175212..8708cbb07ca02b5c 100644
--- a/manual/socket.texi
+++ b/manual/socket.texi
@@ -41,6 +41,7 @@ aren't documented either so far.
is to make it work with Inetd.
* Socket Options:: Miscellaneous low-level socket options.
* Networks Database:: Accessing the database of network names.
+* Other Socket APIs:: Other socket-related functions.
@end menu
@node Socket Concepts
@@ -3134,38 +3135,8 @@ You can use plain @code{recv} (@pxref{Receiving Data}) instead of
treat all possible senders alike). Even @code{read} can be used if
you don't want to specify @var{flags} (@pxref{I/O Primitives}).
-@ignore
-@c sendmsg and recvmsg are like readv and writev in that they
-@c use a series of buffers. It's not clear this is worth
-@c supporting or that we support them.
-@c !!! they can do more; it is hairy
-
-@deftp {Data Type} {struct msghdr}
-@standards{BSD, sys/socket.h}
-@end deftp
-
-@deftypefun ssize_t sendmsg (int @var{socket}, const struct msghdr *@var{message}, int @var{flags})
-@standards{BSD, sys/socket.h}
-@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
-
-This function is defined as a cancellation point in multi-threaded
-programs, so one has to be prepared for this and make sure that
-allocated resources (like memory, files descriptors, semaphores or
-whatever) are freed even if the thread is cancel.
-@c @xref{pthread_cleanup_push}, for a method how to do this.
-@end deftypefun
-
-@deftypefun ssize_t recvmsg (int @var{socket}, struct msghdr *@var{message}, int @var{flags})
-@standards{BSD, sys/socket.h}
-@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
-
-This function is defined as a cancellation point in multi-threaded
-programs, so one has to be prepared for this and make sure that
-allocated resources (like memory, files descriptors, semaphores or
-whatever) are freed even if the thread is canceled.
-@c @xref{pthread_cleanup_push}, for a method how to do this.
-@end deftypefun
-@end ignore
+If you need more flexibility and/or control over sending and receiving
+packets, see @code{sendmsg} and @code{recvmsg} (@pxref{Other Socket APIs}).
@node Datagram Example
@subsection Datagram Socket Example
@@ -3664,3 +3635,20 @@ returns a null pointer if there are no more entries.
@c libc_lock_unlock @aculock
This function closes the networks database.
@end deftypefun
+
+@node Other Socket APIs
+@section Other Socket APIs
+
+@deftp {Data Type} {struct msghdr}
+@standards{BSD, sys/socket.h}
+@end deftp
+
+@deftypefun ssize_t sendmsg (int @var{socket}, const struct msghdr *@var{message}, int @var{flags})
+
+@manpagefunctionstub{sendmsg,2}
+@end deftypefun
+
+@deftypefun ssize_t recvmsg (int @var{socket}, struct msghdr *@var{message}, int @var{flags})
+
+@manpagefunctionstub{recvmsg,2}
+@end deftypefun
diff --git a/manual/startup.texi b/manual/startup.texi
index 9bf24123f562f75b..1426f5e1abfb2f51 100644
--- a/manual/startup.texi
+++ b/manual/startup.texi
@@ -690,7 +690,25 @@ you don't need to know about it because you can just use @theglibc{}'s
@code{chmod} function.
@cindex kernel call
-System calls are sometimes called kernel calls.
+System calls are sometimes called syscalls or kernel calls, and this
+interface is mostly a purely mechanical translation from the kernel's
+ABI to the C ABI. For the set of syscalls where we do not guarantee
+POSIX Thread cancellation the wrappers only organize the incoming
+arguments from the C calling convention to the calling convention of
+the target kernel. For the set of syscalls where we provided POSIX
+Thread cancellation the wrappers set some internal state in the
+library to support cancellation, but this does not impact the
+behaviour of the syscall provided by the kernel.
+
+In some cases, if @theglibc{} detects that a system call has been
+superseded by a more capable one, the wrapper may map the old call to
+the new one. For example, @code{dup2} is implemented via @code{dup3}
+by passing an additional empty flags argument, and @code{open} calls
+@code{openat} passing the additional @code{AT_FDCWD}. Sometimes even
+more is done, such as converting between 32-bit and 64-bit time
+values. In general, though, such processing is only to make the
+system call better match the C ABI, rather than change its
+functionality.
However, there are times when you want to make a system call explicitly,
and for that, @theglibc{} provides the @code{syscall} function.
@@ -712,6 +730,8 @@ we won't describe it here either because anyone who is coding
library source code as a specification of the interface between them
anyway.
+@code{syscall} does not provide cancellation logic, even if the system
+call you're calling is listed as cancellable above.
@code{syscall} is declared in @file{unistd.h}.

30
glibc-RHEL-58357-1.patch Normal file
View File

@ -0,0 +1,30 @@
commit 7d6e30b4b4e83429cc77222d4fe4d5e8843d8e2b
Author: Florian Weimer <fweimer@redhat.com>
Date: Fri Sep 6 14:07:00 2024 +0200
stdlib: Do not use GLIBC_PRIVATE ABI for errno in libc_nonshared.a
Using TLS directly introduces a GLIBC_PRIVATE ABI dependency
into libc_nonshared.a, and thus indirectly into applications.
Adding the !defined LIBC_NONSHARED condition deactivates direct
TLS access, and libc_nonshared.a code switches to using
__errno_location, like application code.
Currently, this has no effect because there is no code in
libc_nonshared.a that accesses errno.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
diff --git a/include/errno.h b/include/errno.h
index c361a785c24b928f..f0ccaa74dd8bebed 100644
--- a/include/errno.h
+++ b/include/errno.h
@@ -20,7 +20,7 @@
# define errno rtld_errno
extern int rtld_errno attribute_hidden;
-# elif IS_IN_LIB && !IS_IN (rtld)
+# elif IS_IN_LIB && !IS_IN (rtld) && !defined LIBC_NONSHARED
# undef errno
# if IS_IN (libc)

50
glibc-RHEL-58357-10.patch Normal file
View File

@ -0,0 +1,50 @@
commit 517846c85dfc48aa231e28e95e8f90a6d8a8efde
Author: Florian Weimer <fweimer@redhat.com>
Date: Wed Mar 12 11:29:10 2025 +0100
Makefile: Clean up pthread_atfork integration
Do not add the pthread_atfork routine again in nptl/Makefile,
instead rely on sysdeps/pthread/Makefile for the integration
(as this is the directory that contains the source file).
In sysdeps/pthread/Makefile, add to static-only-routines.
Reviewed-by: Joseph Myers <josmyers@redhat.com>
Conflicts:
nptl/Makefile (Fixup context due to previous patches)
diff --git a/nptl/Makefile b/nptl/Makefile
index e72b28dc92cd5852..c9d9079cdb8a5643 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -63,7 +63,6 @@ routines = \
old_pthread_cond_signal \
old_pthread_cond_timedwait \
old_pthread_cond_wait \
- pthread_atfork \
pthread_attr_copy \
pthread_attr_destroy \
pthread_attr_extension \
@@ -211,7 +210,6 @@ routines = \
# routines
static-only-routines += \
- pthread_atfork \
pthread_gettid_np \
# static-only-routines
diff --git a/sysdeps/pthread/Makefile b/sysdeps/pthread/Makefile
index 04ea56559ef3a79b..a0f67c8e09327114 100644
--- a/sysdeps/pthread/Makefile
+++ b/sysdeps/pthread/Makefile
@@ -297,7 +297,7 @@ tests-time64 += \
tst-thrd-sleep-time64 \
# tests-time64
-static-only-routines = pthread_atfork
+static-only-routines += pthread_atfork
# Files which must not be linked with libpthread.
tests-nolibpthread += \

33
glibc-RHEL-58357-11.patch Normal file
View File

@ -0,0 +1,33 @@
commit f176bf2a06b458dea8186fb2ff3bb8ea24da6d67
Author: DJ Delorie <dj@redhat.com>
Date: Wed May 7 19:23:06 2025 -0400
manual: fix typo for sched_[sg]etattr
Originally added in 41a90f3f5f which says it's adding sched_getattr
and sched_setattr.
Reviewed-by: Collin Funk <collin.funk1@gmail.com>
diff --git a/manual/resource.texi b/manual/resource.texi
index 40ab3572e04747c7..6729ada79402f0ad 100644
--- a/manual/resource.texi
+++ b/manual/resource.texi
@@ -1003,7 +1003,7 @@ For additional information, consult the manual page
@manpageurl{sched_setattr,2}. @xref{Linux Kernel}.
@end deftp
-@deftypefun int sched_setaddr (pid_t @var{tid}, struct sched_attr *@var{attr}, unsigned int flags)
+@deftypefun int sched_setattr (pid_t @var{tid}, struct sched_attr *@var{attr}, unsigned int flags)
@standards{Linux, sched.h}
@safety{@mtsafe{}@assafe{}@acsafe{}}
This functions applies the scheduling policy described by
@@ -1046,7 +1046,7 @@ policy of the thread @var{tid}.
Other error codes depend on the scheduling policy.
@end deftypefun
-@deftypefun int sched_getaddr (pid_t @var{tid}, struct sched_attr *@var{attr}, unsigned int size, unsigned int flags)
+@deftypefun int sched_getattr (pid_t @var{tid}, struct sched_attr *@var{attr}, unsigned int size, unsigned int flags)
@standards{Linux, sched.h}
@safety{@mtsafe{}@assafe{}@acsafe{}}
This function obtains the scheduling policy of the thread @var{tid}

32
glibc-RHEL-58357-2.patch Normal file
View File

@ -0,0 +1,32 @@
commit 298bc488fdc047da37482f4003023cb9adef78f8
Author: Florian Weimer <fweimer@redhat.com>
Date: Wed Sep 11 10:05:08 2024 +0200
manual: Extract the @manpageurl{func,sec} macro
From the existing @manpagefunctionstub{func,sec} macro,
so that URLs can be included in the manual without the
stub text.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
diff --git a/manual/macros.texi b/manual/macros.texi
index 579da3fb81e59da0..f48dd4ec2282634f 100644
--- a/manual/macros.texi
+++ b/manual/macros.texi
@@ -282,10 +282,13 @@ cwd\comments\
@macro standardsx {element, standard, header}
@end macro
+@macro manpageurl {func, sec}
+@url{https://man7.org/linux/man-pages/man\sec\/\func\.\sec\.html}
+@end macro
+
@macro manpagefunctionstub {func,sec}
This documentation is a stub. For additional information on this
-function, consult the manual page
-@url{https://man7.org/linux/man-pages/man\sec\/\func\.\sec\.html}.
+function, consult the manual page @manpageurl{\func\,\sec\}.
@xref{Linux Kernel}.
@end macro

454
glibc-RHEL-58357-3.patch Normal file
View File

@ -0,0 +1,454 @@
Partial backport (without ABI changes, using libc_nonshared.a instead)
of:
commit 21571ca0d70302909cf72707b2a7736cf12190a0
Author: Florian Weimer <fweimer@redhat.com>
Date: Wed Sep 11 10:05:08 2024 +0200
Linux: Add the sched_setattr and sched_getattr functions
And struct sched_attr.
In sysdeps/unix/sysv/linux/bits/sched.h, the hack that defines
sched_param around the inclusion of <linux/sched/types.h> is quite
ugly, but the definition of struct sched_param has already been
dropped by the kernel, so there is nothing else we can do and maintain
compatibility of <sched.h> with a wide range of kernel header
versions. (An alternative would involve introducing a separate header
for this functionality, but this seems unnecessary.)
The existing sched_* functions that change scheduler parameters
are already incompatible with PTHREAD_PRIO_PROTECT mutexes, so
there is no harm in adding more functionality in this area.
The documentation mostly defers to the Linux manual pages.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
Conflicts:
sysdeps/unix/sysv/linux/Makefile
(variables not sorted downstream, libc_nonshared.a
integration downstream)
sysdeps/unix/sysv/linux/Versions
(not backported)
sysdeps/unix/sysv/linux/*/libc.abilist
(not backported)
The implementation uses the syscall function, not <sysdep.h>,
to avoid implicit TCB layout dependencies. Such dependencies
could happen if the system call macros use information in the
TCB to select the way the kernel is entered.
diff --git a/manual/resource.texi b/manual/resource.texi
index 743cc9439665b9d5..c92df6ee4f028fd6 100644
--- a/manual/resource.texi
+++ b/manual/resource.texi
@@ -478,6 +478,7 @@ POSIX syntax had in mind.
* Absolute Priority:: The first tier of priority. Posix
* Realtime Scheduling:: Scheduling among the process nobility
* Basic Scheduling Functions:: Get/set scheduling policy, priority
+* Extensible Scheduling:: Parameterized scheduling policies.
* Traditional Scheduling:: Scheduling among the vulgar masses
* CPU Affinity:: Limiting execution to certain CPUs
@end menu
@@ -952,6 +953,120 @@ function, so there are no specific @code{errno} values.
@end deftypefun
+@node Extensible Scheduling
+@subsection Extensible Scheduling
+@cindex scheduling, extensible
+
+The type @code{struct sched_attr} and the functions @code{sched_setattr}
+and @code{sched_getattr} are used to implement scheduling policies with
+multiple parameters (not just priority and niceness).
+
+It is expected that these interfaces will be compatible with all future
+scheduling policies.
+
+For additional information about scheduling policies, consult consult
+the manual pages @manpageurl{sched,7} and @manpageurl{sched_setattr,2}.
+@xref{Linux Kernel}.
+
+@strong{Note:} Calling the @code{sched_setattr} function is incompatible
+with support for @code{PTHREAD_PRIO_PROTECT} mutexes.
+
+@deftp {Data Type} {struct sched_attr}
+@standards{Linux, sched.h}
+The @code{sched_attr} structure describes a parameterized scheduling policy.
+
+@strong{Portability note:} In the future, additional fields can be added
+to @code{struct sched_attr} at the end, so that the size of this data
+type changes. Do not use it in places where this matters, such as
+structure fields in installed header files, where such a change could
+impact the application binary interface (ABI).
+
+The following generic fields are available.
+
+@table @code
+@item size
+The actually used size of the data structure. See the description of
+the functions @code{sched_setattr} and @code{sched_getattr} below how this
+field is used to support extension of @code{struct sched_attr} with
+more fields.
+
+@item sched_policy
+The scheduling policy. This field determines which fields in the
+structure are used, and how the @code{sched_flags} field is interpreted.
+
+@item sched_flags
+Scheduling flags associated with the scheduling policy.
+@end table
+
+In addition to the generic fields, policy-specific fields are available.
+For additional information, consult the manual page
+@manpageurl{sched_setattr,2}. @xref{Linux Kernel}.
+@end deftp
+
+@deftypefun int sched_setaddr (pid_t @var{tid}, struct sched_attr *@var{attr}, unsigned int flags)
+@standards{Linux, sched.h}
+@safety{@mtsafe{}@assafe{}@acsafe{}}
+This functions applies the scheduling policy described by
+@code{*@var{attr}} to the thread @var{tid} (the value zero denotes the
+current thread).
+
+It is recommended to initialize unused fields to zero, either using
+@code{memset}, or using a structure initializer. The
+@code{@var{attr->size}} field should be set to @code{sizeof (struct
+sched_attr)}, to inform the kernel of the structure version in use.
+
+The @var{flags} argument must be zero. Other values may become
+available in the future.
+
+On failure, @code{sched_setattr} returns @math{-1} and sets
+@code{errno}. The following errors are related the way
+extensibility is handled.
+@table @code
+@item E2BIG
+A field in @code{*@var{attr}} has a non-zero value, but is unknown to
+the kernel. The application could try to apply a modified policy, where
+more fields are zero.
+
+@item EINVAL
+The policy in @code{@var{attr}->sched_policy} is unknown to the kernel,
+or flags are set in @code{@var{attr}->sched_flags} that the kernel does
+not know how to interpret. The application could try with fewer flags
+set, or a different scheduling policy.
+
+This error also occurs if @var{attr} is @code{NULL} or @var{flags} is
+not zero.
+
+@item EPERM
+The current thread is not sufficiently privileged to assign the policy,
+either because access to the policy is restricted in general, or because
+the current thread does not have the rights to change the scheduling
+policy of the thread @var{tid}.
+@end table
+
+Other error codes depend on the scheduling policy.
+@end deftypefun
+
+@deftypefun int sched_getaddr (pid_t @var{tid}, struct sched_attr *@var{attr}, unsigned int size, unsigned int flags)
+@standards{Linux, sched.h}
+@safety{@mtsafe{}@assafe{}@acsafe{}}
+This function obtains the scheduling policy of the thread @var{tid}
+(zero denotes the current thread) and store it in @code{*@var{attr}},
+which must have space for at least @var{size} bytes.
+
+The @var{flags} argument must be zero. Other values may become
+available in the future.
+
+Upon success, @code{@var{attr}->size} contains the size of the structure
+version used by the kernel. Fields with offsets greater or equal to
+@code{@var{attr}->size} are not updated by the kernel. To obtain
+predictable values for unknown fields, use @code{memset} to set
+all @var{size} bytes to zero prior to calling @code{sched_getattr}.
+
+On failure, @code{sched_getattr} returns @math{-1} and sets @code{errno}.
+If @code{errno} is @code{E2BIG}, this means that the buffer is not large
+large enough, and the application could retry with a larger buffer.
+@end deftypefun
+
@node Traditional Scheduling
@subsection Traditional Scheduling
@cindex scheduling, traditional
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index eee91c7b64d79fe7..a0f79f7513a64616 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -95,6 +95,8 @@ sysdep_routines += \
process_vm_writev \
pselect32 \
readahead \
+ sched_getattr \
+ sched_setattr \
setfsgid \
setfsuid \
setvmaname \
@@ -113,6 +115,12 @@ sysdep_routines += \
xstat64 \
# sysdep_routines
+# The implementations go into libc_nonshared.a, to preserve ABI.
+static-only-routines += \
+ sched_getattr \
+ sched_setattr \
+ # static-only-routines
+
CFLAGS-gethostid.c = -fexceptions
CFLAGS-tee.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-vmsplice.c = -fexceptions -fasynchronous-unwind-tables
@@ -223,6 +231,7 @@ tests += \
tst-process_mrelease \
tst-quota \
tst-rlimit-infinity \
+ tst-sched_setattr \
tst-scm_rights \
tst-sigtimedwait \
tst-sync_file_range \
diff --git a/sysdeps/unix/sysv/linux/bits/sched.h b/sysdeps/unix/sysv/linux/bits/sched.h
index a53e1362a07596bc..e5b7efb887fb98da 100644
--- a/sysdeps/unix/sysv/linux/bits/sched.h
+++ b/sysdeps/unix/sysv/linux/bits/sched.h
@@ -34,10 +34,39 @@
# define SCHED_IDLE 5
# define SCHED_DEADLINE 6
+/* Flags that can be used in policy values. */
# define SCHED_RESET_ON_FORK 0x40000000
-#endif
-#ifdef __USE_GNU
+/* Use "" to work around incorrect macro expansion of the
+ __has_include argument (GCC PR 80005). */
+# ifdef __has_include
+# if __has_include ("linux/sched/types.h")
+/* Some older Linux versions defined sched_param in <linux/sched/types.h>. */
+# define sched_param __glibc_mask_sched_param
+# include <linux/sched/types.h>
+# undef sched_param
+# endif
+# endif
+# ifndef SCHED_ATTR_SIZE_VER0
+# include <linux/types.h>
+# define SCHED_ATTR_SIZE_VER0 48
+# define SCHED_ATTR_SIZE_VER1 56
+struct sched_attr
+{
+ __u32 size;
+ __u32 sched_policy;
+ __u64 sched_flags;
+ __s32 sched_nice;
+ __u32 sched_priority;
+ __u64 sched_runtime;
+ __u64 sched_deadline;
+ __u64 sched_period;
+ __u32 sched_util_min;
+ __u32 sched_util_max;
+ /* Additional fields may be added at the end. */
+};
+# endif /* !SCHED_ATTR_SIZE_VER0 */
+
/* Cloning flags. */
# define CSIGNAL 0x000000ff /* Signal mask to be sent at exit. */
# define CLONE_VM 0x00000100 /* Set if VM shared between processes. */
@@ -97,6 +126,17 @@ extern int getcpu (unsigned int *, unsigned int *) __THROW;
/* Switch process to namespace of type NSTYPE indicated by FD. */
extern int setns (int __fd, int __nstype) __THROW;
+
+/* Apply the scheduling attributes from *ATTR to the process or thread TID. */
+int sched_setattr (pid_t tid, struct sched_attr *attr, unsigned int flags)
+ __THROW __nonnull ((2));
+
+/* Obtain the scheduling attributes of the process or thread TID and
+ store it in *ATTR. */
+int sched_getattr (pid_t tid, struct sched_attr *attr, unsigned int size,
+ unsigned int flags)
+ __THROW __nonnull ((2)) __attr_access ((__write_only__, 2, 3));
+
#endif
__END_DECLS
diff --git a/sysdeps/unix/sysv/linux/sched_getattr.c b/sysdeps/unix/sysv/linux/sched_getattr.c
new file mode 100644
index 0000000000000000..64f0b70514f2b143
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sched_getattr.c
@@ -0,0 +1,30 @@
+/* Reading scheduling policy and attributes.
+ Copyright (C) 2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <sched.h>
+#include <sysdep.h>
+#include <unistd.h>
+
+int
+attribute_hidden
+sched_getattr (pid_t pid, struct sched_attr *attr, unsigned int size,
+ unsigned int flags)
+{
+ /* Use the syscall function for compatibility with libc_nonshared.a. */
+ return syscall (__NR_sched_getattr, pid, attr, size, flags);
+}
diff --git a/sysdeps/unix/sysv/linux/sched_setattr.c b/sysdeps/unix/sysv/linux/sched_setattr.c
new file mode 100644
index 0000000000000000..2a24a734e8d5125b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sched_setattr.c
@@ -0,0 +1,29 @@
+/* Setting scheduling policy and attributes.
+ Copyright (C) 2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <sched.h>
+#include <sysdep.h>
+#include <unistd.h>
+
+int
+attribute_hidden
+sched_setattr (pid_t pid, struct sched_attr *attr, unsigned int flags)
+{
+ /* Use the syscall function for compatibility with libc_nonshared.a. */
+ return syscall (__NR_sched_setattr, pid, attr, flags);
+}
diff --git a/sysdeps/unix/sysv/linux/tst-sched_setattr.c b/sysdeps/unix/sysv/linux/tst-sched_setattr.c
new file mode 100644
index 0000000000000000..a6288a1a7cc2d01b
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-sched_setattr.c
@@ -0,0 +1,105 @@
+/* Tests for sched_setattr and sched_getattr.
+ Copyright (C) 2024 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <sched.h>
+
+#include <errno.h>
+#include <stddef.h>
+#include <string.h>
+#include <support/check.h>
+#include <sys/resource.h>
+#include <unistd.h>
+
+/* Padding struct to detect unexpected writes. */
+union
+{
+ struct sched_attr attr;
+ /* Hopefully the kernel will never need as much. */
+ unsigned char padding[4096];
+} u;
+
+static void
+check_unused (void)
+{
+ TEST_VERIFY (u.attr.size < sizeof (u));
+ for (unsigned int i = u.attr.size; i < sizeof (u); ++i)
+ TEST_COMPARE (u.padding[i], 0xcc);
+}
+
+static int
+do_test (void)
+{
+ TEST_VERIFY (sizeof (struct sched_attr) < sizeof (u));
+
+ /* Check that reading and re-applying the current policy works. */
+ memset (&u, 0xcc, sizeof (u));
+ /* Compiler barrier to bypass write access attribute. */
+ volatile unsigned int size = sizeof (u);
+ TEST_COMPARE (sched_getattr (0, (struct sched_attr *) &u, size, 0), 0);
+ check_unused ();
+ TEST_COMPARE (sched_setattr (0, &u.attr, 0), 0); /* Apply unchanged. */
+
+ /* Try to switch to the SCHED_OTHER policy. */
+ memset (&u, 0, sizeof (u));
+ u.attr.size = sizeof (u); /* With padding, kernel should accept zeroes. */
+ u.attr.sched_policy = SCHED_OTHER; /* Should be the default. */
+ {
+ errno = 0;
+ int prio = getpriority (PRIO_PROCESS, 0);
+ if (errno != 0)
+ prio = 0;
+ u.attr.sched_nice = prio;
+ }
+ TEST_COMPARE (sched_setattr (0, &u.attr, 0), 0);
+
+ /* Non-zero values not known to the kernel result in an E2BIG error. */
+ memset (&u, 0, sizeof (u));
+ TEST_COMPARE (sched_getattr (0, (struct sched_attr *) &u, size, 0), 0);
+ u.padding[u.attr.size] = 0xcc;
+ u.attr.size = sizeof (u);
+ errno = 0;
+ TEST_COMPARE (sched_setattr (0, &u.attr, 0), -1);
+ TEST_COMPARE (errno, E2BIG);
+
+ memset (&u, 0xcc, sizeof (u));
+ TEST_COMPARE (sched_getattr (0, (struct sched_attr *) &u, size, 0), 0);
+ TEST_COMPARE (u.attr.sched_policy, SCHED_OTHER);
+ check_unused ();
+
+ /* Raise the niceless level to 19 and observe its effect. */
+ TEST_COMPARE (nice (19), 19);
+ TEST_COMPARE (sched_getattr (0, &u.attr, sizeof (u.attr), 0), 0);
+ TEST_COMPARE (u.attr.sched_policy, SCHED_OTHER);
+ TEST_COMPARE (u.attr.sched_nice, 19);
+ check_unused ();
+
+ /* Invalid buffer arguments result in EINVAL (not EFAULT). */
+ {
+ errno = 0;
+ void *volatile null_pointer = NULL; /* compiler barrier. */
+ TEST_COMPARE (sched_setattr (0, null_pointer, 0), -1);
+ TEST_COMPARE (errno, EINVAL);
+ errno = 0;
+ TEST_COMPARE (sched_getattr (0, null_pointer, size, 0), -1);
+ TEST_COMPARE (errno, EINVAL);
+ }
+
+ return 0;
+}
+
+#include <support/test-driver.c>

139
glibc-RHEL-58357-4.patch Normal file
View File

@ -0,0 +1,139 @@
commit c444cc1d8335243c5c4e636d6a26c472df85522c
Author: Florian Weimer <fweimer@redhat.com>
Date: Wed Sep 11 10:05:08 2024 +0200
Linux: Add missing scheduler constants to <sched.h>
And add a test, misc/tst-sched-consts, that checks
consistency with <sched.h>.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index a0f79f7513a64616..af7fbac14534e601 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -403,6 +403,16 @@ $(objpfx)tst-mount-compile.out: ../sysdeps/unix/sysv/linux/tst-mount-compile.py
< /dev/null > $@ 2>&1; $(evaluate-test)
$(objpfx)tst-mount-compile.out: $(sysdeps-linux-python-deps)
+tests-special += \
+ $(objpfx)tst-sched-consts.out \
+ # tests-special
+$(objpfx)tst-sched-consts.out: ../sysdeps/unix/sysv/linux/tst-sched-consts.py
+ $(sysdeps-linux-python) \
+ ../sysdeps/unix/sysv/linux/tst-sched-consts.py \
+ $(sysdeps-linux-python-cc) \
+ < /dev/null > $@ 2>&1; $(evaluate-test)
+$(objpfx)tst-sched-consts.out: $(sysdeps-linux-python-deps)
+
tst-rseq-disable-ENV = GLIBC_TUNABLES=glibc.pthread.rseq=0
endif # $(subdir) == misc
diff --git a/sysdeps/unix/sysv/linux/bits/sched.h b/sysdeps/unix/sysv/linux/bits/sched.h
index e5b7efb887fb98da..a02cb69de77794fa 100644
--- a/sysdeps/unix/sysv/linux/bits/sched.h
+++ b/sysdeps/unix/sysv/linux/bits/sched.h
@@ -29,6 +29,7 @@
#define SCHED_FIFO 1
#define SCHED_RR 2
#ifdef __USE_GNU
+# define SCHED_NORMAL SCHED_OTHER
# define SCHED_BATCH 3
# define SCHED_ISO 4
# define SCHED_IDLE 5
@@ -37,6 +38,19 @@
/* Flags that can be used in policy values. */
# define SCHED_RESET_ON_FORK 0x40000000
+/* Flags for the sched_flags field in struct sched_attr. */
+#define SCHED_FLAG_RESET_ON_FORK 0x01
+#define SCHED_FLAG_RECLAIM 0x02
+#define SCHED_FLAG_DL_OVERRUN 0x04
+#define SCHED_FLAG_KEEP_POLICY 0x08
+#define SCHED_FLAG_KEEP_PARAMS 0x10
+#define SCHED_FLAG_UTIL_CLAMP_MIN 0x20
+#define SCHED_FLAG_UTIL_CLAMP_MAX 0x40
+
+/* Combinations of sched_flags fields. */
+#define SCHED_FLAG_KEEP_ALL 0x18
+#define SCHED_FLAG_UTIL_CLAMP 0x60
+
/* Use "" to work around incorrect macro expansion of the
__has_include argument (GCC PR 80005). */
# ifdef __has_include
diff --git a/sysdeps/unix/sysv/linux/tst-sched-consts.py b/sysdeps/unix/sysv/linux/tst-sched-consts.py
new file mode 100644
index 0000000000000000..70071dcd974fe064
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-sched-consts.py
@@ -0,0 +1,56 @@
+#!/usr/bin/python3
+# Test that glibc's sched.h constants match the kernel's.
+# Copyright (C) 2018-2024 Free Software Foundation, Inc.
+# This file is part of the GNU C Library.
+#
+# The GNU C Library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License, or (at your option) any later version.
+#
+# The GNU C Library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with the GNU C Library; if not, see
+# <https://www.gnu.org/licenses/>.
+
+import argparse
+import sys
+
+import glibcextract
+import glibcsyscalls
+
+
+def main():
+ """The main entry point."""
+ parser = argparse.ArgumentParser(
+ description="Test that glibc's sched.h constants "
+ "match the kernel's.")
+ parser.add_argument('--cc', metavar='CC',
+ help='C compiler (including options) to use')
+ args = parser.parse_args()
+ linux_version_headers = glibcsyscalls.linux_kernel_version(args.cc)
+ linux_version_glibc = (6, 10)
+ sys.exit(glibcextract.compare_macro_consts(
+ '#define _GNU_SOURCE 1\n'
+ '#include <sched.h>\n',
+ '#define _GNU_SOURCE 1\n'
+ '#include <linux/sched.h>\n'
+ '#include <linux/sched/types.h>\n',
+ args.cc,
+ 'SCHED_.*',
+ # SCHED_ISO is reserved, but not implemented in the kernel.
+ # SCHED_OTHER is the standard name for SCHED_NORMAL.
+ # SCHED_FLAG_ALL will receive more and more flags, so
+ # exposing it to userspace does not seem useful.
+ 'SCHED_ISO'
+ '|SCHED_OTHER'
+ '|SCHED_FLAG_ALL',
+ linux_version_glibc > linux_version_headers,
+ linux_version_headers > linux_version_glibc))
+
+if __name__ == '__main__':
+ main()
diff --git a/sysdeps/unix/sysv/linux/tst-sched_setattr.c b/sysdeps/unix/sysv/linux/tst-sched_setattr.c
index a6288a1a7cc2d01b..fbb73c31a72de311 100644
--- a/sysdeps/unix/sysv/linux/tst-sched_setattr.c
+++ b/sysdeps/unix/sysv/linux/tst-sched_setattr.c
@@ -44,6 +44,8 @@ check_unused (void)
static int
do_test (void)
{
+ _Static_assert (SCHED_OTHER == SCHED_NORMAL,
+ "SCHED_OTHER, SCHED_NORMAL values");
TEST_VERIFY (sizeof (struct sched_attr) < sizeof (u));
/* Check that reading and re-applying the current policy works. */

73
glibc-RHEL-58357-5.patch Normal file
View File

@ -0,0 +1,73 @@
commit b3a6bd625ce96bcec0e5d41b9835b1367d97e548
Author: Florian Weimer <fweimer@redhat.com>
Date: Mon Jan 20 09:57:09 2025 +0100
Linux: Do not check unused bytes after sched_getattr in tst-sched_setattr
Linux 6.13 was released with a change that overwrites those bytes.
This means that the check_unused subtest fails.
Update the manual accordingly.
Tested-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
diff --git a/manual/resource.texi b/manual/resource.texi
index c92df6ee4f028fd6..40ab3572e04747c7 100644
--- a/manual/resource.texi
+++ b/manual/resource.texi
@@ -1058,9 +1058,9 @@ available in the future.
Upon success, @code{@var{attr}->size} contains the size of the structure
version used by the kernel. Fields with offsets greater or equal to
-@code{@var{attr}->size} are not updated by the kernel. To obtain
-predictable values for unknown fields, use @code{memset} to set
-all @var{size} bytes to zero prior to calling @code{sched_getattr}.
+@code{@var{attr}->size} may not be overwritten by the kernel. To obtain
+predictable values for unknown fields, use @code{memset} to set all
+@var{size} bytes to zero prior to calling @code{sched_getattr}.
On failure, @code{sched_getattr} returns @math{-1} and sets @code{errno}.
If @code{errno} is @code{E2BIG}, this means that the buffer is not large
diff --git a/sysdeps/unix/sysv/linux/tst-sched_setattr.c b/sysdeps/unix/sysv/linux/tst-sched_setattr.c
index fbb73c31a72de311..6b0913aebae96abe 100644
--- a/sysdeps/unix/sysv/linux/tst-sched_setattr.c
+++ b/sysdeps/unix/sysv/linux/tst-sched_setattr.c
@@ -33,14 +33,6 @@ union
unsigned char padding[4096];
} u;
-static void
-check_unused (void)
-{
- TEST_VERIFY (u.attr.size < sizeof (u));
- for (unsigned int i = u.attr.size; i < sizeof (u); ++i)
- TEST_COMPARE (u.padding[i], 0xcc);
-}
-
static int
do_test (void)
{
@@ -53,7 +45,6 @@ do_test (void)
/* Compiler barrier to bypass write access attribute. */
volatile unsigned int size = sizeof (u);
TEST_COMPARE (sched_getattr (0, (struct sched_attr *) &u, size, 0), 0);
- check_unused ();
TEST_COMPARE (sched_setattr (0, &u.attr, 0), 0); /* Apply unchanged. */
/* Try to switch to the SCHED_OTHER policy. */
@@ -81,14 +72,12 @@ do_test (void)
memset (&u, 0xcc, sizeof (u));
TEST_COMPARE (sched_getattr (0, (struct sched_attr *) &u, size, 0), 0);
TEST_COMPARE (u.attr.sched_policy, SCHED_OTHER);
- check_unused ();
/* Raise the niceless level to 19 and observe its effect. */
TEST_COMPARE (nice (19), 19);
TEST_COMPARE (sched_getattr (0, &u.attr, sizeof (u.attr), 0), 0);
TEST_COMPARE (u.attr.sched_policy, SCHED_OTHER);
TEST_COMPARE (u.attr.sched_nice, 19);
- check_unused ();
/* Invalid buffer arguments result in EINVAL (not EFAULT). */
{

225
glibc-RHEL-58357-6.patch Normal file
View File

@ -0,0 +1,225 @@
Partial backport (without ABI changes, using libc_nonshared.a instead)
of:
commit 74d463c50bb1096efef47022405c7db33f83fb5a
Author: Florian Weimer <fweimer@redhat.com>
Date: Wed Mar 12 10:16:31 2025 +0100
Linux: Add the pthread_gettid_np function (bug 27880)
Current Bionic has this function, with enhanced error checking
(the undefined case terminates the process).
Reviewed-by: Joseph Myers <josmyers@redhat.com>
Conflicts:
sysdeps/unix/sysv/linux/*/libc.abilist
(not backported)
nptl/Versions
(not backported)
The alternate libc_nonshared.a implementation relies on the UAPI
encoding of pthread_getcpuclockid, and avoids a TCB layout
dependency.
diff --git a/manual/process.texi b/manual/process.texi
index 8254e5ee864e2515..a8f37e55a3b5b7cd 100644
--- a/manual/process.texi
+++ b/manual/process.texi
@@ -239,6 +239,24 @@ especially regarding reuse of the IDs of threads which have exited.
This function is specific to Linux.
@end deftypefun
+@deftypefun pid_t pthread_gettid_np (pthread_t @var{thread})
+@standards{Linux, pthread.h}
+@safety{@prelim{}@mtsafe{}@assafe{}@acsafe{}}
+This function returns the same value that @code{gettid} would return if
+executed on the running thread @var{thread}.
+
+If @var{thread} is no longer running but it is joinable, it is
+unspecified whether this function returns @minus{}1, or if it returns
+the thread ID of the thread while it was running. If @var{thread} is
+not running and is not joinable, the behavior is undefined.
+
+@strong{Portability Note:} Linux thread IDs can be reused rather quickly,
+so this function differs from the @code{pthread_getunique_np} function
+found on other systems.
+
+This function is specific to Linux.
+@end deftypefun
+
@node Creating a Process
@section Creating a Process
diff --git a/nptl/Makefile b/nptl/Makefile
index bf09603e7b94b286..e72b28dc92cd5852 100644
--- a/nptl/Makefile
+++ b/nptl/Makefile
@@ -124,6 +124,7 @@ routines = \
pthread_getname \
pthread_getschedparam \
pthread_getspecific \
+ pthread_gettid_np \
pthread_join \
pthread_join_common \
pthread_key_create \
@@ -209,7 +210,11 @@ routines = \
vars \
# routines
-static-only-routines = pthread_atfork
+static-only-routines += \
+ pthread_atfork \
+ pthread_gettid_np \
+ # static-only-routines
+
libpthread-routines = libpthread-compat
libpthread-shared-only-routines = libpthread-compat
@@ -318,6 +323,7 @@ tests = \
tst-pthread-timedlock-lockloop \
tst-pthread_exit-nothreads \
tst-pthread_exit-nothreads-static \
+ tst-pthread_gettid_np \
tst-robust-fork \
tst-robustpi1 \
tst-robustpi2 \
diff --git a/nptl/pthread_gettid_np.c b/nptl/pthread_gettid_np.c
new file mode 100644
index 0000000000000000..b602eb7a30bf42a5
--- /dev/null
+++ b/nptl/pthread_gettid_np.c
@@ -0,0 +1,32 @@
+/* Get the Linux TID from a pthread_t handle.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <https://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthreadP.h>
+
+pid_t
+attribute_hidden
+pthread_gettid_np (pthread_t threadid)
+{
+ clockid_t clock;
+ if (pthread_getcpuclockid (threadid, &clock) != 0)
+ return -1;
+ /* Reverse the clock ID encoding to obtain the TID. This is part of
+ the kernel/userspace interface, so it is stable ABI. */
+ return ~(clock >> 3);
+}
diff --git a/nptl/tst-pthread_gettid_np.c b/nptl/tst-pthread_gettid_np.c
new file mode 100644
index 0000000000000000..6a98d864e222b9f5
--- /dev/null
+++ b/nptl/tst-pthread_gettid_np.c
@@ -0,0 +1,79 @@
+/* Test for pthread_gettid_np.
+ Copyright (C) 2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; see the file COPYING.LIB. If
+ not, see <https://www.gnu.org/licenses/>. */
+
+#include <errno.h>
+#include <pthread.h>
+#include <sched.h>
+#include <signal.h>
+#include <support/check.h>
+#include <support/xthread.h>
+#include <unistd.h>
+
+static pthread_barrier_t barrier;
+
+static pid_t thread_tid;
+
+static void *
+thread_func (void *ignored)
+{
+ thread_tid = gettid ();
+ TEST_VERIFY (thread_tid != getpid ());
+ TEST_COMPARE (thread_tid, pthread_gettid_np (pthread_self ()));
+ xpthread_barrier_wait (&barrier);
+ /* The main thread calls pthread_gettid_np here. */
+ xpthread_barrier_wait (&barrier);
+ return NULL;
+}
+
+static int
+do_test (void)
+{
+ TEST_COMPARE (pthread_gettid_np (pthread_self ()), getpid ());
+ TEST_COMPARE (pthread_gettid_np (pthread_self ()), gettid ());
+
+ xpthread_barrier_init (&barrier, NULL, 2);
+
+ pthread_t thr = xpthread_create (NULL, thread_func, NULL);
+ xpthread_barrier_wait (&barrier);
+ TEST_COMPARE (thread_tid, pthread_gettid_np (thr));
+ xpthread_barrier_wait (&barrier);
+
+ while (true)
+ {
+ /* Check if the kernel thread is still running. */
+ if (tgkill (getpid (), thread_tid, 0))
+ {
+ TEST_COMPARE (errno, ESRCH);
+ break;
+ }
+
+ pid_t tid = pthread_gettid_np (thr);
+ if (tid != thread_tid)
+ {
+ TEST_COMPARE (tid, -1);
+ break;
+ }
+ TEST_COMPARE (sched_yield (), 0);
+ }
+
+ TEST_VERIFY (xpthread_join (thr) == NULL);
+
+ return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/nptl/pthread.h b/sysdeps/nptl/pthread.h
index 3d4f4a756c66750d..846e12b4ce484fb7 100644
--- a/sysdeps/nptl/pthread.h
+++ b/sysdeps/nptl/pthread.h
@@ -1317,6 +1317,11 @@ extern int pthread_getcpuclockid (pthread_t __thread_id,
__THROW __nonnull ((2));
#endif
+#ifdef __USE_GNU
+/* Return the Linux TID for THREAD_ID. Returns -1 on failure. */
+extern pid_t pthread_gettid_np (pthread_t __thread_id);
+#endif
+
/* Install handlers to be called when a new process is created with FORK.
The PREPARE handler is called in the parent process just before performing

21
glibc-RHEL-58357-7.patch Normal file
View File

@ -0,0 +1,21 @@
commit 74c68fa61b5ebf4c64605a3cc5e47154a66671ce
Author: Florian Weimer <fweimer@redhat.com>
Date: Wed Mar 12 10:23:47 2025 +0100
Linux: Remove attribute access from sched_getattr (bug 32781)
The GCC attribute expects an element count, not bytes.
diff --git a/sysdeps/unix/sysv/linux/bits/sched.h b/sysdeps/unix/sysv/linux/bits/sched.h
index a02cb69de77794fa..7c75303b80c18de2 100644
--- a/sysdeps/unix/sysv/linux/bits/sched.h
+++ b/sysdeps/unix/sysv/linux/bits/sched.h
@@ -149,7 +149,7 @@ int sched_setattr (pid_t tid, struct sched_attr *attr, unsigned int flags)
store it in *ATTR. */
int sched_getattr (pid_t tid, struct sched_attr *attr, unsigned int size,
unsigned int flags)
- __THROW __nonnull ((2)) __attr_access ((__write_only__, 2, 3));
+ __THROW __nonnull ((2));
#endif

145
glibc-RHEL-58357-8.patch Normal file
View File

@ -0,0 +1,145 @@
commit 1ec411f7aec1bb7fb0992c8e23a42cea306305aa
Author: Florian Weimer <fweimer@redhat.com>
Date: Wed Mar 12 10:23:47 2025 +0100
Linux: Add new test misc/tst-sched_setattr-thread
The straightforward sched_getattr call serves as a test for
bug 32781, too.
Reviewed-by: Joseph Myers <josmyers@redhat.com>
diff --git a/sysdeps/unix/sysv/linux/Makefile b/sysdeps/unix/sysv/linux/Makefile
index af7fbac14534e601..463e3f52bd7e0448 100644
--- a/sysdeps/unix/sysv/linux/Makefile
+++ b/sysdeps/unix/sysv/linux/Makefile
@@ -232,6 +232,7 @@ tests += \
tst-quota \
tst-rlimit-infinity \
tst-sched_setattr \
+ tst-sched_setattr-thread \
tst-scm_rights \
tst-sigtimedwait \
tst-sync_file_range \
diff --git a/sysdeps/unix/sysv/linux/tst-sched_setattr-thread.c b/sysdeps/unix/sysv/linux/tst-sched_setattr-thread.c
new file mode 100644
index 0000000000000000..4600be92fd0a4c28
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/tst-sched_setattr-thread.c
@@ -0,0 +1,116 @@
+/* Test for sched_setattr, sched_getattr involving multiple threads.
+ Copyright (C) 2024-2025 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of the
+ License, or (at your option) any later version.
+
+ The GNU C Library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, see
+ <https://www.gnu.org/licenses/>. */
+
+#include <sched.h>
+
+#include <stddef.h>
+#include <stdio.h>
+#include <support/check.h>
+#include <support/xthread.h>
+#include <unistd.h>
+
+enum { initial_nice_value = 15 };
+
+/* Check that thread TID has nice value EXPECTED. */
+static void
+check_nice_value (int tid, int expected)
+{
+ struct sched_attr attr;
+ if (sched_getattr (tid, &attr, sizeof (attr), 0) != 0)
+ FAIL_EXIT1 ("sched_getattr (%d) failed: %m", tid);
+ TEST_COMPARE (attr.sched_policy, SCHED_OTHER);
+ int nice_value = attr.sched_nice;
+ if (attr.sched_nice != expected)
+ FAIL_EXIT1 ("thread %d: expected nice value %d, got %d"
+ " (called from thread %d)",
+ tid, expected, nice_value, (int) gettid ());
+ printf ("info: thread %d: nice value %d (called from thread %d)\n",
+ tid, nice_value, (int) gettid ());
+}
+
+/* Set the nice value for TID to VALUE. */
+static void
+set_nice_value (int tid, int value)
+{
+ struct sched_attr attr =
+ {
+ .size = sizeof (attr),
+ .sched_policy = SCHED_OTHER,
+ .sched_nice = value,
+ };
+ if (sched_setattr (tid, &attr, 0) != 0)
+ FAIL_EXIT1 ("sched_setattr (%d) failed: %m", tid);
+}
+
+static pthread_barrier_t barrier;
+
+static void *
+thread_routine (void *nice_value_ptr)
+{
+ int nice_value = *(int *) nice_value_ptr;
+ /* Check that the nice value was inherited. */
+ check_nice_value (gettid (), initial_nice_value);
+ xpthread_barrier_wait (&barrier);
+ /* Main thread sets nice value. */
+ xpthread_barrier_wait (&barrier);
+ check_nice_value (gettid (), nice_value);
+ set_nice_value (gettid (), nice_value + 2);
+ xpthread_barrier_wait (&barrier);
+ /* Main thread sets checks value. */
+ xpthread_barrier_wait (&barrier);
+ return NULL;
+}
+
+static int
+do_test (void)
+{
+ if (nice (initial_nice_value) != initial_nice_value)
+ FAIL_UNSUPPORTED ("cannot set nice value to initial_nice_value: %m");
+
+ xpthread_barrier_init (&barrier, NULL, 3);
+
+ check_nice_value (0, initial_nice_value);
+ check_nice_value (gettid (), initial_nice_value);
+
+ int nice0 = initial_nice_value + 1;
+ pthread_t thr0 = xpthread_create (NULL, thread_routine, &nice0);
+ int nice1 = initial_nice_value + 2;
+ pthread_t thr1 = xpthread_create (NULL, thread_routine, &nice1);
+ check_nice_value (pthread_gettid_np (thr0), initial_nice_value);
+ check_nice_value (pthread_gettid_np (thr1), initial_nice_value);
+ xpthread_barrier_wait (&barrier);
+ set_nice_value (pthread_gettid_np (thr0), nice0);
+ check_nice_value (pthread_gettid_np (thr0), nice0);
+ check_nice_value (pthread_gettid_np (thr1), initial_nice_value);
+ set_nice_value (pthread_gettid_np (thr1), nice1);
+ check_nice_value (pthread_gettid_np (thr0), nice0);
+ check_nice_value (pthread_gettid_np (thr1), nice1);
+ xpthread_barrier_wait (&barrier);
+ /* Threads set nice value. */
+ xpthread_barrier_wait (&barrier);
+ check_nice_value (pthread_gettid_np (thr0), nice0 + 2);
+ check_nice_value (pthread_gettid_np (thr1), nice1 + 2);
+ xpthread_barrier_wait (&barrier);
+
+ TEST_VERIFY (xpthread_join (thr1) == NULL);
+ TEST_VERIFY (xpthread_join (thr0) == NULL);
+
+ return 0;
+}
+
+#include <support/test-driver.c>

20
glibc-RHEL-58357-9.patch Normal file
View File

@ -0,0 +1,20 @@
commit 6e30efe570f1ba135747c6d8f4004e78cd24c49c
Author: Florian Weimer <fweimer@redhat.com>
Date: Wed Mar 12 11:10:14 2025 +0100
nptl: Include <stdbool.h> in tst-pthread_gettid_np.c
The test uses the while (true) construct.
diff --git a/nptl/tst-pthread_gettid_np.c b/nptl/tst-pthread_gettid_np.c
index 6a98d864e222b9f5..ced42915106f5390 100644
--- a/nptl/tst-pthread_gettid_np.c
+++ b/nptl/tst-pthread_gettid_np.c
@@ -20,6 +20,7 @@
#include <pthread.h>
#include <sched.h>
#include <signal.h>
+#include <stdbool.h>
#include <support/check.h>
#include <support/xthread.h>
#include <unistd.h>

View File

@ -80,6 +80,8 @@
# glibc_shell_* below. # glibc_shell_* below.
%undefine _auto_set_build_flags %undefine _auto_set_build_flags
%define man_pages_version 6.06-3.el10
############################################################################## ##############################################################################
# Utility functions for pre/post scripts. Stick them at the beginning of # Utility functions for pre/post scripts. Stick them at the beginning of
# any lua %pre, %post, %postun, etc. sections to have them expand into # any lua %pre, %post, %postun, etc. sections to have them expand into
@ -145,7 +147,7 @@ Version: %{glibcversion}
# - It allows using the Release number without the %%dist tag in the dependency # - It allows using the Release number without the %%dist tag in the dependency
# generator to make the generated requires interchangeable between Rawhide # generator to make the generated requires interchangeable between Rawhide
# and ELN (.elnYY < .fcXX). # and ELN (.elnYY < .fcXX).
%global baserelease 50 %global baserelease 52
Release: %{baserelease}%{?dist}.alma.1 Release: %{baserelease}%{?dist}.alma.1
# Licenses: # Licenses:
@ -615,6 +617,19 @@ Patch291: glibc-RHEL-106562-21.patch
Patch292: glibc-RHEL-106562-22.patch Patch292: glibc-RHEL-106562-22.patch
Patch293: glibc-RHEL-106562-23.patch Patch293: glibc-RHEL-106562-23.patch
Patch294: glibc-RHEL-106562-24.patch Patch294: glibc-RHEL-106562-24.patch
Patch295: glibc-RHEL-107861-1.patch
Patch296: glibc-RHEL-107861-2.patch
Patch297: glibc-RHEL-58357-1.patch
Patch298: glibc-RHEL-58357-2.patch
Patch299: glibc-RHEL-58357-3.patch
Patch300: glibc-RHEL-58357-4.patch
Patch301: glibc-RHEL-58357-5.patch
Patch302: glibc-RHEL-58357-6.patch
Patch303: glibc-RHEL-58357-7.patch
Patch304: glibc-RHEL-58357-8.patch
Patch305: glibc-RHEL-58357-9.patch
Patch306: glibc-RHEL-58357-10.patch
Patch307: glibc-RHEL-58357-11.patch
############################################################################## ##############################################################################
# Continued list of core "glibc" package information: # Continued list of core "glibc" package information:
@ -1633,6 +1648,7 @@ build()
%ifarch aarch64 %ifarch aarch64
--enable-memory-tagging \ --enable-memory-tagging \
%endif %endif
--with-man-pages=%{man_pages_version} \
--disable-crypt \ --disable-crypt \
--disable-build-nscd \ --disable-build-nscd \
--disable-nscd \ --disable-nscd \
@ -2633,10 +2649,16 @@ update_gconv_modules_cache ()
%endif %endif
%changelog %changelog
* Thu Aug 07 2025 Eduard Abdullin <eabdullin@almalinux.org> - 2.39-50.alma.1 * Fri Aug 08 2025 Eduard Abdullin <eabdullin@almalinux.org> - 2.39-52.alma.1
- Overwrite target for x86_64_v2 - Overwrite target for x86_64_v2
- Add /usr/lib64/lp64d to ricv64 - Add /usr/lib64/lp64d to ricv64
* Wed Aug 06 2025 Frédéric Bérat <fberat@redhat.com> - 2.39-52
- Resolved a regression impacting `sched_setattr` and `sched_getattr` functions.
* Wed Aug 06 2025 Frédéric Bérat <fberat@redhat.com> - 2.39-51
- Enhanced glibc documentation for core descriptor APIs. (RHEL-107861)
* Wed Aug 06 2025 Arjun Shankar <arjun@redhat.com> - 2.39-50 * Wed Aug 06 2025 Arjun Shankar <arjun@redhat.com> - 2.39-50
- Improve test coverage (RHEL-106562) - Improve test coverage (RHEL-106562)