Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp174279pxk; Wed, 30 Sep 2020 22:28:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy0g2U1ZUDnyxIsIHaEWUHqib4J+G2jbgPWz7iQgbe3PXhuJMu+iRtkLeyRWshYpKQdFzkk X-Received: by 2002:a17:906:5402:: with SMTP id q2mr6161376ejo.316.1601530082214; Wed, 30 Sep 2020 22:28:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601530082; cv=none; d=google.com; s=arc-20160816; b=Gtgng5XDGj6uHE/ducTY2kOUDVs1cOusxW9OL/LCRwGsRTcLEjw1mp6FBV9BqGfPOs BI+B2/D/Ht+BWmd9sK4QONExL/xOFD/Dvlo8MXkErZ4zu3Jn2c5k9VOD8ZMl13xQUiaF eLPd3lkVM+z4XYF6PDPqCLJ1jMlBiYKtfiEN05RZCe0AI0YMp5HlxhD9RvAgmJywgUmn PqPjuT9Y33qgKLEF4Fo42YbnlJ4kt43a3jsCrNMjBJB3/SeiBbGzXuxmlXhAotHbnQ0Z Y1Cr6jIIZ1xQcJfzE+Shk+16rsX9CBk/XwQuiKsySKQFFNhJLi2+PqweLpt95uQ/wKLg LDYA== 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=HmHXTE4F4jHgiV3b6mUSLNF1ue58qvwcw3gNuO6qY4I=; b=txHDpuZ0xaVZoypaWq8LhXrXJ8qNlhH6OMoAC3ZRKRvfHw+SxIk05rwjdh+t3fhZ6f ocb2ctVAUt3bbReJljf96vo6Q6w6rIAnxFh6XxZNrVZsQWCi6+KyDLQw0Z4yJtD2W7FL FwZP0m9+ty5pQUKZF4Bib8bA6Y1hft8iJIhnIEFzj5lBQtk8EUa/1Nm7beDmT/EmzWw7 17mabxPlvLOO0w4a9ugNAOofIAJsMfs2JHhbSF/haAIXMsqa70RylqRkwnr7BduCiU2S Pj6+zmk3+Z6kWUuKDnUUqovD4PtyozGszz5WIo9+T0/BMSFst4x6q28GamD1nGIp85Fp 8PqQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=BwZawTws; 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 da18si2612540edb.466.2020.09.30.22.27.39; Wed, 30 Sep 2020 22:28:02 -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=BwZawTws; 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 S1730022AbgJAF0E (ORCPT + 99 others); Thu, 1 Oct 2020 01:26:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58826 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725878AbgJAF0D (ORCPT ); Thu, 1 Oct 2020 01:26:03 -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 B4585C061755 for ; Wed, 30 Sep 2020 22:26:01 -0700 (PDT) Received: by mail-wm1-x344.google.com with SMTP id q9so1582582wmj.2 for ; Wed, 30 Sep 2020 22:26:01 -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=HmHXTE4F4jHgiV3b6mUSLNF1ue58qvwcw3gNuO6qY4I=; b=BwZawTwssCSHJIY8ZKQ6Lg66wC0Ejy+zgkgNYQxLt6KTAzXZPnNrCsR625R+QwrZMs xbGjtEmW5jSNklim03smW9OxDEuuC+q+9XEShCgD+PCTqRflokfivpMRCpRcqXrQF+l1 FAc9TIQL1ypuiOrhBBdndVzrQM/AkkxBTTXc4kJkwPw5nVOGxZhhwZEaYS0kx0eXTv8b bn570RO4o2xQRpj2ZRhXi2wIRwQkeQDjaX8xBjc8YHq5jyZi5ZbrNkzfrluKQB88Az5S RuNNy28rQ+YGKfm2lB/x/f6CuEi5r1+fFE/uJaF5cF1vd5GtAg7WFK44r7adtouj9/vI jvdQ== 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=HmHXTE4F4jHgiV3b6mUSLNF1ue58qvwcw3gNuO6qY4I=; b=DhXgCmeuXdvYdfUgL43m/Z0PR1YqRAiEH17Wek8rfxP49O38vdTwSWNOa8/4+cYK4V hpTJXt/XmE6zVN+6N7MqLAV/udMdUhUCvgHwbvrgNTex3x1I2SjFZym2SpVYKap3wcRL P5hB3Cp+jMiGZvhEr6qbSJD5I+hdJHzGHHKAWevRzH8Z7dqfCgHBdROrL4j2j0kF1Q8P ZT2lube7hxvI3RUJPeo7ZRz/eY+4wpAdyHg3YO1qcAK98DH7cs0Nl/KDvPxUjXAI6ClG bppRqlnLijFpdiOg+YA1wgnQ6SHI/6kFa5FaRRLcssNOzqHy+sKoMQgxWC2/7G51AgGl WWug== X-Gm-Message-State: AOAM531YCYnddZikrGl7v/qxjD4Iu/ZxhmQfmY9fAgML9I1oWxA5oVra G6QtNKeOLILh8yFaXunOS5Z6of/m/ujsagWxWzWL3Q== X-Received: by 2002:a05:600c:220f:: with SMTP id z15mr6231303wml.87.1601529960166; Wed, 30 Sep 2020 22:26:00 -0700 (PDT) MIME-Version: 1.0 References: <20200930171512.3986425-1-jolsa@kernel.org> <20200930171512.3986425-8-jolsa@kernel.org> In-Reply-To: <20200930171512.3986425-8-jolsa@kernel.org> From: Ian Rogers Date: Wed, 30 Sep 2020 22:25:48 -0700 Message-ID: Subject: Re: [PATCH 7/9] perf tools: Pass build_id object to dso__build_id_equal 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: > > Passing build_id object to dso__build_id_equal, so we can > properly check build id with different size than sha1. > > Signed-off-by: Jiri Olsa Acked-by: Ian Rogers Thanks, Ian > --- > tools/perf/util/dso.c | 5 +++-- > tools/perf/util/dso.h | 2 +- > tools/perf/util/symbol-elf.c | 8 ++++++-- > tools/perf/util/symbol.c | 2 +- > 4 files changed, 11 insertions(+), 6 deletions(-) > > diff --git a/tools/perf/util/dso.c b/tools/perf/util/dso.c > index 4415ce83150b..ca965845b35e 100644 > --- a/tools/perf/util/dso.c > +++ b/tools/perf/util/dso.c > @@ -1332,9 +1332,10 @@ void dso__set_build_id(struct dso *dso, struct build_id *bid) > dso->has_build_id = 1; > } > > -bool dso__build_id_equal(const struct dso *dso, u8 *build_id) > +bool dso__build_id_equal(const struct dso *dso, struct build_id *bid) > { > - return memcmp(dso->bid.data, build_id, sizeof(dso->bid.data)) == 0; > + return dso->bid.size == bid->size && > + memcmp(dso->bid.data, bid->data, dso->bid.size) == 0; > } > > void dso__read_running_kernel_build_id(struct dso *dso, struct machine *machine) > diff --git a/tools/perf/util/dso.h b/tools/perf/util/dso.h > index 5a5678dbdaa5..f926c96bf230 100644 > --- a/tools/perf/util/dso.h > +++ b/tools/perf/util/dso.h > @@ -261,7 +261,7 @@ void dso__set_sorted_by_name(struct dso *dso); > void dso__sort_by_name(struct dso *dso); > > void dso__set_build_id(struct dso *dso, struct build_id *bid); > -bool dso__build_id_equal(const struct dso *dso, u8 *build_id); > +bool dso__build_id_equal(const struct dso *dso, struct build_id *bid); > void dso__read_running_kernel_build_id(struct dso *dso, > struct machine *machine); > int dso__kernel_module_get_build_id(struct dso *dso, const char *root_dir); > diff --git a/tools/perf/util/symbol-elf.c b/tools/perf/util/symbol-elf.c > index 97a55f162ea5..44dd86a4f25f 100644 > --- a/tools/perf/util/symbol-elf.c > +++ b/tools/perf/util/symbol-elf.c > @@ -834,13 +834,17 @@ int symsrc__init(struct symsrc *ss, struct dso *dso, const char *name, > /* Always reject images with a mismatched build-id: */ > if (dso->has_build_id && !symbol_conf.ignore_vmlinux_buildid) { > u8 build_id[BUILD_ID_SIZE]; > + struct build_id bid; > + int size; > > - if (elf_read_build_id(elf, build_id, BUILD_ID_SIZE) < 0) { > + size = elf_read_build_id(elf, build_id, BUILD_ID_SIZE); > + if (size <= 0) { > dso->load_errno = DSO_LOAD_ERRNO__CANNOT_READ_BUILDID; > goto out_elf_end; > } > > - if (!dso__build_id_equal(dso, build_id)) { > + build_id__init(&bid, build_id, size); > + if (!dso__build_id_equal(dso, &bid)) { > pr_debug("%s: build id mismatch for %s.\n", __func__, name); > dso->load_errno = DSO_LOAD_ERRNO__MISMATCHING_BUILDID; > goto out_elf_end; > diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c > index 976632d0baa0..6138866665df 100644 > --- a/tools/perf/util/symbol.c > +++ b/tools/perf/util/symbol.c > @@ -2136,7 +2136,7 @@ static char *dso__find_kallsyms(struct dso *dso, struct map *map) > } > > if (sysfs__read_build_id("/sys/kernel/notes", &bid) == 0) > - is_host = dso__build_id_equal(dso, bid.data); > + is_host = dso__build_id_equal(dso, &bid); > > /* Try a fast path for /proc/kallsyms if possible */ > if (is_host) { > -- > 2.26.2 >