Skip to content

Commit

Permalink
mass_attacher: only log non-attachable kprobes if they pass globs
Browse files Browse the repository at this point in the history
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 <andrii@kernel.org>
  • Loading branch information
anakryiko committed Feb 14, 2024
1 parent 98dc2f6 commit 2d730d4
Showing 1 changed file with 20 additions and 6 deletions.
26 changes: 20 additions & 6 deletions src/mass_attacher.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 2d730d4

Please sign in to comment.