Re: [PATCH v3 11/21] perf auxtrace: Set default period to 1 for PERF_ITRACE_PERIOD_INSTRUCTIONS type
From: Tengda Wu
Date: Wed Jul 22 2026 - 03:06:50 EST
On 2026/7/22 14:32, Adrian Hunter wrote:
> On 21/07/2026 14:39, Tengda Wu wrote:
>> Hi Adrian,
>>
>> On 2026/7/21 16:08, Adrian Hunter wrote:
>>> On 01/07/2026 06:53, Tengda Wu wrote:
>>>> When using --itrace=M for data type profiling on arm64, the 'Percent'
>>>> values in perf annotate output are all zero:
>>>>
>>>> Annotate type: 'struct mmu_gather_batch' in [kernel.kallsyms] (15 samples):
>>>> ============================================================================
>>>> Percent offset size field
>>>> 0.00 0 0x10 struct mmu_gather_batch {
>>>> 0.00 0 0x8 struct mmu_gather_batch* next;
>>>> 0.00 0x8 0x4 unsigned int nr;
>>>> 0.00 0xc 0x4 unsigned int max;
>>>> 0.00 0x10 0 struct encoded_page*[] encoded_pages;
>>>> };
>>>>
>>>> However, adding the -n option reveals non-zero sample counts:
>>>>
>>>> Annotate type: 'struct mmu_gather_batch' in [kernel.kallsyms] (15 samples):
>>>> ============================================================================
>>>> Samples offset size field
>>>> 15 0 0x10 struct mmu_gather_batch {
>>>> 13 0 0x8 struct mmu_gather_batch* next;
>>>> 2 0x8 0x4 unsigned int nr;
>>>> 0 0xc 0x4 unsigned int max;
>>>> 0 0x10 0 struct encoded_page*[] encoded_pages;
>>>> };
>>>>
>>>> The root cause is that when period is not explicitly specified in the
>>>> --itrace option, it remains zero after itrace_do_parse_synth_opts().
>>>> The zero period then flows through annotated_data_type__update_samples()
>>>> where h->period accumulates to zero, and print_annotated_data_type_value()
>>>> calculates the 'Percent' as zero.
>>>
>>> The period is for instructions samples i.e. options 'i' or 'y'. Why is
>>> it being used in the 'M' case? What samples are being synthesized in
>>> that case?
>>>
>>
>> The 'M' case is just one example. On arm64, 't' and 'f' also have the
>> same percent-zero issue.
>>
>> How ARM SPE synthesizes events:
>>
>> ARM SPE can synthesize multiple event types from a single instruction.
>> For example, the 'M' case targets instructions that cause memory
>> interaction events, while the 't' case targets instructions that trigger
>> TLB access/miss events. Users can specify the desired event types via
>> the itrace option to obtain corresponding data type profiling results.
>>
>> How data type computes Percent:
>>
>> Data type profiling computes Percent based on the period. The flow is as
>> follows:
>>
>> arm_spe_prep_sample():
>> sample->period = spe->synth_opts.period;
>
> It seems like only arm-spe has the unusual period handling.
> Please make the period non-zero when it is set up in
> arm_spe_process_auxtrace_info() and add a comment explaining why.
>
Okay, I'll handle it this way.
Thanks,
Tengda