* [PATCH RESEND v1] rt-tests: hwlatdetect: Add field count to samples output
@ 2025-10-16 18:19 Costa Shulyupin
2026-02-19 20:27 ` John Kacur
0 siblings, 1 reply; 2+ messages in thread
From: Costa Shulyupin @ 2025-10-16 18:19 UTC (permalink / raw)
To: linux-rt-users, John Kacur; +Cc: Bart Wensley, Clark Williams, Costa Shulyupin
Kernel commit b396bfdebffc ("tracing: Have hwlat ts be first instance
and record count of instances") adds field `count`.
Add processing of `count` field to hwlatdetect.py.
Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
---
src/hwlatdetect/hwlatdetect.py | 19 ++++++++++++++++---
1 file changed, 16 insertions(+), 3 deletions(-)
diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index 68f312db639f..af9852cc95e8 100755
--- a/src/hwlatdetect/hwlatdetect.py
+++ b/src/hwlatdetect/hwlatdetect.py
@@ -38,6 +38,17 @@
return ','.join([num_hex[max(i - 8, 0):i] for i in range(len(num_hex), 0, -8)][::-1])
+def key_values(fields):
+ """ Extract key:value pairs from a list of fields and return them as a dictionary """
+ return {
+ k: v
+ for field in fields
+ if ':' in field
+ for k, v in [field.split(":", 1)]
+ if k and v
+ }
+
+
#
# Class used to manage mounting and umounting the debugfs
# filesystem. Note that if an instance of this class mounts
@@ -242,19 +253,21 @@ def detect(self):
class Sample:
'private class for tracer sample data'
- __slots__ = 'cpu', 'timestamp', 'inner', 'outer'
+ __slots__ = 'cpu', 'timestamp', 'inner', 'outer', 'count'
def __init__(self, line):
fields = line.split()
+ kv = key_values(fields)
self.cpu = int(fields[1][1:-1])
i, o = fields[6].split('/')
ts = fields[7][3:]
self.timestamp = str(ts)
self.inner = int(i)
self.outer = int(o)
+ self.count = int(kv["count"])
def __str__(self):
- return f"ts: {self.timestamp}, inner:{self.inner}, outer:{self.outer}, cpu:{self.cpu}"
+ return f"ts: {self.timestamp}, inner:{self.inner}, outer:{self.outer}, cpu:{self.cpu}, count:{self.count}"
def display(self):
""" convert object to string and print """
@@ -286,7 +299,7 @@ def set(self, field, val):
def get(self, field):
if field == "count":
- return len(self.samples)
+ return sum(s.count for s in self.samples)
if field == "max":
max = 0
for values in self.samples:
--
2.51.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH RESEND v1] rt-tests: hwlatdetect: Add field count to samples output
2025-10-16 18:19 [PATCH RESEND v1] rt-tests: hwlatdetect: Add field count to samples output Costa Shulyupin
@ 2026-02-19 20:27 ` John Kacur
0 siblings, 0 replies; 2+ messages in thread
From: John Kacur @ 2026-02-19 20:27 UTC (permalink / raw)
To: Costa Shulyupin; +Cc: linux-rt-users, John Kacur, Bart Wensley, Clark Williams
On Thu, 16 Oct 2025, Costa Shulyupin wrote:
> Kernel commit b396bfdebffc ("tracing: Have hwlat ts be first instance
> and record count of instances") adds field `count`.
>
> Add processing of `count` field to hwlatdetect.py.
>
> Signed-off-by: Costa Shulyupin <costa.shul@redhat.com>
> ---
> src/hwlatdetect/hwlatdetect.py | 19 ++++++++++++++++---
> 1 file changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
> index 68f312db639f..af9852cc95e8 100755
> --- a/src/hwlatdetect/hwlatdetect.py
> +++ b/src/hwlatdetect/hwlatdetect.py
> @@ -38,6 +38,17 @@
> return ','.join([num_hex[max(i - 8, 0):i] for i in range(len(num_hex), 0, -8)][::-1])
>
>
> +def key_values(fields):
> + """ Extract key:value pairs from a list of fields and return them as a dictionary """
> + return {
> + k: v
> + for field in fields
> + if ':' in field
> + for k, v in [field.split(":", 1)]
> + if k and v
> + }
> +
> +
> #
> # Class used to manage mounting and umounting the debugfs
> # filesystem. Note that if an instance of this class mounts
> @@ -242,19 +253,21 @@ def detect(self):
>
> class Sample:
> 'private class for tracer sample data'
> - __slots__ = 'cpu', 'timestamp', 'inner', 'outer'
> + __slots__ = 'cpu', 'timestamp', 'inner', 'outer', 'count'
>
> def __init__(self, line):
> fields = line.split()
> + kv = key_values(fields)
> self.cpu = int(fields[1][1:-1])
> i, o = fields[6].split('/')
> ts = fields[7][3:]
> self.timestamp = str(ts)
> self.inner = int(i)
> self.outer = int(o)
> + self.count = int(kv["count"])
>
> def __str__(self):
> - return f"ts: {self.timestamp}, inner:{self.inner}, outer:{self.outer}, cpu:{self.cpu}"
> + return f"ts: {self.timestamp}, inner:{self.inner}, outer:{self.outer}, cpu:{self.cpu}, count:{self.count}"
>
> def display(self):
> """ convert object to string and print """
> @@ -286,7 +299,7 @@ def set(self, field, val):
>
> def get(self, field):
> if field == "count":
> - return len(self.samples)
> + return sum(s.count for s in self.samples)
> if field == "max":
> max = 0
> for values in self.samples:
> --
> 2.51.0
>
>
>
Signed-off-by: John Kacur <jkacur@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-19 20:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-16 18:19 [PATCH RESEND v1] rt-tests: hwlatdetect: Add field count to samples output Costa Shulyupin
2026-02-19 20:27 ` John Kacur
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox