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

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