On Thu, 14 Jan 2021, Jonathan Schwender wrote: > 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 <schwenderjonathan@xxxxxxxxx> > --- > src/cyclictest/cyclictest.c | 7 +++++-- > 1 file changed, 5 insertions(+), 2 deletions(-) > > diff --git a/src/cyclictest/cyclictest.c b/src/cyclictest/cyclictest.c > index f38c453..b104e4c 100644 > --- a/src/cyclictest/cyclictest.c > +++ b/src/cyclictest/cyclictest.c > @@ -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) { > -- > 2.29.2 > > Signed-off-by: John Kacur <jkacur@xxxxxxxxxx> Thanks