Re: [PATCH V2 02/12] perf record: Support new sample type for data page size
From: Arnaldo Carvalho de Melo
Date: Wed Dec 16 2020 - 10:49:43 EST
Em Mon, Dec 07, 2020 at 03:25:07PM -0500, Liang, Kan escreveu:
>
>
> On 12/7/2020 12:07 PM, Arnaldo Carvalho de Melo wrote:
> > Em Mon, Nov 30, 2020 at 09:27:53AM -0800, kan.liang@xxxxxxxxxxxxxxx escreveu:
> > > From: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
> > >
> > > Support new sample type PERF_SAMPLE_DATA_PAGE_SIZE for page size.
> > >
> > > Add new option --data-page-size to record sample data page size.
> >
> > So, trying this on a kernel without this feature I get:
> >
> > [acme@five perf]$ perf record --data-page-size sleep 1
> > Error:
> > The sys_perf_event_open() syscall returned with 22 (Invalid argument) for event (cycles:u).
> > /bin/dmesg | grep -i perf may provide additional information.
> >
> > [acme@five perf]$
> >
> > I'm adding the following patch right after yours, next time please test
> > this and provide a similar error message.
> >
>
> Sorry, I missed it.
>
> Besides the PERF_SAMPLE_DATA_PAGE_SIZE, I think we have to fix the
> PERF_SAMPLE_CODE_PAGE_SIZE as well.
> Should I send a separate patch to fix it?
I've got back to this and what I have is out in acme/perf/core, so you can
continue from there.
I had to add the patch below to fix 'perf test "Sample parsing"'.
- Arnaldo
commit eec7b53d59167a1063e704f86ec0aa36ff765e1a
Author: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
Date: Wed Dec 16 12:45:10 2020 -0300
perf test: Make sample-parsing test aware of PERF_SAMPLE_{CODE,DATA}_PAGE_SIZE
To fix this:
$ perf test -v "Sample parsing".
27: Sample parsing :
--- start ---
test child forked, pid 586013
sample format has changed, some new PERF_SAMPLE_ bit was introduced - test needs updating
test child finished with -1
---- end ----
Sample parsing: FAILED!
$
This patchset is still not completely merged, so when adding the
PERF_SAMPLE_CODE_PAGE_SIZE to 'struct perf_sample' we need to add the
bits added in this patch for 'perf_sample.data_page_size'.
Fixes: 251cc77b8176de37 ("tools headers UAPI: Update tools's copy of linux/perf_event.h")
Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: Ian Rogers <irogers@xxxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Kan Liang <kan.liang@xxxxxxxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
diff --git a/tools/perf/tests/sample-parsing.c b/tools/perf/tests/sample-parsing.c
index a0bdaf390ac8ea78..2393916f6128a6fb 100644
--- a/tools/perf/tests/sample-parsing.c
+++ b/tools/perf/tests/sample-parsing.c
@@ -154,6 +154,9 @@ static bool samples_same(const struct perf_sample *s1,
if (type & PERF_SAMPLE_CGROUP)
COMP(cgroup);
+ if (type & PERF_SAMPLE_DATA_PAGE_SIZE)
+ COMP(data_page_size);
+
if (type & PERF_SAMPLE_AUX) {
COMP(aux_sample.size);
if (memcmp(s1->aux_sample.data, s2->aux_sample.data,
@@ -234,6 +237,7 @@ static int do_test(u64 sample_type, u64 sample_regs, u64 read_format)
},
.phys_addr = 113,
.cgroup = 114,
+ .data_page_size = 115,
.aux_sample = {
.size = sizeof(aux_data),
.data = (void *)aux_data,
@@ -340,7 +344,7 @@ int test__sample_parsing(struct test *test __maybe_unused, int subtest __maybe_u
* were added. Please actually update the test rather than just change
* the condition below.
*/
- if (PERF_SAMPLE_MAX > PERF_SAMPLE_CGROUP << 1) {
+ if (PERF_SAMPLE_MAX > PERF_SAMPLE_CODE_PAGE_SIZE << 1) {
pr_debug("sample format has changed, some new PERF_SAMPLE_ bit was introduced - test needs updating\n");
return -1;
}