cyclictest: Fix --affinity when intermediate CPUs are offline
PATCH 1/1 cyclictest: Fix --affinity when intermediate CPUs are offline
Use max_cpus = sysconf(_SC_NPROCESSORS_CONF) to determine the number of the maximum CPU (+1).
The cpu_for_thread_*() functions check the first max_cpus bits in the cpuset / cpumask.
This fixes failing to set the affinity to CPUs >= num_online_cpus, if some intermediate CPU is offline, e.g. on an AMD system with nosmt.
Signed-off-by Jonathan Schwender <[email protected]>
--- src/cyclictest/cyclictest.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)
src/cyclictest/cyclictest.c +5 -2
@@ -1741,7 +1741,8 @@ int main(int argc, char **argv)int signum =SIGALRM ;int mode;int cpu; -int max_cpus =sysconf (_SC_NPROCESSORS_ONLN); +int max_cpus =sysconf (_SC_NPROCESSORS_CONF); +int online_cpus =sysconf (_SC_NPROCESSORS_ONLN);int i, ret =-1 ;int status;
@@ -1750,8 +1751,10 @@ int main(int argc, char **argv)if (check_privs ())exit (EXIT_FAILURE ); -if (verbose) +if (verbose) {printf ("Max CPUs = %d\n" , max_cpus); +printf ("Online CPUs = %d\n" , online_cpus); + }/* Restrict the main pid to the affinity specified by the user */ if (affinity_mask !=NULL ) {
Signature · 1 line
2.29.2
Quoted 43 lines · Jonathan Schwender
Use
max_cpus=sysconf(_SC_NPROCESSORS_CONF)to determine the number of the maximum CPU (+1).
The cpu_for_thread_*() functions check the firstmax_cpusbits in the cpuset / cpumask.
This fixes failing to set the affinity to CPUs >=num_online_cpus, if some intermediate CPU is offline, e.g. on an AMD system with nosmt.Signed-off-by Jonathan Schwender <[email protected]>--- src/cyclictest/cyclictest.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-)src/cyclictest/cyclictest.c +5
-2@@ -1741,7 +1741,8 @@ int main(int argc, char **argv)int signum =SIGALRM ;int mode;int cpu; -int max_cpus =sysconf (_SC_NPROCESSORS_ONLN); +int max_cpus =sysconf (_SC_NPROCESSORS_CONF); +int online_cpus =sysconf (_SC_NPROCESSORS_ONLN);int i, ret =-1 ;int status;@@ -1750,8 +1751,10 @@ int main(int argc, char **argv)if (check_privs ())exit (EXIT_FAILURE ); -if (verbose) +if (verbose) {printf ("Max CPUs = %d\n" , max_cpus); +printf ("Online CPUs = %d\n" , online_cpus); + }/* Restrict the main pid to the affinity specified by the user */ if (affinity_mask !=NULL ) {Signature · 1 line
2.29.2
Signed-off-by John Kacur <[email protected]>
Thanks