Blame SOURCES/0043-chrt-use-SCHED_FLAG_RESET_ON_FORK-for-sched_setattr.patch

439b44
From f575b6e0857087f46d54f494d9a435af715ea19d Mon Sep 17 00:00:00 2001
439b44
From: Karel Zak <kzak@redhat.com>
439b44
Date: Thu, 1 Oct 2020 10:40:27 +0200
439b44
Subject: [PATCH 43/55] chrt: use SCHED_FLAG_RESET_ON_FORK for sched_setattr()
439b44
439b44
Reviewed by many people, used for years (but probably nobody uses
439b44
SCHED_DEADLINE with reset-on-fork), but we all missed:
439b44
439b44
- sched_setscheduler() uses SCHED_RESET_ON_FORK (0x40000000)
439b44
- sched_setattr() uses SCHED_FLAG_RESET_ON_FORK (0x01)
439b44
439b44
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1884194
439b44
Signed-off-by: Karel Zak <kzak@redhat.com>
439b44
---
439b44
 schedutils/chrt.c | 7 ++++---
439b44
 1 file changed, 4 insertions(+), 3 deletions(-)
439b44
439b44
diff --git a/schedutils/chrt.c b/schedutils/chrt.c
439b44
index b08c78ed8..15556bbad 100644
439b44
--- a/schedutils/chrt.c
439b44
+++ b/schedutils/chrt.c
439b44
@@ -123,7 +123,7 @@ struct chrt_ctl {
439b44
 	uint64_t period;
439b44
 
439b44
 	unsigned int all_tasks : 1,		/* all threads of the PID */
439b44
-		     reset_on_fork : 1,		/* SCHED_RESET_ON_FORK */
439b44
+		     reset_on_fork : 1,		/* SCHED_RESET_ON_FORK or SCHED_FLAG_RESET_ON_FORK */
439b44
 		     altered : 1,		/* sched_set**() used */
439b44
 		     verbose : 1;		/* verbose output */
439b44
 };
439b44
@@ -376,9 +376,10 @@ static int set_sched_one(struct chrt_ctl *ctl, pid_t pid)
439b44
 	sa.sched_period   = ctl->period;
439b44
 	sa.sched_deadline = ctl->deadline;
439b44
 
439b44
-# ifdef SCHED_RESET_ON_FORK
439b44
+# ifdef SCHED_FLAG_RESET_ON_FORK
439b44
+	/* Don't use SCHED_RESET_ON_FORK for sched_setattr()! */
439b44
 	if (ctl->reset_on_fork)
439b44
-		sa.sched_flags |= SCHED_RESET_ON_FORK;
439b44
+		sa.sched_flags |= SCHED_FLAG_RESET_ON_FORK;
439b44
 # endif
439b44
 	errno = 0;
439b44
 	return sched_setattr(pid, &sa, 0);
439b44
-- 
439b44
2.29.2
439b44