Jesse Rosenstock wants taskset to work with an arbitrary number of

leading zeroes for some reason, so take the rightmost 8k of mask data
and test with leading zeroes. (It could instead specifically skip
leading zeroes, but would still have to check sizeof(toybuf) anyway.)

Again, the 6.16 kernel can only set NR_CPUS to 8k (1/4 of the bits in
toybuf) for 2 architectures (x86-64 and powerpc64, and ARM64 maxes out
at 4k (1/8 of toybuf). Last I checked nobody's made hardware anywhere
near that: they thought they might 20 years ago but NUMA didn't scale.
Beowulf clusters existed back in the 1990s and if you really want to
have a cluster mmap() shared memory from network storage you can just do
that and address contentional manually (with manual flock and madvise or
your own bespoke mechanism), or create data stores like riak, or...
This commit is contained in:
Rob Landley 2025-09-05 16:59:37 -05:00
parent be86489b16
commit 62284825a7
2 changed files with 6 additions and 2 deletions

View File

@ -31,6 +31,6 @@ testing 'run on last' \
"$((CPUS-1))\n" '' ''
testing "long mask doesn't segfault" \
'taskset $(printf %99999s | tr \ f) echo; echo $?' '\n0\n' '' ''
'taskset $(printf %99999s | tr \ 0)f echo; echo $?' '\n0\n' '' ''
testing "taskset error checking" \
'taskset 0 echo nope 2>/dev/null; echo $?' '1\n' '' ''

View File

@ -70,7 +70,11 @@ static void do_taskset(pid_t pid)
// Convert hex string to mask[] bits
memset(toybuf, 0, sizeof(toybuf));
k = minof(strlen(s = *toys.optargs), 2*sizeof(toybuf));
j = (k = strlen(s = *toys.optargs))-2*sizeof(toybuf);
if (j>0) {
s += j;
k -= j;
}
s += k;
for (j = 0; j<k; j++) {
unsigned long digit = *(--s) - '0';