2013/12/2 Ingo Weinhold <ingo_weinhold@xxxxxx>: > On 12/01/2013 10:00 PM, Pawel Dziepak wrote: >> typedef struct { >> bigtime_t active_time; >> } cpu_statistics; > > > Topology and current state info could be added. If easily available, the > current load factor as well. The problem with the topology is that we really don't want to introduce any bound on number of topology levels. Perhaps, a separate function like that would be a better solution: status_t get_cpu_topology_ids(uint32 cpu, uint32* topologyIDs, uint32* topologyLevelCount); Where topologyIDs is an array of CPU IDs at each level (starting from SMT), if the ID of two logical CPUs are equal at a certain level then these processors belong to the same unit this level represent. Also, something similar could be done to present cache information (i.e. size of a cache at each level and which CPUs share a given level of cache). Actually, if the application knew the initial APIC ID it would be able to obtain this information without the kernel's help. However, since a syscall is necessary to map processor IDs used by the system to a initial IDs, the kernel could as well present all topology information, especially, since it is a bit tricky to get from CPU and the kernel already has it processed and ready. >> #define get_system_statistics(stat) _get_system_statistics(stat, >> sizeof(*stat)) >> >> status_t _get_system_statistics(system_statistics* stat, size_t size); >> >> #define get_cpu_statistics(firstCPU, cpuCount, stat) >> _get_cpu_statistics(firstCPU, cpuCount, stat, sizeof(*stat)) >> >> status_t _get_system_statistics(int32 firstCPU, int32 cpuCount, >> cpu_statistics* stat, size_t elementSize); >> >> system_statistics is basically current system_info with both >> problematic and obsolete fileds removed. get_cpu_statistics() allow to >> obtain statistics of several logical processors using just one system >> call. Macros ensure that both system_statistics and cpu_statistics can >> be extended without breaking ABI (_get_cpu_statistics() expects stat >> to point to a buffer of size cpuCount * elementSize). > > > The macros won't be necessary. The same can be achieved with ELF symbol > versioning (also allowing reordering of fields). In fact we wouldn't even > need to introduce new structure/function names, but could just continue to > use system_info/cpu_info/get_system_info(). The advantage is that in many > use cases of get_system_info() the code wouldn't even need to be adjusted > (the change of signedness of most fields may cause some warnings, though). I haven't thought about that. That would keep things neater. I don't think the change of signedness would cause much trouble. The only field that an application may compare against while iterating is cpu_count, but any code using that has to be changed anyway due to the removal of system_info::cpu_infos. Paweł