On Tue, Jun 19, 2018 at 3:23 PM, Daniel Lezcano <daniel.lezc...@linaro.org> wrote:
[cut] > +/** > + * idle_injection_wakeup - Wake up all idle injection threads > + * @ii_dev: the idle injection device > + * > + * Every idle injection task belonging to the idle injection device > + * and running on an online CPU will be wake up by this call. > + */ > +static void idle_injection_wakeup(struct idle_injection_device *ii_dev) > +{ > + struct idle_injection_thread *iit; > + unsigned int cpu; > + > + for_each_cpu_and(cpu, to_cpumask(ii_dev->cpumask), cpu_online_mask) { > + iit = per_cpu_ptr(&idle_injection_thread, cpu); > + iit->should_run = 1; > + wake_up_process(iit->tsk); > + } > +} > + > +/** > + * idle_injection_wakeup_fn - idle injection timer callback > + * @timer: a hrtimer structure > + * > + * This function is called when the idle injection timer expires which > + * will wake up the idle injection tasks and these ones, in turn, play > + * idle a specified amount of time. > + * > + * Return: HRTIMER_RESTART. > + */ > +static enum hrtimer_restart idle_injection_wakeup_fn(struct hrtimer *timer) > +{ > + unsigned int duration_ms; > + struct idle_injection_device *ii_dev = > + container_of(timer, struct idle_injection_device, timer); > + > + duration_ms = READ_ONCE(ii_dev->run_duration_ms); > + duration_ms += READ_ONCE(ii_dev->idle_duration_ms); > + > + idle_injection_wakeup(ii_dev); > + > + hrtimer_forward_now(timer, ms_to_ktime(duration_ms)); > + > + return HRTIMER_RESTART; > +} Also, I'd rename the above to idle_inject_timer_fn() for clarity. _wakeup_fn() is kind of too similar to _wakeup() IMO and a bit confusing.