Re: [RFC bpf-next 4/4] selftests/bpf: Add attach bench test

From: Steven Rostedt
Date: Thu Apr 28 2022 - 20:32:03 EST


On Thu, 28 Apr 2022 20:09:45 -0400
Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:

> OK, I think I see the issue you have. Because the functions shown in
> available_filter_functions which uses the simple "%ps" to show the function
> name:
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/trace/ftrace.c#n3692
>
> And the code that does the actual matching uses kallsyms_lookup()
>
> https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/kernel/trace/ftrace.c#n4017
>
> Which appears not to match the function for the address, you can't pass in
> __bpf_tramp_exit because it wont match the symbol returned by
> kallsyms_lookup.

Never mind, in testing this I had marked the weak function as notrace,
which was the reason I couldn't add it to the set_ftrace_notrace.

After removing the notrace, kallsyms_lookup() doesn't make a difference. It
appears that kallsyms will include overridden weak functions into the size
of the function before it. I tried:

ret = kallsyms_lookup(rec->ip, &size, &offset, &modname, str);
if (!ret || offset > size) {
seq_printf(m, "no function at %lx", rec->ip);
} else {
seq_printf(m, "%s", str);
if (modname)
seq_printf(m, " [%s]", modname);
}

And it made no difference.

>
> This does indeed look like a bug in %ps.
>

Yes, this does appear to be a issue with kallsyms in general.

-- Steve