rt-tests: Remove arbitrary num of threads limits
PATCH 1/8 rt-tests: Remove arbitrary num of threads limits
Remove the arbitrary limit to the number of threads in pmqtest, ptsematest, sigwaittest and svsematest.
--- src/pmqtest/pmqtest.c | 2 +- src/ptsematest/ptsematest.c | 2 +- src/sigwaittest/sigwaittest.c | 2 +- src/svsematest/svsematest.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-)
src/pmqtest/pmqtest.c +1 -1
@@ -393,7 +393,7 @@ static void process_options(int argc, char *argv[]) } } -if (num_threads <0 || num_threads >255 ) +if (num_threads <0 ) error =1 ;if (priority <0 || priority >99 )
src/ptsematest/ptsematest.c +1 -1
@@ -299,7 +299,7 @@ static void process_options(int argc, char *argv[]) } } -if (num_threads <0 || num_threads >255 ) +if (num_threads <0 ) error =1 ;if (priority <0 || priority >99 )
src/sigwaittest/sigwaittest.c +1 -1
@@ -369,7 +369,7 @@ static void process_options(int argc, char *argv[])if (duration <0 ) error =1 ; -if (num_threads <1 || num_threads >255 ) +if (num_threads <1 ) error =1 ;if (priority <0 || priority >99 )
src/svsematest/svsematest.c +1 -1
@@ -398,7 +398,7 @@ static void process_options(int argc, char *argv[])if (duration <0 ) error =0 ; -if (num_threads <1 || num_threads >255 ) +if (num_threads <1 ) error =1 ;if (priority <0 || priority >99 )
Signature · 1 line
2.38.1
PATCH 2/8 rt-tests: hackbench: Add error checking to connect and getsockname
Add error checking around the calls connect and getsockname
--- src/hackbench/hackbench.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
src/hackbench/hackbench.c +4 -2
@@ -130,14 +130,16 @@ static int inet_socketpair(int fds[2])if (bind (s1, &sin, len) <0 )barf ("bind" ); -getsockname (s1, &sin, &len); +if (getsockname (s1, &sin, &len) <0 ) +barf ("getsockname" );if (listen (s1,10 ) <0 )barf ("listen" );if (ioctl (s2,FIONBIO , &ul) <0 )barf ("ioctl" );if (ioctl (s1,FIONBIO , &ul) <0 )barf ("ioctl" ); -connect (s2, &sin, len); +if (connect (s2, &sin, len) <0 ) +barf ("connect" );if ((fds[0 ] =accept (s1, &sin, &len)) <0 )barf ("accept" ); ul =0 ;
Signature · 1 line
2.38.1
PATCH 3/8 rt-tests: hackbench: Fix compile comparison of different signed ints
In reply to John KacurFix compile warnings about comparisons of integers of different signedness.
--- src/hackbench/hackbench.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
src/hackbench/hackbench.c +6 -4
@@ -200,7 +200,8 @@ static void *sender(struct sender_context *ctx)/* Now pump to every receiver. */ for (i =0 ; i < loops; i++) {for (j =0 ; j < ctx->num_fds; j++) { -int ret, done =0 ; +int ret; +size_t done =0 ; again: ret =write (ctx->out_fds[j], data + done,sizeof (data)-done);
@@ -231,7 +232,8 @@ static void *receiver(struct receiver_context* ctx)/* Receive them all */ for (i =0 ; i < ctx->num_packets; i++) {char data[datasize]; -int ret, done =0 ; +int ret; +size_t done =0 ; again: ret =read (ctx->in_fds[0 ], data + done, datasize - done);
@@ -289,7 +291,7 @@ static int create_worker(childinfo_t *child, void *ctx, void *(*func)(void *))void signal_workers (childinfo_t *children,unsigned int num_children) { -int i; +unsigned int i;printf ("signaling %d worker threads to terminate\n" , num_children);for (i=0 ; i < num_children; i++) {kill (children[i].pid,SIGTERM );
@@ -517,7 +519,7 @@ int main(int argc, char *argv[])if (setjmp (jmpbuf) ==0 ) { total_children =0 ;for (i =0 ; i < num_groups; i++) { -int c =group (child_tab, total_children, num_fds, readyfds[1 ], wakefds[0 ]); +unsigned int c =group (child_tab, total_children, num_fds, readyfds[1 ], wakefds[0 ]);if ( c != (num_fds*2 ) ) {fprintf (stderr,"%i children started. Expected %i\n" , c, num_fds*2 );reap_workers (child_tab, total_children + c,1 );
Signature · 1 line
2.38.1
PATCH 4/8 rt-tests: hackbench: Fix compile warning about fall through
In reply to John Kacurprint_usage_exit(0) never returns, but the compiler doesn't understand this. In any case it is not harmful to add a break after this statement. Do so to keep the unhelpful compiler warning from triggering.
--- src/hackbench/hackbench.c | 1 + 1 file changed, 1 insertion(+)
src/hackbench/hackbench.c +1 -0
@@ -444,6 +444,7 @@ static void process_options(int argc, char *argv[])break ;case 'h' :print_usage_exit (0 ); +break ;case 'l' :if (!(argv[optind] && (loops =atoi (optarg)) >0 )) {fprintf (stderr,"%s: --loops|-l requires an integer > 0\n" , argv[0 ]);
Signature · 1 line
2.38.1
PATCH 5/8 rt-tests: rt_numa.h: Remove unused paramter max_cpus
In reply to John KacurRemove unused parameter max_cpus.
Note it doesn't appear that this function is currently being called
--- src/cyclictest/rt_numa.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
src/cyclictest/rt_numa.h +1 -2
@@ -72,8 +72,7 @@ static inline unsigned int rt_numa_bitmask_isbitset( const struct bitmask *mask,return numa_bitmask_isbitset (mask,i); } -static inline struct bitmask *rt_numa_parse_cpustring (const char * s, -int max_cpus) +static inline struct bitmask *rt_numa_parse_cpustring (const char * s) {return numa_parse_cpustring_all (s); }
Signature · 1 line
2.38.1
PATCH 6/8 rt-tests: hwlatdetect.py Covert to f-strings
In reply to John KacurFrom: Leah Leshchinsky <[email protected]>
Add f-strings where applicable for readability.
--- src/hwlatdetect/hwlatdetect.py | 74 +++++++++++++++++----------------- 1 file changed, 37 insertions(+), 37 deletions(-)
src/hwlatdetect/hwlatdetect.py +37 -37
@@ -59,7 +59,7 @@ class DebugFS: if self.premounted or self.mounted: debug("not mounting debugfs") return True - debug("mounting debugfs at %s" % path) + debug(f"mounting debugfs at {path}") self.mountpoint = path cmd = ['/bin/mount', '-t', 'debugfs', 'none', path] self.mounted = (subprocess.call(cmd) == 0)
@@ -90,7 +90,7 @@ class DebugFS: try: val = f.readline() except OSError as e: - print("errno: %s" % e) + print(f"errno: {e}") if e.errno == errno.EAGAIN: val = None else:
@@ -192,18 +192,18 @@ class Detector: count = 0 threshold = int(self.get("threshold")) self.c_states_off() - debug("enabling detector module (threshold: %d)" % threshold) + debug(f"enabling detector module (threshold: {threshold})") self.set("enable", 1) while self.get("enable") == 0: debug("still disabled, retrying in a bit") count += 1 time.sleep(0.1) - debug("retrying enable of detector module (%d)" % count) + debug(f"retrying enable of detector module ({count})") self.set("enable", 1) if self.get("threshold") != threshold: debug("start: threshold reset by start, fixing") self.set("threshold", threshold) - debug("detector module enabled (threshold: %d)" % int(self.get("threshold"))) + debug(f"detector module enabled (threshold: {int(self.get('threshold'))})") def stop(self): """ disable the detector """
@@ -214,7 +214,7 @@ class Detector: debug("still enabled, retrying in a bit") count += 1 time.sleep(0.1) - debug("retrying disable of detector module(%d)" % count) + debug(f"retrying disable of detector module({count})") self.set("enable", 0) self.c_states_on() debug("detector module disabled")
@@ -248,7 +248,7 @@ class Tracer(Detector): self.outer = int(o) def __str__(self): - return "ts: %s, inner:%d, outer:%d" % (self.timestamp, self.inner, self.outer) + return f"ts: {self.timestamp}, inner:{self.inner}, outer:{self.outer}" def display(self): """ convert object to string and print """
@@ -322,8 +322,8 @@ class Tracer(Detector): if output: with open(output, "w") as f: for s in self.samples: - f.write("%s\n" % str(s)) - print("report saved to %s (%d samples)" % (output, len(self.samples))) + f.write(f"{s}\n") + print(f"report saved to {output} ({len(self.samples)} samples)") def display(self): for s in self.samples:
@@ -341,7 +341,7 @@ def seconds(sval): if sval.isdigit(): return int(sval) if sval[-2].isalpha(): - raise RuntimeError("illegal suffix for seconds: '%s'" % sval[-2:-1]) + raise RuntimeError(f"illegal suffix for seconds: '{sval[-2:-1]}'") if sval[-1:] == 's': return int(sval[0:-1]) if sval[-1:] == 'm':
@@ -352,7 +352,7 @@ def seconds(sval): return int(sval[0:-1]) * 86400 if sval[-1:] == 'w': return int(sval[0:-1]) * 86400 * 7 - raise RuntimeError("invalid input for seconds: '%s'" % sval) + raise RuntimeError(f"invalid input for seconds: '{sval}'") def milliseconds(sval):
@@ -367,7 +367,7 @@ def milliseconds(sval): return int(sval[0:-1]) * 1000 * 60 if sval[-1] == 'h': return int(sval[0:-1]) * 1000 * 60 * 60 - raise RuntimeError("invalid input for milliseconds: %s" % sval) + raise RuntimeError(f"invalid input for milliseconds: {sval}") def microseconds(sval):
@@ -380,7 +380,7 @@ def microseconds(sval): return int(sval[0:-2]) if sval[-1:] == 's': return int(sval[0:-1]) * 1000 * 1000 - raise RuntimeError("invalid input for microseconds: '%s'" % sval) + raise RuntimeError(f"invalid input for microseconds: '{sval}'") if __name__ == '__main__':
@@ -444,37 +444,37 @@ if __name__ == '__main__': if args.threshold: t = microseconds(args.threshold) detect.set("threshold", t) - debug("threshold set to %dus" % t) + debug(f"threshold set to {t}us") if args.hardlimit: hardlimit = microseconds(args.hardlimit) else: hardlimit = int(detect.get("threshold")) - debug("hardlimit set to %dus" % hardlimit) + debug(f"hardlimit set to {hardlimit}us") if args.window: w = microseconds(args.window) if w < int(detect.get("width")): - debug("shrinking width to %d for new window of %d" % (w/2, w)) + debug(f"shrinking width to {w//2} for new window of {w}") detect.set("width", w/2) - debug("window parameter = %d" % w) + debug(f"window parameter = {w}") detect.set("window", w) - debug("window for sampling set to %dus" % w) + debug(f"window for sampling set to {w}us") if args.width: w = microseconds(args.width) if w > int(detect.get("window")): - debug("widening window to %d for new width of %d" % (w*2, w)) + debug(f"widening window to {w*2} for new width of {w}") detect.set("window", w*2) - debug("width parameter = %d" % w) + debug(f"width parameter = {w}") detect.set("width", w) - debug("sample width set to %dus" % w) + debug(f"sample width set to {w}us") if args.duration: detect.testduration = seconds(args.duration) else: detect.testduration = 120 # 2 minutes - debug("test duration is %ds" % detect.testduration) + debug(f"test duration is {detect.testduration}s") if args.watch: watch = True
@@ -491,18 +491,18 @@ if __name__ == '__main__': 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) + debug(f"set tracing_cpumask to {cpumask:x}") + detect.set("cpumask", f"{cpumask:x}") - info("hwlatdetect: test duration %d seconds" % detect.testduration) - info(" detector: %s" % detect.type) + info(f"hwlatdetect: test duration {detect.testduration} seconds") + info(f" detector: {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"))) - info(" Non-sampling period: %dus" % (int(detect.get("window")) - int(detect.get("width")))) - info(" Output File: %s" % reportfile) + info(f" CPU list: {args.cpulist}") + info(f" Latency threshold: {int(detect.get('threshold'))}us") + info(f" Sample window: {int(detect.get('window'))}us") + info(f" Sample width: {int(detect.get('width'))}us") + info(f" Non-sampling period: {(int(detect.get('window')) - int(detect.get('width')))}us") + info(f" Output File: {reportfile}") info("\nStarting test") detect.detect()
@@ -513,12 +513,12 @@ if __name__ == '__main__': if max_latency == 0: info("Max Latency: Below threshold") else: - info("Max Latency: %dus" % max_latency) + info(f"Max Latency: {int(max_latency)}us") - info("Samples recorded: %d" % len(detect.samples)) + info(f"Samples recorded: {len(detect.samples)}") exceeding = detect.get("count") - info("Samples exceeding threshold: %d" % exceeding) + info(f"Samples exceeding threshold: {exceeding}") if detect.have_msr: finishsmi = detect.getsmicounts()
@@ -527,8 +527,8 @@ if __name__ == '__main__': if count > detect.initsmi[i]: smis = count - detect.initsmi[i] total_smis += smis - print("%d SMIs occured on cpu %d" % (smis, i)) - info("SMIs during run: %d" % total_smis) + print(f"{smis} SMIs occured on cpu {i}") + info(f"SMIs during run: {total_smis}") maxlatency = int(detect.get("max"))
Signature · 1 line
2.38.1
PATCH 7/8 rt-tests: hwlatdetect: Update to integer division
In reply to John KacurFrom: Leah Leshchinsky <[email protected]>
In Python 3, "/" is a float division operator, as opposed to Python 2, which defaults to integer division. This results in an error when calculating width, which assumes an integer.
Update width division to integer division with the "//" operator.
--- src/hwlatdetect/hwlatdetect.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
src/hwlatdetect/hwlatdetect.py +3 -2
@@ -454,9 +454,10 @@ if __name__ == '__main__': if args.window: w = microseconds(args.window) + width = w//2 if w < int(detect.get("width")): - debug(f"shrinking width to {w//2} for new window of {w}") - detect.set("width", w/2) + debug(f"shrinking width to {width} for new window of {w}") + detect.set("width", width) debug(f"window parameter = {w}") detect.set("window", w) debug(f"window for sampling set to {w}us")
Signature · 1 line
2.38.1
PATCH 8/8 rt-tests: hwlatdetect: Fix incorrect comment about testduration
In reply to John KacurAt some point
self.testduration = 10
was changed to
self.testduration = 30
but retained the comment, "ten seconds"
Just change the comment to say, "in seconds" so it's clear what unit we are talking about.
--- src/hwlatdetect/hwlatdetect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/hwlatdetect/hwlatdetect.py +1 -1
@@ -130,7 +130,7 @@ class Detector: if not self.debugfs.mount(): raise RuntimeError("failed to mount debugfs") self.samples = [] - self.testduration = 30 # ten seconds + self.testduration = 30 # in seconds self.have_msr = False self.initsmi = [] if os.path.exists('/usr/sbin/rdmsr'):
Signature · 1 line
2.38.1