-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf util: Move bpf_perf definitions to a libperf header
By following the same protocol, other tools can share hardware PMCs with perf. Move perf_event_attr_map_entry and BPF_PERF_DEFAULT_ATTR_MAP_PATH to bpf_perf.h for other tools to use. Signed-off-by: Song Liu <song@kernel.org> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Cc: Song Liu <songliubraving@fb.com> Cc: kernel-team@fb.com Link: https://lore.kernel.org/r/20210425214333.1090950-2-song@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
- Loading branch information
Song Liu
authored and
Arnaldo Carvalho de Melo
committed
Apr 29, 2021
1 parent
26bda3c
commit ec8149f
Showing
2 changed files
with
34 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) */ | ||
#ifndef __LIBPERF_BPF_PERF_H | ||
#define __LIBPERF_BPF_PERF_H | ||
|
||
#include <linux/types.h> /* for __u32 */ | ||
|
||
/* | ||
* bpf_perf uses a hashmap, the attr_map, to track all the leader programs. | ||
* The hashmap is pinned in bpffs. flock() on this file is used to ensure | ||
* no concurrent access to the attr_map. The key of attr_map is struct | ||
* perf_event_attr, and the value is struct perf_event_attr_map_entry. | ||
* | ||
* struct perf_event_attr_map_entry contains two __u32 IDs, bpf_link of the | ||
* leader prog, and the diff_map. Each perf-stat session holds a reference | ||
* to the bpf_link to make sure the leader prog is attached to sched_switch | ||
* tracepoint. | ||
* | ||
* Since the hashmap only contains IDs of the bpf_link and diff_map, it | ||
* does not hold any references to the leader program. Once all perf-stat | ||
* sessions of these events exit, the leader prog, its maps, and the | ||
* perf_events will be freed. | ||
*/ | ||
struct perf_event_attr_map_entry { | ||
__u32 link_id; | ||
__u32 diff_map_id; | ||
}; | ||
|
||
/* default attr_map name */ | ||
#define BPF_PERF_DEFAULT_ATTR_MAP_PATH "perf_attr_map" | ||
|
||
#endif /* __LIBPERF_BPF_PERF_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters