1 #include "vmlinux.h" 2 3 #include <bpf/bpf_helpers.h> 4 #include <bpf/bpf_core_read.h> 5 6 struct index_pid_pair { 7 uint32_t i; 8 pid_t pid; 9 }; 10 11 static uint32_t i = 0; 12 13 SEC("iter/task") dump_pid(struct bpf_iter__task * ctx)14int dump_pid(struct bpf_iter__task *ctx) 15 { 16 struct seq_file *seq = ctx->meta->seq; 17 struct task_struct *task = ctx->task; 18 struct index_pid_pair p; 19 20 if (!task) 21 return 0; 22 23 p.i = i++; 24 p.pid = task->tgid; 25 26 bpf_seq_write(seq, &p, sizeof(p)); 27 return 0; 28 } 29 30 char _license[] SEC("license") = "GPL"; 31 32