* [PATCH] rt-tests: hwlatdetect: Add option to specify cpumask
@ 2022-04-11 16:49 Oscar Shiang
2022-04-16 20:20 ` John Kacur
0 siblings, 1 reply; 2+ messages in thread
From: Oscar Shiang @ 2022-04-11 16:49 UTC (permalink / raw)
To: John Kacur, Clark Williams; +Cc: rt-users, Oscar Shiang
The hwlat tracer can be configured to run on a set of cpus via
tracing_cpumask [1].
Add a new option cpu-list to support the configuration of
tracing_cpumask in the format of cpu list.
For example, if we want the thread to run on CPU 1,2,3 and 5,
we can specify the cpu list to 1-3,5
The value to pass to hwlatdetect is:
$ hwlatdetect --cpu-list=1-3,5
[1]: https://docs.kernel.org/trace/hwlat_detector.html
Signed-off-by: Oscar Shiang <oscar0225@livemail.tw>
---
src/hwlatdetect/hwlatdetect.8 | 3 +++
src/hwlatdetect/hwlatdetect.py | 19 +++++++++++++++++++
2 files changed, 22 insertions(+)
diff --git a/src/hwlatdetect/hwlatdetect.8 b/src/hwlatdetect/hwlatdetect.8
index df33180..21d0fe4 100644
--- a/src/hwlatdetect/hwlatdetect.8
+++ b/src/hwlatdetect/hwlatdetect.8
@@ -88,6 +88,9 @@ actually sampling. Must be less than the \-\-window value.
Specify the output filename of the detector report. Default
behavior is to print to standard output
.TP
+.B \-\-cpu-list=CPU-LIST
+Specify the CPUs for hwlat thread to move across.
+.TP
.B \-\-debug
Turn on debug prints
.TP
diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
index 27c2b8a..9ef50f8 100755
--- a/src/hwlatdetect/hwlatdetect.py
+++ b/src/hwlatdetect/hwlatdetect.py
@@ -232,6 +232,7 @@ class Tracer(Detector):
'window' : "hwlat_detector/window",
'enable' : "tracing_on",
'threshold' : "tracing_thresh",
+ 'cpumask' : "tracing_cpumask",
}
class Sample:
@@ -410,6 +411,10 @@ if __name__ == '__main__':
dest="report",
help="filename for sample data")
+ parser.add_argument("--cpu-list", default=None,
+ dest="cpulist",
+ help="the CPUs for hwlat thread to move across")
+
parser.add_argument("--debug", action="store_true", default=False,
dest="debug",
help="turn on debugging prints")
@@ -476,9 +481,23 @@ if __name__ == '__main__':
reportfile = args.report
+ if args.cpulist:
+ cpumask = 0
+ for c in args.cpulist.split(','):
+ l, r = 0, 0
+ if '-' in c:
+ l, r = map(int, c.split('-'))
+ else:
+ l, r = map(int, [c, c])
+ for i in range(l, r + 1):
+ cpumask |= (1 << i)
+ debug("set tracing_cpumask to %x" % cpumask)
+ detect.set("cpumask", "%x" % cpumask)
+
info("hwlatdetect: test duration %d seconds" % detect.testduration)
info(" detector: %s" % detect.type)
info(" parameters:")
+ info(" CPU list: %s" % args.cpulist)
info(" Latency threshold: %dus" % int(detect.get("threshold")))
info(" Sample window: %dus" % int(detect.get("window")))
info(" Sample width: %dus" % int(detect.get("width")))
--
2.25.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] rt-tests: hwlatdetect: Add option to specify cpumask
2022-04-11 16:49 [PATCH] rt-tests: hwlatdetect: Add option to specify cpumask Oscar Shiang
@ 2022-04-16 20:20 ` John Kacur
0 siblings, 0 replies; 2+ messages in thread
From: John Kacur @ 2022-04-16 20:20 UTC (permalink / raw)
To: Oscar Shiang; +Cc: Clark Williams, rt-users
On Tue, 12 Apr 2022, Oscar Shiang wrote:
> The hwlat tracer can be configured to run on a set of cpus via
> tracing_cpumask [1].
>
> Add a new option cpu-list to support the configuration of
> tracing_cpumask in the format of cpu list.
>
> For example, if we want the thread to run on CPU 1,2,3 and 5,
> we can specify the cpu list to 1-3,5
>
> The value to pass to hwlatdetect is:
>
> $ hwlatdetect --cpu-list=1-3,5
>
> [1]: https://docs.kernel.org/trace/hwlat_detector.html
>
> Signed-off-by: Oscar Shiang <oscar0225@livemail.tw>
> ---
> src/hwlatdetect/hwlatdetect.8 | 3 +++
> src/hwlatdetect/hwlatdetect.py | 19 +++++++++++++++++++
> 2 files changed, 22 insertions(+)
>
> diff --git a/src/hwlatdetect/hwlatdetect.8 b/src/hwlatdetect/hwlatdetect.8
> index df33180..21d0fe4 100644
> --- a/src/hwlatdetect/hwlatdetect.8
> +++ b/src/hwlatdetect/hwlatdetect.8
> @@ -88,6 +88,9 @@ actually sampling. Must be less than the \-\-window value.
> Specify the output filename of the detector report. Default
> behavior is to print to standard output
> .TP
> +.B \-\-cpu-list=CPU-LIST
> +Specify the CPUs for hwlat thread to move across.
> +.TP
> .B \-\-debug
> Turn on debug prints
> .TP
> diff --git a/src/hwlatdetect/hwlatdetect.py b/src/hwlatdetect/hwlatdetect.py
> index 27c2b8a..9ef50f8 100755
> --- a/src/hwlatdetect/hwlatdetect.py
> +++ b/src/hwlatdetect/hwlatdetect.py
> @@ -232,6 +232,7 @@ class Tracer(Detector):
> 'window' : "hwlat_detector/window",
> 'enable' : "tracing_on",
> 'threshold' : "tracing_thresh",
> + 'cpumask' : "tracing_cpumask",
> }
>
> class Sample:
> @@ -410,6 +411,10 @@ if __name__ == '__main__':
> dest="report",
> help="filename for sample data")
>
> + parser.add_argument("--cpu-list", default=None,
> + dest="cpulist",
> + help="the CPUs for hwlat thread to move across")
> +
> parser.add_argument("--debug", action="store_true", default=False,
> dest="debug",
> help="turn on debugging prints")
> @@ -476,9 +481,23 @@ if __name__ == '__main__':
>
> reportfile = args.report
>
> + if args.cpulist:
> + cpumask = 0
> + for c in args.cpulist.split(','):
> + l, r = 0, 0
> + if '-' in c:
> + l, r = map(int, c.split('-'))
> + else:
> + l, r = map(int, [c, c])
> + for i in range(l, r + 1):
> + cpumask |= (1 << i)
> + debug("set tracing_cpumask to %x" % cpumask)
> + detect.set("cpumask", "%x" % cpumask)
> +
> info("hwlatdetect: test duration %d seconds" % detect.testduration)
> info(" detector: %s" % detect.type)
> info(" parameters:")
> + info(" CPU list: %s" % args.cpulist)
> info(" Latency threshold: %dus" % int(detect.get("threshold")))
> info(" Sample window: %dus" % int(detect.get("window")))
> info(" Sample width: %dus" % int(detect.get("width")))
> --
> 2.25.1
>
>
Nice patch, thanks
Signed-off-by: John Kacur <jkacur@redhat.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-04-16 20:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11 16:49 [PATCH] rt-tests: hwlatdetect: Add option to specify cpumask Oscar Shiang
2022-04-16 20:20 ` John Kacur
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.