Lines Matching +full:run +full:- +full:time
1 // SPDX-License-Identifier: GPL-2.0
8 * states for a specified fraction of time over a specified period.
13 * All of the kthreads used for idle injection are created at init time.
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
50 * struct idle_inject_thread - task on/off switch structure
52 * @should_run: whether or not to run the task (for the smpboot kthread API)
60 * struct idle_inject_device - idle injection data
62 * @idle_duration_ms: duration of CPU idle time to inject
63 * @run_duration_ms: duration of CPU run time to allow
77 * idle_inject_wakeup - Wake up idle injection threads
88 for_each_cpu_and(cpu, to_cpumask(ii_dev->cpumask), cpu_online_mask) { in idle_inject_wakeup()
90 iit->should_run = 1; in idle_inject_wakeup()
91 wake_up_process(iit->tsk); in idle_inject_wakeup()
96 * idle_inject_timer_fn - idle injection timer function
101 * play_idle() to inject a specified amount of CPU idle time.
111 duration_ms = READ_ONCE(ii_dev->run_duration_ms); in idle_inject_timer_fn()
112 duration_ms += READ_ONCE(ii_dev->idle_duration_ms); in idle_inject_timer_fn()
122 * idle_inject_fn - idle injection work function
126 * time.
137 * Let the smpboot main loop know that the task should not run again. in idle_inject_fn()
139 iit->should_run = 0; in idle_inject_fn()
141 play_idle(READ_ONCE(ii_dev->idle_duration_ms)); in idle_inject_fn()
145 * idle_inject_set_duration - idle and run duration update helper
146 * @run_duration_ms: CPU run time to allow in milliseconds
147 * @idle_duration_ms: CPU idle time to inject in milliseconds
154 WRITE_ONCE(ii_dev->run_duration_ms, run_duration_ms); in idle_inject_set_duration()
155 WRITE_ONCE(ii_dev->idle_duration_ms, idle_duration_ms); in idle_inject_set_duration()
160 * idle_inject_get_duration - idle and run duration retrieval helper
161 * @run_duration_ms: memory location to store the current CPU run time
162 * @idle_duration_ms: memory location to store the current CPU idle time
168 *run_duration_ms = READ_ONCE(ii_dev->run_duration_ms); in idle_inject_get_duration()
169 *idle_duration_ms = READ_ONCE(ii_dev->idle_duration_ms); in idle_inject_get_duration()
173 * idle_inject_start - start idle injections
177 * injection kthreads associated with @ii_dev to let them inject CPU idle time
180 * Return: -EINVAL if the CPU idle or CPU run time is not set or 0 on success.
184 unsigned int idle_duration_ms = READ_ONCE(ii_dev->idle_duration_ms); in idle_inject_start()
185 unsigned int run_duration_ms = READ_ONCE(ii_dev->run_duration_ms); in idle_inject_start()
188 return -EINVAL; in idle_inject_start()
191 cpumask_pr_args(to_cpumask(ii_dev->cpumask))); in idle_inject_start()
195 hrtimer_start(&ii_dev->timer, in idle_inject_start()
203 * idle_inject_stop - stops idle injections
207 * If CPU idle time is being injected when this function runs, then it will
219 cpumask_pr_args(to_cpumask(ii_dev->cpumask))); in idle_inject_stop()
221 hrtimer_cancel(&ii_dev->timer); in idle_inject_stop()
238 for_each_cpu(cpu, to_cpumask(ii_dev->cpumask)) { in idle_inject_stop()
240 iit->should_run = 0; in idle_inject_stop()
242 wait_task_inactive(iit->tsk, 0); in idle_inject_stop()
249 * idle_inject_setup - prepare the current task for idle injection
263 * idle_inject_should_run - function helper for the smpboot API
266 * Return: whether or not the thread can run.
273 return iit->should_run; in idle_inject_should_run()
277 * idle_inject_register - initialize idle injection on a set of CPUs
296 cpumask_copy(to_cpumask(ii_dev->cpumask), cpumask); in idle_inject_register()
297 hrtimer_init(&ii_dev->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); in idle_inject_register()
298 ii_dev->timer.function = idle_inject_timer_fn; in idle_inject_register()
300 for_each_cpu(cpu, to_cpumask(ii_dev->cpumask)) { in idle_inject_register()
313 for_each_cpu(cpu_rb, to_cpumask(ii_dev->cpumask)) { in idle_inject_register()
325 * idle_inject_unregister - unregister idle injection control device
338 for_each_cpu(cpu, to_cpumask(ii_dev->cpumask)) in idle_inject_unregister()