提交 82e430a6 编写于 作者: D Daniel Lezcano 提交者: Rafael J. Wysocki

cpuidle: play_idle: Increase the resolution to usec

The play_idle resolution is 1ms. The intel_powerclamp bases the idle
duration on jiffies. The idle injection API is also using msec based
duration but has no user yet.

Unfortunately, msec based time does not fit well when we want to
inject idle cycle precisely with shallow idle state.

In order to set the scene for the incoming idle injection user, move
the precision up to usec when calling play_idle.
Signed-off-by: NDaniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>
上级 97d3eb9d
...@@ -138,7 +138,7 @@ static void idle_inject_fn(unsigned int cpu) ...@@ -138,7 +138,7 @@ static void idle_inject_fn(unsigned int cpu)
*/ */
iit->should_run = 0; iit->should_run = 0;
play_idle(READ_ONCE(ii_dev->idle_duration_ms)); play_idle(READ_ONCE(ii_dev->idle_duration_ms) * USEC_PER_MSEC);
} }
/** /**
......
...@@ -430,7 +430,7 @@ static void clamp_idle_injection_func(struct kthread_work *work) ...@@ -430,7 +430,7 @@ static void clamp_idle_injection_func(struct kthread_work *work)
if (should_skip) if (should_skip)
goto balance; goto balance;
play_idle(jiffies_to_msecs(w_data->duration_jiffies)); play_idle(jiffies_to_usecs(w_data->duration_jiffies));
balance: balance:
if (clamping && w_data->clamping && cpu_online(w_data->cpu)) if (clamping && w_data->clamping && cpu_online(w_data->cpu))
......
...@@ -179,7 +179,7 @@ void arch_cpu_idle_dead(void); ...@@ -179,7 +179,7 @@ void arch_cpu_idle_dead(void);
int cpu_report_state(int cpu); int cpu_report_state(int cpu);
int cpu_check_up_prepare(int cpu); int cpu_check_up_prepare(int cpu);
void cpu_set_state_online(int cpu); void cpu_set_state_online(int cpu);
void play_idle(unsigned long duration_ms); void play_idle(unsigned long duration_us);
#ifdef CONFIG_HOTPLUG_CPU #ifdef CONFIG_HOTPLUG_CPU
bool cpu_wait_death(unsigned int cpu, int seconds); bool cpu_wait_death(unsigned int cpu, int seconds);
......
...@@ -311,7 +311,7 @@ static enum hrtimer_restart idle_inject_timer_fn(struct hrtimer *timer) ...@@ -311,7 +311,7 @@ static enum hrtimer_restart idle_inject_timer_fn(struct hrtimer *timer)
return HRTIMER_NORESTART; return HRTIMER_NORESTART;
} }
void play_idle(unsigned long duration_ms) void play_idle(unsigned long duration_us)
{ {
struct idle_timer it; struct idle_timer it;
...@@ -323,7 +323,7 @@ void play_idle(unsigned long duration_ms) ...@@ -323,7 +323,7 @@ void play_idle(unsigned long duration_ms)
WARN_ON_ONCE(current->nr_cpus_allowed != 1); WARN_ON_ONCE(current->nr_cpus_allowed != 1);
WARN_ON_ONCE(!(current->flags & PF_KTHREAD)); WARN_ON_ONCE(!(current->flags & PF_KTHREAD));
WARN_ON_ONCE(!(current->flags & PF_NO_SETAFFINITY)); WARN_ON_ONCE(!(current->flags & PF_NO_SETAFFINITY));
WARN_ON_ONCE(!duration_ms); WARN_ON_ONCE(!duration_us);
rcu_sleep_check(); rcu_sleep_check();
preempt_disable(); preempt_disable();
...@@ -333,7 +333,8 @@ void play_idle(unsigned long duration_ms) ...@@ -333,7 +333,8 @@ void play_idle(unsigned long duration_ms)
it.done = 0; it.done = 0;
hrtimer_init_on_stack(&it.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); hrtimer_init_on_stack(&it.timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
it.timer.function = idle_inject_timer_fn; it.timer.function = idle_inject_timer_fn;
hrtimer_start(&it.timer, ms_to_ktime(duration_ms), HRTIMER_MODE_REL_PINNED); hrtimer_start(&it.timer, ns_to_ktime(duration_us * NSEC_PER_USEC),
HRTIMER_MODE_REL_PINNED);
while (!READ_ONCE(it.done)) while (!READ_ONCE(it.done))
do_idle(); do_idle();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册