Commit 5f6d858e authored by Peter Zijlstra's avatar Peter Zijlstra Committed by Ingo Molnar

sched: speed up and simplify vslice calculations

speed up and simplify vslice calculations.

[ From: Mike Galbraith <efault@gmx.de>: build fix ]
Signed-off-by: default avatarPeter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent b0ffd246
...@@ -1400,7 +1400,7 @@ extern void sched_idle_next(void); ...@@ -1400,7 +1400,7 @@ extern void sched_idle_next(void);
#ifdef CONFIG_SCHED_DEBUG #ifdef CONFIG_SCHED_DEBUG
extern unsigned int sysctl_sched_latency; extern unsigned int sysctl_sched_latency;
extern unsigned int sysctl_sched_min_granularity; extern unsigned int sysctl_sched_nr_latency;
extern unsigned int sysctl_sched_wakeup_granularity; extern unsigned int sysctl_sched_wakeup_granularity;
extern unsigned int sysctl_sched_batch_wakeup_granularity; extern unsigned int sysctl_sched_batch_wakeup_granularity;
extern unsigned int sysctl_sched_child_runs_first; extern unsigned int sysctl_sched_child_runs_first;
......
...@@ -210,7 +210,7 @@ static int sched_debug_show(struct seq_file *m, void *v) ...@@ -210,7 +210,7 @@ static int sched_debug_show(struct seq_file *m, void *v)
#define PN(x) \ #define PN(x) \
SEQ_printf(m, " .%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x)) SEQ_printf(m, " .%-40s: %Ld.%06ld\n", #x, SPLIT_NS(x))
PN(sysctl_sched_latency); PN(sysctl_sched_latency);
PN(sysctl_sched_min_granularity); PN(sysctl_sched_nr_latency);
PN(sysctl_sched_wakeup_granularity); PN(sysctl_sched_wakeup_granularity);
PN(sysctl_sched_batch_wakeup_granularity); PN(sysctl_sched_batch_wakeup_granularity);
PN(sysctl_sched_child_runs_first); PN(sysctl_sched_child_runs_first);
......
...@@ -46,7 +46,7 @@ const_debug unsigned int sysctl_sched_child_runs_first = 1; ...@@ -46,7 +46,7 @@ const_debug unsigned int sysctl_sched_child_runs_first = 1;
* Minimal preemption granularity for CPU-bound tasks: * Minimal preemption granularity for CPU-bound tasks:
* (default: 2 msec, units: nanoseconds) * (default: 2 msec, units: nanoseconds)
*/ */
unsigned int sysctl_sched_min_granularity __read_mostly = 2000000ULL; const_debug unsigned int sysctl_sched_nr_latency = 20;
/* /*
* sys_sched_yield() compat mode * sys_sched_yield() compat mode
...@@ -222,8 +222,7 @@ static inline struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq) ...@@ -222,8 +222,7 @@ static inline struct sched_entity *__pick_last_entity(struct cfs_rq *cfs_rq)
static u64 __sched_period(unsigned long nr_running) static u64 __sched_period(unsigned long nr_running)
{ {
u64 period = sysctl_sched_latency; u64 period = sysctl_sched_latency;
unsigned long nr_latency = unsigned long nr_latency = sysctl_sched_nr_latency;
sysctl_sched_latency / sysctl_sched_min_granularity;
if (unlikely(nr_running > nr_latency)) { if (unlikely(nr_running > nr_latency)) {
period *= nr_running; period *= nr_running;
...@@ -245,11 +244,15 @@ static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se) ...@@ -245,11 +244,15 @@ static u64 sched_slice(struct cfs_rq *cfs_rq, struct sched_entity *se)
static u64 __sched_vslice(unsigned long nr_running) static u64 __sched_vslice(unsigned long nr_running)
{ {
u64 period = __sched_period(nr_running); unsigned long period = sysctl_sched_latency;
unsigned long nr_latency = sysctl_sched_nr_latency;
do_div(period, nr_running); if (unlikely(nr_running > nr_latency))
nr_running = nr_latency;
return period; period /= nr_running;
return (u64)period;
} }
/* /*
......
...@@ -222,14 +222,11 @@ static ctl_table kern_table[] = { ...@@ -222,14 +222,11 @@ static ctl_table kern_table[] = {
#ifdef CONFIG_SCHED_DEBUG #ifdef CONFIG_SCHED_DEBUG
{ {
.ctl_name = CTL_UNNUMBERED, .ctl_name = CTL_UNNUMBERED,
.procname = "sched_min_granularity_ns", .procname = "sched_nr_latency",
.data = &sysctl_sched_min_granularity, .data = &sysctl_sched_nr_latency,
.maxlen = sizeof(unsigned int), .maxlen = sizeof(unsigned int),
.mode = 0644, .mode = 0644,
.proc_handler = &proc_dointvec_minmax, .proc_handler = &proc_dointvec,
.strategy = &sysctl_intvec,
.extra1 = &min_sched_granularity_ns,
.extra2 = &max_sched_granularity_ns,
}, },
{ {
.ctl_name = CTL_UNNUMBERED, .ctl_name = CTL_UNNUMBERED,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment