mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 13:31:02 +07:00
perf bpf: Add simple pid_filter class accessible to BPF proggies
Will be used in the augmented_raw_syscalls.c to implement 'perf trace --filter-pids'. Cc: Adrian Hunter <adrian.hunter@intel.com> Cc: David Ahern <dsahern@gmail.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Wang Nan <wangnan0@huawei.com> Link: https://lkml.kernel.org/n/tip-9sybmz4vchlbpqwx2am13h9e@git.kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
382b55dbef
commit
8008aab096
21
tools/perf/include/bpf/pid_filter.h
Normal file
21
tools/perf/include/bpf/pid_filter.h
Normal file
@ -0,0 +1,21 @@
|
||||
// SPDX-License-Identifier: LGPL-2.1
|
||||
|
||||
#ifndef _PERF_BPF_PID_FILTER_
|
||||
#define _PERF_BPF_PID_FILTER_
|
||||
|
||||
#include <bpf.h>
|
||||
|
||||
#define pid_filter(name) pid_map(name, bool)
|
||||
|
||||
static int pid_filter__add(struct bpf_map *pids, pid_t pid)
|
||||
{
|
||||
bool value = true;
|
||||
return bpf_map_update_elem(pids, &pid, &value, BPF_NOEXIST);
|
||||
}
|
||||
|
||||
static bool pid_filter__has(struct bpf_map *pids, pid_t pid)
|
||||
{
|
||||
return bpf_map_lookup_elem(pids, &pid) != NULL;
|
||||
}
|
||||
|
||||
#endif // _PERF_BPF_PID_FILTER_
|
Loading…
Reference in New Issue
Block a user