hc
2024-03-26 e9199a72d842cbda78ac614eee5db7cdaa6f2530
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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_