tools:perf:scripts:python:mem-phys-addr fix behavior
PATCH 1/1 tools:perf:scripts:python:mem-phys-addr fix behavior
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 <[email protected]>
--- tools/perf/scripts/python/mem-phys-addr.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-)
tools/perf/scripts/python/mem-phys-addr.py +13 -8
@@ -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:
Signature · 1 line
2.25.1