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