diff options
author | Sebastian Andrzej Siewior <bigeasy@linutronix.de> | 2022-06-15 13:38:46 +0200 |
---|---|---|
committer | John Kacur <jkacur@redhat.com> | 2022-06-29 10:51:17 -0400 |
commit | c58720de416d0a53b56f6974d95d9423b338ea3e (patch) | |
tree | 601c7525bde54a93bc515e69a122532a5d5262c0 | |
parent | 1b28b9425fcc639aec4b414340e2cc3b862b9c00 (diff) | |
download | rt-tests-c58720de416d0a53b56f6974d95d9423b338ea3e.tar.gz |
cyclictest: Delay setting of main_affinity_mask after creating threads.
Assuming the current affinity mask of the task is 0x31 (CPUs 0, 4, 5).
Starting cyclictest with '-S' option will fork the following threads:
- monitor, mask 0x31
- measure thread 1, mask 0x01
- measure thread 2, mask 0x10
- measure thread 3, mask 0x20
works as expected. Using the options '-S --mainaffinity=0' leads to:
- monitor, mask 0x01
- measure thread 1, mask 0x01
- measure thread 2, mask 0x01
- measure thread 3, mask 0x01
because the mask of the main thread has been reset early to 0x01 and
does not allow a CPU mask outside of this mask while setting the
affinity for the new threads.
Delay setting the affinity of the main/ monitor thread after the
measuring threads have been deployed. This leads to the following
state:
- monitor, mask 0x01
- measure thread 1, mask 0x01
- measure thread 2, mask 0x10
- measure thread 3, mask 0x20
Signed-off-by: Sebastian Andrzej Savior <bigeasy@linutronix.de>
Signed-off-by: John Kacur <jkacur@redhat.com>
-rw-r--r-- | src/cyclictest/cyclictest.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c index da430dc..d90228a 100644 --- a/src/cyclictest/cyclictest.c +++ b/src/cyclictest/cyclictest.c @@ -1868,10 +1868,7 @@ int main(int argc, char **argv) printf("Online CPUs = %d\n", online_cpus); } - /* Restrict the main pid to the affinity specified by the user */ - if (main_affinity_mask != NULL) { - set_main_thread_affinity(main_affinity_mask); - } else if (affinity_mask != NULL) { + if (affinity_mask != NULL) { set_main_thread_affinity(affinity_mask); if (verbose) printf("Using %u cpus.\n", @@ -2145,6 +2142,10 @@ int main(int argc, char **argv) fatal("failed to create thread %d: %s\n", i, strerror(status)); } + /* Restrict the main pid to the affinity specified by the user */ + if (main_affinity_mask != NULL) + set_main_thread_affinity(main_affinity_mask); + if (use_fifo) { status = pthread_create(&fifo_threadid, NULL, fifothread, NULL); if (status) |