1 // SPDX-License-Identifier: GPL-2.0
5 #include <bpf/bpf_helpers.h>
6 #include <bpf/bpf_tracing.h>
8 #include "bpf_experimental.h"
10 char _license[] SEC("license") = "GPL";
13 int procs_cnt, threads_cnt, proc_threads_cnt, invalid_cnt;
15 void bpf_rcu_read_lock(void) __ksym;
16 void bpf_rcu_read_unlock(void) __ksym;
18 SEC("fentry.s/" SYS_PREFIX "sys_getpgid")
19 int iter_task_for_each_sleep(void *ctx)
21 struct task_struct *cur_task = bpf_get_current_task_btf();
22 struct task_struct *pos;
24 if (cur_task->pid != target_pid)
26 procs_cnt = threads_cnt = proc_threads_cnt = 0;
29 bpf_for_each(task, pos, NULL, ~0U) {
30 /* Below instructions shouldn't be executed for invalid flags */
34 bpf_for_each(task, pos, NULL, BPF_TASK_ITER_PROC_THREADS) {
35 /* Below instructions shouldn't be executed for invalid task__nullable */
39 bpf_for_each(task, pos, NULL, BPF_TASK_ITER_ALL_PROCS)
40 if (pos->pid == target_pid)
43 bpf_for_each(task, pos, cur_task, BPF_TASK_ITER_PROC_THREADS)
46 bpf_for_each(task, pos, NULL, BPF_TASK_ITER_ALL_THREADS)
47 if (pos->tgid == target_pid)
49 bpf_rcu_read_unlock();