[PATCH] rt-tests: hwlatdetect: Add option to specify cpumask

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
---
 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




[Index of Archives]     [RT Stable]     [Kernel Newbies]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux