Commit f107b400 authored by Cyril Hrubis's avatar Cyril Hrubis Committed by Cheng Yu
Browse files

sched/rt: sysctl_sched_rr_timeslice show default timeslice after reset

stable inclusion
from stable-v4.19.308
commit 1f80bc015277247c9fd9646f7c21f1c728b5d908
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9K4H3

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?h=linux-4.19.y&id=1f80bc015277247c9fd9646f7c21f1c728



--------------------------------

[ Upstream commit c1fc6484 ]

The sched_rr_timeslice can be reset to default by writing value that is
<= 0. However after reading from this file we always got the last value
written, which is not useful at all.

$ echo -1 > /proc/sys/kernel/sched_rr_timeslice_ms
$ cat /proc/sys/kernel/sched_rr_timeslice_ms
-1

Fix this by setting the variable that holds the sysctl file value to the
jiffies_to_msecs(RR_TIMESLICE) in case that <= 0 value was written.

Signed-off-by: default avatarCyril Hrubis <chrubis@suse.cz>
Signed-off-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: default avatarPetr Vorel <pvorel@suse.cz>
Acked-by: default avatarMel Gorman <mgorman@suse.de>
Tested-by: default avatarPetr Vorel <pvorel@suse.cz>
Link: https://lore.kernel.org/r/20230802151906.25258-3-chrubis@suse.cz


Signed-off-by: default avatarPetr Vorel <pvorel@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarCheng Yu <serein.chengyu@huawei.com>
parent 5d7f26cf
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -2732,6 +2732,9 @@ int sched_rr_handler(struct ctl_table *table, int write,
		sched_rr_timeslice =
			sysctl_sched_rr_timeslice <= 0 ? RR_TIMESLICE :
			msecs_to_jiffies(sysctl_sched_rr_timeslice);

		if (sysctl_sched_rr_timeslice <= 0)
			sysctl_sched_rr_timeslice = jiffies_to_msecs(RR_TIMESLICE);
	}
	mutex_unlock(&mutex);