On Mon, Jan 24, 2022 at 05:26:26PM +0100, Sebastian Andrzej Siewior wrote: > On 2022-01-24 09:58:31 [-0300], Marcelo Tosatti wrote: > > You mean "using all CPUs which are part of the current affinity mask by > > default" ? (where current affinity mask would mean user specified CPU > > mask). > > > > > And then either specify the > > > requested CPU mask or use explicitly all CPUs. > > > > Do you mean to drop > > > > /* > > * Clear bits that are not set in both the cpuset from the > > * environment, and in the user specified affinity. > > > > And just attempt to use the user specified mask? (which will then return > > failure to the user in which case he can correct it). > > > After reading it again, I don't get it. > cyclictest -a > > Uses all CPUs in the system. > > cyclictest -a $CPU > > Uses the $CPU (mask) specified. If $CPU is not part of the current CPU > mask, why shouldn't it work? -a, --affinity[=PROC-SET] Run threads on the set of processors given by PROC-SET. If PROC-SET is not specified, all processors will be used. Threads will be assigned to processors in the set in numeric order, in a round-robin fashion. The set of processors can be specified as A,B,C, or A-C, or A-B,D-F, and so on*. The ! character can be used to negate a set. For example, !B-D means to use all available CPUs except B through D. The cpu numbers are the same as shown in the processor field in /proc/cpuinfo. See numa(3) for more information on specifying CPU sets. * Support for CPU sets requires libnuma version >= 2. For libnuma v1, PROC-SET, if specified, must be a single CPU number. /* * After this function is called, affinity_mask is the intersection of * the user supplied affinity mask and the affinity mask from the run * time environment */ static void use_current_cpuset(int max_cpus, struct bitmask *cpumask) { struct bitmask *curmask; int i; curmask = numa_allocate_cpumask(); numa_sched_getaffinity(getpid(), curmask); /* * Clear bits that are not set in both the cpuset from the * environment, and in the user specified affinity. */ for (i = 0; i < max_cpus; i++) { if ((!numa_bitmask_isbitset(cpumask, i)) || (!numa_bitmask_isbitset(curmask, i))) numa_bitmask_clearbit(cpumask, i); } numa_bitmask_free(curmask); } Consider 8 CPU system booted with isolcpus=3-7, and execution of "cyclictest -a 3-7". sched_getaffinity() returns mask with bits set for CPUs 0 and 1. The user supplied mask has bits 3-7 set. The intersection between the user supplied mask and the affinity mask from the run time environment has no bits set.