Re: [PATCH 6/8] lib: bitmap: support "N" as an alias for size of bitmap

From: Paul Gortmaker
Date: Wed Jan 27 2021 - 03:24:52 EST


[Re: [PATCH 6/8] lib: bitmap: support "N" as an alias for size of bitmap] On 26/01/2021 (Tue 23:37) Andy Shevchenko wrote:

> On Tue, Jan 26, 2021 at 12:11:39PM -0500, Paul Gortmaker wrote:
> > While this is done for all bitmaps, the original use case in mind was
> > for CPU masks and cpulist_parse() as described below.
> >
> > It seems that a common configuration is to use the 1st couple cores for
> > housekeeping tasks. This tends to leave the remaining ones to form a
> > pool of similarly configured cores to take on the real workload of
> > interest to the user.
> >
> > So on machine A - with 32 cores, it could be 0-3 for "system" and then
> > 4-31 being used in boot args like nohz_full=, or rcu_nocbs= as part of
> > setting up the worker pool of CPUs.
> >
> > But then newer machine B is added, and it has 48 cores, and so while
> > the 0-3 part remains unchanged, the pool setup cpu list becomes 4-47.
> >
> > Multiple deployment becomes easier when we can just simply replace 31
> > and 47 with "N" and let the system substitute in the actual number at
> > boot; a number that it knows better than we do.
>
> I would accept lower 'n' as well.
>
> ...
>
> > -static const char *bitmap_getnum(const char *str, unsigned int *num)
> > +static const char *__bitmap_getnum(const char *str, unsigned int nbits,
> > + unsigned int *num)
> > {
> > unsigned long long n;
> > unsigned int len;
> >
> > + if (str[0] == 'N') {
> > + *num = nbits - 1;
> > + return str + 1;
> > + }
>
> But locating it here makes possible to enter a priori invalid input, like N for
> start of the region.

Actually, no. N can be valid input for start of the region - or for any
field in the region. I was originally thinking like you -- that N
was only valid as the end of the region, but Yury made a compelling
argument that N should be treated exactly as any other number is.

Skip down to where Yury says:
So, when I do echo N-N > cpuset.cpus, I want it to work as
if I do echo 15-15 > cpuset.cpus.

https://lore.kernel.org/lkml/20210126171811.GC23530@xxxxxxxxxxxxx/

You weren't Cc'd at that point as I'd not added any self-test changes
to the series yet - so you didn't probably see that discussion.

This is why you'll see "N-N:N/N" added as a self-test that works. It
doesn't make any more sense than using 15-15:15/15 does (vs. "15") but
both are equally valid inputs, in that they don't trigger an error.

Thanks,
Paul.
--

>
> I think this should be separate helper which is called in places where it makes
> sense.
>
> > len = _parse_integer(str, 10, &n);
> > if (!len)
> > return ERR_PTR(-EINVAL);
>
>
> --
> With Best Regards,
> Andy Shevchenko
>
>