tools/power turbostat: Add PMT directory iterator helper
authorPatryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Thu, 12 Dec 2024 17:59:25 +0000 (18:59 +0100)
committerLen Brown <len.brown@intel.com>
Mon, 27 Jan 2025 17:35:22 +0000 (11:35 -0600)
commit4265a86582eaa224d171328be0c71e2a7ccd194f
treef53be7f4cde9f74c8f063467958b74a43408508c
parent089134cb0502ba962bce9402ce96e0875876d401
tools/power turbostat: Add PMT directory iterator helper

PMT directories exposed in sysfs use the following pattern:
  telem%u
for example:
  telem0, telem2, telem3, ..., telem15, telem16

This naming scheme preserves the ordering from the PCIe discovery, which
is important to correctly map the telemetry directory to the specific
domain (cpu, core, package etc).

Because readdir() traverses the entries in alphabetical order, causing
for example "telem13" to be traversed before "telem3", it is necessary
to use scandir() with custom compare() callback to preserve the PCIe
ordering.

Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
tools/power/x86/turbostat/turbostat.c