Skip to content

Commit 2f60f03

Browse files
Patryk Wlazlynlenb
authored andcommitted
tools/power turbostat: Fix PMT mmaped file size rounding
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: f0e4ed7 ("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>
1 parent 4a358ba commit 2f60f03

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/power/x86/turbostat/turbostat.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@
9595
#define INTEL_ECORE_TYPE 0x20
9696
#define INTEL_PCORE_TYPE 0x40
9797

98+
#define ROUND_UP_TO_PAGE_SIZE(n) (((n) + 0x1000UL-1UL) & ~(0x1000UL-1UL))
99+
98100
enum counter_scope { SCOPE_CPU, SCOPE_CORE, SCOPE_PACKAGE };
99101
enum counter_type { COUNTER_ITEMS, COUNTER_CYCLES, COUNTER_SECONDS, COUNTER_USEC, COUNTER_K2M };
100102
enum counter_format { FORMAT_RAW, FORMAT_DELTA, FORMAT_PERCENT, FORMAT_AVERAGE };
@@ -8996,7 +8998,7 @@ struct pmt_mmio *pmt_mmio_open(unsigned int target_guid)
89968998
if (fd_pmt == -1)
89978999
goto loop_cleanup_and_break;
89989000

8999-
mmap_size = (size + 0x1000UL) & (~0x1000UL);
9001+
mmap_size = ROUND_UP_TO_PAGE_SIZE(size);
90009002
mmio = mmap(0, mmap_size, PROT_READ, MAP_SHARED, fd_pmt, 0);
90019003
if (mmio != MAP_FAILED) {
90029004

0 commit comments

Comments
 (0)