public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@kernel.org>
To: Namhyung Kim <namhyung@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>, lkml <linux-kernel@vger.kernel.org>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ingo Molnar <mingo@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Michael Petlan <mpetlan@redhat.com>,
	Song Liu <songliubraving@fb.com>,
	"Frank Ch. Eigler" <fche@redhat.com>,
	Ian Rogers <irogers@google.com>,
	Stephane Eranian <eranian@google.com>,
	Alexey Budankov <alexey.budankov@linux.intel.com>,
	Andi Kleen <ak@linux.intel.com>,
	Adrian Hunter <adrian.hunter@intel.com>
Subject: Re: [PATCH 24/26] perf tools: Add buildid-list --store option
Date: Mon, 14 Sep 2020 12:14:13 -0300	[thread overview]
Message-ID: <20200914151413.GB160517@kernel.org> (raw)
In-Reply-To: <CAM9d7ch5Od3Pz6GORmkW6RfUQL6ON0DVJ+dndA9mGCv6ppLsbA@mail.gmail.com>

Em Mon, Sep 14, 2020 at 03:42:55PM +0900, Namhyung Kim escreveu:
> On Mon, Sep 14, 2020 at 6:05 AM Jiri Olsa <jolsa@kernel.org> wrote:
> >
> > Adding buildid-list --store option to populate
> > .debug data with build id files.
> 
> Hmm.. isn't it better to add it to the buildid-cache command?

Yes, that is the right place. 'buildid-list' is about perf.data files,
buildid-cache is about .debug cache.

- Arnaldo
 
> >
> >   $ rm -rf ~/.debug/
> >
> >   $ perf buildid-list
> >   1805c738c8f3ec0f47b7ea09080c28f34d18a82b /usr/lib64/ld-2.31.so
> >   d278249792061c6b74d1693ca59513be1def13f2 /usr/lib64/libc-2.31.so
> >
> >   $ perf buildid-list --store
> >
> >   $ find ~/.debug/
> >   .../.debug/
> >   .../.debug/usr
> >   .../.debug/usr/lib64
> >   .../.debug/usr/lib64/ld-2.31.so
> >   .../.debug/usr/lib64/ld-2.31.so/1805c738c8f3ec0f47b7ea09080c28f34d18a82b
> >   .../.debug/usr/lib64/ld-2.31.so/1805c738c8f3ec0f47b7ea09080c28f34d18a82b/elf
> >   .../.debug/usr/lib64/ld-2.31.so/1805c738c8f3ec0f47b7ea09080c28f34d18a82b/debug
> >   .../.debug/usr/lib64/ld-2.31.so/1805c738c8f3ec0f47b7ea09080c28f34d18a82b/probes
> >   .../.debug/usr/lib64/libc-2.31.so
> >   .../.debug/usr/lib64/libc-2.31.so/d278249792061c6b74d1693ca59513be1def13f2
> >   .../.debug/usr/lib64/libc-2.31.so/d278249792061c6b74d1693ca59513be1def13f2/elf
> >   .../.debug/usr/lib64/libc-2.31.so/d278249792061c6b74d1693ca59513be1def13f2/debug
> >   .../.debug/usr/lib64/libc-2.31.so/d278249792061c6b74d1693ca59513be1def13f2/probes
> >   .../.debug/.build-id
> >   .../.debug/.build-id/18
> >   .../.debug/.build-id/18/05c738c8f3ec0f47b7ea09080c28f34d18a82b
> >   .../.debug/.build-id/d2
> >   .../.debug/.build-id/d2/78249792061c6b74d1693ca59513be1def13f2
> >
> > It's possible to query debuginfod daemon for binaries by defining
> > DEBUGINFOD_URLS variable with server URL, like:
> >
> >   $ DEBUGINFOD_URLS=http://192.168.122.174:8002 perf buildid-list --store
> >   OK   439fe9bdeaed66af2bb8b8de5e650d5ecc3d8d46 .../.debug/.build-id/43/9fe9bdeaed66af2bb8b8de5e650d5ecc3d8d46/elf
> >   FAIL 23b87f5b0560481043257e82be670bc97786a171 /lib/modules/5.9.0-0.rc3.1.mmap3.fc34.x86_64/kernel/net/ipv4/netfilter/ip_tables.ko.xz
> >   FAIL d2b3be372bcdd4ebc15e479d2ff803657de0fd1e /lib/modules/5.9.0-0.rc3.1.mmap3.fc34.x86_64/kernel/drivers/block/virtio_blk.ko.xz
> >   FAIL 1466a71bcd0ff5c975ee79b72752137c0143d225 /lib/modules/5.9.0-0.rc3.1.mmap3.fc34.x86_64/kernel/fs/xfs/xfs.ko.xz
> >   OK   ad60d10b38c93bd8738d5aa594e240f01bb328cd /usr/lib/systemd/systemd
> >   OK   589e403a34f55486bcac848a45e00bcdeedd1ca8 /usr/lib64/libcrypto.so.1.1.1g
> >   OK   3b9b2ef537520303411ad5038b596d5d18e7c2b8 /usr/lib64/libpcre2-8.so.0.10.0
> >
> > Increasing debug level in util/probe-event.c to get rid
> > of the sdt probes messages on single verbose level (-v).
> >
> > Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> > ---
> [SNIP]
> > +static int dso__store(struct dso *dso, struct machine *machine __maybe_unused, void *priv)
> > +{
> > +       struct dso_store_data *data = priv;
> > +       char sbuild_id[SBUILD_ID_SIZE];
> > +       u8 bid[BUILD_ID_SIZE];
> > +       char *path = NULL;
> > +       bool is_kallsyms;
> > +       int err = -1;
> > +
> > +       if (!dso->has_build_id ||
> > +           !build_id__is_defined(dso->build_id))
> > +               return 0;
> > +
> > +       if (data->with_hits && !dso->hit)
> > +               return 0;
> > +
> > +       /*
> > +        * The storing process is:
> > +        *   - get build id of the dso
> > +        *   - check if it matches provided build id from mmap3 event
> > +        *   - if not, try debuginfod to download the binary
> > +        *   - store binary to build id database
> > +        */
> > +       is_kallsyms = !strcmp(machine->mmap_name, dso->short_name);
> > +       build_id__sprintf(dso->build_id, sizeof(dso->build_id), sbuild_id);
> > +
> > +       if (is_kallsyms) {
> > +               /*
> > +                * Find out if we are on the same kernel as perf.data
> > +                * and keel kallsyms in that case.
> > +                */
> > +               path = strdup(dso->long_name);
> > +               if (!path)
> > +                       goto out_err;
> > +
> > +               err = sysfs__read_build_id("/sys/kernel/notes", &bid, sizeof(bid));
> > +               if (err < 0)
> > +                       goto out_err;
> > +       } else {
> > +               struct stat st;
> > +
> > +               /*
> > +                * Does the file exists in the first place, if it does,
> > +                * resolve path and read the build id.
> > +                */
> > +               if (stat(dso->long_name, &st)) {
> > +                       zfree(&path);
> > +                       goto try_download;
> > +               }
> > +
> > +               path = nsinfo__realpath(dso->long_name, dso->nsinfo);
> > +               if (!path)
> > +                       goto out_err;
> > +
> > +               err = filename__read_build_id(path, &bid, sizeof(bid));
> 
> Is it ok to read the file out of the namespace?
> 
> Thanks
> Namhyung
> 
> 
> > +               if (err != sizeof(bid))
> > +                       goto out_err;
> > +       }
> > +
> > +       /*
> > +        * If we match then we want in mmap3 event,
> > +        * is what we got in the binary, so we're happy.
> > +        */
> > +       if (memcmp(&bid, dso->build_id, BUILD_ID_SIZE)) {
> > +               char sbid[SBUILD_ID_SIZE];
> > +
> > +               build_id__sprintf(bid, sizeof(bid), sbid);
> > +               pr_debug("mmap build id <%s> does not match for %s <%s>\n",
> > +                        sbuild_id, path, sbid);
> > +               zfree(&path);
> > +       }
> > +
> > +try_download:
> > +       /*
> > +        * We did not match build id or did not find the
> > +        * binary - try debuginfod as last resort.
> > +        */
> > +       if (!path) {
> > +               char *tmp = NULL;
> > +
> > +               /*
> > +                * The debuginfo retrieval is handled within
> > +                * build_id_cache__add function.
> > +                */
> > +               if (get_executable(sbuild_id, &tmp)) {
> > +                       err = -1;
> > +                       goto out_err;
> > +               }
> > +
> > +               path = tmp;
> > +
> > +               /*
> > +                * The kernel dso is now elf binary, so disable is_kallsyms
> > +                * so build_id_cache__add can prepare proper file names.
> > +                */
> > +               is_kallsyms = false;
> > +       }
> > +
> > +       pr_debug("linking %s %s <%s>\n", dso->short_name, path, sbuild_id);
> > +
> > +       err = build_id_cache__add(sbuild_id, path, path,
> > +                                 dso->nsinfo, is_kallsyms, false);
> > +out_err:
> > +       free(path);
> > +       fprintf(stderr, "%s %s %s\n", err ? "FAIL" : "OK  ", sbuild_id, dso->long_name);
> > +       return 0;
> > +}

-- 

- Arnaldo

  reply	other threads:[~2020-09-14 15:15 UTC|newest]

Thread overview: 93+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-13 21:02 [RFC 00/26] perf: Add mmap3 support Jiri Olsa
2020-09-13 21:02 ` [PATCH 01/26] bpf: Move stack_map_get_build_id into lib Jiri Olsa
2020-09-14  6:09   ` Song Liu
2020-09-13 21:02 ` [PATCH 02/26] perf: Introduce mmap3 version of mmap event Jiri Olsa
2020-09-14  5:38   ` Namhyung Kim
2020-09-14  6:20     ` Song Liu
2020-09-14 19:38       ` Jiri Olsa
2020-09-14 15:28     ` Arnaldo Carvalho de Melo
2020-09-14 16:35       ` peterz
2020-09-14 17:08         ` Ian Rogers
2020-09-14 20:07           ` Jiri Olsa
2020-09-15  5:49             ` Adrian Hunter
2020-09-14 19:38         ` Jiri Olsa
2020-09-14 19:39       ` Jiri Olsa
2020-09-14 22:00         ` Arnaldo Carvalho de Melo
2020-09-15  5:39           ` Adrian Hunter
2020-09-14 19:38     ` Jiri Olsa
2020-09-15  2:54       ` Namhyung Kim
2020-09-14  6:41   ` Stephane Eranian
2020-09-14  9:08     ` peterz
2020-09-14 15:32       ` Arnaldo Carvalho de Melo
2020-09-14 17:26       ` Stephane Eranian
2020-09-14 19:56         ` Jiri Olsa
2020-09-15  0:03         ` Ian Rogers
2020-09-14 15:31     ` Arnaldo Carvalho de Melo
2020-09-14 19:50       ` Jiri Olsa
2020-09-14 22:38         ` Arnaldo Carvalho de Melo
2020-09-14 19:45     ` Jiri Olsa
2020-09-14  9:36   ` peterz
2020-09-13 21:02 ` [PATCH 03/26] tools headers uapi: Sync tools/include/uapi/linux/perf_event.h Jiri Olsa
2020-09-14  5:39   ` Namhyung Kim
2020-09-13 21:02 ` [PATCH 04/26] perf tools: Add filename__decompress function Jiri Olsa
2020-09-14 15:35   ` Arnaldo Carvalho de Melo
2020-09-14 20:43     ` Jiri Olsa
2020-09-17 18:54       ` Arnaldo Carvalho de Melo
2020-09-18 10:51         ` Jiri Olsa
2020-09-13 21:02 ` [PATCH 05/26] perf tools: Add build_id__is_defined function Jiri Olsa
2020-09-14  5:44   ` Namhyung Kim
2020-09-14 16:03     ` Arnaldo Carvalho de Melo
2020-09-14 20:49       ` Jiri Olsa
2020-09-14 20:47     ` Jiri Olsa
2020-09-14 21:51       ` Arnaldo Carvalho de Melo
2020-09-13 21:02 ` [PATCH 06/26] perf tools: Add support to read build id from compressed elf Jiri Olsa
2020-09-14 16:04   ` Arnaldo Carvalho de Melo
2020-09-14 20:49     ` Jiri Olsa
2020-09-13 21:02 ` [PATCH 07/26] perf tools: Add check for existing link in buildid dir Jiri Olsa
2020-09-14  5:54   ` Namhyung Kim
2020-09-14 20:18     ` Jiri Olsa
2020-09-13 21:02 ` [PATCH 08/26] perf tools: Use struct extra_kernel_map in machine__process_kernel_mmap_event Jiri Olsa
2020-09-13 21:02 ` [PATCH 09/26] perf tools: Try load vmlinux from buildid database Jiri Olsa
2020-09-14  6:25   ` Namhyung Kim
2020-09-14 20:29     ` Jiri Olsa
2020-09-15  2:58       ` Namhyung Kim
2020-09-13 21:02 ` [PATCH 10/26] perf tools: Enable mmap3 map event when supported Jiri Olsa
2020-09-14 16:05   ` Arnaldo Carvalho de Melo
2020-09-13 21:02 ` [PATCH 11/26] perf tools: Add mmap3 support Jiri Olsa
2020-09-13 21:02 ` [PATCH 12/26] perf tools: Set build id for kernel dso objects Jiri Olsa
2020-09-13 21:03 ` [PATCH 13/26] perf tools: Plug in mmap3 event Jiri Olsa
2020-09-13 21:03 ` [PATCH 14/26] perf tools: Add mmap3 events to --show-mmap-events option Jiri Olsa
2020-09-14  6:30   ` Namhyung Kim
2020-09-14 20:29     ` Jiri Olsa
2020-09-13 21:03 ` [PATCH 15/26] perf tools: Synthesize proc tasks with mmap3 Jiri Olsa
2020-09-14 16:07   ` Arnaldo Carvalho de Melo
2020-09-14 20:51     ` Jiri Olsa
2020-09-13 21:03 ` [PATCH 16/26] perf tools: Synthesize modules " Jiri Olsa
2020-09-14 16:07   ` Arnaldo Carvalho de Melo
2020-09-15 20:17     ` Ian Rogers
2020-09-16  8:20       ` Jiri Olsa
2020-09-16 14:07         ` Arnaldo Carvalho de Melo
2020-09-16 14:17           ` peterz
2020-09-16 15:10             ` Arnaldo Carvalho de Melo
2020-09-16 15:20               ` peterz
2020-09-16 15:21               ` Jiri Olsa
2020-09-16 15:42                 ` Arnaldo Carvalho de Melo
2020-09-13 21:03 ` [PATCH 17/26] perf tools: Synthesize kernel " Jiri Olsa
2020-09-14 16:08   ` Arnaldo Carvalho de Melo
2020-09-13 21:03 ` [PATCH 18/26] perf tests: Add mmap3 support for perf record test Jiri Olsa
2020-09-13 21:03 ` [PATCH 19/26] perf tools: Add buildid-list support for mmap3 Jiri Olsa
2020-09-13 21:03 ` [PATCH 20/26] perf tools: Add build_id_cache__add function Jiri Olsa
2020-09-14 16:13   ` Arnaldo Carvalho de Melo
2020-09-13 21:03 ` [PATCH 21/26] perf tools: Add machine__for_each_dso function Jiri Olsa
2020-09-14 16:15   ` Arnaldo Carvalho de Melo
2020-09-13 21:03 ` [PATCH 22/26] perf tools: Use machine__for_each_dso in perf_session__cache_build_ids Jiri Olsa
2020-09-13 21:03 ` [PATCH 23/26] perf tools: Add __perf_session__cache_build_ids function Jiri Olsa
2020-09-13 21:03 ` [PATCH 24/26] perf tools: Add buildid-list --store option Jiri Olsa
2020-09-14  6:42   ` Namhyung Kim
2020-09-14 15:14     ` Arnaldo Carvalho de Melo [this message]
2020-09-14 20:42       ` Jiri Olsa
2020-09-14 20:42     ` Jiri Olsa
2020-09-13 21:03 ` [PATCH 25/26] perf tools: Move debuginfo download code into get_debuginfo Jiri Olsa
2020-09-13 21:03 ` [PATCH 26/26] perf tools: Add report --store option Jiri Olsa
2020-09-14  5:25 ` [RFC 00/26] perf: Add mmap3 support Namhyung Kim
2020-09-14 15:13   ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200914151413.GB160517@kernel.org \
    --to=acme@kernel.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=adrian.hunter@intel.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=alexey.budankov@linux.intel.com \
    --cc=eranian@google.com \
    --cc=fche@redhat.com \
    --cc=irogers@google.com \
    --cc=jolsa@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@kernel.org \
    --cc=mpetlan@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=songliubraving@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox