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
59extern unsigned int sysctl_sched_autogroup_enabled;59extern unsigned int sysctl_sched_autogroup_enabled;
60#endif60#endif
61 61
62extern int sysctl_sched_rr_timeslice;
62extern int sched_rr_timeslice;63extern int sched_rr_timeslice;
63 64
64extern int sched_rr_handler(struct ctl_table *table, int write,65extern 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
8471 /* make sure that internally we keep jiffies */8471 /* make sure that internally we keep jiffies */
8472 /* also, writing zero resets timeslice to default */8472 /* also, writing zero resets timeslice to default */
8473 if (!ret && write) {8473 if (!ret && write) {
8474 sched_rr_timeslice = sched_rr_timeslice <= 0 ?8474 sched_rr_timeslice =
8475 RR_TIMESLICE : msecs_to_jiffies(sched_rr_timeslice);8475 sysctl_sched_rr_timeslice <= 0 ? RR_TIMESLICE :
8476 msecs_to_jiffies(sysctl_sched_rr_timeslice);
8476 }8477 }
8477 mutex_unlock(&mutex);8478 mutex_unlock(&mutex);
8478 return ret;8479 return ret;
kernel/sched/rt.c+1−0
@@ -9,6 +9,7 @@ · 8 unmodified lines
9#include <linux/irq_work.h>9#include <linux/irq_work.h>
10 10
11int sched_rr_timeslice = RR_TIMESLICE;11int sched_rr_timeslice = RR_TIMESLICE;
12int sysctl_sched_rr_timeslice = (MSEC_PER_SEC / HZ) * RR_TIMESLICE;
12 13
13static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun);14static int do_sched_rt_period_timer(struct rt_bandwidth *rt_b, int overrun);
14 15
kernel/sysctl.c+1−1
@@ -416,7 +416,7 @@ static struct ctl_table kern_table[] = { · 415 unmodified lines
416 },416 },
417 {417 {
418 .procname = "sched_rr_timeslice_ms",418 .procname = "sched_rr_timeslice_ms",
419 .data = &sched_rr_timeslice,419 .data = &sysctl_sched_rr_timeslice,
420 .maxlen = sizeof(int),420 .maxlen = sizeof(int),
421 .mode = 0644,421 .mode = 0644,
422 .proc_handler = sched_rr_handler,422 .proc_handler = sched_rr_handler,