All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up
@ 2022-08-09 17:36 Sander Vanheule
  2022-08-09 17:36 ` [PATCH v1 1/3] cpumask: align signatures of UP implementations Sander Vanheule
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Sander Vanheule @ 2022-08-09 17:36 UTC (permalink / raw)
  To: Yury Norov, Andy Shevchenko, Rasmus Villemoes
  Cc: linux-kernel, Sander Vanheule

As an older version of the UP optimisation fixes was merged, not all
review feedback has been implemented.  These patches implement the
feedback received on the merged version [1], and the respin [2], for
changes related to include/linux/cpumask.h and lib/cpumask.c.

[1] https://lore.kernel.org/lkml/cover.1656777646.git.sander@svanheule.net/
[2] https://lore.kernel.org/lkml/cover.1659077534.git.sander@svanheule.net/

Sander Vanheule (3):
  cpumask: align signatures of UP implementations
  lib/cpumask: add inline cpumask_next_wrap() for UP
  lib/cpumask: drop always-true preprocessor guard

 include/linux/cpumask.h | 26 +++++++++++++++++++++++---
 lib/Makefile            |  3 ++-
 lib/cpumask.c           |  2 --
 3 files changed, 25 insertions(+), 6 deletions(-)

-- 
2.37.1


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

* [PATCH v1 1/3] cpumask: align signatures of UP implementations
  2022-08-09 17:36 [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up Sander Vanheule
@ 2022-08-09 17:36 ` Sander Vanheule
  2022-08-09 17:36 ` [PATCH v1 2/3] lib/cpumask: add inline cpumask_next_wrap() for UP Sander Vanheule
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 8+ messages in thread
From: Sander Vanheule @ 2022-08-09 17:36 UTC (permalink / raw)
  To: Yury Norov, Andy Shevchenko, Rasmus Villemoes
  Cc: linux-kernel, Sander Vanheule

Between the generic version, and their uniprocessor optimised
implementations, the return types of cpumask_any_and_distribute() and
cpumask_any_distribute() are not identical.  Change the UP versions to
'unsigned int', to match the generic versions.

Suggested-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Sander Vanheule <sander@svanheule.net>
---
 include/linux/cpumask.h | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 0d435d0edbcb..d8c2a40f8beb 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -202,12 +202,13 @@ static inline unsigned int cpumask_local_spread(unsigned int i, int node)
 	return 0;
 }
 
-static inline int cpumask_any_and_distribute(const struct cpumask *src1p,
-					     const struct cpumask *src2p) {
+static inline unsigned int cpumask_any_and_distribute(const struct cpumask *src1p,
+						      const struct cpumask *src2p)
+{
 	return cpumask_first_and(src1p, src2p);
 }
 
-static inline int cpumask_any_distribute(const struct cpumask *srcp)
+static inline unsigned int cpumask_any_distribute(const struct cpumask *srcp)
 {
 	return cpumask_first(srcp);
 }
-- 
2.37.1


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

* [PATCH v1 2/3] lib/cpumask: add inline cpumask_next_wrap() for UP
  2022-08-09 17:36 [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up Sander Vanheule
  2022-08-09 17:36 ` [PATCH v1 1/3] cpumask: align signatures of UP implementations Sander Vanheule
@ 2022-08-09 17:36 ` Sander Vanheule
  2022-08-09 17:36 ` [PATCH v1 3/3] lib/cpumask: drop always-true preprocessor guard Sander Vanheule
  2022-08-10  4:55 ` [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up Yury Norov
  3 siblings, 0 replies; 8+ messages in thread
From: Sander Vanheule @ 2022-08-09 17:36 UTC (permalink / raw)
  To: Yury Norov, Andy Shevchenko, Rasmus Villemoes
  Cc: linux-kernel, Sander Vanheule

In the uniprocessor case, cpumask_next_wrap() can be simplified, as the
number of valid argument combinations is limited:
    - 'start' can only be 0
    - 'n' can only be -1 or 0

The only valid CPU that can then be returned, if any, will be the first
one set in the provided 'mask'.

For NR_CPUS == 1, include/linux/cpumask.h now provides an inline
definition of cpumask_next_wrap(), which will conflict with the one
provided by lib/cpumask.c.  Make building of lib/cpumask.o again depend
on CONFIG_SMP=y (i.e. NR_CPUS > 1) to avoid the re-definition.

Suggested-by: Yury Norov <yury.norov@gmail.com>
Signed-off-by: Sander Vanheule <sander@svanheule.net>
---
 include/linux/cpumask.h | 19 +++++++++++++++++++
 lib/Makefile            |  3 ++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index d8c2a40f8beb..bd047864c7ac 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -262,7 +262,26 @@ unsigned int cpumask_next_and(int n, const struct cpumask *src1p,
 		(cpu) = cpumask_next_zero((cpu), (mask)),	\
 		(cpu) < nr_cpu_ids;)
 
+#if NR_CPUS == 1
+static inline
+unsigned int cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap)
+{
+	cpumask_check(start);
+	if (n != -1)
+		cpumask_check(n);
+
+	/*
+	 * Return the first available CPU when wrapping, or when starting before cpu0,
+	 * since there is only one valid option.
+	 */
+	if (wrap && n >= 0)
+		return nr_cpumask_bits;
+
+	return cpumask_first(mask);
+}
+#else
 unsigned int __pure cpumask_next_wrap(int n, const struct cpumask *mask, int start, bool wrap);
+#endif
 
 /**
  * for_each_cpu_wrap - iterate over every cpu in a mask, starting at a specified location
diff --git a/lib/Makefile b/lib/Makefile
index c95212141928..5927d7fa0806 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -34,9 +34,10 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \
 	 is_single_threaded.o plist.o decompress.o kobject_uevent.o \
 	 earlycpio.o seq_buf.o siphash.o dec_and_lock.o \
 	 nmi_backtrace.o win_minmax.o memcat_p.o \
-	 buildid.o cpumask.o
+	 buildid.o
 
 lib-$(CONFIG_PRINTK) += dump_stack.o
+lib-$(CONFIG_SMP) += cpumask.o
 
 lib-y	+= kobject.o klist.o
 obj-y	+= lockref.o
-- 
2.37.1


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

* [PATCH v1 3/3] lib/cpumask: drop always-true preprocessor guard
  2022-08-09 17:36 [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up Sander Vanheule
  2022-08-09 17:36 ` [PATCH v1 1/3] cpumask: align signatures of UP implementations Sander Vanheule
  2022-08-09 17:36 ` [PATCH v1 2/3] lib/cpumask: add inline cpumask_next_wrap() for UP Sander Vanheule
@ 2022-08-09 17:36 ` Sander Vanheule
  2022-08-10  4:55 ` [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up Yury Norov
  3 siblings, 0 replies; 8+ messages in thread
From: Sander Vanheule @ 2022-08-09 17:36 UTC (permalink / raw)
  To: Yury Norov, Andy Shevchenko, Rasmus Villemoes
  Cc: linux-kernel, Sander Vanheule

Since lib/cpumask.o is only built for CONFIG_SMP=y, NR_CPUS will always
be greater than 1 at compile time.  This makes checking for that
condition unnecesarry, so it can be dropped.

Signed-off-by: Sander Vanheule <sander@svanheule.net>
---
 lib/cpumask.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/lib/cpumask.c b/lib/cpumask.c
index 8baeb37e23d3..f0ae119be8c4 100644
--- a/lib/cpumask.c
+++ b/lib/cpumask.c
@@ -109,7 +109,6 @@ void __init free_bootmem_cpumask_var(cpumask_var_t mask)
 }
 #endif
 
-#if NR_CPUS > 1
 /**
  * cpumask_local_spread - select the i'th cpu with local numa cpu's first
  * @i: index number
@@ -197,4 +196,3 @@ unsigned int cpumask_any_distribute(const struct cpumask *srcp)
 	return next;
 }
 EXPORT_SYMBOL(cpumask_any_distribute);
-#endif /* NR_CPUS */
-- 
2.37.1


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

* Re: [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up
  2022-08-09 17:36 [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up Sander Vanheule
                   ` (2 preceding siblings ...)
  2022-08-09 17:36 ` [PATCH v1 3/3] lib/cpumask: drop always-true preprocessor guard Sander Vanheule
@ 2022-08-10  4:55 ` Yury Norov
  2022-08-10  8:18   ` Sander Vanheule
  3 siblings, 1 reply; 8+ messages in thread
From: Yury Norov @ 2022-08-10  4:55 UTC (permalink / raw)
  To: Sander Vanheule; +Cc: Andy Shevchenko, Rasmus Villemoes, linux-kernel

On Tue, Aug 09, 2022 at 07:36:32PM +0200, Sander Vanheule wrote:
> As an older version of the UP optimisation fixes was merged, not all
> review feedback has been implemented.  These patches implement the
> feedback received on the merged version [1], and the respin [2], for
> changes related to include/linux/cpumask.h and lib/cpumask.c.
> 
> [1] https://lore.kernel.org/lkml/cover.1656777646.git.sander@svanheule.net/
> [2] https://lore.kernel.org/lkml/cover.1659077534.git.sander@svanheule.net/
> 
> Sander Vanheule (3):
>   cpumask: align signatures of UP implementations
>   lib/cpumask: add inline cpumask_next_wrap() for UP
>   lib/cpumask: drop always-true preprocessor guard

Acked-by: Yury Norov <yury.norov@gmail.com>

Applying at bitmap-for-next, after some testing.

Thanks,
Yury

>  include/linux/cpumask.h | 26 +++++++++++++++++++++++---
>  lib/Makefile            |  3 ++-
>  lib/cpumask.c           |  2 --
>  3 files changed, 25 insertions(+), 6 deletions(-)
> 
> -- 
> 2.37.1

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

* Re: [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up
  2022-08-10  4:55 ` [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up Yury Norov
@ 2022-08-10  8:18   ` Sander Vanheule
  2022-08-10  8:39     ` Yury Norov
  0 siblings, 1 reply; 8+ messages in thread
From: Sander Vanheule @ 2022-08-10  8:18 UTC (permalink / raw)
  To: Yury Norov; +Cc: Andy Shevchenko, Rasmus Villemoes, linux-kernel

On Tue, 2022-08-09 at 21:55 -0700, Yury Norov wrote:
> On Tue, Aug 09, 2022 at 07:36:32PM +0200, Sander Vanheule wrote:
> > As an older version of the UP optimisation fixes was merged, not all
> > review feedback has been implemented.  These patches implement the
> > feedback received on the merged version [1], and the respin [2], for
> > changes related to include/linux/cpumask.h and lib/cpumask.c.
> > 
> > [1] https://lore.kernel.org/lkml/cover.1656777646.git.sander@svanheule.net/
> > [2] https://lore.kernel.org/lkml/cover.1659077534.git.sander@svanheule.net/
> > 
> > Sander Vanheule (3):
> >   cpumask: align signatures of UP implementations
> >   lib/cpumask: add inline cpumask_next_wrap() for UP
> >   lib/cpumask: drop always-true preprocessor guard
> 
> Acked-by: Yury Norov <yury.norov@gmail.com>
> 
> Applying at bitmap-for-next, after some testing.

Thanks! Any chance to get this in for 6.0? I would rather avoid building cpumask.o only on 6.0, but
otherwise I don't think anything is functionally wrong with what is currently merged.

Best,
Sander

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

* Re: [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up
  2022-08-10  8:18   ` Sander Vanheule
@ 2022-08-10  8:39     ` Yury Norov
  2022-08-10  8:42       ` Sander Vanheule
  0 siblings, 1 reply; 8+ messages in thread
From: Yury Norov @ 2022-08-10  8:39 UTC (permalink / raw)
  To: Sander Vanheule; +Cc: Andy Shevchenko, Rasmus Villemoes, linux-kernel

On Wed, Aug 10, 2022 at 10:18:09AM +0200, Sander Vanheule wrote:
> On Tue, 2022-08-09 at 21:55 -0700, Yury Norov wrote:
> > On Tue, Aug 09, 2022 at 07:36:32PM +0200, Sander Vanheule wrote:
> > > As an older version of the UP optimisation fixes was merged, not all
> > > review feedback has been implemented.  These patches implement the
> > > feedback received on the merged version [1], and the respin [2], for
> > > changes related to include/linux/cpumask.h and lib/cpumask.c.
> > > 
> > > [1] https://lore.kernel.org/lkml/cover.1656777646.git.sander@svanheule.net/
> > > [2] https://lore.kernel.org/lkml/cover.1659077534.git.sander@svanheule.net/
> > > 
> > > Sander Vanheule (3):
> > >   cpumask: align signatures of UP implementations
> > >   lib/cpumask: add inline cpumask_next_wrap() for UP
> > >   lib/cpumask: drop always-true preprocessor guard
> > 
> > Acked-by: Yury Norov <yury.norov@gmail.com>
> > 
> > Applying at bitmap-for-next, after some testing.
> 
> Thanks! Any chance to get this in for 6.0? I would rather avoid building cpumask.o only on 6.0, but
> otherwise I don't think anything is functionally wrong with what is currently merged.

Functionally not, but something is still wrong, right? :)

I think -rc2 would be our best option for this, because this series is
a fix to v4, and because it will let this spend some time in -next.

Are you OK with this?

Thanks,
Yury

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

* Re: [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up
  2022-08-10  8:39     ` Yury Norov
@ 2022-08-10  8:42       ` Sander Vanheule
  0 siblings, 0 replies; 8+ messages in thread
From: Sander Vanheule @ 2022-08-10  8:42 UTC (permalink / raw)
  To: Yury Norov; +Cc: Andy Shevchenko, Rasmus Villemoes, linux-kernel



On Wed, 2022-08-10 at 01:39 -0700, Yury Norov wrote:
> On Wed, Aug 10, 2022 at 10:18:09AM +0200, Sander Vanheule wrote:
> > On Tue, 2022-08-09 at 21:55 -0700, Yury Norov wrote:
> > > On Tue, Aug 09, 2022 at 07:36:32PM +0200, Sander Vanheule wrote:
> > > > As an older version of the UP optimisation fixes was merged, not all
> > > > review feedback has been implemented.  These patches implement the
> > > > feedback received on the merged version [1], and the respin [2], for
> > > > changes related to include/linux/cpumask.h and lib/cpumask.c.
> > > > 
> > > > [1] https://lore.kernel.org/lkml/cover.1656777646.git.sander@svanheule.net/
> > > > [2] https://lore.kernel.org/lkml/cover.1659077534.git.sander@svanheule.net/
> > > > 
> > > > Sander Vanheule (3):
> > > >   cpumask: align signatures of UP implementations
> > > >   lib/cpumask: add inline cpumask_next_wrap() for UP
> > > >   lib/cpumask: drop always-true preprocessor guard
> > > 
> > > Acked-by: Yury Norov <yury.norov@gmail.com>
> > > 
> > > Applying at bitmap-for-next, after some testing.
> > 
> > Thanks! Any chance to get this in for 6.0? I would rather avoid building cpumask.o only on 6.0,
> > but
> > otherwise I don't think anything is functionally wrong with what is currently merged.
> 
> Functionally not, but something is still wrong, right? :)
> 
> I think -rc2 would be our best option for this, because this series is
> a fix to v4, and because it will let this spend some time in -next.
> 
> Are you OK with this?

Sounds perfect!

Thanks,
Sander

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

end of thread, other threads:[~2022-08-10  8:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-09 17:36 [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up Sander Vanheule
2022-08-09 17:36 ` [PATCH v1 1/3] cpumask: align signatures of UP implementations Sander Vanheule
2022-08-09 17:36 ` [PATCH v1 2/3] lib/cpumask: add inline cpumask_next_wrap() for UP Sander Vanheule
2022-08-09 17:36 ` [PATCH v1 3/3] lib/cpumask: drop always-true preprocessor guard Sander Vanheule
2022-08-10  4:55 ` [PATCH v1 0/3] cpumask: UP optimisation fixes follow-up Yury Norov
2022-08-10  8:18   ` Sander Vanheule
2022-08-10  8:39     ` Yury Norov
2022-08-10  8:42       ` Sander Vanheule

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.