When sysctl_sched_rr_timeslice was set a non-positive number, only
sched_rr_timeslice was reset to default, This behavior should let
users know.
So reset sysctl_sched_rr_timeslice at the same time when it
non-positive.
Signed-off-by: Yajun Deng <[email protected]>
---
kernel/sched/rt.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c
index 0a11f44adee5..0723a6297f96 100644
--- a/kernel/sched/rt.c
+++ b/kernel/sched/rt.c
@@ -3036,9 +3036,12 @@ static int sched_rr_handler(struct ctl_table *table, int write, void *buffer,
* Also, writing zero resets the timeslice to default:
*/
if (!ret && write) {
- sched_rr_timeslice =
- sysctl_sched_rr_timeslice <= 0 ? RR_TIMESLICE :
- msecs_to_jiffies(sysctl_sched_rr_timeslice);
+ if (sysctl_sched_rr_timeslice > 0)
+ sched_rr_timeslice = msecs_to_jiffies(sysctl_sched_rr_timeslice);
+ else {
+ sched_rr_timeslice = RR_TIMESLICE;
+ sysctl_sched_rr_timeslice = (MSEC_PER_SEC / HZ) * RR_TIMESLICE;
+ }
}
mutex_unlock(&mutex);
--
2.25.1