1 // SPDX-License-Identifier: GPL-2.0
2 /* Copyright (c) 2022 Meta Platforms, Inc. and affiliates. */
4 #include <bpf/bpf_helpers.h>
6 char _license[] SEC("license") = "GPL";
8 __u32 unique_tgid_cnt = 0;
16 int get_vma_offset(struct bpf_iter__task_vma *ctx)
18 struct vm_area_struct *vma = ctx->vma;
19 struct seq_file *seq = ctx->meta->seq;
20 struct task_struct *task = ctx->task;
22 if (task == NULL || vma == NULL)
25 if (last_tgid != task->tgid)
27 last_tgid = task->tgid;
29 if (task->tgid != pid)
32 if (vma->vm_start <= address && vma->vm_end > address) {
33 offset = address - vma->vm_start + (vma->vm_pgoff << page_shift);
34 BPF_SEQ_PRINTF(seq, "OK\n");