Skip to content

Commit 8008aab

Browse files
committed
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>
1 parent 382b55d commit 8008aab

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// SPDX-License-Identifier: LGPL-2.1
2+
3+
#ifndef _PERF_BPF_PID_FILTER_
4+
#define _PERF_BPF_PID_FILTER_
5+
6+
#include <bpf.h>
7+
8+
#define pid_filter(name) pid_map(name, bool)
9+
10+
static int pid_filter__add(struct bpf_map *pids, pid_t pid)
11+
{
12+
bool value = true;
13+
return bpf_map_update_elem(pids, &pid, &value, BPF_NOEXIST);
14+
}
15+
16+
static bool pid_filter__has(struct bpf_map *pids, pid_t pid)
17+
{
18+
return bpf_map_lookup_elem(pids, &pid) != NULL;
19+
}
20+
21+
#endif // _PERF_BPF_PID_FILTER_

0 commit comments

Comments
 (0)