linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicholas Fraser <nfraser@codeweavers.com>
To: Jiri Olsa <jolsa@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Arnaldo Carvalho de Melo <acme@kernel.org>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Ian Rogers <irogers@google.com>,
	"Frank Ch. Eigler" <fche@redhat.com>,
	Song Liu <songliubraving@fb.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Kim Phillips <kim.phillips@amd.com>,
	Tommi Rantala <tommi.t.rantala@nokia.com>,
	Remi Bernon <rbernon@codeweavers.com>,
	linux-kernel@vger.kernel.org,
	Ulrich Czekalla <uczekalla@codeweavers.com>,
	Huw Davies <huw@codeweavers.com>
Subject: Re: [PATCH 1/4] perf buildid-cache: Don't skip 16-byte build-ids
Date: Tue, 16 Feb 2021 11:35:06 -0500	[thread overview]
Message-ID: <7f5bc880-7724-643b-5344-c27c4de572ae@codeweavers.com> (raw)
In-Reply-To: <YCqF3ENDLNLXoa2j@krava>

No problem, I've added a call to "perf buildid-cache -l" in check() to make
sure the added IDs are reported. The MD5 test fails without the previous
patch to allow 16-byte build-ids.

Do you also want PE files tested by this test script? This would make the
script depend on a number of things:

- We'd need to change "readelf" to something that can read the build-id of
  PE files;

- We'd need MinGW installed to build them on the fly the same as the ELF
  test cases, although we could use tests/pe-file.exe instead which is
  already included;

- We'd need Wine to actually run it under perf record, which I'm sure you
  don't want to depend on;

- We'd need to detect whether perf was built with libbfd support. Easily
  done by calling perf version --build-options but by this point the test
  case is getting pretty out of hand for what it's supposed to test.

I'll send patches for this test without PE support. It still tests 16-byte
build-ids because it tests an MD5 ELF file. Let me know if you also want me
to add PE support to this script. We can make it optionally perform PE
tests if all of the necessary tools are installed but it would take some
pretty large changes to the script.

Nick


On 2021-02-15 9:31 a.m., Jiri Olsa wrote:
> On Wed, Feb 10, 2021 at 02:17:25PM -0500, Nicholas Fraser wrote:
>> lsdir_bid_tail_filter() ignored any build-id that wasn't exactly 20
>> bytes. This worked only for SHA-1 build-ids. The build-id for a PE file
>> is always a 16-byte GUID and ELF files can also have MD5 or UUID
>> build-ids.
>>
>> This fix changes the filter to allow build-ids between 16 and 20 bytes.
> 
> hi,
> there's tests/shell/buildid.sh test for this, please add
> testcase for this.. looks like perf buildid-cacle -l will
> end up calling this function
> 
> thanks,
> jirka
> 
>>
>> Signed-off-by: Nicholas Fraser <nfraser@codeweavers.com>
>> ---
>>  tools/perf/util/build-id.c | 5 +++--
>>  tools/perf/util/build-id.h | 4 +++-
>>  2 files changed, 6 insertions(+), 3 deletions(-)
>>
>> diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
>> index 02df36b30ac5..e32e8f2ff3bd 100644
>> --- a/tools/perf/util/build-id.c
>> +++ b/tools/perf/util/build-id.c
>> @@ -448,7 +448,8 @@ static bool lsdir_bid_tail_filter(const char *name __maybe_unused,
>>  	int i = 0;
>>  	while (isxdigit(d->d_name[i]) && i < SBUILD_ID_SIZE - 3)
>>  		i++;
>> -	return (i == SBUILD_ID_SIZE - 3) && (d->d_name[i] == '\0');
>> +	return (i >= SBUILD_ID_MIN_SIZE - 3) && (i <= SBUILD_ID_SIZE - 3) &&
>> +		(d->d_name[i] == '\0');
>>  }
>>  
>>  struct strlist *build_id_cache__list_all(bool validonly)
>> @@ -490,7 +491,7 @@ struct strlist *build_id_cache__list_all(bool validonly)
>>  		}
>>  		strlist__for_each_entry(nd2, linklist) {
>>  			if (snprintf(sbuild_id, SBUILD_ID_SIZE, "%s%s",
>> -				     nd->s, nd2->s) != SBUILD_ID_SIZE - 1)
>> +				     nd->s, nd2->s) > SBUILD_ID_SIZE - 1)
>>  				goto err_out;
>>  			if (validonly && !build_id_cache__valid_id(sbuild_id))
>>  				continue;
>> diff --git a/tools/perf/util/build-id.h b/tools/perf/util/build-id.h
>> index 02613f4b2c29..c19617151670 100644
>> --- a/tools/perf/util/build-id.h
>> +++ b/tools/perf/util/build-id.h
>> @@ -2,8 +2,10 @@
>>  #ifndef PERF_BUILD_ID_H_
>>  #define PERF_BUILD_ID_H_ 1
>>  
>> -#define BUILD_ID_SIZE	20
>> +#define BUILD_ID_SIZE	20 /* SHA-1 length in bytes */
>> +#define BUILD_ID_MIN_SIZE	16 /* MD5/UUID/GUID length in bytes */
>>  #define SBUILD_ID_SIZE	(BUILD_ID_SIZE * 2 + 1)
>> +#define SBUILD_ID_MIN_SIZE	(BUILD_ID_MIN_SIZE * 2 + 1)
>>  
>>  #include "machine.h"
>>  #include "tool.h"
>> -- 
>> 2.30.0
>>
> 

  reply	other threads:[~2021-02-16 16:36 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-10 19:17 [PATCH 1/4] perf buildid-cache: Don't skip 16-byte build-ids Nicholas Fraser
2021-02-15 14:31 ` Jiri Olsa
2021-02-16 16:35   ` Nicholas Fraser [this message]
2021-02-17 18:19     ` Arnaldo Carvalho de Melo
2021-02-17 19:24     ` Jiri Olsa
2021-02-17 19:54 ` Jiri Olsa
2021-02-18 19:42   ` 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=7f5bc880-7724-643b-5344-c27c4de572ae@codeweavers.com \
    --to=nfraser@codeweavers.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=fche@redhat.com \
    --cc=huw@codeweavers.com \
    --cc=irogers@google.com \
    --cc=jolsa@redhat.com \
    --cc=kim.phillips@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=rbernon@codeweavers.com \
    --cc=songliubraving@fb.com \
    --cc=tommi.t.rantala@nokia.com \
    --cc=uczekalla@codeweavers.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;
as well as URLs for NNTP newsgroup(s).