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>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230109093347.6639-1-apantykhin@gmail.com>
Date:   Mon,  9 Jan 2023 14:33:47 +0500
From:   Alexander Pantyukhin <apantykhin@...il.com>
To:     mark.rutland@....com
Cc:     peterz@...radead.org, mingo@...hat.com, acme@...nel.org,
        alexander.shishkin@...ux.intel.com, jolsa@...nel.org,
        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 performance

Avoid double strip() calls for getting memory type.

Signed-off-by: Alexander Pantyukhin <apantykhin@...il.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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ