Signed-off-by: Chris Redpath chris.redpath@arm.com --- kernel/sched/fair.c | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-)
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index da45671..431c3c9 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -3557,26 +3557,31 @@ static enum hrtimer_restart hmp_cpu_keepalive_notify(struct hrtimer *hrtimer) return HRTIMER_NORESTART; }
-static void hmp_keepalive_delay(unsigned int *delay) +static void hmp_keepalive_delay(unsigned int *ns_delay) { struct cpuidle_driver *drv; drv = cpuidle_driver_ref(); if (drv) { - int least=0, next=0, idx; + unsigned int us_next = UINT_MAX; + unsigned int us_least = UINT_MAX; + unsigned int ns_next; + int idx; for (idx = 0; idx < drv->state_count; idx++) { - if (drv->states[idx].target_residency < - drv->states[least].target_residency) { - least = idx; - next = idx; - } else if (drv->states[idx].target_residency < - drv->states[next].target_residency) { - next = idx; + if (drv->states[idx].target_residency < us_least) { + us_least = drv->states[idx].target_residency; } } - *delay = drv->states[next].target_residency; - if (*delay) - *delay = *delay - 1; - printk("keepalive: use duration %u for cpu%d\n", *delay, smp_processor_id()); + for (idx = 0; idx < drv->state_count; idx++) { + if (drv->states[idx].target_residency > us_least && + drv->states[idx].target_residency < us_next) { + us_next = drv->states[idx].target_residency; + } + } + if (us_next) + us_next>>=1; + ns_next = us_next << 10; + *ns_delay = *ns_delay < ns_next ? *ns_delay : ns_next; + printk("keepalive: use duration %u for cpu%d\n", *ns_delay, smp_processor_id()); } cpuidle_driver_unref(); }