]> git.ipfire.org Git - thirdparty/util-linux.git/commit
cpuset: Use stride in cpulist_create
authorJesse Rosenstock <jmr@google.com>
Tue, 1 Jul 2025 10:38:24 +0000 (12:38 +0200)
committerJesse Rosenstock <jmr@google.com>
Tue, 8 Jul 2025 10:21:42 +0000 (12:21 +0200)
commit9938ae4d49f64cbcfb48158d537454ac740d7dba
treeb8546130d92f8732738f5fbed3d585202af78d94
parent6c87a3ac5ee96194e0e461db24b1bbfe369bdb59
cpuset: Use stride in cpulist_create

Format cpu lists for `taskset -c`, `lscpu`, etc. using stride.  This
usually produces shorter output.

Now:
% ./taskset -c 0-24:2,25-47:4 ./taskset -pc 0
pid 3937653's current affinity list: 0-24:2,25-45:4

Previously:
% ./taskset -c 0-23:2,24-47:4 ./taskset -pc 0
pid 3933321's current affinity list: 0,2,4,6,8,10,12,14,16,18,20,22,24,28,32,36,40,44

The ranges are constructed greedily; in general it is difficult to
construct a minimal list.
% ./taskset -c 0-63:3,0-63:4 ./taskset -pc 0
pid 3926213's current affinity list: 0,3,4-8:2,9-15:3,16-20:2,21-27:3,28-32:2,33-39:3,40-44:2,45

Signed-off-by: Jesse Rosenstock <jmr@google.com>
lib/cpuset.c
tests/expected/lscpu/lscpu-x86_64-64cpu
tests/expected/misc/bits-list
tests/expected/misc/bits-parse-mask
tests/expected/schedutils/cpuset