* [PATCH] tools:perf:scripts:python:mem-phys-addr fix behavior
@ 2023-01-10 21:59 Alexander Pantyukhin
0 siblings, 0 replies; only message in thread
From: Alexander Pantyukhin @ 2023-01-10 21:59 UTC (permalink / raw)
To: jolsa
Cc: akpm, peterz, mingo, acme, alexander.shishkin, namhyung,
linux-perf-users, linux-kernel, Alexander Pantyukhin
Fix the case when phys_addr belongs to the end of the range.
Example:
system_ram = [10, 20]
is_system_ram(20) - returns False
Expected: True
Signed-off-by: Alexander Pantyukhin <apantykhin@gmail.com>
---
tools/perf/scripts/python/mem-phys-addr.py | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/tools/perf/scripts/python/mem-phys-addr.py b/tools/perf/scripts/python/mem-phys-addr.py
index 1f332e72b9b0..b1daa22bd405 100644
--- a/tools/perf/scripts/python/mem-phys-addr.py
+++ b/tools/perf/scripts/python/mem-phys-addr.py
@@ -59,18 +59,23 @@ def trace_end():
print_memory_type()
f.close()
+def is_value_inside_one_of_range(memory_ranges, value):
+ position = bisect.bisect(memory_ranges, value)
+
+ if position == 0:
+ return False
+
+ if position % 2 == 0:
+ return value == memory_ranges[position - 1]
+
+ return True
+
def is_system_ram(phys_addr):
#/proc/iomem is sorted
- position = bisect.bisect(system_ram, phys_addr)
- if position % 2 == 0:
- return False
- return True
+ return is_value_inside_one_of_range(system_ram, phys_addr)
def is_persistent_mem(phys_addr):
- position = bisect.bisect(pmem, phys_addr)
- if position % 2 == 0:
- return False
- return True
+ return is_value_inside_one_of_range(pmem, phys_addr)
def find_memory_type(phys_addr):
if phys_addr == 0:
--
2.25.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-10 22:00 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-10 21:59 [PATCH] tools:perf:scripts:python:mem-phys-addr fix behavior Alexander Pantyukhin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®