]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
bpf: Introduce task_vma bpf_iter
authorSong Liu <songliubraving@fb.com>
Fri, 12 Feb 2021 18:31:05 +0000 (10:31 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 12 Feb 2021 20:56:53 +0000 (12:56 -0800)
commit3a7b35b899dedd29468301a3cbc4fa48a49e2131
treed3881356d0f0c93e866b1fe062f899b6863fc370
parenta79e88dd2ca6686dca77c9c53c3e12c031347348
bpf: Introduce task_vma bpf_iter

Introduce task_vma bpf_iter to print memory information of a process. It
can be used to print customized information similar to /proc/<pid>/maps.

Current /proc/<pid>/maps and /proc/<pid>/smaps provide information of
vma's of a process. However, these information are not flexible enough to
cover all use cases. For example, if a vma cover mixed 2MB pages and 4kB
pages (x86_64), there is no easy way to tell which address ranges are
backed by 2MB pages. task_vma solves the problem by enabling the user to
generate customize information based on the vma (and vma->vm_mm,
vma->vm_file, etc.).

To access the vma safely in the BPF program, task_vma iterator holds
target mmap_lock while calling the BPF program. If the mmap_lock is
contended, task_vma unlocks mmap_lock between iterations to unblock the
writer(s). This lock contention avoidance mechanism is similar to the one
used in show_smaps_rollup().

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20210212183107.50963-2-songliubraving@fb.com
kernel/bpf/task_iter.c