From 2d730d468719ed35d0f3bc2dbc958bd90f31342e Mon Sep 17 00:00:00 2001 From: Andrii Nakryiko Date: Wed, 14 Feb 2024 14:40:07 -0800 Subject: [PATCH] mass_attacher: only log non-attachable kprobes if they pass globs Instead of logging every BTF FUNC record that doesn't match globs *or* doesn't have a corresponding attachable kprobes, filter out all the records that don't satisfy globs first, so that we can log high signal message about functions that are not attachable, but were requested by user through globs. Signed-off-by: Andrii Nakryiko --- src/mass_attacher.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/src/mass_attacher.c b/src/mass_attacher.c index 60363b1..5fcb779 100644 --- a/src/mass_attacher.c +++ b/src/mass_attacher.c @@ -397,14 +397,20 @@ int mass_attacher__prepare(struct mass_attacher *att) if (!btf_is_func(t)) continue; - /* check if we already processed a function with such name */ + /* skip BTF function if it doesn't match globs */ func_name = btf__str_by_offset(att->vmlinux_btf, t->name_off); + if (!glob_set__match(&att->globs, func_name, NULL, NULL)) + continue; + + /* check if we have a matching attachable kprobe */ kp = find_kprobe(att, func_name, NULL); if (!kp) { - if (att->debug_extra) - printf("Function '%s' is not attachable kprobe, skipping.\n", func_name); + if (att->verbose) + printf("Function '%s' is not an attachable kprobe, skipping.\n", func_name); continue; } + + /* we might have already processed it, skip if so */ if (kp->used) continue; @@ -456,15 +462,23 @@ int mass_attacher__prepare(struct mass_attacher *att) if (!btf_is_func(t)) continue; - /* check if we already processed a function with such name */ + /* skip BTF function if it doesn't match globs */ func_name = btf__str_by_offset(btf, t->name_off); + if (!glob_set__match(&att->globs, func_name, mod, NULL)) + continue; + + /* check if we have a matching attachable kprobe */ kp = find_kprobe(att, func_name, mod); if (!kp) { - if (att->debug_extra) - printf("Function '%s [%s]' is not attachable kprobe, skipping.\n", func_name, mod); + if (att->verbose) + printf("Function '%s [%s]' is not an attachable kprobe, skipping.\n", func_name, mod); continue; } + /* we might have already processed it, skip if so */ + if (kp->used) + continue; + err = prepare_func(att, kp, btf, j); if (err) return err;