Skip to content

Commit 1bd2d1f

Browse files
author
CKI KWF Bot
committed
Merge: tools/power turbostat: Fix incorrect sorting of PMT telemetry
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/7605 JIRA: https://issues.redhat.com/browse/RHEL-127415 commit cafb47b Author: Kaushlendra Kumar <kaushlendra.kumar@intel.com> Date: Sat Aug 9 10:35:15 2025 +0530 tools/power turbostat: Fix incorrect sorting of PMT telemetry The pmt_telemdir_sort() comparison function was returning a boolean value (0 or 1) instead of the required negative, zero, or positive value for proper sorting. This caused unpredictable and incorrect ordering of telemetry directories named telem0, telem1, ..., telemN. Update the comparison logic to return -1, 0, or 1 based on the numerical value extracted from the directory name, ensuring correct numerical ordering when using scandir. This change improves stability and correctness when iterating PMT telemetry directories. Signed-off-by: Kaushlendra Kumar <kaushlendra.kumar@intel.com> Signed-off-by: Len Brown <len.brown@intel.com> (cherry picked from commit cafb47b) Assisted-by: Patchpal Signed-off-by: David Arcari <darcari@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 80fca0b + 547e9e2 commit 1bd2d1f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/power/x86/turbostat/turbostat.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1890,7 +1890,7 @@ int pmt_telemdir_sort(const struct dirent **a, const struct dirent **b)
18901890
sscanf((*a)->d_name, "telem%u", &aidx);
18911891
sscanf((*b)->d_name, "telem%u", &bidx);
18921892

1893-
return aidx >= bidx;
1893+
return (aidx > bidx) ? 1 : (aidx < bidx) ? -1 : 0;
18941894
}
18951895

18961896
const struct dirent *pmt_diriter_next(struct pmt_diriter_t *iter)

0 commit comments

Comments
 (0)