12 #include <linux/err.h> 13 #include <linux/kernel.h> 26 if (sigsetjmp(
jmpbuf, 1)) {
27 pr_warning(
"Fatal error (SEGFAULT) in perf hook '%s'\n",
31 current_perf_hook =
desc;
34 current_perf_hook = NULL;
39 if (current_perf_hook)
43 #define PERF_HOOK(name) \ 44 perf_hook_func_t __perf_hook_func_##name = NULL; \ 45 struct perf_hook_desc __perf_hook_desc_##name = \ 46 {.hook_name = #name, \ 47 .p_hook_func = &__perf_hook_func_##name, \ 52 #define PERF_HOOK(name) \ 53 &__perf_hook_desc_##name, 66 for (i = 0; i < ARRAY_SIZE(perf_hooks); i++) {
67 if (strcmp(hook_name, perf_hooks[i]->hook_name) != 0)
71 pr_warning(
"Overwrite existing hook: %s\n", hook_name);
83 for (i = 0; i < ARRAY_SIZE(perf_hooks); i++) {
84 if (strcmp(hook_name, perf_hooks[i]->hook_name) != 0)
89 return ERR_PTR(-ENOENT);
void(* perf_hook_func_t)(void *ctx)
int perf_hooks__set_hook(const char *hook_name, perf_hook_func_t hook_func, void *hook_ctx)
perf_hook_func_t perf_hooks__get_hook(const char *hook_name)
void perf_hooks__invoke(const struct perf_hook_desc *desc)
const char *const hook_name
static struct perf_hook_desc * perf_hooks[]
static const struct perf_hook_desc * current_perf_hook
#define pr_warning(fmt,...)
void perf_hooks__recover(void)
perf_hook_func_t *const p_hook_func