Missing information in HEADER_CPU_DOMAIN_INFO
Hi Swapnil,
Commit d40c68a49f69 ("perf header: Support CPU DOMAIN relation info") introduced the HEADER_CPU_DOMAIN_INFO bit and the necessary data.
However two issues came to my attention.
1. The documentation is incomplete.
File Documentation/perf.data-file-format.txt differs from the data written in function write_cpu_domain_info().
The first two values written to the header section are schedstat_version and max_sched_domains. They are missing in the documentation.
2. The function write_cpu_domain_info() writes a variable amount of data, but does not indicate how much CPU members have actually been written. This makes it much harder to read back that data from a perf.data file, because the reader does not know in advance how much data to read. Since the data structures also contain strings, the file section size does not help at all, because strings are of variable size.
In my opinion the structure should contain the number of CPU data to read. My suggestion:
Modify structure cpu_domain_info, which contains the
missing schedstat_version and max_sched_domains fields and contains the number of CPU records actually written to that header section. Here is an idea:
HEADER_CPU_DOMAIN_INFO = 32,
List of cpu-domain relation info. The format of the data is as below.
struct domain_info {
int domain;
char dname[];
char cpumask[];
char cpulist[];};
struct cpu_domain_info {
int schedstat_version;
int max_sched_domains;
int nr_cpus; <--- new
struct {
u32 cpu;
u32 nr_domains;
struct domain_info [nr_domains];
} [nr_cpus];};
The above syntax is also in sync the other sections of that documentation file.
What do you think?
Signature · 9 lines
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany -- IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
Hi Thomas,
Thank you for pointing this issues.
Quoted 6 lines · Thomas Richter
Hi Swapnil,
Commit
d40c68a49f69("perf header: Support CPU DOMAIN relation info") introduced theHEADER_CPU_DOMAIN_INFObit and the necessary data.
Quoted 8 lines
However two issues came to my attention.
1. The documentation is incomplete.
FileDocumentation/perf.data-file-format.txtdiffers from the data written in functionwrite_cpu_domain_info().
The first two values written to the header section areschedstat_versionandmax_sched_domains. They are missing in the documentation.
I agree with this. I will update the documentation for the same.
Quoted 36 lines
2. The function
write_cpu_domain_info()writes a variable amount of data, but does not indicate how much CPU members have actually been written. This makes it much harder to read back that data from a perf.data file, because the reader does not know in advance how much data to read. Since the data structures also contain strings, the file section size does not help at all, because strings are of variable size.In my opinion the structure should contain the number of CPU data to read. My suggestion:
Modify structurecpu_domain_info, which contains the
missingschedstat_versionandmax_sched_domainsfields and contains the number of CPU records actually written to that header section. Here is an idea:
HEADER_CPU_DOMAIN_INFO= 32,List of cpu-domain relation info. The format of the data is as below.
struct domain_info { int domain; char dname[]; char cpumask[]; char cpulist[]; }; struct cpu_domain_info { int schedstat_version; int max_sched_domains; int nr_cpus; <--- new struct { u32 cpu; u32 nr_domains; struct domain_info [nr_domains]; } [nr_cpus]; };
Quoted 4 lines
The above syntax is also in sync the other sections of that documentation file.
What do you think?
I agree with you on addition of schedstat_version and max_sched_domains fields to struct cpu_domain_info.
Regarding nr_cpus: since /proc/schedstat only contains stats for online CPUs, the number of CPU stats written equals env->nr_cpus_online. This information is already available via HEADER_NRCPUS, so I didn't include it in cpu_domain_info. Please let me know if I've overlooked something.
--
Thanks and Regards,
Swapnil
Quoted 11 lines
--
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany --
IBM Deutschland Research & Development GmbHVorsitzender des Aufsichtsrats: Wolfgang Wendt
Geschäftsführung: David Faller
Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
Quoted 13 lines · Swapnil Sapkal
Hi Thomas,
Thank you for pointing this issues.
Quoted 8 lines · Thomas Richter
Hi Swapnil,
Commit
d40c68a49f69("perf header: Support CPU DOMAIN relation info") introduced theHEADER_CPU_DOMAIN_INFObit and the necessary data.However two issues came to my attention.
Quoted 8 lines
Quoted 6 lines
1. The documentation is incomplete.
FileDocumentation/perf.data-file-format.txtdiffers from the data written in functionwrite_cpu_domain_info().
The first two values written to the header section areschedstat_versionandmax_sched_domains. They are missing in the documentation.I agree with this. I will update the documentation for the same.
Great Thanks
Quoted 37 lines
Quoted 37 lines
2. The function
write_cpu_domain_info()writes a variable amount of data, but does not indicate how much CPU members have actually been written. This makes it much harder to read back that data from a perf.data file, because the reader does not know in advance how much data to read. Since the data structures also contain strings, the file section size does not help at all, because strings are of variable size.In my opinion the structure should contain the number of CPU data to read. My suggestion:
Modify structurecpu_domain_info, which contains the
missingschedstat_versionandmax_sched_domainsfields and contains the number of CPU records actually written to that header section. Here is an idea:
HEADER_CPU_DOMAIN_INFO= 32,List of cpu-domain relation info. The format of the data is as below.
struct
domain_info{
int domain;
char dname[];
char cpumask[];
char cpulist[];
};struct
cpu_domain_info{
intschedstat_version;
intmax_sched_domains;
int nr_cpus; <--- new
struct {
u32 cpu;
u32nr_domains;
structdomain_info[nr_domains];
} [nr_cpus];
};
Quoted 9 lines
Quoted 4 lines
The above syntax is also in sync the other sections of that documentation file.
What do you think?
I agree with you on addition of
schedstat_versionandmax_sched_domainsfields to structcpu_domain_info.Regarding
nr_cpus: since/proc/schedstatonly contains stats for online CPUs, the number of CPU stats written equalsenv->nr_cpus_online. This information is already available viaHEADER_NRCPUS, so I didn't include it incpu_domain_info. Please let me know if I've overlooked something.
Ah, now I get it. This is fine with me but should be mentioned in the documentation as well. See header feature HEADER_CPU_TOPOLOGY documentation.
There is a similar situation and is expained in the comment:
struct {
uint32_t core_id;
uint32_t socket_id;
} cpus[nr]; /* Variable length records */
/* 'nr' comes from previously processed HEADER_NRCPUS's nr_cpu_avail */ <--- hereSo the reader is aware of the cross reference and what value to use when reading the feature file section.
Quoted 4 lines
Signature · 2 lines
Thanks and Regards, Swapnil
Thanks.
Signature · 9 lines
Thomas Richter, Dept 3303, IBM s390 Linux Development, Boeblingen, Germany -- IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Wolfgang Wendt Geschäftsführung: David Faller Sitz der Gesellschaft: Böblingen / Registergericht: Amtsgericht Stuttgart, HRB 243294
Hi Thomas,
Quoted 67 lines · Thomas Richter
Quoted 13 lines · Swapnil Sapkal
Hi Thomas,
Thank you for pointing this issues.
Quoted 8 lines · Thomas Richter
Hi Swapnil,
Commit
d40c68a49f69("perf header: Support CPU DOMAIN relation info") introduced theHEADER_CPU_DOMAIN_INFObit and the necessary data.However two issues came to my attention.
Quoted 8 lines
Quoted 6 lines
1. The documentation is incomplete.
FileDocumentation/perf.data-file-format.txtdiffers from the data written in functionwrite_cpu_domain_info().
The first two values written to the header section areschedstat_versionandmax_sched_domains. They are missing in the documentation.I agree with this. I will update the documentation for the same.
Great Thanks
Quoted 42 lines
Quoted 41 lines
2. The function
write_cpu_domain_info()writes a variable amount of data, but does not indicate how much CPU members have actually been written. This makes it much harder to read back that data from a perf.data file, because the reader does not know in advance how much data to read. Since the data structures also contain strings, the file section size does not help at all, because strings are of variable size.In my opinion the structure should contain the number of CPU data to read. My suggestion:
Modify structurecpu_domain_info, which contains the
missingschedstat_versionandmax_sched_domainsfields and contains the number of CPU records actually written to that header section. Here is an idea:
HEADER_CPU_DOMAIN_INFO= 32,List of cpu-domain relation info. The format of the data is as below.
struct
domain_info{
int domain;
char dname[];
char cpumask[];
char cpulist[];
};struct
cpu_domain_info{
intschedstat_version;
intmax_sched_domains;
int nr_cpus; <--- new struct {
u32 cpu;
u32nr_domains;
structdomain_info[nr_domains]; } [nr_cpus];
};The above syntax is also in sync the other sections of that documentation file.
What do you think?
Quoted 6 lines
Quoted 4 lines
I agree with you on addition of
schedstat_versionandmax_sched_domainsfields to structcpu_domain_info.Regarding
nr_cpus: since/proc/schedstatonly contains stats for online CPUs, the number of CPU stats written equalsenv->nr_cpus_online. This information is already available viaHEADER_NRCPUS, so I didn't include it incpu_domain_info. Please let me know if I've overlooked something.Ah, now I get it. This is fine with me but should be mentioned in the documentation as well.
Sure, I will modify the documenation accordingly.
Quoted 10 lines
See header feature
HEADER_CPU_TOPOLOGYdocumentation. There is a similar situation and is expained in the comment:struct { uint32_t core_id; uint32_t socket_id; } cpus[nr]; /* Variable length records */ /* 'nr' comes from previously processed HEADER_NRCPUS's nr_cpu_avail */ <--- hereSo the reader is aware of the cross reference and what value to use when reading the feature file section.
I appreciate you bringing that to my attention.
Quoted 10 lines
Quoted 5 lines
Signature · 3 lines
-- Thanks and Regards, SwapnilThanks.
--
Thanks and Regards,
Swapnil