Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp176568pxk; Wed, 30 Sep 2020 22:33:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxy1qA7Lg142lmlkB3yhtwF4OrZJpukz9l7HxWsQs1QHPdWaCfHO3JSoCVkrEB+HSz5xzVq X-Received: by 2002:a05:6402:326:: with SMTP id q6mr6420732edw.216.1601530412489; Wed, 30 Sep 2020 22:33:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601530412; cv=none; d=google.com; s=arc-20160816; b=p5+Eygemc2kK4cCZftChrM6NIs4vRhlaBr8CcoyBkGjl4Hp9aifVcyeATstwCZqGOn NUt4a/1fLN/mqr2rQd8hScmdNs86b/5O/ZfwFnlONQebVzitKbawZql03isB23n16sYc CPG/iuS2hcs3OKJR6K/VkBVpxJblT67gTFXTasP9PNVSfcB2yb7Iv/EwjazK83JJvALG WtdOxAgkjhjnMPcfRCdb3TFn39yF0dlGs4hsZ07FZ48hnapNgIkz8uoghLFPWwCRsAbe uEjEWjb11PUtTWWWsvhgdMIlyJgEX1tLRSOF6P8L49+KoAgvi/F74RCtKahzy6FSp5wx fXDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=eXLNt1HM/rpSQJlqYVshAKj+ovYp4BRi6qSvoua5+XU=; b=gBpceWBaq7NsTjcL5cGbSM57wHs4t3yQdBhoJhoLUpcJtwdqCaI04n5IOhVcsTOYdF TQi/TMlXEcjhVjIJmKDnQGo0OlftKjxk8uRTwMLQarortvICY9ouq2xxGYvQmzMlFiJE Zw7s4Lbfgc6NL+WgU5ydALZm/nSsEdgNFeA/TrNTA9FvsnZPvgMTQl5mRqHTuINZwxAm 57FqUxZ87lYlnh8/BVXw9w3pfhgPtM6dRH5SJjfNewJLLYbPVJgtuWBCiqIybw3XEkQZ fC6iM97TzFRTRrbrfahcYh2Pc6nsSAtvx372xTmQeGPe/an3EoA1BBKTMExxrF3dvkzB ob4Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CQz2x6Fd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t21si2760329edy.123.2020.09.30.22.33.10; Wed, 30 Sep 2020 22:33:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CQz2x6Fd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725897AbgJAFcA (ORCPT + 99 others); Thu, 1 Oct 2020 01:32:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59732 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbgJAFcA (ORCPT ); Thu, 1 Oct 2020 01:32:00 -0400 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 14157C061755 for ; Wed, 30 Sep 2020 22:32:00 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id l15so1411021wmh.1 for ; Wed, 30 Sep 2020 22:31:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=eXLNt1HM/rpSQJlqYVshAKj+ovYp4BRi6qSvoua5+XU=; b=CQz2x6FdUV3I2nS3AU1vSN4zyF/eEjw2A6KvOYIidHB3dKZJ/9DN/oglyI0aL8TkS+ fSsYh0SgJD9kK2xlEzIMW7CTbVnxEsan54EWAXU7v52j2go9ikr7xuDEjHrK+188VIUZ sX2KF5W7iiCs7JGrtFE8lJsNDbMGvweF6mrHlD2nI+DNSqY6ZEjMp413vGcsTLGY2Ho0 Med7Rer7awVE8tLpmChm4yFD+pW8F86tl5lN9+yjDWulwOSOmqLC2ZLrXKDlo01cliIl hmTe9N+lAloqDOnfCzEen4EKQS0jc3l6rqLGiFkaH9ZlPba6O+Wv52h0+m8Yshj6MR8g 8yOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=eXLNt1HM/rpSQJlqYVshAKj+ovYp4BRi6qSvoua5+XU=; b=f35YS90OobFqLtD8JcjhuBeYcktzHUH6iZ6Tyfdqf8wpcxWkQ2Ac1m06qLaUSjmJRy fh4/i9Q78GZqaswEMV2B0lxRPs/qiUCjAExPeL73VPVjX4LcqSGkqwsYWzYJGplVrktx T9KoUZ38hjTQAwdTdPOwv9DzKA83iggUOew2Hkr3XB3mRWfa8HRvV1VygLRWBoGjrV19 yYZjmdh1komzyq2/ZmAqmUvVmD3Rqu9/LRPuHa6FLFVsBMLo7aBHVUpKLUQqwuvXt+AC i3rnxHGcoq4n9nFPVrVomf6Md/ZNG9SFVHWhF5ugclt/U15lAswfDWh9rVav62jnYD5k cGFQ== X-Gm-Message-State: AOAM531HresSzwjuV6PpiCk8vr9D6+yiAin7XEAkZaTkcWCfcyguGkvk cJMKGHVjK5OuVJdqIXTmnBHV8xTnke8ueqEeDumtjQ== X-Received: by 2002:a7b:cd08:: with SMTP id f8mr6385669wmj.124.1601530318496; Wed, 30 Sep 2020 22:31:58 -0700 (PDT) MIME-Version: 1.0 References: <20200930171512.3986425-1-jolsa@kernel.org> <20200930171512.3986425-9-jolsa@kernel.org> In-Reply-To: <20200930171512.3986425-9-jolsa@kernel.org> From: Ian Rogers Date: Wed, 30 Sep 2020 22:31:47 -0700 Message-ID: Subject: Re: [PATCH 8/9] perf tools: Add size to struct perf_record_header_build_id To: Jiri Olsa Cc: Arnaldo Carvalho de Melo , lkml , Peter Zijlstra , Ingo Molnar , Mark Rutland , Namhyung Kim , Alexander Shishkin , Michael Petlan , Stephane Eranian Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Sep 30, 2020 at 10:15 AM Jiri Olsa wrote: > > We do not store size with build ids in perf data, > but there's enough space to do it. Adding misc bit > PERF_RECORD_MISC_BUILD_ID_SIZE to mark build id event > with size. > > With this fix the dso with md5 build id will have correct > build id data and will be usable for debuginfod processing > if needed (coming in following patches). > > Signed-off-by: Jiri Olsa Acked-by: Ian Rogers Thanks, Ian > --- > tools/lib/perf/include/perf/event.h | 12 +++++++++++- > tools/perf/util/build-id.c | 8 +++++--- > tools/perf/util/header.c | 10 +++++++--- > 3 files changed, 23 insertions(+), 7 deletions(-) > > diff --git a/tools/lib/perf/include/perf/event.h b/tools/lib/perf/include/perf/event.h > index a6dbba6b9073..988c539bedb6 100644 > --- a/tools/lib/perf/include/perf/event.h > +++ b/tools/lib/perf/include/perf/event.h > @@ -201,10 +201,20 @@ struct perf_record_header_tracing_data { > __u32 size; > }; > > +#define PERF_RECORD_MISC_BUILD_ID_SIZE (1 << 15) > + > struct perf_record_header_build_id { > struct perf_event_header header; > pid_t pid; > - __u8 build_id[24]; > + union { > + __u8 build_id[24]; > + struct { > + __u8 data[20]; > + __u8 size; > + __u8 reserved1__; > + __u16 reserved2__; > + }; > + }; > char filename[]; > }; > > diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c > index b5648735f01f..8763772f1095 100644 > --- a/tools/perf/util/build-id.c > +++ b/tools/perf/util/build-id.c > @@ -296,7 +296,7 @@ char *dso__build_id_filename(const struct dso *dso, char *bf, size_t size, > continue; \ > else > > -static int write_buildid(const char *name, size_t name_len, u8 *build_id, > +static int write_buildid(const char *name, size_t name_len, struct build_id *bid, > pid_t pid, u16 misc, struct feat_fd *fd) > { > int err; > @@ -307,7 +307,9 @@ static int write_buildid(const char *name, size_t name_len, u8 *build_id, > len = PERF_ALIGN(len, NAME_ALIGN); > > memset(&b, 0, sizeof(b)); > - memcpy(&b.build_id, build_id, BUILD_ID_SIZE); > + memcpy(&b.data, bid->data, bid->size); > + b.size = (u8) bid->size; > + misc |= PERF_RECORD_MISC_BUILD_ID_SIZE; > b.pid = pid; > b.header.misc = misc; > b.header.size = sizeof(b) + len; > @@ -354,7 +356,7 @@ static int machine__write_buildid_table(struct machine *machine, > in_kernel = pos->kernel || > is_kernel_module(name, > PERF_RECORD_MISC_CPUMODE_UNKNOWN); > - err = write_buildid(name, name_len, pos->bid.data, machine->pid, > + err = write_buildid(name, name_len, &pos->bid, machine->pid, > in_kernel ? kmisc : umisc, fd); > if (err) > break; > diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c > index 21243adbb9fd..8da3886f10a8 100644 > --- a/tools/perf/util/header.c > +++ b/tools/perf/util/header.c > @@ -2083,8 +2083,12 @@ static int __event_process_build_id(struct perf_record_header_build_id *bev, > if (dso != NULL) { > char sbuild_id[SBUILD_ID_SIZE]; > struct build_id bid; > + size_t size = BUILD_ID_SIZE; > > - build_id__init(&bid, bev->build_id, BUILD_ID_SIZE); > + if (bev->header.misc & PERF_RECORD_MISC_BUILD_ID_SIZE) > + size = bev->size; > + > + build_id__init(&bid, bev->data, size); > dso__set_build_id(dso, &bid); > > if (dso_space != DSO_SPACE__USER) { > @@ -2098,8 +2102,8 @@ static int __event_process_build_id(struct perf_record_header_build_id *bev, > } > > build_id__sprintf(&dso->bid, sbuild_id); > - pr_debug("build id event received for %s: %s\n", > - dso->long_name, sbuild_id); > + pr_debug("build id event received for %s: %s [%lu]\n", > + dso->long_name, sbuild_id, size); > dso__put(dso); > } > > -- > 2.26.2 >