Check if sched_attr is in glibc

Resolves: RHEL-92953
Signed-off-by: John Kacur <jkacur@redhat.com>
This commit is contained in:
John Kacur 2025-05-22 15:33:29 -04:00
parent 0bc0413bd1
commit ebee3fc2c0
2 changed files with 42 additions and 2 deletions

View File

@ -0,0 +1,33 @@
From b79c1777ee16901b3d27cd25e50435f4f060cfa8 Mon Sep 17 00:00:00 2001
From: John Kacur <jkacur@redhat.com>
Date: Thu, 22 May 2025 11:33:07 -0400
Subject: [PATCH] stalld: sched_attr: Do not define for glibc >= 2.41
glibc >=2.41 has definitions for struct sched_attr and
sched_setattr and sched_getattr
Sometimes this is backported by distributions so define conditionally on
SCHED_ATTR_SIZE_VER0
Signed-off-by: John Kacur <jkacur@redhat.com>
---
src/stalld.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/stalld.h b/src/stalld.h
index 0c4dcee503ca..7b4d7e60f5f7 100644
--- a/src/stalld.h
+++ b/src/stalld.h
@@ -110,7 +110,8 @@ struct stalld_backend {
void (*destroy)(void);
};
-#if ! __GLIBC_PREREQ(2, 41) && !defined(GLIBC_HAS_SCHED_ATTR)
+/* sched_attr is not defined in glibc < 2.41, unless backported */
+#ifndef SCHED_ATTR_SIZE_VER0
#ifdef __x86_64__
# define __NR_sched_setattr 314
--
2.49.0

View File

@ -1,6 +1,6 @@
Name: stalld
Version: 1.19.8
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Daemon that finds starving tasks and gives them a temporary boost
License: GPL-2.0-or-later AND GPL-2.0-only
@ -22,6 +22,9 @@ BuildRequires: libbpf-devel
Requires: libbpf
%endif
# Patches
Patch1: stalld-sched_attr-Do-not-define-for-glibc-2.41.patch
%define _hardened_build 1
%description
@ -33,7 +36,7 @@ boost using the SCHED_DEADLINE policy. The default is to
allow 10 microseconds of runtime for 1 second of clock time.
%prep
%autosetup
%autosetup -p1
%build
%make_build RPMCFLAGS="%{optflags} %{build_cflags} -DVERSION="\\\"%{version}\\\""" RPMLDFLAGS="%{build_ldflags}"
@ -61,6 +64,10 @@ allow 10 microseconds of runtime for 1 second of clock time.
%systemd_postun_with_restart %{name}.service
%changelog
* Thu May 22 2025 John Kacur <jkacur@redhat.com> - 1.19.8-2
- Check if sched_attr is in glibc
Resolves: RHEL-92953
* Wed Feb 12 2025 Clark Williams <williams@redhat.com> - 1.19.8-1
- sched_debug: fix non x86 support
- stalld.h: fix prototype mis-patch with cleanup_regex()