Lines Matching +full:run +full:- +full:control

1 // SPDX-License-Identifier: GPL-2.0
19 * The idle + run duration is specified via separate helpers and that allows
34 * It is up to the user of this framework to provide a lock for higher-level
51 * struct idle_inject_thread - task on/off switch structure
53 * @should_run: whether or not to run the task (for the smpboot kthread API)
61 * struct idle_inject_device - idle injection data
64 * @run_duration_us: duration of CPU run time to allow
71 * instance has an idle duration, a run duration and mask of CPUs to inject
78 * update() - This callback is invoked just before waking up CPUs to inject
80 * cycle. It also allows the caller to readjust the idle and run duration by
96 * idle_inject_wakeup - Wake up idle injection threads
107 for_each_cpu_and(cpu, to_cpumask(ii_dev->cpumask), cpu_online_mask) {
109 iit->should_run = 1;
110 wake_up_process(iit->tsk);
115 * idle_inject_timer_fn - idle injection timer function
130 if (!ii_dev->update || ii_dev->update())
133 duration_us = READ_ONCE(ii_dev->run_duration_us);
134 duration_us += READ_ONCE(ii_dev->idle_duration_us);
142 * idle_inject_fn - idle injection work function
157 * Let the smpboot main loop know that the task should not run again.
159 iit->should_run = 0;
161 play_idle_precise(READ_ONCE(ii_dev->idle_duration_us) * NSEC_PER_USEC,
162 READ_ONCE(ii_dev->latency_us) * NSEC_PER_USEC);
166 * idle_inject_set_duration - idle and run duration update helper
167 * @ii_dev: idle injection control device structure
168 * @run_duration_us: CPU run time to allow in microseconds
176 WRITE_ONCE(ii_dev->run_duration_us, run_duration_us);
177 WRITE_ONCE(ii_dev->idle_duration_us, idle_duration_us);
185 * idle_inject_get_duration - idle and run duration retrieval helper
186 * @ii_dev: idle injection control device structure
187 * @run_duration_us: memory location to store the current CPU run time
194 *run_duration_us = READ_ONCE(ii_dev->run_duration_us);
195 *idle_duration_us = READ_ONCE(ii_dev->idle_duration_us);
200 * idle_inject_set_latency - set the maximum latency allowed
201 * @ii_dev: idle injection control device structure
207 WRITE_ONCE(ii_dev->latency_us, latency_us);
212 * idle_inject_start - start idle injections
213 * @ii_dev: idle injection control device structure
219 * Return: -EINVAL if the CPU idle or CPU run time is not set or 0 on success.
223 unsigned int idle_duration_us = READ_ONCE(ii_dev->idle_duration_us);
224 unsigned int run_duration_us = READ_ONCE(ii_dev->run_duration_us);
227 return -EINVAL;
230 cpumask_pr_args(to_cpumask(ii_dev->cpumask)));
234 hrtimer_start(&ii_dev->timer,
244 * idle_inject_stop - stops idle injections
245 * @ii_dev: idle injection control device structure
260 cpumask_pr_args(to_cpumask(ii_dev->cpumask)));
262 hrtimer_cancel(&ii_dev->timer);
279 for_each_cpu(cpu, to_cpumask(ii_dev->cpumask)) {
281 iit->should_run = 0;
283 wait_task_inactive(iit->tsk, TASK_ANY);
291 * idle_inject_setup - prepare the current task for idle injection
303 * idle_inject_should_run - function helper for the smpboot API
306 * Return: whether or not the thread can run.
313 return iit->should_run;
317 * idle_inject_register_full - initialize idle injection on a set of CPUs
322 * This function creates an idle injection control device structure for the
327 * Return: NULL if memory allocation fails, idle injection control device
341 cpumask_copy(to_cpumask(ii_dev->cpumask), cpumask);
342 hrtimer_setup(&ii_dev->timer, idle_inject_timer_fn, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
343 ii_dev->latency_us = UINT_MAX;
344 ii_dev->update = update;
346 for_each_cpu(cpu, to_cpumask(ii_dev->cpumask)) {
359 for_each_cpu(cpu_rb, to_cpumask(ii_dev->cpumask)) {
372 * idle_inject_register - initialize idle injection on a set of CPUs
375 * This function creates an idle injection control device structure for the
379 * Return: NULL if memory allocation fails, idle injection control device
389 * idle_inject_unregister - unregister idle injection control device
390 * @ii_dev: idle injection control device to unregister
392 * The function stops idle injection for the given control device,
402 for_each_cpu(cpu, to_cpumask(ii_dev->cpumask))