Song Liu 7c7e3d31e7 bpf: Introduce helper bpf_find_vma
In some profiler use cases, it is necessary to map an address to the
backing file, e.g., a shared library. bpf_find_vma helper provides a
flexible way to achieve this. bpf_find_vma maps an address of a task to
the vma (vm_area_struct) for this address, and feed the vma to an callback
BPF function. The callback function is necessary here, as we need to
ensure mmap_sem is unlocked.

It is necessary to lock mmap_sem for find_vma. To lock and unlock mmap_sem
safely when irqs are disable, we use the same mechanism as stackmap with
build_id. Specifically, when irqs are disabled, the unlocked is postponed
in an irq_work. Refactor stackmap.c so that the irq_work is shared among
bpf_find_vma and stackmap helpers.

Signed-off-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Tested-by: Hengqi Chen <hengqi.chen@gmail.com>
Acked-by: Yonghong Song <yhs@fb.com>
Link: https://lore.kernel.org/bpf/20211105232330.1936330-2-songliubraving@fb.com
2021-11-07 11:54:51 -08:00
..
2021-11-07 11:54:51 -08:00
2021-09-07 12:08:04 -07:00
2021-11-01 16:33:53 -07:00
2021-11-02 06:20:58 -07:00
2021-10-19 17:27:05 +02:00
2021-10-29 11:58:35 +02:00
2021-09-02 13:00:15 -07:00
2021-11-01 20:05:19 -07:00
2021-11-01 20:25:38 -07:00
2021-11-01 20:25:38 -07:00
2021-11-07 11:54:51 -08:00
2021-11-01 21:17:39 -07:00
2021-11-01 21:17:39 -07:00
2021-11-01 21:17:39 -07:00
2021-08-11 13:11:12 -07:00
2021-09-08 15:32:35 -07:00
2021-11-01 13:48:52 -07:00
2021-11-01 13:48:52 -07:00
2021-06-18 11:43:08 +02:00
2021-09-08 15:32:34 -07:00
2021-05-07 00:26:33 -07:00
2021-11-01 20:05:19 -07:00
2021-11-01 20:05:19 -07:00
2021-06-18 11:43:09 +02:00
2021-11-01 14:03:56 -07:00
2021-10-07 13:51:11 +02:00
2021-05-07 00:26:34 -07:00