summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatryk Wlazlyn <patryk.wlazlyn@linux.intel.com>2024-12-20 13:38:34 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-08 09:58:09 +0100
commitd562d14f1b11f669eda2e503b1a5bc201ae3c8a3 (patch)
tree8a035c5635b06e9ff63ba8e44f2f85c37abd55c5
parentcd89d5745a180c27b1fdda674835a9d3a9675f0a (diff)
tools/power turbostat: Fix PMT mmaped file size rounding
[ Upstream commit 2f60f03934a50bc1fb69bb4f47a25cddd6807b0b ] This (the old code) is just not how you round up to a page size. Noticed on a recent Intel platform. Previous ones must have been reporting sizes already aligned to a page and so the bug was missed when testing. Fixes: f0e4ed752fda ("tools/power turbostat: Add early support for PMT counters") Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com> Signed-off-by: Len Brown <len.brown@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r--tools/power/x86/turbostat/turbostat.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/power/x86/turbostat/turbostat.c b/tools/power/x86/turbostat/turbostat.c
index 38363f11f49f..da97f4327650 100644
--- a/tools/power/x86/turbostat/turbostat.c
+++ b/tools/power/x86/turbostat/turbostat.c
@@ -95,6 +95,8 @@
#define INTEL_ECORE_TYPE 0x20
#define INTEL_PCORE_TYPE 0x40
+#define ROUND_UP_TO_PAGE_SIZE(n) (((n) + 0x1000UL-1UL) & ~(0x1000UL-1UL))
+
enum counter_scope { SCOPE_CPU, SCOPE_CORE, SCOPE_PACKAGE };
enum counter_type { COUNTER_ITEMS, COUNTER_CYCLES, COUNTER_SECONDS, COUNTER_USEC, COUNTER_K2M };
enum counter_format { FORMAT_RAW, FORMAT_DELTA, FORMAT_PERCENT, FORMAT_AVERAGE };
@@ -8853,7 +8855,7 @@ struct pmt_mmio *pmt_mmio_open(unsigned int target_guid)
if (fd_pmt == -1)
goto loop_cleanup_and_break;
- mmap_size = (size + 0x1000UL) & (~0x1000UL);
+ mmap_size = ROUND_UP_TO_PAGE_SIZE(size);
mmio = mmap(0, mmap_size, PROT_READ, MAP_SHARED, fd_pmt, 0);
if (mmio != MAP_FAILED) {