2023-02-17 22:32:45

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH v5 0/2] perf tool: 'config3' attribute support

This series adds the perf tool support for 'config3' attr. This is
the last part to enable Arm SPEv1.2 support. The necessary kernel side
changes are pending for v6.3[1].

[1] https://lore.kernel.org/all/20230207124250.GA12385@willie-the-truck/

---
Changes in v5:
- Rebase on v6.2-rc1
- Drop applied config attr fix
- Link to v4: https://lore.kernel.org/r/[email protected]

Changes in v4:
- Fix event parsing test segfault
- Add 'config3' in event parsing tests
- Link to v3: https://lore.kernel.org/r/[email protected]

---
Rob Herring (2):
perf tools: Sync perf_event_attr::config3 addition
perf: Add support for perf_event_attr::config3

tools/include/uapi/linux/perf_event.h | 3 +++
tools/perf/tests/parse-events.c | 13 ++++++++++++-
tools/perf/util/parse-events.c | 6 ++++++
tools/perf/util/parse-events.h | 1 +
tools/perf/util/parse-events.l | 1 +
tools/perf/util/pmu.c | 3 +++
tools/perf/util/pmu.h | 1 +
7 files changed, 27 insertions(+), 1 deletion(-)
---
base-commit: 9abf2313adc1ca1b6180c508c25f22f9395cc780
change-id: 20220914-arm-perf-tool-spe1-2-v2-cab789c5d598

Best regards,
--
Rob Herring <[email protected]>



2023-02-17 22:32:47

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH v5 1/2] perf tools: Sync perf_event_attr::config3 addition

Arm SPEv1.2 adds another 64-bits of event filtering control. As the
existing perf_event_attr::configN fields are all used up for SPE PMU, an
additional field is needed. Add a new 'config3' field.

Signed-off-by: Rob Herring <[email protected]>
---
This matches commit 09519ec3b19e ("perf: Add perf_event_attr::config3")
for the kernel queued in linux-next.
---
tools/include/uapi/linux/perf_event.h | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
index ea6defacc1a7..a38814ce9485 100644
--- a/tools/include/uapi/linux/perf_event.h
+++ b/tools/include/uapi/linux/perf_event.h
@@ -365,6 +365,7 @@ enum perf_event_read_format {
#define PERF_ATTR_SIZE_VER5 112 /* add: aux_watermark */
#define PERF_ATTR_SIZE_VER6 120 /* add: aux_sample_size */
#define PERF_ATTR_SIZE_VER7 128 /* add: sig_data */
+#define PERF_ATTR_SIZE_VER8 136 /* add: config3 */

/*
* Hardware event_id to monitor via a performance monitoring event:
@@ -506,6 +507,8 @@ struct perf_event_attr {
* truncated accordingly on 32 bit architectures.
*/
__u64 sig_data;
+
+ __u64 config3; /* extension of config2 */
};

/*

--
2.39.1


2023-02-17 22:32:51

by Rob Herring (Arm)

[permalink] [raw]
Subject: [PATCH v5 2/2] perf: Add support for perf_event_attr::config3

perf_event_attr has gained a new field, config3, so add support for it
extending the existing configN support.

Signed-off-by: Rob Herring <[email protected]>
---
v5:
- Rebase on v6.2-rc1

v4:
- Add config3 to event parsing tests
---
tools/perf/tests/parse-events.c | 13 ++++++++++++-
tools/perf/util/parse-events.c | 6 ++++++
tools/perf/util/parse-events.h | 1 +
tools/perf/util/parse-events.l | 1 +
tools/perf/util/pmu.c | 3 +++
tools/perf/util/pmu.h | 1 +
6 files changed, 24 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/parse-events.c b/tools/perf/tests/parse-events.c
index 459afdb256a1..ddd5bdfe5723 100644
--- a/tools/perf/tests/parse-events.c
+++ b/tools/perf/tests/parse-events.c
@@ -444,6 +444,7 @@ static int test__checkevent_pmu(struct evlist *evlist)
TEST_ASSERT_VAL("wrong config", 10 == evsel->core.attr.config);
TEST_ASSERT_VAL("wrong config1", 1 == evsel->core.attr.config1);
TEST_ASSERT_VAL("wrong config2", 3 == evsel->core.attr.config2);
+ TEST_ASSERT_VAL("wrong config3", 0 == evsel->core.attr.config3);
/*
* The period value gets configured within evlist__config,
* while this test executes only parse events method.
@@ -464,6 +465,7 @@ static int test__checkevent_list(struct evlist *evlist)
TEST_ASSERT_VAL("wrong config", 1 == evsel->core.attr.config);
TEST_ASSERT_VAL("wrong config1", 0 == evsel->core.attr.config1);
TEST_ASSERT_VAL("wrong config2", 0 == evsel->core.attr.config2);
+ TEST_ASSERT_VAL("wrong config3", 0 == evsel->core.attr.config3);
TEST_ASSERT_VAL("wrong exclude_user", !evsel->core.attr.exclude_user);
TEST_ASSERT_VAL("wrong exclude_kernel", !evsel->core.attr.exclude_kernel);
TEST_ASSERT_VAL("wrong exclude_hv", !evsel->core.attr.exclude_hv);
@@ -625,6 +627,15 @@ static int test__checkterms_simple(struct list_head *terms)
TEST_ASSERT_VAL("wrong val", term->val.num == 3);
TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config2"));

+ /* config3=4 */
+ term = list_entry(term->list.next, struct parse_events_term, list);
+ TEST_ASSERT_VAL("wrong type term",
+ term->type_term == PARSE_EVENTS__TERM_TYPE_CONFIG3);
+ TEST_ASSERT_VAL("wrong type val",
+ term->type_val == PARSE_EVENTS__TERM_TYPE_NUM);
+ TEST_ASSERT_VAL("wrong val", term->val.num == 4);
+ TEST_ASSERT_VAL("wrong config", !strcmp(term->config, "config3"));
+
/* umask=1*/
term = list_entry(term->list.next, struct parse_events_term, list);
TEST_ASSERT_VAL("wrong type term",
@@ -1983,7 +1994,7 @@ struct terms_test {

static const struct terms_test test__terms[] = {
[0] = {
- .str = "config=10,config1,config2=3,umask=1,read,r0xead",
+ .str = "config=10,config1,config2=3,config3=4,umask=1,read,r0xead",
.check = test__checkterms_simple,
},
};
diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 5973f46c2375..a2ae92736aac 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -944,6 +944,7 @@ static const char *config_term_names[__PARSE_EVENTS__TERM_TYPE_NR] = {
[PARSE_EVENTS__TERM_TYPE_CONFIG] = "config",
[PARSE_EVENTS__TERM_TYPE_CONFIG1] = "config1",
[PARSE_EVENTS__TERM_TYPE_CONFIG2] = "config2",
+ [PARSE_EVENTS__TERM_TYPE_CONFIG3] = "config3",
[PARSE_EVENTS__TERM_TYPE_NAME] = "name",
[PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD] = "period",
[PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ] = "freq",
@@ -983,6 +984,7 @@ config_term_avail(int term_type, struct parse_events_error *err)
case PARSE_EVENTS__TERM_TYPE_CONFIG:
case PARSE_EVENTS__TERM_TYPE_CONFIG1:
case PARSE_EVENTS__TERM_TYPE_CONFIG2:
+ case PARSE_EVENTS__TERM_TYPE_CONFIG3:
case PARSE_EVENTS__TERM_TYPE_NAME:
case PARSE_EVENTS__TERM_TYPE_METRIC_ID:
case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
@@ -1028,6 +1030,10 @@ do { \
CHECK_TYPE_VAL(NUM);
attr->config2 = term->val.num;
break;
+ case PARSE_EVENTS__TERM_TYPE_CONFIG3:
+ CHECK_TYPE_VAL(NUM);
+ attr->config3 = term->val.num;
+ break;
case PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD:
CHECK_TYPE_VAL(NUM);
break;
diff --git a/tools/perf/util/parse-events.h b/tools/perf/util/parse-events.h
index 07df7bb7b042..34db4870a56b 100644
--- a/tools/perf/util/parse-events.h
+++ b/tools/perf/util/parse-events.h
@@ -60,6 +60,7 @@ enum {
PARSE_EVENTS__TERM_TYPE_CONFIG,
PARSE_EVENTS__TERM_TYPE_CONFIG1,
PARSE_EVENTS__TERM_TYPE_CONFIG2,
+ PARSE_EVENTS__TERM_TYPE_CONFIG3,
PARSE_EVENTS__TERM_TYPE_NAME,
PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD,
PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ,
diff --git a/tools/perf/util/parse-events.l b/tools/perf/util/parse-events.l
index 3a9ce96c8bce..51fe0a9fb3de 100644
--- a/tools/perf/util/parse-events.l
+++ b/tools/perf/util/parse-events.l
@@ -285,6 +285,7 @@ modifier_bp [rwx]{1,3}
config { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG); }
config1 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG1); }
config2 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG2); }
+config3 { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_CONFIG3); }
name { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_NAME); }
period { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_PERIOD); }
freq { return term(yyscanner, PARSE_EVENTS__TERM_TYPE_SAMPLE_FREQ); }
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 03284059175f..2d9a0c35c6c3 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -1278,6 +1278,9 @@ static int pmu_config_term(const char *pmu_name,
case PERF_PMU_FORMAT_VALUE_CONFIG2:
vp = &attr->config2;
break;
+ case PERF_PMU_FORMAT_VALUE_CONFIG3:
+ vp = &attr->config3;
+ break;
default:
return -EINVAL;
}
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 68e15c38ae71..2e6bd1bf304a 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -17,6 +17,7 @@ enum {
PERF_PMU_FORMAT_VALUE_CONFIG,
PERF_PMU_FORMAT_VALUE_CONFIG1,
PERF_PMU_FORMAT_VALUE_CONFIG2,
+ PERF_PMU_FORMAT_VALUE_CONFIG3,
PERF_PMU_FORMAT_VALUE_CONFIG_END,
};


--
2.39.1


2023-02-18 13:22:21

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH v5 1/2] perf tools: Sync perf_event_attr::config3 addition

Em Fri, Feb 17, 2023 at 04:32:10PM -0600, Rob Herring escreveu:
> Arm SPEv1.2 adds another 64-bits of event filtering control. As the
> existing perf_event_attr::configN fields are all used up for SPE PMU, an
> additional field is needed. Add a new 'config3' field.
>
> Signed-off-by: Rob Herring <[email protected]>
> ---
> This matches commit 09519ec3b19e ("perf: Add perf_event_attr::config3")
> for the kernel queued in linux-next.

When you mention linux-next where was it that it picked this from?

For me to get this merged into the perf tools "next" (perf/core) it must
already have been merged in the kernel counterpart (tip/perf/core).

Ok so it is not in tip/perf/core, but got in next yesterday, and PeterZ
acked it, good, will process it soon.

- Arnaldo

⬢[acme@toolbox perf]$ git show 09519ec3b19e
commit 09519ec3b19e4144b5f6e269c54fbb9c294a9fcb
Author: Rob Herring <[email protected]>
Date: Mon Jan 9 13:26:23 2023 -0600

perf: Add perf_event_attr::config3

Arm SPEv1.2 adds another 64-bits of event filtering control. As the
existing perf_event_attr::configN fields are all used up for SPE PMU, an
additional field is needed. Add a new 'config3' field.

Tested-by: James Clark <[email protected]>
Signed-off-by: Rob Herring <[email protected]>
Acked-by: Peter Zijlstra (Intel) <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Will Deacon <[email protected]>

diff --git a/include/uapi/linux/perf_event.h b/include/uapi/linux/perf_event.h
index ccb7f5dad59be96b..37675437b76860ae 100644
--- a/include/uapi/linux/perf_event.h
+++ b/include/uapi/linux/perf_event.h
@@ -374,6 +374,7 @@ enum perf_event_read_format {
#define PERF_ATTR_SIZE_VER5 112 /* add: aux_watermark */
#define PERF_ATTR_SIZE_VER6 120 /* add: aux_sample_size */
#define PERF_ATTR_SIZE_VER7 128 /* add: sig_data */
+#define PERF_ATTR_SIZE_VER8 136 /* add: config3 */

/*
* Hardware event_id to monitor via a performance monitoring event:
@@ -515,6 +516,8 @@ struct perf_event_attr {
* truncated accordingly on 32 bit architectures.
*/
__u64 sig_data;
+
+ __u64 config3; /* extension of config2 */
};

/*
⬢[acme@toolbox perf]$
⬢[acme@toolbox perf]$
⬢[acme@toolbox perf]$
⬢[acme@toolbox perf]$
⬢[acme@toolbox perf]$ git tag --contains 09519ec3b19e4144b5f6e269c54fbb9c294a9fcb
next-20230217
⬢[acme@toolbox perf]$


> ---
> tools/include/uapi/linux/perf_event.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
> index ea6defacc1a7..a38814ce9485 100644
> --- a/tools/include/uapi/linux/perf_event.h
> +++ b/tools/include/uapi/linux/perf_event.h
> @@ -365,6 +365,7 @@ enum perf_event_read_format {
> #define PERF_ATTR_SIZE_VER5 112 /* add: aux_watermark */
> #define PERF_ATTR_SIZE_VER6 120 /* add: aux_sample_size */
> #define PERF_ATTR_SIZE_VER7 128 /* add: sig_data */
> +#define PERF_ATTR_SIZE_VER8 136 /* add: config3 */
>
> /*
> * Hardware event_id to monitor via a performance monitoring event:
> @@ -506,6 +507,8 @@ struct perf_event_attr {
> * truncated accordingly on 32 bit architectures.
> */
> __u64 sig_data;
> +
> + __u64 config3; /* extension of config2 */
> };
>
> /*
>
> --
> 2.39.1
>

2023-02-23 14:24:23

by kajoljain

[permalink] [raw]
Subject: Re: [PATCH v5 1/2] perf tools: Sync perf_event_attr::config3 addition



On 2/18/23 04:02, Rob Herring wrote:
> Arm SPEv1.2 adds another 64-bits of event filtering control. As the
> existing perf_event_attr::configN fields are all used up for SPE PMU, an
> additional field is needed. Add a new 'config3' field.
>
> Signed-off-by: Rob Herring <[email protected]>
> ---
> This matches commit 09519ec3b19e ("perf: Add perf_event_attr::config3")
> for the kernel queued in linux-next.
> ---
> tools/include/uapi/linux/perf_event.h | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/tools/include/uapi/linux/perf_event.h b/tools/include/uapi/linux/perf_event.h
> index ea6defacc1a7..a38814ce9485 100644
> --- a/tools/include/uapi/linux/perf_event.h
> +++ b/tools/include/uapi/linux/perf_event.h
> @@ -365,6 +365,7 @@ enum perf_event_read_format {
> #define PERF_ATTR_SIZE_VER5 112 /* add: aux_watermark */
> #define PERF_ATTR_SIZE_VER6 120 /* add: aux_sample_size */
> #define PERF_ATTR_SIZE_VER7 128 /* add: sig_data */
> +#define PERF_ATTR_SIZE_VER8 136 /* add: config3 */
>
> /*
> * Hardware event_id to monitor via a performance monitoring event:
> @@ -506,6 +507,8 @@ struct perf_event_attr {
> * truncated accordingly on 32 bit architectures.
> */
> __u64 sig_data;
> +
> + __u64 config3; /* extension of config2 */

Patch looks fine to me.

Reviewed-by: Kajol Jain <[email protected]>

Thanks,
Kajol Jain
> };
>
> /*
>

2023-03-20 18:29:22

by Rob Herring (Arm)

[permalink] [raw]
Subject: Re: [PATCH v5 1/2] perf tools: Sync perf_event_attr::config3 addition

On Sat, Feb 18, 2023 at 7:21 AM Arnaldo Carvalho de Melo
<[email protected]> wrote:
>
> Em Fri, Feb 17, 2023 at 04:32:10PM -0600, Rob Herring escreveu:
> > Arm SPEv1.2 adds another 64-bits of event filtering control. As the
> > existing perf_event_attr::configN fields are all used up for SPE PMU, an
> > additional field is needed. Add a new 'config3' field.
> >
> > Signed-off-by: Rob Herring <[email protected]>
> > ---
> > This matches commit 09519ec3b19e ("perf: Add perf_event_attr::config3")
> > for the kernel queued in linux-next.
>
> When you mention linux-next where was it that it picked this from?
>
> For me to get this merged into the perf tools "next" (perf/core) it must
> already have been merged in the kernel counterpart (tip/perf/core).
>
> Ok so it is not in tip/perf/core, but got in next yesterday, and PeterZ
> acked it, good, will process it soon.

Hi Arnaldo, Are you going to apply this or are you expecting something from me?

Rob

2023-03-21 12:44:05

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH v5 1/2] perf tools: Sync perf_event_attr::config3 addition

Em Mon, Mar 20, 2023 at 01:21:10PM -0500, Rob Herring escreveu:
> On Sat, Feb 18, 2023 at 7:21 AM Arnaldo Carvalho de Melo
> <[email protected]> wrote:
> >
> > Em Fri, Feb 17, 2023 at 04:32:10PM -0600, Rob Herring escreveu:
> > > Arm SPEv1.2 adds another 64-bits of event filtering control. As the
> > > existing perf_event_attr::configN fields are all used up for SPE PMU, an
> > > additional field is needed. Add a new 'config3' field.
> > >
> > > Signed-off-by: Rob Herring <[email protected]>
> > > ---
> > > This matches commit 09519ec3b19e ("perf: Add perf_event_attr::config3")
> > > for the kernel queued in linux-next.
> >
> > When you mention linux-next where was it that it picked this from?
> >
> > For me to get this merged into the perf tools "next" (perf/core) it must
> > already have been merged in the kernel counterpart (tip/perf/core).
> >
> > Ok so it is not in tip/perf/core, but got in next yesterday, and PeterZ
> > acked it, good, will process it soon.
>
> Hi Arnaldo, Are you going to apply this or are you expecting something from me?

Sorry for the delay, applied.

- Arnaldo