Add perf_type_uprobe() to get the perf_type of uprobe and perf_type_kprobe() to get the perf_type of kprobe. Signed-off-by: Yafang Shao <laoar.shao@xxxxxxxxx> --- include/linux/perf_event.h | 3 +++ kernel/events/core.c | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h index d5628a7..79dbc70 100644 --- a/include/linux/perf_event.h +++ b/include/linux/perf_event.h @@ -1881,4 +1881,7 @@ static inline void perf_lopwr_cb(bool mode) } #endif +int perf_type_kprobe(void); +int perf_type_uprobe(void); + #endif /* _LINUX_PERF_EVENT_H */ diff --git a/kernel/events/core.c b/kernel/events/core.c index db016e4..075d4fb 100644 --- a/kernel/events/core.c +++ b/kernel/events/core.c @@ -10456,6 +10456,24 @@ static inline bool perf_event_is_tracing(struct perf_event *event) return false; } +int perf_type_kprobe(void) +{ +#ifdef CONFIG_KPROBE_EVENTS + return perf_kprobe.type; +#else + return -EOPNOTSUPP; +#endif +} + +int perf_type_uprobe(void) +{ +#ifdef CONFIG_UPROBE_EVENTS + return perf_uprobe.type; +#else + return -EOPNOTSUPP; +#endif +} + int perf_event_set_bpf_prog(struct perf_event *event, struct bpf_prog *prog, u64 bpf_cookie) { -- 1.8.3.1