Messages in this thread Patch in this message | | | From | Alexander Pantyukhin <> | Subject | [PATCH] tools:perf:scripts:python:mem-phys-addr fix behavior | Date | Wed, 11 Jan 2023 02:59:36 +0500 |
| |
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
| |