Lines Matching full:task
85 struct task_struct *g, *task;
122 for_each_process_thread(g, task) {
123 WARN_ON_ONCE(test_tsk_thread_flag(task, TIF_PATCH_PENDING));
124 task->patch_state = KLP_TRANSITION_IDLE;
129 task = idle_task(cpu);
130 WARN_ON_ONCE(test_tsk_thread_flag(task, TIF_PATCH_PENDING));
131 task->patch_state = KLP_TRANSITION_IDLE;
169 * Switch the patched state of the task to the set of functions in the target
172 * NOTE: If task is not 'current', the caller must ensure the task is inactive.
175 void klp_update_patch_state(struct task_struct *task)
195 if (test_and_clear_tsk_thread_flag(task, TIF_PATCH_PENDING))
196 task->patch_state = READ_ONCE(klp_target_state);
251 * Determine whether it's safe to transition the task to the target patch state
254 static int klp_check_stack(struct task_struct *task, const char **oldname)
264 ret = stack_trace_save_tsk_reliable(task, entries, MAX_STACK_ENTRIES);
284 static int klp_check_and_switch_task(struct task_struct *task, void *arg)
288 if (task_curr(task) && task != current)
291 ret = klp_check_stack(task, arg);
295 clear_tsk_thread_flag(task, TIF_PATCH_PENDING);
296 task->patch_state = klp_target_state;
301 * Try to safely switch a task to the target patch state. If it's currently
305 static bool klp_try_switch_task(struct task_struct *task)
310 /* check if this task has already switched over */
311 if (task->patch_state == klp_target_state)
323 * functions. If all goes well, switch the task to the target patch
326 if (task == current)
329 ret = task_call_func(task, klp_check_and_switch_task, &old_name);
337 __func__, task->comm, task->pid);
341 __func__, task->comm, task->pid);
345 __func__, task->comm, task->pid, old_name);
350 __func__, ret, task->comm, task->pid);
365 * able to switch to this task while it's running.
389 struct task_struct *g, *task;
395 for_each_process_thread(g, task) {
396 if (!klp_patch_pending(task))
402 * Meanwhile the task could migrate itself and the action
405 if (task->flags & PF_KTHREAD) {
410 wake_up_state(task, TASK_INTERRUPTIBLE);
416 set_notify_signal(task);
425 * to-be-unpatched functions. If such functions are found, the task can't be
433 struct task_struct *g, *task;
443 * is deemed unreliable, the task can't be switched yet.
449 for_each_process_thread(g, task)
450 if (!klp_try_switch_task(task))
459 task = idle_task(cpu);
461 if (!klp_try_switch_task(task)) {
463 /* Make idle task go through the main loop. */
466 } else if (task->patch_state != klp_target_state) {
468 clear_tsk_thread_flag(task, TIF_PATCH_PENDING);
469 task->patch_state = klp_target_state;
511 struct task_struct *g, *task;
526 for_each_process_thread(g, task)
527 if (task->patch_state != klp_target_state)
528 set_tsk_thread_flag(task, TIF_PATCH_PENDING);
537 task = idle_task(cpu);
538 if (task->patch_state != klp_target_state)
539 set_tsk_thread_flag(task, TIF_PATCH_PENDING);
554 struct task_struct *g, *task;
578 for_each_process_thread(g, task) {
579 WARN_ON_ONCE(task->patch_state != KLP_TRANSITION_IDLE);
580 task->patch_state = initial_state;
588 task = idle_task(cpu);
589 WARN_ON_ONCE(task->patch_state != KLP_TRANSITION_IDLE);
590 task->patch_state = initial_state;
594 * Enforce the order of the task->patch_state initializations and the
596 * see a func in transition with a task->patch_state of KLP_TRANSITION_IDLE.
600 * __klp_sched_try_switch() don't set a task->patch_state to
630 struct task_struct *g, *task;
643 for_each_process_thread(g, task)
644 clear_tsk_thread_flag(task, TIF_PATCH_PENDING);
668 * task->patch_state to the wrong value.
682 * the task flag up to date with the parent here.
701 * NOTE: klp_update_patch_state(task) requires the task to be inactive or
709 struct task_struct *g, *task;
715 for_each_process_thread(g, task)
716 klp_update_patch_state(task);