diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2019-11-09 17:05:14 +0100 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2019-11-09 17:07:44 +0100 |
commit | a82fb1b9d8a046e01dbad33bb57d064815d60e5c (patch) | |
tree | e4bebb81de379358ff6bff46948894069818f7d4 | |
parent | 2f57b5139e701e04a7b543220f6bb117b5e71967 (diff) | |
download | busybox-w32-a82fb1b9d8a046e01dbad33bb57d064815d60e5c.tar.gz busybox-w32-a82fb1b9d8a046e01dbad33bb57d064815d60e5c.tar.bz2 busybox-w32-a82fb1b9d8a046e01dbad33bb57d064815d60e5c.zip |
taskset: implement stride argument
function old new delta
taskset_main 925 986 +61
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | util-linux/taskset.c | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/util-linux/taskset.c b/util-linux/taskset.c index 157bf5e4c..df1bc0a4f 100644 --- a/util-linux/taskset.c +++ b/util-linux/taskset.c | |||
@@ -121,10 +121,8 @@ static unsigned long *get_aff(int pid, unsigned *sz) | |||
121 | * Parse the CPU list and set the mask accordingly. | 121 | * Parse the CPU list and set the mask accordingly. |
122 | * | 122 | * |
123 | * The list element can be either a CPU index or a range of CPU indices. | 123 | * The list element can be either a CPU index or a range of CPU indices. |
124 | * Example: "1,3,5-7". | 124 | * Example: "1,3,5-7". Stride can be specified: "0-7:2" is "0,2,4,6". |
125 | * | 125 | * Note: leading and trailing whitespace is not allowed. |
126 | * note1: stride (e.g. 0-255:2) is not supported | ||
127 | * note2: leading and trailing whitespace is not allowed | ||
128 | * util-linux 2.31 allows leading and sometimes trailing whitespace: | 126 | * util-linux 2.31 allows leading and sometimes trailing whitespace: |
129 | * ok: taskset -c ' 1, 2' | 127 | * ok: taskset -c ' 1, 2' |
130 | * ok: taskset -c ' 1 , 2' | 128 | * ok: taskset -c ' 1 , 2' |
@@ -137,21 +135,28 @@ static void parse_cpulist(ul *mask, unsigned max, char *s) | |||
137 | char *aff = s; | 135 | char *aff = s; |
138 | for (;;) { | 136 | for (;;) { |
139 | unsigned bit, end; | 137 | unsigned bit, end; |
138 | unsigned stride = 1; | ||
140 | 139 | ||
141 | bit = end = bb_strtou(s, &s, 10); | 140 | bit = end = bb_strtou(s, &s, 10); |
142 | if (*s == '-') { | 141 | if (*s == '-') { |
143 | s++; | 142 | s++; |
144 | end = bb_strtou(s, &s, 10); | 143 | end = bb_strtou(s, &s, 10); |
144 | if (*s == ':') { | ||
145 | s++; | ||
146 | stride = bb_strtou(s, &s, 10); | ||
147 | } | ||
145 | } | 148 | } |
146 | if ((*s != ',' && *s != '\0') | 149 | if ((*s != ',' && *s != '\0') |
147 | || bit > end | 150 | || bit > end |
148 | || end == UINT_MAX /* bb_strtou returns this on malformed / ERANGE numbers */ | 151 | || end == UINT_MAX /* bb_strtou returns this on malformed / ERANGE numbers */ |
152 | || stride == 0 | ||
153 | || stride == UINT_MAX | ||
149 | ) { | 154 | ) { |
150 | bb_error_msg_and_die("bad affinity '%s'", aff); | 155 | bb_error_msg_and_die("bad affinity '%s'", aff); |
151 | } | 156 | } |
152 | while (bit <= end && bit < max) { | 157 | while (bit <= end && bit < max) { |
153 | mask[bit / BITS_UL] |= (1UL << (bit & MASK_UL)); | 158 | mask[bit / BITS_UL] |= (1UL << (bit & MASK_UL)); |
154 | bit++; | 159 | bit += stride; |
155 | } | 160 | } |
156 | if (*s == '\0') | 161 | if (*s == '\0') |
157 | break; | 162 | break; |