On 01/31/2019 10:19 AM, Martynas Pumputis wrote: > Previously, bpf_num_possible_cpus() had a bug when calculating a > number of possible CPUs in the case of sparse CPU allocations, as > it was considering only the first range or element of > /sys/devices/system/cpu/possible. > > E.g. in the case of "0,2-3" (CPU 1 is not available), the function > returned 1 instead of 3. > > This patch fixes the function by making it parse all CPU ranges and > elements. > > Signed-off-by: Martynas Pumputis <m...@lambda.lt> > > --- > Testing of the patch: > https://gist.github.com/brb/5369b5cfd08babb80cf2c4081dc19762 > --- > tools/testing/selftests/bpf/bpf_util.h | 31 +++++++++++++++++--------- > 1 file changed, 21 insertions(+), 10 deletions(-) > > diff --git a/tools/testing/selftests/bpf/bpf_util.h > b/tools/testing/selftests/bpf/bpf_util.h > index 315a44fa32af..442c3ab2d688 100644 > --- a/tools/testing/selftests/bpf/bpf_util.h > +++ b/tools/testing/selftests/bpf/bpf_util.h > @@ -9,11 +9,12 @@ > > static inline unsigned int bpf_num_possible_cpus(void) > { > + > static const char *fcpu = "/sys/devices/system/cpu/possible";
Applied and removed above whitespace while at it, thanks!