Message ID | TYCP286MB1913F333CCBD550E845C4CFDA1EA9@TYCP286MB1913.JPNP286.PROD.OUTLOOK.COM |
---|---|
State | New |
Headers | show |
Series | rt-tests: hwlatdetect: Add option to specify cpumask | expand |
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>
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")))
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(+)