lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230110215936.4716-1-apantykhin@gmail.com>
Date:   Wed, 11 Jan 2023 02:59:36 +0500
From:   Alexander Pantyukhin <apantykhin@...il.com>
To:     jolsa@...nel.org
Cc:     akpm@...ux-foundation.org, peterz@...radead.org, mingo@...hat.com,
        acme@...nel.org, alexander.shishkin@...ux.intel.com,
        namhyung@...nel.org, linux-perf-users@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Alexander Pantyukhin <apantykhin@...il.com>
Subject: [PATCH] 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 <apantykhin@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ