linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] tools:perf:scripts:python:mem-phys-addr fix performance
@ 2023-01-09  9:33 Alexander Pantyukhin
  2023-01-09 20:44 ` Alexander Pantyukhin
  0 siblings, 1 reply; 2+ messages in thread
From: Alexander Pantyukhin @ 2023-01-09  9:33 UTC (permalink / raw)
  To: mark.rutland
  Cc: peterz, mingo, acme, alexander.shishkin, jolsa, namhyung,
	linux-perf-users, linux-kernel, Alexander Pantyukhin

Avoid double strip() calls for getting memory type.

Signed-off-by: Alexander Pantyukhin <apantykhin@gmail.com>
---
 tools/perf/scripts/python/mem-phys-addr.py | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/perf/scripts/python/mem-phys-addr.py b/tools/perf/scripts/python/mem-phys-addr.py
index 1f332e72b9b0..f267d8382eda 100644
--- a/tools/perf/scripts/python/mem-phys-addr.py
+++ b/tools/perf/scripts/python/mem-phys-addr.py
@@ -8,7 +8,6 @@ from __future__ import print_function
 
 import os
 import sys
-import struct
 import re
 import bisect
 import collections
@@ -30,12 +29,14 @@ event_name = None
 def parse_iomem():
 	global f
 	f = open('/proc/iomem', 'r')
-	for i, j in enumerate(f):
+	for _, j in enumerate(f):
 		m = re.split('-|:',j,2)
-		if m[2].strip() == 'System RAM':
+		memory_type = m[2].strip()
+
+		if memory_type == 'System RAM':
 			system_ram.append(int(m[0], 16))
 			system_ram.append(int(m[1], 16))
-		if m[2].strip() == 'Persistent Memory':
+		elif memory_type == 'Persistent Memory':
 			pmem.append(int(m[0], 16))
 			pmem.append(int(m[1], 16))
 
@@ -75,6 +76,7 @@ def is_persistent_mem(phys_addr):
 def find_memory_type(phys_addr):
 	if phys_addr == 0:
 		return "N/A"
+
 	if is_system_ram(phys_addr):
 		return "System RAM"
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-09 20:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-09  9:33 [PATCH] tools:perf:scripts:python:mem-phys-addr fix performance Alexander Pantyukhin
2023-01-09 20:44 ` Alexander Pantyukhin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).