Re: [PATCH v2 1/1] cpumask: Don't waste memory for sysfs cpulist nodes

From: Rasmus Villemoes
Date: Fri Sep 23 2022 - 08:25:27 EST


On 22/09/2022 21.49, Andy Shevchenko wrote:

> + * which allows to count the exact maximum length in the worst case,
> + * i.e. when each second CPU is being listed.

I don't think that's actually the worst case. I think that would be
where 2 out of 3 cpus are listed. I.e., with 16 cpus

0-1,3-4,6-7,9-10,12-13,15

is certainly longer than

0,2,4,6,8,10,12,14

It's trivial to see that no bitmap with four consecutive bits can be a
worst-case, and any bitmap with some three consecutive bits is as bad as
the same one with the middle bit cleared (the rep just changes a - to a
,), so the worst case is definitely obtained among bitmaps with at most
two consecutive bits.

Rasmus