cpufreq: interactive: Use del_timer/add_timer_on to rearm timers
Replace mod_timer_pinned() with del_timer(), add_timer_on(). mod_timer_pinned() always adds timer onto current CPU. Interactive governor expects each CPU's timers to be running on the same CPU. If cpufreq_interactive_timer_resched() is called from another CPU, the timer will be armed on the wrong CPU. Replacing mod_timer_pinned() with del_timer() and add_timer_on() guarantees timers are still run on the right CPU even if another CPU reschedules the timer. This would provide more flexibility for future changes. Change-Id: I3a10be37632afc0ea4e0cc9c86323b9783b216b1 [junjiew@codeaurora.org: Dropped changes that are no longer needed due to removal of relevant code] Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
This commit is contained in:
parent
bbe0d10d97
commit
3b48f85cd1
1 changed files with 11 additions and 7 deletions
|
@ -155,9 +155,9 @@ static u64 round_to_nw_start(u64 jif,
|
||||||
return (jif + 1) * step;
|
return (jif + 1) * step;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cpufreq_interactive_timer_resched(
|
static void cpufreq_interactive_timer_resched(unsigned long cpu)
|
||||||
struct cpufreq_interactive_cpuinfo *pcpu)
|
|
||||||
{
|
{
|
||||||
|
struct cpufreq_interactive_cpuinfo *pcpu = &per_cpu(cpuinfo, cpu);
|
||||||
struct cpufreq_interactive_tunables *tunables =
|
struct cpufreq_interactive_tunables *tunables =
|
||||||
pcpu->policy->governor_data;
|
pcpu->policy->governor_data;
|
||||||
u64 expires;
|
u64 expires;
|
||||||
|
@ -171,12 +171,16 @@ static void cpufreq_interactive_timer_resched(
|
||||||
pcpu->cputime_speedadj = 0;
|
pcpu->cputime_speedadj = 0;
|
||||||
pcpu->cputime_speedadj_timestamp = pcpu->time_in_idle_timestamp;
|
pcpu->cputime_speedadj_timestamp = pcpu->time_in_idle_timestamp;
|
||||||
expires = round_to_nw_start(pcpu->last_evaluated_jiffy, tunables);
|
expires = round_to_nw_start(pcpu->last_evaluated_jiffy, tunables);
|
||||||
mod_timer_pinned(&pcpu->cpu_timer, expires);
|
del_timer(&pcpu->cpu_timer);
|
||||||
|
pcpu->cpu_timer.expires = expires;
|
||||||
|
add_timer_on(&pcpu->cpu_timer, cpu);
|
||||||
|
|
||||||
if (tunables->timer_slack_val >= 0 &&
|
if (tunables->timer_slack_val >= 0 &&
|
||||||
pcpu->target_freq > pcpu->policy->min) {
|
pcpu->target_freq > pcpu->policy->min) {
|
||||||
expires += usecs_to_jiffies(tunables->timer_slack_val);
|
expires += usecs_to_jiffies(tunables->timer_slack_val);
|
||||||
mod_timer_pinned(&pcpu->cpu_slack_timer, expires);
|
del_timer(&pcpu->cpu_slack_timer);
|
||||||
|
pcpu->cpu_slack_timer.expires = expires;
|
||||||
|
add_timer_on(&pcpu->cpu_slack_timer, cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_unlock_irqrestore(&pcpu->load_lock, flags);
|
spin_unlock_irqrestore(&pcpu->load_lock, flags);
|
||||||
|
@ -193,6 +197,7 @@ static void cpufreq_interactive_timer_start(
|
||||||
u64 expires = round_to_nw_start(pcpu->last_evaluated_jiffy, tunables);
|
u64 expires = round_to_nw_start(pcpu->last_evaluated_jiffy, tunables);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
|
spin_lock_irqsave(&pcpu->load_lock, flags);
|
||||||
pcpu->cpu_timer.expires = expires;
|
pcpu->cpu_timer.expires = expires;
|
||||||
add_timer_on(&pcpu->cpu_timer, cpu);
|
add_timer_on(&pcpu->cpu_timer, cpu);
|
||||||
if (tunables->timer_slack_val >= 0 &&
|
if (tunables->timer_slack_val >= 0 &&
|
||||||
|
@ -202,7 +207,6 @@ static void cpufreq_interactive_timer_start(
|
||||||
add_timer_on(&pcpu->cpu_slack_timer, cpu);
|
add_timer_on(&pcpu->cpu_slack_timer, cpu);
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_irqsave(&pcpu->load_lock, flags);
|
|
||||||
pcpu->time_in_idle =
|
pcpu->time_in_idle =
|
||||||
get_cpu_idle_time(cpu, &pcpu->time_in_idle_timestamp,
|
get_cpu_idle_time(cpu, &pcpu->time_in_idle_timestamp,
|
||||||
tunables->io_is_busy);
|
tunables->io_is_busy);
|
||||||
|
@ -492,7 +496,7 @@ static void cpufreq_interactive_timer(unsigned long data)
|
||||||
|
|
||||||
rearm:
|
rearm:
|
||||||
if (!timer_pending(&pcpu->cpu_timer))
|
if (!timer_pending(&pcpu->cpu_timer))
|
||||||
cpufreq_interactive_timer_resched(pcpu);
|
cpufreq_interactive_timer_resched(data);
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
up_read(&pcpu->enable_sem);
|
up_read(&pcpu->enable_sem);
|
||||||
|
@ -513,7 +517,7 @@ static void cpufreq_interactive_idle_end(void)
|
||||||
|
|
||||||
/* Arm the timer for 1-2 ticks later if not already. */
|
/* Arm the timer for 1-2 ticks later if not already. */
|
||||||
if (!timer_pending(&pcpu->cpu_timer)) {
|
if (!timer_pending(&pcpu->cpu_timer)) {
|
||||||
cpufreq_interactive_timer_resched(pcpu);
|
cpufreq_interactive_timer_resched(smp_processor_id());
|
||||||
} else if (time_after_eq(jiffies, pcpu->cpu_timer.expires)) {
|
} else if (time_after_eq(jiffies, pcpu->cpu_timer.expires)) {
|
||||||
del_timer(&pcpu->cpu_timer);
|
del_timer(&pcpu->cpu_timer);
|
||||||
del_timer(&pcpu->cpu_slack_timer);
|
del_timer(&pcpu->cpu_slack_timer);
|
||||||
|
|
Loading…
Add table
Reference in a new issue