Re: [PATCH v2 6/8] perf header: Parse non-cpu pmu capabilities

Ravi Bangoria
2022-05-16T13:47:29Z

On 16-May-22 6:58 PM, Arnaldo Carvalho de Melo wrote:
> Em Mon, May 09, 2022 at 10:19:12AM +0530, Ravi Bangoria escreveu:
>> Pmus advertise their capabilities via sysfs attribute files but
>> perf tool currently parses only core(cpu) pmu capabilities. Add
>> support for parsing non-cpu pmu capabilities.
>>
>> Signed-off-by: Ravi Bangoria <ravi.bangoria@amd.com>
>> ---
>> .../Documentation/perf.data-file-format.txt | 18 ++
>> tools/perf/util/env.c | 48 +++-
>> tools/perf/util/env.h | 11 +
>> tools/perf/util/header.c | 211 ++++++++++++++++++
>> tools/perf/util/header.h | 1 +
>> tools/perf/util/pmu.c | 15 +-
>> tools/perf/util/pmu.h | 2 +
>> 7 files changed, 301 insertions(+), 5 deletions(-)
>>
>> diff --git a/tools/perf/Documentation/perf.data-file-format.txt b/tools/perf/Documentation/perf.data-file-format.txt
>> index f56d0e0fbff6..dea3acb36558 100644
>> --- a/tools/perf/Documentation/perf.data-file-format.txt
>> +++ b/tools/perf/Documentation/perf.data-file-format.txt
>> @@ -435,6 +435,24 @@ struct {
>> } [nr_pmu];
>> };
>>
>> + HEADER_PMU_CAPS = 32,
>> +
>> + List of pmu capabilities (except cpu pmu which is already
>> + covered by HEADER_CPU_PMU_CAPS)
>> +
>> +struct {
>> + u32 nr_pmus;
>> + struct {
>> + u8 core_type; /* For hybrid topology */
>
> Humm, I'd say use u32 here and..
>
>> + char pmu_name[];
>> + u16 nr_caps;
>
> Here, no need to save space here, I guess.

Yeah I know it's not a biggie but fwiw I thoughtfully allocated space.
256 types should be more than enough for core_type. Similarly no real
pmu will have more than 65,536 capabilities :)

Anyway, will convert them to u32.

Thanks,
Ravi