Lines Matching full:task
94 struct task_struct *g, *task; in klp_complete_transition() local
131 for_each_process_thread(g, task) { in klp_complete_transition()
132 WARN_ON_ONCE(test_tsk_thread_flag(task, TIF_PATCH_PENDING)); in klp_complete_transition()
133 task->patch_state = KLP_TRANSITION_IDLE; in klp_complete_transition()
138 task = idle_task(cpu); in klp_complete_transition()
139 WARN_ON_ONCE(test_tsk_thread_flag(task, TIF_PATCH_PENDING)); in klp_complete_transition()
140 task->patch_state = KLP_TRANSITION_IDLE; in klp_complete_transition()
178 * Switch the patched state of the task to the set of functions in the target
181 * NOTE: If task is not 'current', the caller must ensure the task is inactive.
184 void klp_update_patch_state(struct task_struct *task) in klp_update_patch_state() argument
204 if (test_and_clear_tsk_thread_flag(task, TIF_PATCH_PENDING)) in klp_update_patch_state()
205 task->patch_state = READ_ONCE(klp_target_state); in klp_update_patch_state()
260 * Determine whether it's safe to transition the task to the target patch state
263 static int klp_check_stack(struct task_struct *task, const char **oldname) in klp_check_stack() argument
273 ret = stack_trace_save_tsk_reliable(task, entries, MAX_STACK_ENTRIES); in klp_check_stack()
293 static int klp_check_and_switch_task(struct task_struct *task, void *arg) in klp_check_and_switch_task() argument
297 if (task_curr(task) && task != current) in klp_check_and_switch_task()
300 ret = klp_check_stack(task, arg); in klp_check_and_switch_task()
304 clear_tsk_thread_flag(task, TIF_PATCH_PENDING); in klp_check_and_switch_task()
305 task->patch_state = klp_target_state; in klp_check_and_switch_task()
310 * Try to safely switch a task to the target patch state. If it's currently
314 static bool klp_try_switch_task(struct task_struct *task) in klp_try_switch_task() argument
319 /* check if this task has already switched over */ in klp_try_switch_task()
320 if (task->patch_state == klp_target_state) in klp_try_switch_task()
332 * functions. If all goes well, switch the task to the target patch in klp_try_switch_task()
335 if (task == current) in klp_try_switch_task()
338 ret = task_call_func(task, klp_check_and_switch_task, &old_name); in klp_try_switch_task()
346 __func__, task->comm, task->pid); in klp_try_switch_task()
350 __func__, task->comm, task->pid); in klp_try_switch_task()
354 __func__, task->comm, task->pid, old_name); in klp_try_switch_task()
359 __func__, ret, task->comm, task->pid); in klp_try_switch_task()
378 * able to switch this task while it's running. in __klp_sched_try_switch()
410 struct task_struct *g, *task; in klp_send_signals() local
416 for_each_process_thread(g, task) { in klp_send_signals()
417 if (!klp_patch_pending(task)) in klp_send_signals()
423 * Meanwhile the task could migrate itself and the action in klp_send_signals()
426 if (task->flags & PF_KTHREAD) { in klp_send_signals()
431 wake_up_state(task, TASK_INTERRUPTIBLE); in klp_send_signals()
437 set_notify_signal(task); in klp_send_signals()
446 * to-be-unpatched functions. If such functions are found, the task can't be
454 struct task_struct *g, *task; in klp_try_complete_transition() local
464 * is deemed unreliable, the task can't be switched yet. in klp_try_complete_transition()
470 for_each_process_thread(g, task) in klp_try_complete_transition()
471 if (!klp_try_switch_task(task)) in klp_try_complete_transition()
480 task = idle_task(cpu); in klp_try_complete_transition()
482 if (!klp_try_switch_task(task)) { in klp_try_complete_transition()
484 /* Make idle task go through the main loop. */ in klp_try_complete_transition()
487 } else if (task->patch_state != klp_target_state) { in klp_try_complete_transition()
489 clear_tsk_thread_flag(task, TIF_PATCH_PENDING); in klp_try_complete_transition()
490 task->patch_state = klp_target_state; in klp_try_complete_transition()
532 struct task_struct *g, *task; in klp_start_transition() local
547 for_each_process_thread(g, task) in klp_start_transition()
548 if (task->patch_state != klp_target_state) in klp_start_transition()
549 set_tsk_thread_flag(task, TIF_PATCH_PENDING); in klp_start_transition()
558 task = idle_task(cpu); in klp_start_transition()
559 if (task->patch_state != klp_target_state) in klp_start_transition()
560 set_tsk_thread_flag(task, TIF_PATCH_PENDING); in klp_start_transition()
575 struct task_struct *g, *task; in klp_init_transition() local
599 for_each_process_thread(g, task) { in klp_init_transition()
600 WARN_ON_ONCE(task->patch_state != KLP_TRANSITION_IDLE); in klp_init_transition()
601 task->patch_state = initial_state; in klp_init_transition()
609 task = idle_task(cpu); in klp_init_transition()
610 WARN_ON_ONCE(task->patch_state != KLP_TRANSITION_IDLE); in klp_init_transition()
611 task->patch_state = initial_state; in klp_init_transition()
615 * Enforce the order of the task->patch_state initializations and the in klp_init_transition()
617 * see a func in transition with a task->patch_state of KLP_TRANSITION_IDLE. in klp_init_transition()
621 * __klp_sched_try_switch() don't set a task->patch_state to in klp_init_transition()
651 struct task_struct *g, *task; in klp_reverse_transition() local
664 for_each_process_thread(g, task) in klp_reverse_transition()
665 clear_tsk_thread_flag(task, TIF_PATCH_PENDING); in klp_reverse_transition()
689 * task->patch_state to the wrong value. in klp_reverse_transition()
703 * the task flag up to date with the parent here. in klp_copy_process()
722 * NOTE: klp_update_patch_state(task) requires the task to be inactive or
730 struct task_struct *g, *task; in klp_force_transition() local
736 for_each_process_thread(g, task) in klp_force_transition()
737 klp_update_patch_state(task); in klp_force_transition()