Commit 6581114
committed
libct: make MaxCPU exclusive
MaxCPU was documented and enforced as the highest CPU/NUMA node ID that
ToCPUSet accepts, i.e. an inclusive bound, while unix.NewCPUSet takes an
exclusive one. As a result, tryResetCPUAffinity's NewCPUSet(MaxCPU) mask
was one ID short of what ToCPUSet can parse.
This is harmless in practice, as sched_setaffinity(2) truncates the mask
to cpumask_size() anyway, and no kernel is configured with anywhere near
64K CPUs. Still, having a single constant mean two different things in
two different files is asking for a real off-by-one later on.
Make MaxCPU exclusive to match NewCPUSet, so that NewCPUSet(MaxCPU) is
correct as written, and ToCPUSet's NewCPUSet(maxID+1) can never exceed
it. This restores the "ret >= max" check and the "max-1" wording used
before MaxCPU was introduced, and shifts the test boundary cases by one.
Fixes: daf934f ("libct: use CPUSetDynamic for affinity and mempolicy masks")
Fixes: c55649b ("libct: reuse configs.MaxCPU")
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>1 parent f1a7e38 commit 6581114
2 files changed
Lines changed: 11 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
307 | 307 | | |
308 | 308 | | |
309 | 309 | | |
310 | | - | |
311 | | - | |
312 | | - | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
313 | 314 | | |
314 | 315 | | |
315 | 316 | | |
| |||
349 | 350 | | |
350 | 351 | | |
351 | 352 | | |
352 | | - | |
353 | | - | |
| 353 | + | |
| 354 | + | |
354 | 355 | | |
355 | 356 | | |
356 | 357 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
| 62 | + | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
74 | 75 | | |
75 | 76 | | |
76 | 77 | | |
77 | | - | |
78 | | - | |
| 78 | + | |
| 79 | + | |
79 | 80 | | |
80 | 81 | | |
81 | 82 | | |
| |||
0 commit comments