From: German Gomez <hidden> Date: 2021-12-15 18:46:18
Synthesize instruction events per every decoded ARM SPE record.
Because Arm SPE implements a hardware-based sample period, and perf
implements a software-based one that gets applied on top, also add a
warning to make the user aware.
Signed-off-by: German Gomez <redacted>
---
Changes since v1 [https://lore.kernel.org/all/20211117142833.226629-1-german.gomez@arm.com]
- Generate events with "--itrace=i" instead of "--itrace=o".
- Generate events with virt_addr, phys_addr, and data_src values.
---
tools/perf/util/arm-spe.c | 58 +++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
@@ -480,6 +512,12 @@ static int arm_spe_sample(struct arm_spe_queue *speq)returnerr;}+if(spe->sample_instructions){+err=arm_spe__synth_instruction_sample(speq,spe->instructions_id,data_src);+if(err)+returnerr;+}+return0;}
@@ -1107,6 +1145,26 @@ arm_spe_synth_events(struct arm_spe *spe, struct perf_session *session)returnerr;spe->memory_id=id;arm_spe_set_event_name(evlist,id,"memory");+id+=1;+}++if(spe->synth_opts.instructions){+if(spe->synth_opts.period_type!=PERF_ITRACE_PERIOD_INSTRUCTIONS)+return-EINVAL;++if(spe->synth_opts.period>1)+pr_warning("Arm SPE has a hardware-based sample period.\n"+"More instruction events will be discarded by --itrace\n");++spe->sample_instructions=true;+attr.config=PERF_COUNT_HW_INSTRUCTIONS;+attr.sample_period=spe->synth_opts.period;+spe->instructions_sample_period=attr.sample_period;+err=arm_spe_synth_event(session,&attr,id);+if(err)+returnerr;+spe->instructions_id=id;+arm_spe_set_event_name(evlist,id,"instructions");}return0;
--
2.25.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
From: Namhyung Kim <namhyung@kernel.org> Date: 2021-12-16 01:19:08
Hello,
On Wed, Dec 15, 2021 at 10:46 AM German Gomez [off-list ref] wrote:
quoted hunk
Synthesize instruction events per every decoded ARM SPE record.
Because Arm SPE implements a hardware-based sample period, and perf
implements a software-based one that gets applied on top, also add a
warning to make the user aware.
Signed-off-by: German Gomez <redacted>
---
Changes since v1 [https://lore.kernel.org/all/20211117142833.226629-1-german.gomez@arm.com]
- Generate events with "--itrace=i" instead of "--itrace=o".
- Generate events with virt_addr, phys_addr, and data_src values.
---
tools/perf/util/arm-spe.c | 58 +++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
From: German Gomez <hidden> Date: 2021-12-16 11:12:01
Hi Namhyung, thanks for your comments.
On 16/12/2021 01:18, Namhyung Kim wrote:
Hello,
On Wed, Dec 15, 2021 at 10:46 AM German Gomez [off-list ref] wrote:
quoted
Synthesize instruction events per every decoded ARM SPE record.
Because Arm SPE implements a hardware-based sample period, and perf
implements a software-based one that gets applied on top, also add a
warning to make the user aware.
Signed-off-by: German Gomez <redacted>
---
Changes since v1 [https://lore.kernel.org/all/20211117142833.226629-1-german.gomez@arm.com]
- Generate events with "--itrace=i" instead of "--itrace=o".
- Generate events with virt_addr, phys_addr, and data_src values.
---
tools/perf/util/arm-spe.c | 58 +++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
Hi German,
On Wed, Dec 15, 2021 at 06:46:05PM +0000, German Gomez wrote:
quoted hunk
Synthesize instruction events per every decoded ARM SPE record.
Because Arm SPE implements a hardware-based sample period, and perf
implements a software-based one that gets applied on top, also add a
warning to make the user aware.
Signed-off-by: German Gomez <redacted>
---
Changes since v1 [https://lore.kernel.org/all/20211117142833.226629-1-german.gomez@arm.com]
- Generate events with "--itrace=i" instead of "--itrace=o".
- Generate events with virt_addr, phys_addr, and data_src values.
---
tools/perf/util/arm-spe.c | 58 +++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
Will this break some perf commands, like "perf report" or other perf
report commands?
See the the function arm_spe_process_auxtrace_info(), it invokes [1]:
itrace_synth_opts__set_default(&spe->synth_opts, false);
So synth_opts.instructions is initialized to true,
synth_opts.period_type is set to PERF_ITRACE_DEFAULT_PERIOD_TYPE (2),
so the perf tool will directly bail out when synth_opts.period_type is
not equal to PERF_ITRACE_PERIOD_INSTRUCTIONS.
If we only support period type PERF_ITRACE_PERIOD_INSTRUCTIONS at
current stage, I think we use the checking like below:
if (spe->synth_opts.instructions &&
(spe->synth_opts.period_type == PERF_ITRACE_PERIOD_INSTRUCTIONS)) {
...
}
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/util/arm-spe.c#n1180
+
+ if (spe->synth_opts.period > 1)
+ pr_warning("Arm SPE has a hardware-based sample period.\n"
+ "More instruction events will be discarded by --itrace\n");
Okay, Since Arm SPE is statistical profiling, so this is the right thing to
do.
Please also address Namhyung's two comments, the rest of this patch looks
good to me.
Thanks,
Leo
From: German Gomez <hidden> Date: 2021-12-16 15:00:42
Hi Leo,
Thanks for your comments. I'll send a revised patch shortly.
Thanks,
German
On 16/12/2021 11:11, Leo Yan wrote:
Hi German,
On Wed, Dec 15, 2021 at 06:46:05PM +0000, German Gomez wrote:
quoted
Synthesize instruction events per every decoded ARM SPE record.
Because Arm SPE implements a hardware-based sample period, and perf
implements a software-based one that gets applied on top, also add a
warning to make the user aware.
Signed-off-by: German Gomez <redacted>
---
Changes since v1 [https://lore.kernel.org/all/20211117142833.226629-1-german.gomez@arm.com]
- Generate events with "--itrace=i" instead of "--itrace=o".
- Generate events with virt_addr, phys_addr, and data_src values.
---
tools/perf/util/arm-spe.c | 58 +++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
Will this break some perf commands, like "perf report" or other perf
report commands?
See the the function arm_spe_process_auxtrace_info(), it invokes [1]:
itrace_synth_opts__set_default(&spe->synth_opts, false);
So synth_opts.instructions is initialized to true,
synth_opts.period_type is set to PERF_ITRACE_DEFAULT_PERIOD_TYPE (2),
so the perf tool will directly bail out when synth_opts.period_type is
not equal to PERF_ITRACE_PERIOD_INSTRUCTIONS.
If we only support period type PERF_ITRACE_PERIOD_INSTRUCTIONS at
current stage, I think we use the checking like below:
if (spe->synth_opts.instructions &&
(spe->synth_opts.period_type == PERF_ITRACE_PERIOD_INSTRUCTIONS)) {
...
}
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/util/arm-spe.c#n1180
quoted
+
+ if (spe->synth_opts.period > 1)
+ pr_warning("Arm SPE has a hardware-based sample period.\n"
+ "More instruction events will be discarded by --itrace\n");
Okay, Since Arm SPE is statistical profiling, so this is the right thing to
do.
Please also address Namhyung's two comments, the rest of this patch looks
good to me.
Thanks,
Leo