perf metrics: Avoid segv if default metricgroup isn't set
Subsystems (2)
Ian Rogers
reviewerPATCH 1/2 perf metrics: Avoid segv if default metricgroup isn't set
A metric is default by having "Default" within its groups. The default metricgroup name needn't be set and this can result in segv in default_metricgroup_cmp and perf_stat__print_shadow_stats_metricgroup that assume it has a value when there is a Default metric group. To avoid the segv initialize the value to "".
--- tools/perf/util/metricgroup.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/metricgroup.c +1 -1
@@ -225,7 +225,7 @@ static struct metric *metric__new(const struct pmu_metric *pm, m->pmu = pm->pmu ?:"cpu" ; m->metric_name = pm->metric_name; - m->default_metricgroup_name = pm->default_metricgroup_name; + m->default_metricgroup_name = pm->default_metricgroup_name ?:"" ; m->modifier =NULL ;if (modifier) { m->modifier =strdup (modifier);
Signature · 1 line
2.43.0.rc2.451.g8631bc7472-goog
Ian Rogers
reviewerPATCH 2/2 perf vendor events arm64: Fix default AmpereOne metrics
Add default metric group name for TopdownL1 metrics.
--- tools/perf/pmu-events/arch/arm64/ampere/ampereone/metrics.json | 2 ++ 1 file changed, 2 insertions(+)
tools/perf/pmu-events/arch/arm64/ampere/ampereone/metrics.json +2 -0
@@ -231,6 +231,7 @@ "MetricName": "slots_lost_misspeculation_fraction", "MetricExpr": "100 * ((OP_SPEC - OP_RETIRED) / (CPU_CYCLES * #slots))", "BriefDescription": "Fraction of slots lost due to misspeculation", + "DefaultMetricgroupName": "TopdownL1", "MetricGroup": "Default;TopdownL1", "ScaleUnit": "1percent of slots" },
@@ -238,6 +239,7 @@ "MetricName": "retired_fraction", "MetricExpr": "100 * (OP_RETIRED / (CPU_CYCLES * #slots))", "BriefDescription": "Fraction of slots retiring, useful work", + "DefaultMetricgroupName": "TopdownL1", "MetricGroup": "Default;TopdownL1", "ScaleUnit": "1percent of slots" },
Signature · 1 line
2.43.0.rc2.451.g8631bc7472-goog
Quoted 8 lines · Ian Rogers
A metric is default by having "Default" within its groups. The default metricgroup name needn't be set and this can result in segv in
default_metricgroup_cmpandperf_stat__print_shadow_stats_metricgroupthat assume it has a value when there is a Default metric group. To avoid the segv initialize the value to "".Fixes 1c0e47956a8e ("perf metrics: Sort the Default metricgroup")Signed-off-by Ian Rogers <[email protected]>
Thanks! I was going to look for the bug but got pulled to other tasks. The patch looks good to me and I tested it successfully on AmpereOne.
Cheers, Ilkka
Quoted 21 lines
---
tools/perf/util/metricgroup.c| 2 +-1 file changed, 1 insertion(+), 1 deletion(-)tools/perf/util/metricgroup.c +1
-1@@ -225,7 +225,7 @@ static struct metric *metric__new(const struct pmu_metric *pm, m->pmu = pm->pmu ?:"cpu" ; m->metric_name = pm->metric_name; - m->default_metricgroup_name = pm->default_metricgroup_name; + m->default_metricgroup_name = pm->default_metricgroup_name ?:"" ; m->modifier =NULL ;if (modifier) { m->modifier =strdup (modifier);Signature · 1 line
2.43.0.rc2.451.g8631bc7472-goog
Namhyung Kim
maintainerHello,
Quoted 10 lines · Ilkka Koskinen
Quoted 6 lines · Ian Rogers
A metric is default by having "Default" within its groups. The default metricgroup name needn't be set and this can result in segv in
default_metricgroup_cmpandperf_stat__print_shadow_stats_metricgroupthat assume it has a value when there is a Default metric group. To avoid the segv initialize the value to "".
Quoted 8 lines
Quoted 2 lines
Fixes 1c0e47956a8e ("perf metrics: Sort the Default metricgroup")Signed-off-by Ian Rogers <[email protected]>Thanks! I was going to look for the bug but got pulled to other tasks. The patch looks good to me and I tested it successfully on AmpereOne.
Reviewed-and-tested-by Ilkka Koskinen <[email protected]>
Looks like it needs to go through perf-tools for v6.7. Ian, do you think this one is enough?
Thanks,
Namhyung
Ian Rogers
reviewerQuoted 18 lines · Namhyung Kim
Hello,
Quoted 13 lines · Ilkka Koskinen
Quoted 8 lines · Ian Rogers
A metric is default by having "Default" within its groups. The default metricgroup name needn't be set and this can result in segv in
default_metricgroup_cmpandperf_stat__print_shadow_stats_metricgroupthat assume it has a value when there is a Default metric group. To avoid the segv initialize the value to "".Fixes 1c0e47956a8e ("perf metrics: Sort the Default metricgroup")Signed-off-by Ian Rogers <[email protected]>
Quoted 8 lines
Quoted 5 lines
Thanks! I was going to look for the bug but got pulled to other tasks. The patch looks good to me and I tested it successfully on AmpereOne.
Reviewed-and-tested-by Ilkka Koskinen <[email protected]>Looks like it needs to go through perf-tools for v6.7. Ian, do you think this one is enough?
From a user's pov the json fix is nicer as otherwise perf stat output for the relevant metrics lacks a heading on the left. This fix is smaller. I'm easy about which to take :-)
Thanks,
Ian
Quoted 2 lines
Thanks,
Namhyung
Arnaldo Carvalho de Melo
maintainerEm Mon, Dec 04, 2023 at 07:33:18PM -0800, Namhyung Kim escreveu:
Quoted 11 lines · Ilkka Koskinen
Quoted 9 lines · Ian Rogers
Quoted 8 lines
A metric is default by having "Default" within its groups. The default metricgroup name needn't be set and this can result in segv in
default_metricgroup_cmpandperf_stat__print_shadow_stats_metricgroupthat assume it has a value when there is a Default metric group. To avoid the segv initialize the value to "".Fixes 1c0e47956a8e ("perf metrics: Sort the Default metricgroup")Signed-off-by Ian Rogers <[email protected]>
Quoted 8 lines
Quoted 5 lines
Thanks! I was going to look for the bug but got pulled to other tasks. The patch looks good to me and I tested it successfully on AmpereOne.
Reviewed-and-tested-by Ilkka Koskinen <[email protected]>Looks like it needs to go through perf-tools for v6.7. Ian, do you think this one is enough?
So I had this on my local perf-tools-next, removed now, I also have some other fixes by Ian on the tmp.perf-tools-next, please let me know what you guys decide to have in perf-tools for v6.7 so that I can remove it from there.
- Arnaldo
Namhyung Kim
maintainerHi Arnaldo,
Quoted 19 lines · Arnaldo Carvalho de Melo
Em Mon, Dec 04, 2023 at 07:33:18PM -0800, Namhyung Kim escreveu:
Quoted 16 lines · Ilkka Koskinen
Quoted 15 lines · Ian Rogers
Quoted 8 lines
A metric is default by having "Default" within its groups. The default metricgroup name needn't be set and this can result in segv in
default_metricgroup_cmpandperf_stat__print_shadow_stats_metricgroupthat assume it has a value when there is a Default metric group. To avoid the segv initialize the value to "".Fixes 1c0e47956a8e ("perf metrics: Sort the Default metricgroup")Signed-off-by Ian Rogers <[email protected]>Thanks! I was going to look for the bug but got pulled to other tasks. The patch looks good to me and I tested it successfully on AmpereOne.
Reviewed-and-tested-by Ilkka Koskinen <[email protected]>
Quoted 7 lines
Quoted 2 lines
Looks like it needs to go through perf-tools for v6.7. Ian, do you think this one is enough?
So I had this on my local perf-tools-next, removed now, I also have some other fixes by Ian on the tmp.perf-tools-next, please let me know what you guys decide to have in perf-tools for v6.7 so that I can remove it from there.
I think we need this one and the Ampere default-metric-group fix.
https://lore.kernel.org/r/[email protected]/
Also perf list JSON fix can go to v6.7.
https://lore.kernel.org/r/[email protected]/
Thanks,
Namhyung
Arnaldo Carvalho de Melo
maintainerEm Tue, Dec 05, 2023 at 09:24:42AM -0800, Namhyung Kim escreveu:
Quoted 30 lines
Hi Arnaldo,
Quoted 19 lines · Arnaldo Carvalho de Melo
Em Mon, Dec 04, 2023 at 07:33:18PM -0800, Namhyung Kim escreveu:
Quoted 16 lines · Ilkka Koskinen
Quoted 15 lines · Ian Rogers
Quoted 8 lines
A metric is default by having "Default" within its groups. The default metricgroup name needn't be set and this can result in segv in
default_metricgroup_cmpandperf_stat__print_shadow_stats_metricgroupthat assume it has a value when there is a Default metric group. To avoid the segv initialize the value to "".Fixes 1c0e47956a8e ("perf metrics: Sort the Default metricgroup")Signed-off-by Ian Rogers <[email protected]>Thanks! I was going to look for the bug but got pulled to other tasks. The patch looks good to me and I tested it successfully on AmpereOne.
Reviewed-and-tested-by Ilkka Koskinen <[email protected]>Quoted 7 lines
Quoted 2 lines
Looks like it needs to go through perf-tools for v6.7. Ian, do you think this one is enough?
So I had this on my local perf-tools-next, removed now, I also have some other fixes by Ian on the tmp.perf-tools-next, please let me know what you guys decide to have in perf-tools for v6.7 so that I can remove it from there.
Quoted 7 lines
I think we need this one and the Ampere default-metric-group fix.
https://lore.kernel.org/r/[email protected]/
Also perf list JSON fix can go to v6.7.
Ok, removed both, please augment the later description to:
"perf list: Fix JSON segfault by setting the used skip_fuplicate_pmus callback"
The original description was vague, improving it a bit like that helps when just looking at the output of "git log --oneline".
Thanks,
- Arnaldo
Namhyung Kim
maintainerQuoted 38 lines · Arnaldo Carvalho de Melo
Em Tue, Dec 05, 2023 at 09:24:42AM -0800, Namhyung Kim escreveu:
Quoted 36 lines
Hi Arnaldo,
Quoted 19 lines · Arnaldo Carvalho de Melo
Em Mon, Dec 04, 2023 at 07:33:18PM -0800, Namhyung Kim escreveu:
Quoted 16 lines · Ilkka Koskinen
Quoted 15 lines · Ian Rogers
Quoted 8 lines
A metric is default by having "Default" within its groups. The default metricgroup name needn't be set and this can result in segv in
default_metricgroup_cmpandperf_stat__print_shadow_stats_metricgroupthat assume it has a value when there is a Default metric group. To avoid the segv initialize the value to "".Fixes 1c0e47956a8e ("perf metrics: Sort the Default metricgroup")Signed-off-by Ian Rogers <[email protected]>Thanks! I was going to look for the bug but got pulled to other tasks. The patch looks good to me and I tested it successfully on AmpereOne.
Reviewed-and-tested-by Ilkka Koskinen <[email protected]>Quoted 7 lines
Quoted 2 lines
Looks like it needs to go through perf-tools for v6.7. Ian, do you think this one is enough?
So I had this on my local perf-tools-next, removed now, I also have some other fixes by Ian on the tmp.perf-tools-next, please let me know what you guys decide to have in perf-tools for v6.7 so that I can remove it from there.
I think we need this one and the Ampere default-metric-group fix.
https://lore.kernel.org/r/[email protected]/
Also perf list JSON fix can go to v6.7.
Quoted 8 lines
Quoted 1 line
Ok, removed both, please augment the later description to:
"perf list: Fix JSON segfault by setting the used
skip_fuplicate_pmuscallback"The original description was vague, improving it a bit like that helps when just looking at the output of "git log --oneline".
Done and pushed to tmp.perf-tools!
Thanks,
Namhyung
Ian Rogers
reviewerQuoted 43 lines · Namhyung Kim
Quoted 40 lines · Arnaldo Carvalho de Melo
Em Tue, Dec 05, 2023 at 09:24:42AM -0800, Namhyung Kim escreveu:
Quoted 37 lines
Hi Arnaldo,
Quoted 19 lines · Arnaldo Carvalho de Melo
Em Mon, Dec 04, 2023 at 07:33:18PM -0800, Namhyung Kim escreveu:
Quoted 16 lines · Ilkka Koskinen
Quoted 15 lines · Ian Rogers
Quoted 8 lines
A metric is default by having "Default" within its groups. The default metricgroup name needn't be set and this can result in segv in
default_metricgroup_cmpandperf_stat__print_shadow_stats_metricgroupthat assume it has a value when there is a Default metric group. To avoid the segv initialize the value to "".Fixes 1c0e47956a8e ("perf metrics: Sort the Default metricgroup")Signed-off-by Ian Rogers <[email protected]>Thanks! I was going to look for the bug but got pulled to other tasks. The patch looks good to me and I tested it successfully on AmpereOne.
Reviewed-and-tested-by Ilkka Koskinen <[email protected]>Quoted 7 lines
Quoted 2 lines
Looks like it needs to go through perf-tools for v6.7. Ian, do you think this one is enough?
So I had this on my local perf-tools-next, removed now, I also have some other fixes by Ian on the tmp.perf-tools-next, please let me know what you guys decide to have in perf-tools for v6.7 so that I can remove it from there.
I think we need this one and the Ampere default-metric-group fix.
https://lore.kernel.org/r/[email protected]/
Also perf list JSON fix can go to v6.7.
Quoted 8 lines
Quoted 6 lines
Ok, removed both, please augment the later description to:
"perf list: Fix JSON segfault by setting the used
skip_fuplicate_pmuscallback"The original description was vague, improving it a bit like that helps when just looking at the output of "git log --oneline".
Done and pushed to tmp.perf-tools!
Thanks Namhyung, there was a typo in Arnaldo's commit message "s/fuplicate/duplicate/" could you fix?
Ian
Quoted 2 lines
Thanks,
Namhyung
Namhyung Kim
maintainerQuoted 8 lines · Ian Rogers
Quoted 6 lines · Namhyung Kim
Quoted 2 lines · Arnaldo Carvalho de Melo
"perf list: Fix JSON segfault by setting the used
skip_fuplicate_pmuscallback"
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
The original description was vague, improving it a bit like that helps when just looking at the output of "git log --oneline".
Done and pushed to tmp.perf-tools!
Thanks Namhyung, there was a typo in Arnaldo's commit message "s/fuplicate/duplicate/" could you fix?
Oops, fixed now. Thanks for checking.
Namhyung
Em Mon, Dec 04, 2023 at 02:44:54PM -0800, Ilkka Koskinen escreveu:
Quoted 9 lines · Ian Rogers
Quoted 6 lines
A metric is default by having "Default" within its groups. The default metricgroup name needn't be set and this can result in segv in
default_metricgroup_cmpandperf_stat__print_shadow_stats_metricgroupthat assume it has a value when there is a Default metric group. To avoid the segv initialize the value to "".
Quoted 7 lines
Quoted 2 lines
Fixes 1c0e47956a8e ("perf metrics: Sort the Default metricgroup")Signed-off-by Ian Rogers <[email protected]>Thanks! I was going to look for the bug but got pulled to other tasks. The patch looks good to me and I tested it successfully on AmpereOne.
Reviewed-and-tested-by Ilkka Koskinen <[email protected]>
Thanks, applied to perf-tools-next.
- Arnaldo