From: Alexander Pantyukhin <apantykhin@gmail.com>
To: jolsa@kernel.org
Cc: akpm@linux-foundation.org, peterz@infradead.org,
mingo@redhat.com, acme@kernel.org,
alexander.shishkin@linux.intel.com, namhyung@kernel.org,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
Alexander Pantyukhin <apantykhin@gmail.com>
Subject: [PATCH] tools:perf:scripts:python:mem-phys-addr fix behavior
Date: Wed, 11 Jan 2023 02:59:36 +0500 [thread overview]
Message-ID: <20230110215936.4716-1-apantykhin@gmail.com> (raw)
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
reply other threads:[~2023-01-10 22:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230110215936.4716-1-apantykhin@gmail.com \
--to=apantykhin@gmail.com \
--cc=acme@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=peterz@infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®