History

sched/rt: Show the 'sched_rr_timeslice' SCHED_RR timeslice tuning knob in milliseconds

We added the 'sched_rr_timeslice_ms' SCHED_RR tuning knob in this commit: ce0dbbbb30ae ("sched/rt: Add a tuning knob to allow changing SCHED_RR timeslice") ... which name suggests to users that it's in milliseconds, while in reality it's being set in milliseconds but the result is shown in jiffies. This is obviously confusing when HZ is not 1000, it makes it appear like the value set failed, such as HZ=100: root# echo 100 > /proc/sys/kernel/sched_rr_timeslice_ms root# cat /proc/sys/kernel/sched_rr_timeslice_ms 10 Fix this to be milliseconds all around.

Shile Zhang committed 9 years ago

Commit 975e1551 parent 733ce724 files · +6 −3Browse files

Unified · Split

4 files
  1. include/linux/sched/sysctl.h +1 −0
  2. kernel/sched/core.c +3 −2
  3. kernel/sched/rt.c +1 −0
  4. kernel/sysctl.c +1 −1
include/linux/sched/sysctl.h+1−0
@@ -59,6 +59,7 @@ extern unsigned int sysctl_sched_cfs_bandwidth_slice; · 58 unmodified lines
5959 extern unsigned int sysctl_sched_autogroup_enabled;
6060 #endif
6161
62+extern int sysctl_sched_rr_timeslice;
6263 extern int sched_rr_timeslice;
6364
6465 extern int sched_rr_handler(struct ctl_table *table, int write,
kernel/sched/core.c+3−2
@@ -8471,8 +8471,9 @@ int sched_rr_handler(struct ctl_table *table, int write, · 8470 unmodified lines
84718471 /* make sure that internally we keep jiffies */
84728472 /* also, writing zero resets timeslice to default */
84738473 if (!ret && write) {
8474− sched_rr_timeslice = sched_rr_timeslice <= 0 ?
8475− RR_TIMESLICE : msecs_to_jiffies(sched_rr_timeslice);
8474+ sched_rr_timeslice =
8475+ sysctl_sched_rr_timeslice <= 0 ? RR_TIMESLICE :
8476+ msecs_to_jiffies(sysctl_sched_rr_timeslice);
84768477 }
84778478 mutex_unlock(&mutex);
84788479 return ret;
kernel/sched/rt.c+1−0
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 #include <linux/irq_work.h>
1010
1111 int sched_rr_timeslice = RR_TIMESLICE;
12+int sysctl_sched_rr_timeslice = (MSEC_PER_SEC / HZ) * RR_TIMESLICE;
1213
1314 static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun);
1415
kernel/sysctl.c+1−1
@@ -416,7 +416,7 @@ static struct ctl_table kern_table[] = { · 415 unmodified lines
416416 },
417417 {
418418 .procname = "sched_rr_timeslice_ms",
419− .data = &sched_rr_timeslice,
419+ .data = &sysctl_sched_rr_timeslice,
420420 .maxlen = sizeof(int),
421421 .mode = 0644,
422422 .proc_handler = sched_rr_handler,