linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/2] bitmap_parselist: support 'all' semantics
@ 2021-04-21  3:13 Yury Norov
  2021-04-21  3:13 ` [PATCH 1/2] bitmap_parse: " Yury Norov
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Yury Norov @ 2021-04-21  3:13 UTC (permalink / raw)
  To: linux-kernel, rcu, linux-doc, Andrew Morton, Paul E. McKenney
  Cc: Yury Norov, Andy Shevchenko, Joel Fernandes, Jonathan Corbet,
	Lai Jiangshan, Mathieu Desnoyers, Palmer Dabbelt, Paul Gortmaker,
	Randy Dunlap, Rasmus Villemoes, Steven Rostedt

RCU code supports a special group 'all' which selects all bits in a bitmap.
We have recently added 'N' extension for bitmap parse, so that '0-N' would
have exactly the same meaning as 'all'. But because the 'all' is already
used by RCU, it would be reasonable to support it in core bitmap code as a
common and easy-readable alias for '0-N'.

Moving the 'all' support to core bitmap code adds another level of
flexibility for system configuration by supporting patterns. For example,
every second bit in cpumask may be selected like this:
	isolcpus=all:1/2

v2:
 - cleanup patch 1;
 - in patch 2 explain why dropping legacy comment.

Yury Norov (2):
  bitmap_parse: support 'all' semantics
  rcu/tree_plugin: don't handle the case of 'all' CPU range

 Documentation/admin-guide/kernel-parameters.rst | 5 +++++
 kernel/rcu/tree_plugin.h                        | 9 +++------
 lib/bitmap.c                                    | 9 +++++++++
 lib/test_bitmap.c                               | 7 +++++++
 4 files changed, 24 insertions(+), 6 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2] bitmap_parse: support 'all' semantics
  2021-04-21  3:13 [PATCH v2 0/2] bitmap_parselist: support 'all' semantics Yury Norov
@ 2021-04-21  3:13 ` Yury Norov
  2021-04-21 15:19   ` Steven Rostedt
  2021-04-21  3:13 ` [PATCH 2/2] rcu/tree_plugin: don't handle the case of 'all' CPU range Yury Norov
  2021-04-21 17:30 ` [PATCH v2 0/2] bitmap_parselist: support 'all' semantics Paul E. McKenney
  2 siblings, 1 reply; 11+ messages in thread
From: Yury Norov @ 2021-04-21  3:13 UTC (permalink / raw)
  To: linux-kernel, rcu, linux-doc, Andrew Morton, Paul E. McKenney
  Cc: Yury Norov, Andy Shevchenko, Joel Fernandes, Jonathan Corbet,
	Lai Jiangshan, Mathieu Desnoyers, Palmer Dabbelt, Paul Gortmaker,
	Randy Dunlap, Rasmus Villemoes, Steven Rostedt

RCU code supports an 'all' group as a special case when parsing
rcu_nocbs parameter. This patch moves the 'all' support to the core
bitmap_parse code, so that all bitmap users can enjoy this extension.

Moving 'all' parsing to a bitmap_parse level, also allows users to
pass patterns together with 'all' in regular group:pattern format

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 Documentation/admin-guide/kernel-parameters.rst | 5 +++++
 lib/bitmap.c                                    | 9 +++++++++
 lib/test_bitmap.c                               | 7 +++++++
 3 files changed, 21 insertions(+)

diff --git a/Documentation/admin-guide/kernel-parameters.rst b/Documentation/admin-guide/kernel-parameters.rst
index 3996b54158bf..7178d9c4de7f 100644
--- a/Documentation/admin-guide/kernel-parameters.rst
+++ b/Documentation/admin-guide/kernel-parameters.rst
@@ -76,6 +76,11 @@ to change, such as less cores in the CPU list, then N and any ranges using N
 will also change.  Use the same on a small 4 core system, and "16-N" becomes
 "16-3" and now the same boot input will be flagged as invalid (start > end).
 
+The special case-tolerant group name "all" has a meaning of selecting all CPUs,
+such that "isolcpus=all" is the equivalent of "isolcpus=0-N".
+
+The semantics of "N" and "all" is supported on a level of bitmaps and holds for
+all users of bitmap_parse().
 
 This document may not be entirely up to date and comprehensive. The command
 "modinfo -p ${modulename}" shows a current list of all parameters of a loadable
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 74ceb02f45e3..6e29b2aae6ba 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -581,6 +581,14 @@ static const char *bitmap_parse_region(const char *str, struct region *r)
 {
 	unsigned int lastbit = r->nbits - 1;
 
+	if (!strncasecmp(str, "all", 3)) {
+		r->start = 0;
+		r->end = lastbit;
+		str += 3;
+
+		goto check_pattern;
+	}
+
 	str = bitmap_getnum(str, &r->start, lastbit);
 	if (IS_ERR(str))
 		return str;
@@ -595,6 +603,7 @@ static const char *bitmap_parse_region(const char *str, struct region *r)
 	if (IS_ERR(str))
 		return str;
 
+check_pattern:
 	if (end_of_region(*str))
 		goto no_pattern;
 
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index 9cd575583180..4ea73f5aed41 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -366,6 +366,13 @@ static const struct test_bitmap_parselist parselist_tests[] __initconst = {
 	{0, "0-31:1/3,1-31:1/3,2-31:1/3",	&exp1[8 * step], 32, 0},
 	{0, "1-10:8/12,8-31:24/29,0-31:0/3",	&exp1[9 * step], 32, 0},
 
+	{0,	  "all",		&exp1[8 * step], 32, 0},
+	{0,	  "0, 1, all,  ",	&exp1[8 * step], 32, 0},
+	{0,	  "all:1/2",		&exp1[4 * step], 32, 0},
+	{0,	  "ALL:1/2",		&exp1[4 * step], 32, 0},
+	{-EINVAL, "al", NULL, 8, 0},
+	{-EINVAL, "alll", NULL, 8, 0},
+
 	{-EINVAL, "-1",	NULL, 8, 0},
 	{-EINVAL, "-0",	NULL, 8, 0},
 	{-EINVAL, "10-1", NULL, 8, 0},
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH 2/2] rcu/tree_plugin: don't handle the case of 'all' CPU range
  2021-04-21  3:13 [PATCH v2 0/2] bitmap_parselist: support 'all' semantics Yury Norov
  2021-04-21  3:13 ` [PATCH 1/2] bitmap_parse: " Yury Norov
@ 2021-04-21  3:13 ` Yury Norov
  2021-04-21 17:30 ` [PATCH v2 0/2] bitmap_parselist: support 'all' semantics Paul E. McKenney
  2 siblings, 0 replies; 11+ messages in thread
From: Yury Norov @ 2021-04-21  3:13 UTC (permalink / raw)
  To: linux-kernel, rcu, linux-doc, Andrew Morton, Paul E. McKenney
  Cc: Yury Norov, Andy Shevchenko, Joel Fernandes, Jonathan Corbet,
	Lai Jiangshan, Mathieu Desnoyers, Palmer Dabbelt, Paul Gortmaker,
	Randy Dunlap, Rasmus Villemoes, Steven Rostedt

The 'all' semantics is now supported by the bitmap_parselist() so we can
drop supporting it as a special case in RCU code. Since 'all' is properly
supported in core bitmap code, drop legacy comment in RCU for it.

This patch does not add any functional changes for existing users.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 kernel/rcu/tree_plugin.h | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/kernel/rcu/tree_plugin.h b/kernel/rcu/tree_plugin.h
index 464b16132866..334eaf4d561f 100644
--- a/kernel/rcu/tree_plugin.h
+++ b/kernel/rcu/tree_plugin.h
@@ -1511,13 +1511,10 @@ static void rcu_cleanup_after_idle(void)
 static int __init rcu_nocb_setup(char *str)
 {
 	alloc_bootmem_cpumask_var(&rcu_nocb_mask);
-	if (!strcasecmp(str, "all"))		/* legacy: use "0-N" instead */
+	if (cpulist_parse(str, rcu_nocb_mask)) {
+		pr_warn("rcu_nocbs= bad CPU range, all CPUs set\n");
 		cpumask_setall(rcu_nocb_mask);
-	else
-		if (cpulist_parse(str, rcu_nocb_mask)) {
-			pr_warn("rcu_nocbs= bad CPU range, all CPUs set\n");
-			cpumask_setall(rcu_nocb_mask);
-		}
+	}
 	return 1;
 }
 __setup("rcu_nocbs=", rcu_nocb_setup);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] bitmap_parse: support 'all' semantics
  2021-04-21  3:13 ` [PATCH 1/2] bitmap_parse: " Yury Norov
@ 2021-04-21 15:19   ` Steven Rostedt
  2021-04-21 15:57     ` Paul E. McKenney
  2021-04-21 23:45     ` Paul Gortmaker
  0 siblings, 2 replies; 11+ messages in thread
From: Steven Rostedt @ 2021-04-21 15:19 UTC (permalink / raw)
  To: Yury Norov
  Cc: linux-kernel, rcu, linux-doc, Andrew Morton, Paul E. McKenney,
	Andy Shevchenko, Joel Fernandes, Jonathan Corbet, Lai Jiangshan,
	Mathieu Desnoyers, Palmer Dabbelt, Paul Gortmaker, Randy Dunlap,
	Rasmus Villemoes

On Tue, 20 Apr 2021 20:13:25 -0700
Yury Norov <yury.norov@gmail.com> wrote:

> @@ -76,6 +76,11 @@ to change, such as less cores in the CPU list, then N and any ranges using N
>  will also change.  Use the same on a small 4 core system, and "16-N" becomes
>  "16-3" and now the same boot input will be flagged as invalid (start > end).
>  
> +The special case-tolerant group name "all" has a meaning of selecting all CPUs,
> +such that "isolcpus=all" is the equivalent of "isolcpus=0-N".

I'm OK with the concept of this patch set, but really? That is a horrible
example. One should NEVER set isolcpus to all!

-- Steve


> +
> +The semantics of "N" and "all" is supported on a level of bitmaps and holds for
> +all users of bitmap_parse().
>  

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] bitmap_parse: support 'all' semantics
  2021-04-21 15:19   ` Steven Rostedt
@ 2021-04-21 15:57     ` Paul E. McKenney
  2021-04-21 23:45     ` Paul Gortmaker
  1 sibling, 0 replies; 11+ messages in thread
From: Paul E. McKenney @ 2021-04-21 15:57 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Yury Norov, linux-kernel, rcu, linux-doc, Andrew Morton,
	Andy Shevchenko, Joel Fernandes, Jonathan Corbet, Lai Jiangshan,
	Mathieu Desnoyers, Palmer Dabbelt, Paul Gortmaker, Randy Dunlap,
	Rasmus Villemoes

On Wed, Apr 21, 2021 at 11:19:32AM -0400, Steven Rostedt wrote:
> On Tue, 20 Apr 2021 20:13:25 -0700
> Yury Norov <yury.norov@gmail.com> wrote:
> 
> > @@ -76,6 +76,11 @@ to change, such as less cores in the CPU list, then N and any ranges using N
> >  will also change.  Use the same on a small 4 core system, and "16-N" becomes
> >  "16-3" and now the same boot input will be flagged as invalid (start > end).
> >  
> > +The special case-tolerant group name "all" has a meaning of selecting all CPUs,
> > +such that "isolcpus=all" is the equivalent of "isolcpus=0-N".
> 
> I'm OK with the concept of this patch set, but really? That is a horrible
> example. One should NEVER set isolcpus to all!

How about "isolcpus=all:2/4"?  ;-)

							Thanx, Paul

> -- Steve
> 
> 
> > +
> > +The semantics of "N" and "all" is supported on a level of bitmaps and holds for
> > +all users of bitmap_parse().
> >  

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 0/2] bitmap_parselist: support 'all' semantics
  2021-04-21  3:13 [PATCH v2 0/2] bitmap_parselist: support 'all' semantics Yury Norov
  2021-04-21  3:13 ` [PATCH 1/2] bitmap_parse: " Yury Norov
  2021-04-21  3:13 ` [PATCH 2/2] rcu/tree_plugin: don't handle the case of 'all' CPU range Yury Norov
@ 2021-04-21 17:30 ` Paul E. McKenney
  2021-04-21 17:49   ` Yury Norov
  2 siblings, 1 reply; 11+ messages in thread
From: Paul E. McKenney @ 2021-04-21 17:30 UTC (permalink / raw)
  To: Yury Norov
  Cc: linux-kernel, rcu, linux-doc, Andrew Morton, Andy Shevchenko,
	Joel Fernandes, Jonathan Corbet, Lai Jiangshan,
	Mathieu Desnoyers, Palmer Dabbelt, Paul Gortmaker, Randy Dunlap,
	Rasmus Villemoes, Steven Rostedt

On Tue, Apr 20, 2021 at 08:13:24PM -0700, Yury Norov wrote:
> RCU code supports a special group 'all' which selects all bits in a bitmap.
> We have recently added 'N' extension for bitmap parse, so that '0-N' would
> have exactly the same meaning as 'all'. But because the 'all' is already
> used by RCU, it would be reasonable to support it in core bitmap code as a
> common and easy-readable alias for '0-N'.
> 
> Moving the 'all' support to core bitmap code adds another level of
> flexibility for system configuration by supporting patterns. For example,
> every second bit in cpumask may be selected like this:
> 	isolcpus=all:1/2
> 
> v2:
>  - cleanup patch 1;
>  - in patch 2 explain why dropping legacy comment.

Nice!

I have pulled this into -rcu with some minor updates, including replacing
the "isolcpus=all" with "rcu_nocbs=all:1/2" per Steve Rostedt's feedback.

Could you please check to make sure that I didn't mess anything up?

If tests go well, this will go into -next later today or tomorrow.
Although I cannot prove that this will not make the upcoming merge window,
but Murphy insists that it will instead be the v5.14 merge window.

							Thanx, Paul

> Yury Norov (2):
>   bitmap_parse: support 'all' semantics
>   rcu/tree_plugin: don't handle the case of 'all' CPU range
> 
>  Documentation/admin-guide/kernel-parameters.rst | 5 +++++
>  kernel/rcu/tree_plugin.h                        | 9 +++------
>  lib/bitmap.c                                    | 9 +++++++++
>  lib/test_bitmap.c                               | 7 +++++++
>  4 files changed, 24 insertions(+), 6 deletions(-)
> 
> -- 
> 2.25.1
> 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 0/2] bitmap_parselist: support 'all' semantics
  2021-04-21 17:30 ` [PATCH v2 0/2] bitmap_parselist: support 'all' semantics Paul E. McKenney
@ 2021-04-21 17:49   ` Yury Norov
  0 siblings, 0 replies; 11+ messages in thread
From: Yury Norov @ 2021-04-21 17:49 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: linux-kernel, rcu, linux-doc, Andrew Morton, Andy Shevchenko,
	Joel Fernandes, Jonathan Corbet, Lai Jiangshan,
	Mathieu Desnoyers, Palmer Dabbelt, Paul Gortmaker, Randy Dunlap,
	Rasmus Villemoes, Steven Rostedt

On Wed, Apr 21, 2021 at 10:30:08AM -0700, Paul E. McKenney wrote:
> On Tue, Apr 20, 2021 at 08:13:24PM -0700, Yury Norov wrote:
> > RCU code supports a special group 'all' which selects all bits in a bitmap.
> > We have recently added 'N' extension for bitmap parse, so that '0-N' would
> > have exactly the same meaning as 'all'. But because the 'all' is already
> > used by RCU, it would be reasonable to support it in core bitmap code as a
> > common and easy-readable alias for '0-N'.
> > 
> > Moving the 'all' support to core bitmap code adds another level of
> > flexibility for system configuration by supporting patterns. For example,
> > every second bit in cpumask may be selected like this:
> > 	isolcpus=all:1/2
> > 
> > v2:
> >  - cleanup patch 1;
> >  - in patch 2 explain why dropping legacy comment.
> 
> Nice!
> 
> I have pulled this into -rcu with some minor updates, including replacing
> the "isolcpus=all" with "rcu_nocbs=all:1/2" per Steve Rostedt's feedback.

Thank you Paul and Steven for fixing this 'isolcpus=all'.
'rcu_nocbs=all:1/2' would look better in the documentation.
 
> Could you please check to make sure that I didn't mess anything up?

Everything is OK. Thank you for fixing this.

> If tests go well, this will go into -next later today or tomorrow.
> Although I cannot prove that this will not make the upcoming merge window,
> but Murphy insists that it will instead be the v5.14 merge window.
> 
> 							Thanx, Paul
> 
> > Yury Norov (2):
> >   bitmap_parse: support 'all' semantics
> >   rcu/tree_plugin: don't handle the case of 'all' CPU range
> > 
> >  Documentation/admin-guide/kernel-parameters.rst | 5 +++++
> >  kernel/rcu/tree_plugin.h                        | 9 +++------
> >  lib/bitmap.c                                    | 9 +++++++++
> >  lib/test_bitmap.c                               | 7 +++++++
> >  4 files changed, 24 insertions(+), 6 deletions(-)
> > 
> > -- 
> > 2.25.1
> > 

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] bitmap_parse: support 'all' semantics
  2021-04-21 15:19   ` Steven Rostedt
  2021-04-21 15:57     ` Paul E. McKenney
@ 2021-04-21 23:45     ` Paul Gortmaker
  1 sibling, 0 replies; 11+ messages in thread
From: Paul Gortmaker @ 2021-04-21 23:45 UTC (permalink / raw)
  To: Steven Rostedt
  Cc: Yury Norov, linux-kernel, rcu, linux-doc, Andrew Morton,
	Paul E. McKenney, Andy Shevchenko, Joel Fernandes,
	Jonathan Corbet, Lai Jiangshan, Mathieu Desnoyers,
	Palmer Dabbelt, Randy Dunlap, Rasmus Villemoes

[Re: [PATCH 1/2] bitmap_parse: support 'all' semantics] On 21/04/2021 (Wed 11:19) Steven Rostedt wrote:

> On Tue, 20 Apr 2021 20:13:25 -0700
> Yury Norov <yury.norov@gmail.com> wrote:
> 
> > @@ -76,6 +76,11 @@ to change, such as less cores in the CPU list, then N and any ranges using N
> >  will also change.  Use the same on a small 4 core system, and "16-N" becomes
> >  "16-3" and now the same boot input will be flagged as invalid (start > end).
> >  
> > +The special case-tolerant group name "all" has a meaning of selecting all CPUs,
> > +such that "isolcpus=all" is the equivalent of "isolcpus=0-N".
> 
> I'm OK with the concept of this patch set, but really? That is a horrible
> example. One should NEVER set isolcpus to all!

It wouldn't have parsed anyways.  The "isolcpus=" would just think "all" was
an unsupported flag and discard it before it ever got to cpu/bitmap
processing.   See 3662daf02350 "sched/isolation: Allow "isolcpus=" to
skip unknown sub-parameters".

The use case example Paul chose (not me; the smart Paul) is better.

Paul.
--

> 
> -- Steve
> 
> 
> > +
> > +The semantics of "N" and "all" is supported on a level of bitmaps and holds for
> > +all users of bitmap_parse().
> >  

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] bitmap_parse: support 'all' semantics
  2021-04-20 10:17   ` Andy Shevchenko
@ 2021-04-20 19:32     ` Yury Norov
  0 siblings, 0 replies; 11+ messages in thread
From: Yury Norov @ 2021-04-20 19:32 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: linux-kernel, rcu, linux-doc, Andrew Morton, Paul E. McKenney,
	Joel Fernandes, Jonathan Corbet, Lai Jiangshan,
	Mathieu Desnoyers, Palmer Dabbelt, Paul Gortmaker, Randy Dunlap,
	Rasmus Villemoes, Steven Rostedt

On Tue, Apr 20, 2021 at 01:17:52PM +0300, Andy Shevchenko wrote:
> On Mon, Apr 19, 2021 at 05:01:30PM -0700, Yury Norov wrote:
> > RCU code supports an 'all' group as a special case when parsing
> > rcu_nocbs parameter. This patch moves the 'all' support to the core
> > bitmap_parse code, so that all bitmap users can enjoy this extension.
> > 
> > Moving 'all' parsing to a bitmap_parse level, also allows users to
> > pass patterns together with 'all' in regular group:pattern format
> 
> ...
> 
> >  	{0, "0-31:1/3,1-31:1/3,2-31:1/3",	&exp1[8 * step], 32, 0},
> >  	{0, "1-10:8/12,8-31:24/29,0-31:0/3",	&exp1[9 * step], 32, 0},
> >  
> > +	{0,	  "all",		&exp1[8 * step], 32, 0},
> > +	{0,	  "0, 1, all,  ",	&exp1[8 * step], 32, 0},
> > +	{0,	  "all:1/2",		&exp1[4 * step], 32, 0},
> > +	{0,	  "ALL:1/2",		&exp1[4 * step], 32, 0},
> 
> > +	{-EINVAL, "al", NULL, 8, 0},
> > +	{-EINVAL, "alll", NULL, 8, 0},
> > +
> 
> Looking at the below hunk it seems like the two above should be actually placed
> there.
> 
> >  	{-EINVAL, "-1",	NULL, 8, 0},
> >  	{-EINVAL, "-0",	NULL, 8, 0},
> >  	{-EINVAL, "10-1", NULL, 8, 0},
> > @@ -384,7 +391,6 @@ static const struct test_bitmap_parselist parselist_tests[] __initconst = {
> >  	{-EINVAL, "a-31:10/1", NULL, 8, 0},
> >  	{-EINVAL, "0-31:a/1", NULL, 8, 0},
> >  	{-EINVAL, "0-\n", NULL, 8, 0},
> > -
> 
> Otherwise this change doesn't belong to the series.

My bad, I'll fix it in v2.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] bitmap_parse: support 'all' semantics
  2021-04-20  0:01 ` [PATCH 1/2] bitmap_parse: " Yury Norov
@ 2021-04-20 10:17   ` Andy Shevchenko
  2021-04-20 19:32     ` Yury Norov
  0 siblings, 1 reply; 11+ messages in thread
From: Andy Shevchenko @ 2021-04-20 10:17 UTC (permalink / raw)
  To: Yury Norov
  Cc: linux-kernel, rcu, linux-doc, Andrew Morton, Paul E. McKenney,
	Joel Fernandes, Jonathan Corbet, Lai Jiangshan,
	Mathieu Desnoyers, Palmer Dabbelt, Paul Gortmaker, Randy Dunlap,
	Rasmus Villemoes, Steven Rostedt

On Mon, Apr 19, 2021 at 05:01:30PM -0700, Yury Norov wrote:
> RCU code supports an 'all' group as a special case when parsing
> rcu_nocbs parameter. This patch moves the 'all' support to the core
> bitmap_parse code, so that all bitmap users can enjoy this extension.
> 
> Moving 'all' parsing to a bitmap_parse level, also allows users to
> pass patterns together with 'all' in regular group:pattern format

...

>  	{0, "0-31:1/3,1-31:1/3,2-31:1/3",	&exp1[8 * step], 32, 0},
>  	{0, "1-10:8/12,8-31:24/29,0-31:0/3",	&exp1[9 * step], 32, 0},
>  
> +	{0,	  "all",		&exp1[8 * step], 32, 0},
> +	{0,	  "0, 1, all,  ",	&exp1[8 * step], 32, 0},
> +	{0,	  "all:1/2",		&exp1[4 * step], 32, 0},
> +	{0,	  "ALL:1/2",		&exp1[4 * step], 32, 0},

> +	{-EINVAL, "al", NULL, 8, 0},
> +	{-EINVAL, "alll", NULL, 8, 0},
> +

Looking at the below hunk it seems like the two above should be actually placed
there.

>  	{-EINVAL, "-1",	NULL, 8, 0},
>  	{-EINVAL, "-0",	NULL, 8, 0},
>  	{-EINVAL, "10-1", NULL, 8, 0},
> @@ -384,7 +391,6 @@ static const struct test_bitmap_parselist parselist_tests[] __initconst = {
>  	{-EINVAL, "a-31:10/1", NULL, 8, 0},
>  	{-EINVAL, "0-31:a/1", NULL, 8, 0},
>  	{-EINVAL, "0-\n", NULL, 8, 0},
> -

Otherwise this change doesn't belong to the series.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2] bitmap_parse: support 'all' semantics
  2021-04-20  0:01 [PATCH " Yury Norov
@ 2021-04-20  0:01 ` Yury Norov
  2021-04-20 10:17   ` Andy Shevchenko
  0 siblings, 1 reply; 11+ messages in thread
From: Yury Norov @ 2021-04-20  0:01 UTC (permalink / raw)
  To: linux-kernel, rcu, linux-doc, Andrew Morton, Paul E. McKenney
  Cc: Yury Norov, Andy Shevchenko, Joel Fernandes, Jonathan Corbet,
	Lai Jiangshan, Mathieu Desnoyers, Palmer Dabbelt, Paul Gortmaker,
	Randy Dunlap, Rasmus Villemoes, Steven Rostedt

RCU code supports an 'all' group as a special case when parsing
rcu_nocbs parameter. This patch moves the 'all' support to the core
bitmap_parse code, so that all bitmap users can enjoy this extension.

Moving 'all' parsing to a bitmap_parse level, also allows users to
pass patterns together with 'all' in regular group:pattern format

Signed-off-by: Yury Norov <yury.norov@gmail.com>
---
 Documentation/admin-guide/kernel-parameters.rst | 5 +++++
 lib/bitmap.c                                    | 9 +++++++++
 lib/test_bitmap.c                               | 8 +++++++-
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/Documentation/admin-guide/kernel-parameters.rst b/Documentation/admin-guide/kernel-parameters.rst
index 3996b54158bf..7178d9c4de7f 100644
--- a/Documentation/admin-guide/kernel-parameters.rst
+++ b/Documentation/admin-guide/kernel-parameters.rst
@@ -76,6 +76,11 @@ to change, such as less cores in the CPU list, then N and any ranges using N
 will also change.  Use the same on a small 4 core system, and "16-N" becomes
 "16-3" and now the same boot input will be flagged as invalid (start > end).
 
+The special case-tolerant group name "all" has a meaning of selecting all CPUs,
+such that "isolcpus=all" is the equivalent of "isolcpus=0-N".
+
+The semantics of "N" and "all" is supported on a level of bitmaps and holds for
+all users of bitmap_parse().
 
 This document may not be entirely up to date and comprehensive. The command
 "modinfo -p ${modulename}" shows a current list of all parameters of a loadable
diff --git a/lib/bitmap.c b/lib/bitmap.c
index 74ceb02f45e3..6e29b2aae6ba 100644
--- a/lib/bitmap.c
+++ b/lib/bitmap.c
@@ -581,6 +581,14 @@ static const char *bitmap_parse_region(const char *str, struct region *r)
 {
 	unsigned int lastbit = r->nbits - 1;
 
+	if (!strncasecmp(str, "all", 3)) {
+		r->start = 0;
+		r->end = lastbit;
+		str += 3;
+
+		goto check_pattern;
+	}
+
 	str = bitmap_getnum(str, &r->start, lastbit);
 	if (IS_ERR(str))
 		return str;
@@ -595,6 +603,7 @@ static const char *bitmap_parse_region(const char *str, struct region *r)
 	if (IS_ERR(str))
 		return str;
 
+check_pattern:
 	if (end_of_region(*str))
 		goto no_pattern;
 
diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c
index 9cd575583180..ab278cfa9145 100644
--- a/lib/test_bitmap.c
+++ b/lib/test_bitmap.c
@@ -366,6 +366,13 @@ static const struct test_bitmap_parselist parselist_tests[] __initconst = {
 	{0, "0-31:1/3,1-31:1/3,2-31:1/3",	&exp1[8 * step], 32, 0},
 	{0, "1-10:8/12,8-31:24/29,0-31:0/3",	&exp1[9 * step], 32, 0},
 
+	{0,	  "all",		&exp1[8 * step], 32, 0},
+	{0,	  "0, 1, all,  ",	&exp1[8 * step], 32, 0},
+	{0,	  "all:1/2",		&exp1[4 * step], 32, 0},
+	{0,	  "ALL:1/2",		&exp1[4 * step], 32, 0},
+	{-EINVAL, "al", NULL, 8, 0},
+	{-EINVAL, "alll", NULL, 8, 0},
+
 	{-EINVAL, "-1",	NULL, 8, 0},
 	{-EINVAL, "-0",	NULL, 8, 0},
 	{-EINVAL, "10-1", NULL, 8, 0},
@@ -384,7 +391,6 @@ static const struct test_bitmap_parselist parselist_tests[] __initconst = {
 	{-EINVAL, "a-31:10/1", NULL, 8, 0},
 	{-EINVAL, "0-31:a/1", NULL, 8, 0},
 	{-EINVAL, "0-\n", NULL, 8, 0},
-
 };
 
 static void __init test_bitmap_parselist(void)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2021-04-21 23:45 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-21  3:13 [PATCH v2 0/2] bitmap_parselist: support 'all' semantics Yury Norov
2021-04-21  3:13 ` [PATCH 1/2] bitmap_parse: " Yury Norov
2021-04-21 15:19   ` Steven Rostedt
2021-04-21 15:57     ` Paul E. McKenney
2021-04-21 23:45     ` Paul Gortmaker
2021-04-21  3:13 ` [PATCH 2/2] rcu/tree_plugin: don't handle the case of 'all' CPU range Yury Norov
2021-04-21 17:30 ` [PATCH v2 0/2] bitmap_parselist: support 'all' semantics Paul E. McKenney
2021-04-21 17:49   ` Yury Norov
  -- strict thread matches above, loose matches on Subject: below --
2021-04-20  0:01 [PATCH " Yury Norov
2021-04-20  0:01 ` [PATCH 1/2] bitmap_parse: " Yury Norov
2021-04-20 10:17   ` Andy Shevchenko
2021-04-20 19:32     ` Yury Norov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).