diff mbox series

[rt-tests,v4,05/16] signaltest: Simplify --smp vs --affinity vs --threads argument logic

Message ID 20210210133450.6991-6-dwagner@suse.de
State New
Headers show
Series rt-numa.h cleanups | expand

Commit Message

Daniel Wagner Feb. 10, 2021, 1:34 p.m. UTC
Allow each command line only to update one variable and do the final
decission at the end of the parsing step. With this the order
of the command line is not important.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
---
 src/signaltest/signaltest.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)
diff mbox series

Patch

diff --git a/src/signaltest/signaltest.c b/src/signaltest/signaltest.c
index e19fc9a740a9..61420fa13347 100644
--- a/src/signaltest/signaltest.c
+++ b/src/signaltest/signaltest.c
@@ -210,7 +210,6 @@  static struct bitmask *affinity_mask = NULL;
 static void process_options(int argc, char *argv[], unsigned int max_cpus)
 {
 	int error = 0;
-	int numa = 0;
 	int smp = 0;
 
 	for (;;) {
@@ -236,10 +235,6 @@  static void process_options(int argc, char *argv[], unsigned int max_cpus)
 			break;
 		switch (c) {
 		case 'a':
-			/* smp sets AFFINITY_USEALL in OPT_SMP */
-			if (smp)
-				break;
-			numa = 1;
 			if (optarg) {
 				parse_cpumask(optarg, max_cpus, &affinity_mask);
 			} else if (optind < argc &&
@@ -261,12 +256,7 @@  static void process_options(int argc, char *argv[], unsigned int max_cpus)
 		case 'm': lockall = 1; break;
 		case 'p': priority = atoi(optarg); break;
 		case 'q': quiet = 1; break;
-		case 'S':
-			if (numa)
-				fatal("numa and smp options are mutually exclusive\n");
-			smp = 1;
-			num_threads = -1; /* update after parsing */
-			break;
+		case 'S': smp = 1; break;
 		case 't': num_threads = atoi(optarg); break;
 		case 'v': verbose = 1; break;
 		}
@@ -278,15 +268,16 @@  static void process_options(int argc, char *argv[], unsigned int max_cpus)
 	if (priority < 0 || priority > 99)
 		error = 1;
 
-	if (num_threads == -1)
-		num_threads = get_available_cpus(affinity_mask);
+	if (smp) {
+		if (affinity_mask)
+			warn("--affinity overwrites smp mode\n");
+		else
+			num_threads = get_available_cpus(affinity_mask);
+	}
 
 	if (num_threads < 2)
 		error = 1;
 
-	if (smp && affinity_mask)
-		warn("-a ignored due to smp mode\n");
-
 	if (error) {
 		if (affinity_mask)
 			numa_bitmask_free(affinity_mask);