Skip to contentSkip to conversation

hwlatdetect: correctly get CPU number from different sample formats

PATCH In review Luis Claudio R. Goncalves 2 participants 2 messages Feb 13 – Feb 19

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 hwlatdetect: correctly get CPU number from different sample formats

Make hwlatdetect able to get the CPU number from samples in both 'nolatency-format' (currently covered by the code) and also from samples in 'latency-format'.

With this change the code is now able to get the CPU from samples in the following formats:

- nolatency-format:

   <...>-3820    [007] d.... 22851.463472: #2     inner/outer(us):    0/233   ts:1770937572.925294075 count:1
   <...>-3820    [011] d.... 22855.495526: #3     inner/outer(us):  308/305   ts:1770937576.805213360 count:49

- latency-format:

   <...>-3835     13d.... 12608167us : #2     inner/outer(us):  307/299   ts:1770937629.988530678 count:49
   <...>-3835     16d.... 15632212us : #3     inner/outer(us):  308/296   ts:1770937633.322710076 count:24
Fixes 96e780938322 ("rt-tests: hwlatdetect: Add field cpu to samples output")
---
 src/hwlatdetect/hwlatdetect.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/hwlatdetect/hwlatdetect.py +1 -1
index 68f312db639f..26694abe099a 100755
@@ -246,7 +246,7 @@ class Tracer(Detector):
 
         def __init__(self, line):
             fields = line.split()
-            self.cpu = int(fields[1][1:-1])
+            self.cpu = int(fields[1][1:-1]) if fields[1][0] == '[' else int(fields[1][:-5])
             i, o = fields[6].split('/')
             ts = fields[7][3:]
             self.timestamp = str(ts)
Signature · 1 line
2.53.0
#1 lore raw
Quoted 27 lines · Luis Claudio R. Goncalves

Make hwlatdetect able to get the CPU number from samples in both 'nolatency-format' (currently covered by the code) and also from samples in 'latency-format'.

With this change the code is now able to get the CPU from samples in the following formats:

- nolatency-format:

   <...>-3820    [007] d.... 22851.463472: #2     inner/outer(us):    0/233   ts:1770937572.925294075 count:1
   <...>-3820    [011] d.... 22855.495526: #3     inner/outer(us):  308/305   ts:1770937576.805213360 count:49

- latency-format:

   <...>-3835     13d.... 12608167us : #2     inner/outer(us):  307/299   ts:1770937629.988530678 count:49
   <...>-3835     16d.... 15632212us : #3     inner/outer(us):  308/296   ts:1770937633.322710076 count:24
Fixes 96e780938322 ("rt-tests: hwlatdetect: Add field cpu to samples output")
---
 src/hwlatdetect/hwlatdetect.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
src/hwlatdetect/hwlatdetect.py +0 -0
index 68f312db639f..26694abe099a 100755

src/hwlatdetect/hwlatdetect.py class Tracer(Detector): · line 252

Quoted 8 lines
src/hwlatdetect/hwlatdetect.py +1 -1
@@ -246,7 +246,7 @@ class Tracer(Detector):
 
         def __init__(self, line):
             fields = line.split()
-            self.cpu = int(fields[1][1:-1])
+            self.cpu = int(fields[1][1:-1]) if fields[1][0] == '[' else int(fields[1][:-5])
             i, o = fields[6].split('/')
             ts = fields[7][3:]
             self.timestamp = str(ts)