]> www.infradead.org Git - users/jedix/linux-maple.git/commit
perf probe: Fix retrieval of source files from a debuginfod server
authorArnaldo Carvalho de Melo <acme@kernel.org>
Mon, 28 Oct 2024 21:31:28 +0000 (18:31 -0300)
committerNamhyung Kim <namhyung@kernel.org>
Tue, 29 Oct 2024 23:36:39 +0000 (16:36 -0700)
commit54afc56db221c831479dd1b59eb0657c078355d1
treedd21d1ccbb08b65b6b643e144c03430b22ed361c
parent35f5aa9ccc83f4a4171cdb6ba023e514e2b2ecff
perf probe: Fix retrieval of source files from a debuginfod server

When perf is linked with libdebuginfod:

  root@number:~# ldd ~/bin/perf | grep debuginfod
libdebuginfod.so.1 => /lib64/libdebuginfod.so.1 (0x00007ff5c3930000)
  root@number:~# perf check feature debuginfod
            debuginfod: [ on  ]  # HAVE_DEBUGINFOD_SUPPORT
  root@number:~#

And we don't have a debuginfo package installed for the binary we're
trying to use, vmlinux in this case as we didn't specify any using 'perf
probe -x', it will use the build for the running kernel:

  root@number:~# perf buildid-list -k
  38e927fd7799d50dbc4d99ec5e3f781b6105a6a9
  root@number:~#

And communicate with a debuginfo server, be it configured in a
~/.perfconfig file, excerpt from the 'perf config' man page:

       buildid-cache.*
           buildid-cache.debuginfod=URLs Specify debuginfod URLs to be
   used when retrieving perf.data binaries, it follows the same
   syntax as the DEBUGINFOD_URLS variable, like:

               buildid-cache.debuginfod=http://192.168.122.174:8002

Or via the DEBUGINFOD_URLS env var, as distros like fedora do by
default:

  root@number:~# echo $DEBUGINFOD_URLS
  https://debuginfod.fedoraproject.org/
  root@number:~#

To pick and cache just what is needed, instead of requiring the manual
installation of the entire kernel-debuginfo package, which is really
large.

It will, in this example, use the following cache files, deleted
before/after this patch just to test the whole process:

  root@number:~# rm -f /root/.cache/debuginfod_client/38e927fd7799d50dbc4d99ec5e3f781b6105a6a9/source-a1414a5d-#usr#src#debug#kernel-6.11.4#linux-6.11.4-201.fc40.x86_64#net#ipv4#icmp.c
  root@number:~# rm -f /root/.cache/debuginfod_client/38e927fd7799d50dbc4d99ec5e3f781b6105a6a9/debuginfo

Before this patch:

  root@number:~# perf probe -L icmp_rcv
  Failed to find source file path.
    Error: Failed to show lines.
  root@number:~#

This is because 'perf probe' was using just the relative file name, in
this case "net/ipv4/icmp.c", that is where the 'icmp_rcv' function is
located, if we add it and comply with the debuginfo_find_source()
function man page, it contacts the server, finds the necessary files,
cache them locally and all works:

  root@number:~# perf probe -L icmp_rcv | head
  <icmp_rcv@/root/.cache/debuginfod_client/38e927fd7799d50dbc4d99ec5e3f781b6105a6a9/source-a1414a5d-#usr#src#debug#kernel-6.11.4#linux-6.11.4-201.fc40.x86_64#net#ipv4#icmp.c:0>
        0  int icmp_rcv(struct sk_buff *skb)
           {
        2   enum skb_drop_reason reason = SKB_DROP_REASON_NOT_SPECIFIED;
            struct rtable *rt = skb_rtable(skb);
            struct net *net = dev_net(rt->dst.dev);
            struct icmphdr *icmph;

            if (!xfrm4_policy_check(NULL, XFRM_POLICY_IN, skb)) {
        8   struct sec_path *sp = skb_sec_path(skb);
  root@number:~#

Acked-by: Frank Ch. Eigler <fche@redhat.com>
Cc: Aaron Merey <amerey@redhat.com>
Cc: Francesco Nigro <fnigro@redhat.com>
Cc: Masami Hiramatsu <mhiramat@kernel.org>
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Link: https://lore.kernel.org/r/ZyACsIFUETsr7-09@x1
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/probe-finder.c