From 25753e0396abea2534c4d0ac3051b2c29b5c36b1 Mon Sep 17 00:00:00 2001 From: Arnaldo Carvalho de Melo Date: Mon, 16 Nov 2020 08:15:23 -0300 Subject: [PATCH] pfunct: Use load stealer to speed up --class We were loading everything to then iterate looking for functions with pointers to the --class argument, do it in the stealer and go on ditching the already processed data, greatly speeding up the process. $ pfunct -c perf_event_attr security_perf_event_open register_user_hw_breakpoint modify_user_hw_breakpoint perf_event_create_kernel_counter register_wide_hw_breakpoint bpf_lsm_perf_event_open modify_user_hw_breakpoint_check perf_event_create_kernel_counter $ $ $ pfunct bpf_lsm_perf_event_open int bpf_lsm_perf_event_open(struct perf_event_attr * attr, int type); $ $ for function in `pfunct -c perf_event_attr` ; do pfunct $function ; done int security_perf_event_open(struct perf_event_attr * attr, int type); struct perf_event * register_user_hw_breakpoint(struct perf_event_attr * attr, perf_overflow_handler_t triggered, void * context, struct task_struct * tsk); int modify_user_hw_breakpoint(struct perf_event * bp, struct perf_event_attr * attr); struct perf_event * perf_event_create_kernel_counter(struct perf_event_attr * attr, int cpu, struct task_struct * task, perf_overflow_handler_t callback, void * context); struct perf_event * * register_wide_hw_breakpoint(struct perf_event_attr * attr, perf_overflow_handler_t triggered, void * context); int bpf_lsm_perf_event_open(struct perf_event_attr * attr, int type); int modify_user_hw_breakpoint_check(struct perf_event * bp, struct perf_event_attr * attr, bool check); struct perf_event * perf_event_create_kernel_counter(struct perf_event_attr * attr, int cpu, struct task_struct * task, perf_overflow_handler_t callback, void * context); $ Signed-off-by: Arnaldo Carvalho de Melo --- pfunct.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pfunct.c b/pfunct.c index 73ddd84..bc8e4ab 100644 --- a/pfunct.c +++ b/pfunct.c @@ -33,6 +33,7 @@ static bool expand_types; static bool compilable_output; static struct type_emissions emissions; static uint64_t addr; +static char *class_name; static char *function_name; static struct conf_fprintf conf; @@ -505,6 +506,8 @@ static enum load_steal_kind pfunct_stealer(struct cu *cu, struct conf_load *conf function__show(tag__function(tag), cu); return LSK__STOP_LOADING; } + } else if (class_name) { + cu_class_iterator(cu, class_name); } return LSK__DELETE; @@ -647,7 +650,6 @@ static const struct argp_option pfunct__options[] = { }; static void (*formatter)(const struct fn_stats *f) = fn_stats_fmtr; -static char *class_name; static int show_total_inline_expansion_stats; static error_t pfunct__options_parser(int key, char *arg, @@ -737,7 +739,7 @@ int main(int argc, char *argv[]) goto out_dwarves_exit; } - if (function_name) + if (function_name || class_name) conf_load.steal = pfunct_stealer; try_sole_arg_as_function_name: @@ -773,8 +775,6 @@ try_sole_arg_as_function_name: function__show(f, cu); } else if (show_total_inline_expansion_stats) print_total_inline_stats(); - else if (class_name != NULL) - cus__for_each_cu(cus, cu_class_iterator, class_name, NULL); else if (function_name != NULL || expand_types) cus__for_each_cu(cus, cu_function_iterator, function_name, NULL);