/* The program is only used for PID or TGID filter types. */
SEC("tp_btf/task_newtask") int BPF_PROG(on_newtask, struct task_struct *task, __u64 clone_flags)
{
__u32 parent_key, child_key; struct bperf_filter_value *parent_fval; struct bperf_filter_value child_fval = { 0 };
/* Check if the current task is one of the target tasks to be counted */
parent_fval = bpf_map_lookup_elem(&filter, &parent_key); if (!parent_fval) return0;
/* Start counting for the new task by adding it into filter map, *inherittheaccumkeyofitsparenttasksothattheycanbe *countedtogether.
*/
child_fval.accum_key = parent_fval->accum_key;
child_fval.exited = 0;
bpf_map_update_elem(&filter, &child_key, &child_fval, BPF_NOEXIST);
return0;
}
/* The program is only used for PID or TGID filter types. */
SEC("tp_btf/sched_process_exit") int BPF_PROG(on_exittask, struct task_struct *task)
{
__u32 pid; struct bperf_filter_value *fval;
if (!enabled) return0;
/* Stop counting for this task by removing it from filter map. *ForTGIDtype,ifthepidcanbefoundinthemap,itmeansthat *thispidbelongstotheleadertask.Afterthetaskexits,the *tgidofitschildtasks(ifany)willbe1,sothepidcanbe *safelyremoved.
*/
pid = task->pid;
fval = bpf_map_lookup_elem(&filter, &pid); if (fval)
fval->exited = 1;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.