-
Notifications
You must be signed in to change notification settings - Fork 386
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tetragon: Use do_task_dead probe for exit sensor
Hooking on do_task_dead kernel function, which is the last one the task would execute after exiting. It's stable since v4.19, so it's safe to hook for us. To find out if we are the last thread of execution in the task we use current->signal->live counter (thanks Djalal! ;-) ) It's initialized for thread leader: clone { copy_process copy_signal atomic_set(&sig->live, 1); } Incremented for each new thread: clone { copy_process atomic_inc(¤t->signal->live); ... wake_up_new_task } Decremented for each exiting thread: do_exit { atomic_dec_and_test(&tsk->signal->live); ... do_task_dead __schedule BUG } If task->signal->live == 0 we are the last thread of execution and we won't race with another clone, because there's no other thread to call it (current thread is in do_exit). Signed-off-by: Jiri Olsa <[email protected]>
- Loading branch information
Showing
5 changed files
with
54 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters