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