All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] kernel/cpu.c: eliminate some indirection
@ 2015-09-25 18:22 Rasmus Villemoes
  2015-09-25 18:22 ` [PATCH 1/5] kernel/cpu.c: change type of cpu_possible_bits and friends Rasmus Villemoes
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Rasmus Villemoes @ 2015-09-25 18:22 UTC (permalink / raw)
  To: Thomas Gleixner, Oleg Nesterov, Paul E. McKenney, Rusty Russell,
	Greg Kroah-Hartman
  Cc: Rasmus Villemoes, linux-kernel

Maybe third time's the charm...

The four cpumasks cpu_{possible,online,present,active}_bits are
exposed readonly via the corresponding const variables
cpu_xyz_mask. But they are also accessible for arbitrary writing via
the exposed functions set_cpu_xyz. There's quite a bit of code
throughout the kernel which iterates over or otherwise accesses these
bitmaps, and having the access go via the cpu_xyz_mask variables is
simply a useless indirection.

It may be that any problem in CS can be solved by an extra level of
indirection, but that doesn't mean every extra indirection solves a
problem. In this case, it even necessitates some minor ugliness (see
3/5).

The first four patches eliminate the cpu_xyz_mask variables by simply
exposing the actual bitmaps, after renaming them to discourage direct
access - that still happens through cpu_xyz_mask, which are now simply
macros with the same type and value as they used to have.

After that, there's no longer any reason to have the setter functions
be out-of-line: The boolean parameter is almost always a literal true
or false, so by making them static inlines they will usually compile
to one or two instructions.

For a defconfig build, bloat-o-meter says we save ~3000 bytes.

Rasmus Villemoes (5):
  kernel/cpu.c: change type of cpu_possible_bits and friends
  kernel/cpu.c: export __cpu_*_mask
  drivers/base/cpu.c: use __cpu_*_mask directly
  kernel/cpu.c: eliminate cpu_*_mask
  kernel/cpu.c: make set_cpu_* static inlines

 drivers/base/cpu.c      | 10 ++++----
 include/linux/cpumask.h | 55 +++++++++++++++++++++++++++++++++++-------
 kernel/cpu.c            | 64 ++++++++++---------------------------------------
 3 files changed, 65 insertions(+), 64 deletions(-)

-- 
2.1.3


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

* [PATCH 1/5] kernel/cpu.c: change type of cpu_possible_bits and friends
  2015-09-25 18:22 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
@ 2015-09-25 18:22 ` Rasmus Villemoes
  2015-09-25 18:22 ` [PATCH 2/5] kernel/cpu.c: export __cpu_*_mask Rasmus Villemoes
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Rasmus Villemoes @ 2015-09-25 18:22 UTC (permalink / raw)
  To: Thomas Gleixner, Oleg Nesterov, Paul E. McKenney, Rusty Russell,
	Greg Kroah-Hartman, K. Y. Srinivasan, Peter Zijlstra (Intel),
	Vitaly Kuznetsov, Mathias Krause
  Cc: Rasmus Villemoes, linux-kernel

Change cpu_possible_bits and friends (online, present, active) from
being bitmaps that happen to have the right size to actually being
struct cpumasks. Also rename them to __cpu_xyz_mask. This is mostly a
small cleanup in preparation for exporting them and, eventually,
eliminating the extra indirection through the cpu_xyz_mask variables.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 kernel/cpu.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 82cf9dff4295..fea4a3ce3011 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -772,71 +772,71 @@ const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL;
 EXPORT_SYMBOL(cpu_all_bits);
 
 #ifdef CONFIG_INIT_ALL_POSSIBLE
-static DECLARE_BITMAP(cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly
-	= CPU_BITS_ALL;
+static struct cpumask __cpu_possible_mask __read_mostly
+	= {CPU_BITS_ALL};
 #else
-static DECLARE_BITMAP(cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly;
+static struct cpumask __cpu_possible_mask __read_mostly;
 #endif
-const struct cpumask *const cpu_possible_mask = to_cpumask(cpu_possible_bits);
+const struct cpumask *const cpu_possible_mask = &__cpu_possible_mask;
 EXPORT_SYMBOL(cpu_possible_mask);
 
-static DECLARE_BITMAP(cpu_online_bits, CONFIG_NR_CPUS) __read_mostly;
-const struct cpumask *const cpu_online_mask = to_cpumask(cpu_online_bits);
+static struct cpumask __cpu_online_mask __read_mostly;
+const struct cpumask *const cpu_online_mask = &__cpu_online_mask;
 EXPORT_SYMBOL(cpu_online_mask);
 
-static DECLARE_BITMAP(cpu_present_bits, CONFIG_NR_CPUS) __read_mostly;
-const struct cpumask *const cpu_present_mask = to_cpumask(cpu_present_bits);
+static struct cpumask __cpu_present_mask __read_mostly;
+const struct cpumask *const cpu_present_mask = &__cpu_present_mask;
 EXPORT_SYMBOL(cpu_present_mask);
 
-static DECLARE_BITMAP(cpu_active_bits, CONFIG_NR_CPUS) __read_mostly;
-const struct cpumask *const cpu_active_mask = to_cpumask(cpu_active_bits);
+static struct cpumask __cpu_active_mask __read_mostly;
+const struct cpumask *const cpu_active_mask = &__cpu_active_mask;
 EXPORT_SYMBOL(cpu_active_mask);
 
 void set_cpu_possible(unsigned int cpu, bool possible)
 {
 	if (possible)
-		cpumask_set_cpu(cpu, to_cpumask(cpu_possible_bits));
+		cpumask_set_cpu(cpu, &__cpu_possible_mask);
 	else
-		cpumask_clear_cpu(cpu, to_cpumask(cpu_possible_bits));
+		cpumask_clear_cpu(cpu, &__cpu_possible_mask);
 }
 
 void set_cpu_present(unsigned int cpu, bool present)
 {
 	if (present)
-		cpumask_set_cpu(cpu, to_cpumask(cpu_present_bits));
+		cpumask_set_cpu(cpu, &__cpu_present_mask);
 	else
-		cpumask_clear_cpu(cpu, to_cpumask(cpu_present_bits));
+		cpumask_clear_cpu(cpu, &__cpu_present_mask);
 }
 
 void set_cpu_online(unsigned int cpu, bool online)
 {
 	if (online) {
-		cpumask_set_cpu(cpu, to_cpumask(cpu_online_bits));
-		cpumask_set_cpu(cpu, to_cpumask(cpu_active_bits));
+		cpumask_set_cpu(cpu, &__cpu_online_mask);
+		cpumask_set_cpu(cpu, &__cpu_active_mask);
 	} else {
-		cpumask_clear_cpu(cpu, to_cpumask(cpu_online_bits));
+		cpumask_clear_cpu(cpu, &__cpu_online_mask);
 	}
 }
 
 void set_cpu_active(unsigned int cpu, bool active)
 {
 	if (active)
-		cpumask_set_cpu(cpu, to_cpumask(cpu_active_bits));
+		cpumask_set_cpu(cpu, &__cpu_active_mask);
 	else
-		cpumask_clear_cpu(cpu, to_cpumask(cpu_active_bits));
+		cpumask_clear_cpu(cpu, &__cpu_active_mask);
 }
 
 void init_cpu_present(const struct cpumask *src)
 {
-	cpumask_copy(to_cpumask(cpu_present_bits), src);
+	cpumask_copy(&__cpu_present_mask, src);
 }
 
 void init_cpu_possible(const struct cpumask *src)
 {
-	cpumask_copy(to_cpumask(cpu_possible_bits), src);
+	cpumask_copy(&__cpu_possible_mask, src);
 }
 
 void init_cpu_online(const struct cpumask *src)
 {
-	cpumask_copy(to_cpumask(cpu_online_bits), src);
+	cpumask_copy(&__cpu_online_mask, src);
 }
-- 
2.1.3


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

* [PATCH 2/5] kernel/cpu.c: export __cpu_*_mask
  2015-09-25 18:22 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
  2015-09-25 18:22 ` [PATCH 1/5] kernel/cpu.c: change type of cpu_possible_bits and friends Rasmus Villemoes
@ 2015-09-25 18:22 ` Rasmus Villemoes
  2015-09-25 18:22 ` [PATCH 3/5] drivers/base/cpu.c: use __cpu_*_mask directly Rasmus Villemoes
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Rasmus Villemoes @ 2015-09-25 18:22 UTC (permalink / raw)
  To: Thomas Gleixner, Oleg Nesterov, Paul E. McKenney, Rusty Russell,
	Greg Kroah-Hartman, K. Y. Srinivasan, Peter Zijlstra (Intel),
	Vitaly Kuznetsov, Mathias Krause
  Cc: Rasmus Villemoes, linux-kernel

Exporting the cpumasks __cpu_possible_mask and friends will allow us
to remove the extra indirection through the cpu_*_mask variables. It
will also allow the set_cpu_* functions to become static inlines,
which will give a .text reduction.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/cpumask.h |  4 ++++
 kernel/cpu.c            | 14 +++++++++-----
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 59915ea5373c..d4545a1852f2 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -89,6 +89,10 @@ extern const struct cpumask *const cpu_possible_mask;
 extern const struct cpumask *const cpu_online_mask;
 extern const struct cpumask *const cpu_present_mask;
 extern const struct cpumask *const cpu_active_mask;
+extern struct cpumask __cpu_possible_mask;
+extern struct cpumask __cpu_online_mask;
+extern struct cpumask __cpu_present_mask;
+extern struct cpumask __cpu_active_mask;
 
 #if NR_CPUS > 1
 #define num_online_cpus()	cpumask_weight(cpu_online_mask)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index fea4a3ce3011..e08db26d351b 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -772,23 +772,27 @@ const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL;
 EXPORT_SYMBOL(cpu_all_bits);
 
 #ifdef CONFIG_INIT_ALL_POSSIBLE
-static struct cpumask __cpu_possible_mask __read_mostly
+struct cpumask __cpu_possible_mask __read_mostly
 	= {CPU_BITS_ALL};
 #else
-static struct cpumask __cpu_possible_mask __read_mostly;
+struct cpumask __cpu_possible_mask __read_mostly;
 #endif
+EXPORT_SYMBOL(__cpu_possible_mask);
 const struct cpumask *const cpu_possible_mask = &__cpu_possible_mask;
 EXPORT_SYMBOL(cpu_possible_mask);
 
-static struct cpumask __cpu_online_mask __read_mostly;
+struct cpumask __cpu_online_mask __read_mostly;
+EXPORT_SYMBOL(__cpu_online_mask);
 const struct cpumask *const cpu_online_mask = &__cpu_online_mask;
 EXPORT_SYMBOL(cpu_online_mask);
 
-static struct cpumask __cpu_present_mask __read_mostly;
+struct cpumask __cpu_present_mask __read_mostly;
+EXPORT_SYMBOL(__cpu_present_mask);
 const struct cpumask *const cpu_present_mask = &__cpu_present_mask;
 EXPORT_SYMBOL(cpu_present_mask);
 
-static struct cpumask __cpu_active_mask __read_mostly;
+struct cpumask __cpu_active_mask __read_mostly;
+EXPORT_SYMBOL(__cpu_active_mask);
 const struct cpumask *const cpu_active_mask = &__cpu_active_mask;
 EXPORT_SYMBOL(cpu_active_mask);
 
-- 
2.1.3


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

* [PATCH 3/5] drivers/base/cpu.c: use __cpu_*_mask directly
  2015-09-25 18:22 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
  2015-09-25 18:22 ` [PATCH 1/5] kernel/cpu.c: change type of cpu_possible_bits and friends Rasmus Villemoes
  2015-09-25 18:22 ` [PATCH 2/5] kernel/cpu.c: export __cpu_*_mask Rasmus Villemoes
@ 2015-09-25 18:22 ` Rasmus Villemoes
  2015-10-04 19:09   ` Greg Kroah-Hartman
  2015-09-25 18:22 ` [PATCH 4/5] kernel/cpu.c: eliminate cpu_*_mask Rasmus Villemoes
                   ` (2 subsequent siblings)
  5 siblings, 1 reply; 15+ messages in thread
From: Rasmus Villemoes @ 2015-09-25 18:22 UTC (permalink / raw)
  To: Thomas Gleixner, Oleg Nesterov, Paul E. McKenney, Rusty Russell,
	Greg Kroah-Hartman
  Cc: Rasmus Villemoes, linux-kernel

The only user of the lvalue-ness of the cpu_*_mask variables is in
drivers/base/cpu.c, and that is mostly a work-around for the fact that
not even const variables can be used in static initialization. Now
that the underlying struct cpumasks are exposed we can take their
address.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 drivers/base/cpu.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 91bbb1959d8d..691eeea2f19a 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -200,7 +200,7 @@ static const struct attribute_group *hotplugable_cpu_attr_groups[] = {
 
 struct cpu_attr {
 	struct device_attribute attr;
-	const struct cpumask *const * const map;
+	const struct cpumask *const map;
 };
 
 static ssize_t show_cpus_attr(struct device *dev,
@@ -209,7 +209,7 @@ static ssize_t show_cpus_attr(struct device *dev,
 {
 	struct cpu_attr *ca = container_of(attr, struct cpu_attr, attr);
 
-	return cpumap_print_to_pagebuf(true, buf, *ca->map);
+	return cpumap_print_to_pagebuf(true, buf, ca->map);
 }
 
 #define _CPU_ATTR(name, map) \
@@ -217,9 +217,9 @@ static ssize_t show_cpus_attr(struct device *dev,
 
 /* Keep in sync with cpu_subsys_attrs */
 static struct cpu_attr cpu_attrs[] = {
-	_CPU_ATTR(online, &cpu_online_mask),
-	_CPU_ATTR(possible, &cpu_possible_mask),
-	_CPU_ATTR(present, &cpu_present_mask),
+	_CPU_ATTR(online, &__cpu_online_mask),
+	_CPU_ATTR(possible, &__cpu_possible_mask),
+	_CPU_ATTR(present, &__cpu_present_mask),
 };
 
 /*
-- 
2.1.3


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

* [PATCH 4/5] kernel/cpu.c: eliminate cpu_*_mask
  2015-09-25 18:22 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
                   ` (2 preceding siblings ...)
  2015-09-25 18:22 ` [PATCH 3/5] drivers/base/cpu.c: use __cpu_*_mask directly Rasmus Villemoes
@ 2015-09-25 18:22 ` Rasmus Villemoes
  2015-09-28  6:02   ` kbuild test robot
  2015-09-25 18:22 ` [PATCH 5/5] kernel/cpu.c: make set_cpu_* static inlines Rasmus Villemoes
  2015-09-27  6:31 ` [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rusty Russell
  5 siblings, 1 reply; 15+ messages in thread
From: Rasmus Villemoes @ 2015-09-25 18:22 UTC (permalink / raw)
  To: Thomas Gleixner, Oleg Nesterov, Paul E. McKenney, Rusty Russell,
	Greg Kroah-Hartman, K. Y. Srinivasan, Peter Zijlstra (Intel),
	Vitaly Kuznetsov, Mathias Krause
  Cc: Rasmus Villemoes, linux-kernel

Replace the variables cpu_possible_mask, cpu_online_mask,
cpu_present_mask and cpu_active_mask with macros expanding to
expressions of the same type and value, eliminating some indirection.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/cpumask.h | 8 ++++----
 kernel/cpu.c            | 8 --------
 2 files changed, 4 insertions(+), 12 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index d4545a1852f2..52ab539aefce 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -85,14 +85,14 @@ extern int nr_cpu_ids;
  *    only one CPU.
  */
 
-extern const struct cpumask *const cpu_possible_mask;
-extern const struct cpumask *const cpu_online_mask;
-extern const struct cpumask *const cpu_present_mask;
-extern const struct cpumask *const cpu_active_mask;
 extern struct cpumask __cpu_possible_mask;
 extern struct cpumask __cpu_online_mask;
 extern struct cpumask __cpu_present_mask;
 extern struct cpumask __cpu_active_mask;
+#define cpu_possible_mask ((const struct cpumask *)&__cpu_possible_mask)
+#define cpu_online_mask   ((const struct cpumask *)&__cpu_online_mask)
+#define cpu_present_mask  ((const struct cpumask *)&__cpu_present_mask)
+#define cpu_active_mask   ((const struct cpumask *)&__cpu_active_mask)
 
 #if NR_CPUS > 1
 #define num_online_cpus()	cpumask_weight(cpu_online_mask)
diff --git a/kernel/cpu.c b/kernel/cpu.c
index e08db26d351b..dd70f600442f 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -778,23 +778,15 @@ struct cpumask __cpu_possible_mask __read_mostly
 struct cpumask __cpu_possible_mask __read_mostly;
 #endif
 EXPORT_SYMBOL(__cpu_possible_mask);
-const struct cpumask *const cpu_possible_mask = &__cpu_possible_mask;
-EXPORT_SYMBOL(cpu_possible_mask);
 
 struct cpumask __cpu_online_mask __read_mostly;
 EXPORT_SYMBOL(__cpu_online_mask);
-const struct cpumask *const cpu_online_mask = &__cpu_online_mask;
-EXPORT_SYMBOL(cpu_online_mask);
 
 struct cpumask __cpu_present_mask __read_mostly;
 EXPORT_SYMBOL(__cpu_present_mask);
-const struct cpumask *const cpu_present_mask = &__cpu_present_mask;
-EXPORT_SYMBOL(cpu_present_mask);
 
 struct cpumask __cpu_active_mask __read_mostly;
 EXPORT_SYMBOL(__cpu_active_mask);
-const struct cpumask *const cpu_active_mask = &__cpu_active_mask;
-EXPORT_SYMBOL(cpu_active_mask);
 
 void set_cpu_possible(unsigned int cpu, bool possible)
 {
-- 
2.1.3


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

* [PATCH 5/5] kernel/cpu.c: make set_cpu_* static inlines
  2015-09-25 18:22 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
                   ` (3 preceding siblings ...)
  2015-09-25 18:22 ` [PATCH 4/5] kernel/cpu.c: eliminate cpu_*_mask Rasmus Villemoes
@ 2015-09-25 18:22 ` Rasmus Villemoes
  2015-09-27  6:31 ` [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rusty Russell
  5 siblings, 0 replies; 15+ messages in thread
From: Rasmus Villemoes @ 2015-09-25 18:22 UTC (permalink / raw)
  To: Thomas Gleixner, Oleg Nesterov, Paul E. McKenney, Rusty Russell,
	Greg Kroah-Hartman, K. Y. Srinivasan, Peter Zijlstra (Intel),
	Vitaly Kuznetsov, Mathias Krause
  Cc: Rasmus Villemoes, linux-kernel

Almost all callers of the set_cpu_* functions pass an explicit true
or false. Making them static inline thus replaces the function calls
with a simple set_bit/clear_bit, saving some .text.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 include/linux/cpumask.h | 43 +++++++++++++++++++++++++++++++++++++++----
 kernel/cpu.c            | 34 ----------------------------------
 2 files changed, 39 insertions(+), 38 deletions(-)

diff --git a/include/linux/cpumask.h b/include/linux/cpumask.h
index 52ab539aefce..fc14275ff34e 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -720,14 +720,49 @@ extern const DECLARE_BITMAP(cpu_all_bits, NR_CPUS);
 #define for_each_present_cpu(cpu)  for_each_cpu((cpu), cpu_present_mask)
 
 /* Wrappers for arch boot code to manipulate normally-constant masks */
-void set_cpu_possible(unsigned int cpu, bool possible);
-void set_cpu_present(unsigned int cpu, bool present);
-void set_cpu_online(unsigned int cpu, bool online);
-void set_cpu_active(unsigned int cpu, bool active);
 void init_cpu_present(const struct cpumask *src);
 void init_cpu_possible(const struct cpumask *src);
 void init_cpu_online(const struct cpumask *src);
 
+static inline void
+set_cpu_possible(unsigned int cpu, bool possible)
+{
+	if (possible)
+		cpumask_set_cpu(cpu, &__cpu_possible_mask);
+	else
+		cpumask_clear_cpu(cpu, &__cpu_possible_mask);
+}
+
+static inline void
+set_cpu_present(unsigned int cpu, bool present)
+{
+	if (present)
+		cpumask_set_cpu(cpu, &__cpu_present_mask);
+	else
+		cpumask_clear_cpu(cpu, &__cpu_present_mask);
+}
+
+static inline void
+set_cpu_online(unsigned int cpu, bool online)
+{
+	if (online) {
+		cpumask_set_cpu(cpu, &__cpu_online_mask);
+		cpumask_set_cpu(cpu, &__cpu_active_mask);
+	} else {
+		cpumask_clear_cpu(cpu, &__cpu_online_mask);
+	}
+}
+
+static inline void
+set_cpu_active(unsigned int cpu, bool active)
+{
+	if (active)
+		cpumask_set_cpu(cpu, &__cpu_active_mask);
+	else
+		cpumask_clear_cpu(cpu, &__cpu_active_mask);
+}
+
+
 /**
  * to_cpumask - convert an NR_CPUS bitmap to a struct cpumask *
  * @bitmap: the bitmap
diff --git a/kernel/cpu.c b/kernel/cpu.c
index dd70f600442f..5210d80efc28 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -788,40 +788,6 @@ EXPORT_SYMBOL(__cpu_present_mask);
 struct cpumask __cpu_active_mask __read_mostly;
 EXPORT_SYMBOL(__cpu_active_mask);
 
-void set_cpu_possible(unsigned int cpu, bool possible)
-{
-	if (possible)
-		cpumask_set_cpu(cpu, &__cpu_possible_mask);
-	else
-		cpumask_clear_cpu(cpu, &__cpu_possible_mask);
-}
-
-void set_cpu_present(unsigned int cpu, bool present)
-{
-	if (present)
-		cpumask_set_cpu(cpu, &__cpu_present_mask);
-	else
-		cpumask_clear_cpu(cpu, &__cpu_present_mask);
-}
-
-void set_cpu_online(unsigned int cpu, bool online)
-{
-	if (online) {
-		cpumask_set_cpu(cpu, &__cpu_online_mask);
-		cpumask_set_cpu(cpu, &__cpu_active_mask);
-	} else {
-		cpumask_clear_cpu(cpu, &__cpu_online_mask);
-	}
-}
-
-void set_cpu_active(unsigned int cpu, bool active)
-{
-	if (active)
-		cpumask_set_cpu(cpu, &__cpu_active_mask);
-	else
-		cpumask_clear_cpu(cpu, &__cpu_active_mask);
-}
-
 void init_cpu_present(const struct cpumask *src)
 {
 	cpumask_copy(&__cpu_present_mask, src);
-- 
2.1.3


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

* Re: [PATCH 0/5] kernel/cpu.c: eliminate some indirection
  2015-09-25 18:22 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
                   ` (4 preceding siblings ...)
  2015-09-25 18:22 ` [PATCH 5/5] kernel/cpu.c: make set_cpu_* static inlines Rasmus Villemoes
@ 2015-09-27  6:31 ` Rusty Russell
  2015-09-28  6:21   ` Rasmus Villemoes
  5 siblings, 1 reply; 15+ messages in thread
From: Rusty Russell @ 2015-09-27  6:31 UTC (permalink / raw)
  To: Rasmus Villemoes, Thomas Gleixner, Oleg Nesterov,
	Paul E. McKenney, Greg Kroah-Hartman
  Cc: Rasmus Villemoes, linux-kernel

Rasmus Villemoes <linux@rasmusvillemoes.dk> writes:
> Maybe third time's the charm...
>
> The four cpumasks cpu_{possible,online,present,active}_bits are
> exposed readonly via the corresponding const variables
> cpu_xyz_mask. But they are also accessible for arbitrary writing via
> the exposed functions set_cpu_xyz. There's quite a bit of code
> throughout the kernel which iterates over or otherwise accesses these
> bitmaps, and having the access go via the cpu_xyz_mask variables is
> simply a useless indirection.

Thanks, consider all patches Acked-by: Rusty Russell <rusty@rustcorp.com.au>

But to be clear, it has outlived its usefulness, but it was not useless.

In particular, there used to be a debug config where 'struct cpumask'
wasn't defined, so we could catch people declaring 'struct cpumask' on
the stack (or passing by value).

There was a plan to remove CONFIG_NR_CPUS (ie. having no compile-time
cpu limit), but it seemed overkill and was abandoned.  But avoiding
'struct cpumask' (not struct cpumask *) in the core wherever possible
was a step towards it.

Hope that clarifies,
Rusty.

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

* Re: [PATCH 4/5] kernel/cpu.c: eliminate cpu_*_mask
  2015-09-25 18:22 ` [PATCH 4/5] kernel/cpu.c: eliminate cpu_*_mask Rasmus Villemoes
@ 2015-09-28  6:02   ` kbuild test robot
  2015-09-28  6:39     ` Rasmus Villemoes
  0 siblings, 1 reply; 15+ messages in thread
From: kbuild test robot @ 2015-09-28  6:02 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: kbuild-all, Thomas Gleixner, Oleg Nesterov, Paul E. McKenney,
	Rusty Russell, Greg Kroah-Hartman, K. Y. Srinivasan,
	Peter Zijlstra (Intel),
	Vitaly Kuznetsov, Mathias Krause, Rasmus Villemoes, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 5090 bytes --]

Hi Rasmus,

[auto build test results on v4.3-rc2 -- if it's inappropriate base, please ignore]

config: powerpc-allyesconfig (attached as .config)
reproduce:
  wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
  chmod +x ~/bin/make.cross
  git checkout c14fd9e74ebf7540e312ff440343f9843917ec66
  # save the attached .config to linux build tree
  make.cross ARCH=powerpc 

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/rcupdate.h:40:0,
                    from include/linux/idr.h:18,
                    from include/linux/kernfs.h:14,
                    from include/linux/sysfs.h:15,
                    from include/linux/kobject.h:21,
                    from include/linux/pci.h:28,
                    from arch/powerpc/kernel/prom.c:25:
>> include/linux/cpumask.h:93:29: error: expected identifier or '(' before 'const'
    #define cpu_online_mask   ((const struct cpumask *)&__cpu_online_mask)
                                ^
>> arch/powerpc/include/asm/fadump.h:194:17: note: in expansion of macro 'cpu_online_mask'
     struct cpumask cpu_online_mask;
                    ^
>> include/linux/cpumask.h:93:52: error: expected ')' before '&' token
    #define cpu_online_mask   ((const struct cpumask *)&__cpu_online_mask)
                                                       ^
>> arch/powerpc/include/asm/fadump.h:194:17: note: in expansion of macro 'cpu_online_mask'
     struct cpumask cpu_online_mask;
                    ^
   In file included from arch/powerpc/kernel/prom.c:56:0:
>> arch/powerpc/include/asm/fadump.h:195:1: warning: no semicolon at end of struct or union
    };
    ^
--
   In file included from include/linux/rcupdate.h:40:0,
                    from include/linux/srcu.h:33,
                    from include/linux/notifier.h:15,
                    from include/linux/memory_hotplug.h:6,
                    from include/linux/mmzone.h:812,
                    from include/linux/gfp.h:5,
                    from include/linux/mm.h:9,
                    from include/linux/memblock.h:18,
                    from arch/powerpc/kernel/fadump.c:31:
>> include/linux/cpumask.h:93:29: error: expected identifier or '(' before 'const'
    #define cpu_online_mask   ((const struct cpumask *)&__cpu_online_mask)
                                ^
>> arch/powerpc/include/asm/fadump.h:194:17: note: in expansion of macro 'cpu_online_mask'
     struct cpumask cpu_online_mask;
                    ^
>> include/linux/cpumask.h:93:52: error: expected ')' before '&' token
    #define cpu_online_mask   ((const struct cpumask *)&__cpu_online_mask)
                                                       ^
>> arch/powerpc/include/asm/fadump.h:194:17: note: in expansion of macro 'cpu_online_mask'
     struct cpumask cpu_online_mask;
                    ^
   In file included from arch/powerpc/kernel/fadump.c:42:0:
>> arch/powerpc/include/asm/fadump.h:195:1: warning: no semicolon at end of struct or union
    };
    ^
   In file included from include/linux/rcupdate.h:40:0,
                    from include/linux/srcu.h:33,
                    from include/linux/notifier.h:15,
                    from include/linux/memory_hotplug.h:6,
                    from include/linux/mmzone.h:812,
                    from include/linux/gfp.h:5,
                    from include/linux/mm.h:9,
                    from include/linux/memblock.h:18,
                    from arch/powerpc/kernel/fadump.c:31:
   arch/powerpc/kernel/fadump.c: In function 'crash_fadump':
>> include/linux/cpumask.h:93:27: error: expected identifier before '(' token
    #define cpu_online_mask   ((const struct cpumask *)&__cpu_online_mask)
                              ^
>> arch/powerpc/kernel/fadump.c:418:7: note: in expansion of macro 'cpu_online_mask'
     fdh->cpu_online_mask = *cpu_online_mask;
          ^
   arch/powerpc/kernel/fadump.c: In function 'fadump_build_cpu_notes':
>> include/linux/cpumask.h:93:27: error: expected identifier before '(' token
    #define cpu_online_mask   ((const struct cpumask *)&__cpu_online_mask)
                              ^
   arch/powerpc/kernel/fadump.c:649:43: note: in expansion of macro 'cpu_online_mask'
      if (fdh && !cpumask_test_cpu(cpu, &fdh->cpu_online_mask)) {
                                              ^

vim +93 include/linux/cpumask.h

    87	
    88	extern struct cpumask __cpu_possible_mask;
    89	extern struct cpumask __cpu_online_mask;
    90	extern struct cpumask __cpu_present_mask;
    91	extern struct cpumask __cpu_active_mask;
    92	#define cpu_possible_mask ((const struct cpumask *)&__cpu_possible_mask)
  > 93	#define cpu_online_mask   ((const struct cpumask *)&__cpu_online_mask)
    94	#define cpu_present_mask  ((const struct cpumask *)&__cpu_present_mask)
    95	#define cpu_active_mask   ((const struct cpumask *)&__cpu_active_mask)
    96	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/octet-stream, Size: 46370 bytes --]

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

* Re: [PATCH 0/5] kernel/cpu.c: eliminate some indirection
  2015-09-27  6:31 ` [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rusty Russell
@ 2015-09-28  6:21   ` Rasmus Villemoes
  2015-09-28 21:44     ` Rusty Russell
  0 siblings, 1 reply; 15+ messages in thread
From: Rasmus Villemoes @ 2015-09-28  6:21 UTC (permalink / raw)
  To: Rusty Russell
  Cc: Thomas Gleixner, Oleg Nesterov, Paul E. McKenney,
	Greg Kroah-Hartman, linux-kernel

On Sun, Sep 27 2015, Rusty Russell <rusty@rustcorp.com.au> wrote:

> But to be clear, it has outlived its usefulness, but it was not useless.
>
> In particular, there used to be a debug config where 'struct cpumask'
> wasn't defined, so we could catch people declaring 'struct cpumask' on
> the stack (or passing by value).
>
> There was a plan to remove CONFIG_NR_CPUS (ie. having no compile-time
> cpu limit), but it seemed overkill and was abandoned.  But avoiding
> 'struct cpumask' (not struct cpumask *) in the core wherever possible
> was a step towards it.
>
> Hope that clarifies,

It does, thanks! Should some of that be edited into one of the
changelogs?

Rasmus

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

* Re: [PATCH 4/5] kernel/cpu.c: eliminate cpu_*_mask
  2015-09-28  6:02   ` kbuild test robot
@ 2015-09-28  6:39     ` Rasmus Villemoes
  2015-10-05 23:10       ` Rasmus Villemoes
  0 siblings, 1 reply; 15+ messages in thread
From: Rasmus Villemoes @ 2015-09-28  6:39 UTC (permalink / raw)
  To: kbuild test robot, Benjamin Herrenschmidt, Michael Ellerman
  Cc: kbuild-all, Thomas Gleixner, Oleg Nesterov, Paul E. McKenney,
	Rusty Russell, Greg Kroah-Hartman, K. Y. Srinivasan,
	Peter Zijlstra (Intel),
	Vitaly Kuznetsov, Mathias Krause, linux-kernel

On Mon, Sep 28 2015, kbuild test robot <lkp@intel.com> wrote:

> Hi Rasmus,
>
> [auto build test results on v4.3-rc2 -- if it's inappropriate base, please ignore]
>
> config: powerpc-allyesconfig (attached as .config)
> reproduce:
>   wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>   chmod +x ~/bin/make.cross
>   git checkout c14fd9e74ebf7540e312ff440343f9843917ec66
>   # save the attached .config to linux build tree
>   make.cross ARCH=powerpc 
>
> All error/warnings (new ones prefixed by >>):
>
>    In file included from include/linux/rcupdate.h:40:0,
>                     from include/linux/idr.h:18,
>                     from include/linux/kernfs.h:14,
>                     from include/linux/sysfs.h:15,
>                     from include/linux/kobject.h:21,
>                     from include/linux/pci.h:28,
>                     from arch/powerpc/kernel/prom.c:25:
>>> include/linux/cpumask.h:93:29: error: expected identifier or '(' before 'const'
>     #define cpu_online_mask   ((const struct cpumask *)&__cpu_online_mask)
>                                 ^

Gah, I didn't check for struct members called cpu_online_mask :(

PPC people: The issue is that I changed cpu_online_mask (and friends)
from being "const struct cpumask *const" exported variables to macros
with the same type and value (after exporting what they pointed to). But
that conflicts with that identifier used in struct
fadump_crash_info_header. Would you be ok with renaming that member to
just "online_mask"? I think it would be

Subject: [PATCH] ppc: rename cpu_online_mask member of struct
 fadump_crash_info_header

As preparation for eliminating the indirect access to the various
global cpu_xyz_bits bitmaps via the pointer variables cpu_xyz_mask,
rename the cpu_online_mask of struct fadump_crash_info_header to
simply online_mask, to allow cpu_online_mask to become a macro.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 arch/powerpc/include/asm/fadump.h | 2 +-
 arch/powerpc/kernel/fadump.c      | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/arch/powerpc/include/asm/fadump.h b/arch/powerpc/include/asm/fadump.h
index 493e72f64b35..b4407d0add27 100644
--- a/arch/powerpc/include/asm/fadump.h
+++ b/arch/powerpc/include/asm/fadump.h
@@ -191,7 +191,7 @@ struct fadump_crash_info_header {
 	u64		elfcorehdr_addr;
 	u32		crashing_cpu;
 	struct pt_regs	regs;
-	struct cpumask	cpu_online_mask;
+	struct cpumask	online_mask;
 };
 
 /* Crash memory ranges */
diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
index 26d091a1a54c..3cb3b02a13dd 100644
--- a/arch/powerpc/kernel/fadump.c
+++ b/arch/powerpc/kernel/fadump.c
@@ -415,7 +415,7 @@ void crash_fadump(struct pt_regs *regs, const char *str)
 	else
 		ppc_save_regs(&fdh->regs);
 
-	fdh->cpu_online_mask = *cpu_online_mask;
+	fdh->online_mask = *cpu_online_mask;
 
 	/* Call ibm,os-term rtas call to trigger firmware assisted dump */
 	rtas_os_term((char *)str);
@@ -646,7 +646,7 @@ static int __init fadump_build_cpu_notes(const struct fadump_mem_struct *fdm)
 		}
 		/* Lower 4 bytes of reg_value contains logical cpu id */
 		cpu = be64_to_cpu(reg_entry->reg_value) & FADUMP_CPU_ID_MASK;
-		if (fdh && !cpumask_test_cpu(cpu, &fdh->cpu_online_mask)) {
+		if (fdh && !cpumask_test_cpu(cpu, &fdh->online_mask)) {
 			SKIP_TO_NEXT_CPU(reg_entry);
 			continue;
 		}
-- 
2.1.3



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

* Re: [PATCH 0/5] kernel/cpu.c: eliminate some indirection
  2015-09-28  6:21   ` Rasmus Villemoes
@ 2015-09-28 21:44     ` Rusty Russell
  0 siblings, 0 replies; 15+ messages in thread
From: Rusty Russell @ 2015-09-28 21:44 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: Thomas Gleixner, Oleg Nesterov, Paul E. McKenney,
	Greg Kroah-Hartman, linux-kernel

Rasmus Villemoes <linux@rasmusvillemoes.dk> writes:
> On Sun, Sep 27 2015, Rusty Russell <rusty@rustcorp.com.au> wrote:
>
>> But to be clear, it has outlived its usefulness, but it was not useless.
>>
>> In particular, there used to be a debug config where 'struct cpumask'
>> wasn't defined, so we could catch people declaring 'struct cpumask' on
>> the stack (or passing by value).
>>
>> There was a plan to remove CONFIG_NR_CPUS (ie. having no compile-time
>> cpu limit), but it seemed overkill and was abandoned.  But avoiding
>> 'struct cpumask' (not struct cpumask *) in the core wherever possible
>> was a step towards it.
>>
>> Hope that clarifies,
>
> It does, thanks! Should some of that be edited into one of the
> changelogs?

Well, you could describe it as "now-useless", since it looks like you've
got another rev coming anyway?

Cheers,
Rusty.

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

* Re: [PATCH 3/5] drivers/base/cpu.c: use __cpu_*_mask directly
  2015-09-25 18:22 ` [PATCH 3/5] drivers/base/cpu.c: use __cpu_*_mask directly Rasmus Villemoes
@ 2015-10-04 19:09   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 15+ messages in thread
From: Greg Kroah-Hartman @ 2015-10-04 19:09 UTC (permalink / raw)
  To: Rasmus Villemoes
  Cc: Thomas Gleixner, Oleg Nesterov, Paul E. McKenney, Rusty Russell,
	linux-kernel

On Fri, Sep 25, 2015 at 08:22:25PM +0200, Rasmus Villemoes wrote:
> The only user of the lvalue-ness of the cpu_*_mask variables is in
> drivers/base/cpu.c, and that is mostly a work-around for the fact that
> not even const variables can be used in static initialization. Now
> that the underlying struct cpumasks are exposed we can take their
> address.
> 
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

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

* Re: [PATCH 4/5] kernel/cpu.c: eliminate cpu_*_mask
  2015-09-28  6:39     ` Rasmus Villemoes
@ 2015-10-05 23:10       ` Rasmus Villemoes
  2015-10-06  6:26         ` Michael Ellerman
  0 siblings, 1 reply; 15+ messages in thread
From: Rasmus Villemoes @ 2015-10-05 23:10 UTC (permalink / raw)
  To: Benjamin Herrenschmidt, Michael Ellerman; +Cc: linuxppc-dev

Hi PPC maintainers

Can I get you to ack or nak this? It's a prerequisite for a minor
patch series for kernel/cpu.c and include/linux/cpumask.h of mine.

Thanks,
Rasmus

On Mon, Sep 28 2015, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:

> Gah, I didn't check for struct members called cpu_online_mask :(
>
> PPC people: The issue is that I changed cpu_online_mask (and friends)
> from being "const struct cpumask *const" exported variables to macros
> with the same type and value (after exporting what they pointed to). But
> that conflicts with that identifier used in struct
> fadump_crash_info_header. Would you be ok with renaming that member to
> just "online_mask"? I think it would be
>
> Subject: [PATCH] ppc: rename cpu_online_mask member of struct
>  fadump_crash_info_header
>
> As preparation for eliminating the indirect access to the various
> global cpu_xyz_bits bitmaps via the pointer variables cpu_xyz_mask,
> rename the cpu_online_mask of struct fadump_crash_info_header to
> simply online_mask, to allow cpu_online_mask to become a macro.
>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
>  arch/powerpc/include/asm/fadump.h | 2 +-
>  arch/powerpc/kernel/fadump.c      | 4 ++--
>  2 files changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/include/asm/fadump.h b/arch/powerpc/include/asm/fadump.h
> index 493e72f64b35..b4407d0add27 100644
> --- a/arch/powerpc/include/asm/fadump.h
> +++ b/arch/powerpc/include/asm/fadump.h
> @@ -191,7 +191,7 @@ struct fadump_crash_info_header {
>  	u64		elfcorehdr_addr;
>  	u32		crashing_cpu;
>  	struct pt_regs	regs;
> -	struct cpumask	cpu_online_mask;
> +	struct cpumask	online_mask;
>  };
>  
>  /* Crash memory ranges */
> diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
> index 26d091a1a54c..3cb3b02a13dd 100644
> --- a/arch/powerpc/kernel/fadump.c
> +++ b/arch/powerpc/kernel/fadump.c
> @@ -415,7 +415,7 @@ void crash_fadump(struct pt_regs *regs, const char *str)
>  	else
>  		ppc_save_regs(&fdh->regs);
>  
> -	fdh->cpu_online_mask = *cpu_online_mask;
> +	fdh->online_mask = *cpu_online_mask;
>  
>  	/* Call ibm,os-term rtas call to trigger firmware assisted dump */
>  	rtas_os_term((char *)str);
> @@ -646,7 +646,7 @@ static int __init fadump_build_cpu_notes(const struct fadump_mem_struct *fdm)
>  		}
>  		/* Lower 4 bytes of reg_value contains logical cpu id */
>  		cpu = be64_to_cpu(reg_entry->reg_value) & FADUMP_CPU_ID_MASK;
> -		if (fdh && !cpumask_test_cpu(cpu, &fdh->cpu_online_mask)) {
> +		if (fdh && !cpumask_test_cpu(cpu, &fdh->online_mask)) {
>  			SKIP_TO_NEXT_CPU(reg_entry);
>  			continue;
>  		}

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

* Re: [PATCH 4/5] kernel/cpu.c: eliminate cpu_*_mask
  2015-10-05 23:10       ` Rasmus Villemoes
@ 2015-10-06  6:26         ` Michael Ellerman
  0 siblings, 0 replies; 15+ messages in thread
From: Michael Ellerman @ 2015-10-06  6:26 UTC (permalink / raw)
  To: Rasmus Villemoes; +Cc: Benjamin Herrenschmidt, linuxppc-dev

On Tue, 2015-10-06 at 01:10 +0200, Rasmus Villemoes wrote:
> Hi PPC maintainers
> 
> Can I get you to ack or nak this? It's a prerequisite for a minor
> patch series for kernel/cpu.c and include/linux/cpumask.h of mine.

Yeah fine by me.

Acked-by: Michael Ellerman <mpe@ellerman.id.au>

cheers

> On Mon, Sep 28 2015, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
> 
> > Gah, I didn't check for struct members called cpu_online_mask :(
> >
> > PPC people: The issue is that I changed cpu_online_mask (and friends)
> > from being "const struct cpumask *const" exported variables to macros
> > with the same type and value (after exporting what they pointed to). But
> > that conflicts with that identifier used in struct
> > fadump_crash_info_header. Would you be ok with renaming that member to
> > just "online_mask"? I think it would be
> >
> > Subject: [PATCH] ppc: rename cpu_online_mask member of struct
> >  fadump_crash_info_header
> >
> > As preparation for eliminating the indirect access to the various
> > global cpu_xyz_bits bitmaps via the pointer variables cpu_xyz_mask,
> > rename the cpu_online_mask of struct fadump_crash_info_header to
> > simply online_mask, to allow cpu_online_mask to become a macro.
> >
> > Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> > ---
> >  arch/powerpc/include/asm/fadump.h | 2 +-
> >  arch/powerpc/kernel/fadump.c      | 4 ++--
> >  2 files changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/powerpc/include/asm/fadump.h b/arch/powerpc/include/asm/fadump.h
> > index 493e72f64b35..b4407d0add27 100644
> > --- a/arch/powerpc/include/asm/fadump.h
> > +++ b/arch/powerpc/include/asm/fadump.h
> > @@ -191,7 +191,7 @@ struct fadump_crash_info_header {
> >  	u64		elfcorehdr_addr;
> >  	u32		crashing_cpu;
> >  	struct pt_regs	regs;
> > -	struct cpumask	cpu_online_mask;
> > +	struct cpumask	online_mask;
> >  };
> >  
> >  /* Crash memory ranges */
> > diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c
> > index 26d091a1a54c..3cb3b02a13dd 100644
> > --- a/arch/powerpc/kernel/fadump.c
> > +++ b/arch/powerpc/kernel/fadump.c
> > @@ -415,7 +415,7 @@ void crash_fadump(struct pt_regs *regs, const char *str)
> >  	else
> >  		ppc_save_regs(&fdh->regs);
> >  
> > -	fdh->cpu_online_mask = *cpu_online_mask;
> > +	fdh->online_mask = *cpu_online_mask;
> >  
> >  	/* Call ibm,os-term rtas call to trigger firmware assisted dump */
> >  	rtas_os_term((char *)str);
> > @@ -646,7 +646,7 @@ static int __init fadump_build_cpu_notes(const struct fadump_mem_struct *fdm)
> >  		}
> >  		/* Lower 4 bytes of reg_value contains logical cpu id */
> >  		cpu = be64_to_cpu(reg_entry->reg_value) & FADUMP_CPU_ID_MASK;
> > -		if (fdh && !cpumask_test_cpu(cpu, &fdh->cpu_online_mask)) {
> > +		if (fdh && !cpumask_test_cpu(cpu, &fdh->online_mask)) {
> >  			SKIP_TO_NEXT_CPU(reg_entry);
> >  			continue;
> >  		}
> 

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

* [PATCH 1/5] kernel/cpu.c: change type of cpu_possible_bits and friends
  2015-05-06 22:52 Rasmus Villemoes
@ 2015-05-06 22:52 ` Rasmus Villemoes
  0 siblings, 0 replies; 15+ messages in thread
From: Rasmus Villemoes @ 2015-05-06 22:52 UTC (permalink / raw)
  To: Ingo Molnar, Rafael J. Wysocki, Paul E. McKenney
  Cc: Rasmus Villemoes, linux-kernel

Change cpu_possible_bits and friends (online, present, active) from
being bitmaps that happen to have the right size to actually being
struct cpumasks. Also rename them to __cpu_xyz_mask. This is mostly a
small cleanup in preparation for exporting them and, eventually,
eliminating the extra indirection through the cpu_xyz_mask variables.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
 kernel/cpu.c | 44 ++++++++++++++++++++++----------------------
 1 file changed, 22 insertions(+), 22 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 94bbe4695232..de38b31b4a3d 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -755,71 +755,71 @@ const DECLARE_BITMAP(cpu_all_bits, NR_CPUS) = CPU_BITS_ALL;
 EXPORT_SYMBOL(cpu_all_bits);
 
 #ifdef CONFIG_INIT_ALL_POSSIBLE
-static DECLARE_BITMAP(cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly
-	= CPU_BITS_ALL;
+static struct cpumask __cpu_possible_mask __read_mostly
+	= {CPU_BITS_ALL};
 #else
-static DECLARE_BITMAP(cpu_possible_bits, CONFIG_NR_CPUS) __read_mostly;
+static struct cpumask __cpu_possible_mask __read_mostly;
 #endif
-const struct cpumask *const cpu_possible_mask = to_cpumask(cpu_possible_bits);
+const struct cpumask *const cpu_possible_mask = &__cpu_possible_mask;
 EXPORT_SYMBOL(cpu_possible_mask);
 
-static DECLARE_BITMAP(cpu_online_bits, CONFIG_NR_CPUS) __read_mostly;
-const struct cpumask *const cpu_online_mask = to_cpumask(cpu_online_bits);
+static struct cpumask __cpu_online_mask __read_mostly;
+const struct cpumask *const cpu_online_mask = &__cpu_online_mask;
 EXPORT_SYMBOL(cpu_online_mask);
 
-static DECLARE_BITMAP(cpu_present_bits, CONFIG_NR_CPUS) __read_mostly;
-const struct cpumask *const cpu_present_mask = to_cpumask(cpu_present_bits);
+static struct cpumask __cpu_present_mask __read_mostly;
+const struct cpumask *const cpu_present_mask = &__cpu_present_mask;
 EXPORT_SYMBOL(cpu_present_mask);
 
-static DECLARE_BITMAP(cpu_active_bits, CONFIG_NR_CPUS) __read_mostly;
-const struct cpumask *const cpu_active_mask = to_cpumask(cpu_active_bits);
+static struct cpumask __cpu_active_mask __read_mostly;
+const struct cpumask *const cpu_active_mask = &__cpu_active_mask;
 EXPORT_SYMBOL(cpu_active_mask);
 
 void set_cpu_possible(unsigned int cpu, bool possible)
 {
 	if (possible)
-		cpumask_set_cpu(cpu, to_cpumask(cpu_possible_bits));
+		cpumask_set_cpu(cpu, &__cpu_possible_mask);
 	else
-		cpumask_clear_cpu(cpu, to_cpumask(cpu_possible_bits));
+		cpumask_clear_cpu(cpu, &__cpu_possible_mask);
 }
 
 void set_cpu_present(unsigned int cpu, bool present)
 {
 	if (present)
-		cpumask_set_cpu(cpu, to_cpumask(cpu_present_bits));
+		cpumask_set_cpu(cpu, &__cpu_present_mask);
 	else
-		cpumask_clear_cpu(cpu, to_cpumask(cpu_present_bits));
+		cpumask_clear_cpu(cpu, &__cpu_present_mask);
 }
 
 void set_cpu_online(unsigned int cpu, bool online)
 {
 	if (online) {
-		cpumask_set_cpu(cpu, to_cpumask(cpu_online_bits));
-		cpumask_set_cpu(cpu, to_cpumask(cpu_active_bits));
+		cpumask_set_cpu(cpu, &__cpu_online_mask);
+		cpumask_set_cpu(cpu, &__cpu_active_mask);
 	} else {
-		cpumask_clear_cpu(cpu, to_cpumask(cpu_online_bits));
+		cpumask_clear_cpu(cpu, &__cpu_online_mask);
 	}
 }
 
 void set_cpu_active(unsigned int cpu, bool active)
 {
 	if (active)
-		cpumask_set_cpu(cpu, to_cpumask(cpu_active_bits));
+		cpumask_set_cpu(cpu, &__cpu_active_mask);
 	else
-		cpumask_clear_cpu(cpu, to_cpumask(cpu_active_bits));
+		cpumask_clear_cpu(cpu, &__cpu_active_mask);
 }
 
 void init_cpu_present(const struct cpumask *src)
 {
-	cpumask_copy(to_cpumask(cpu_present_bits), src);
+	cpumask_copy(&__cpu_present_mask, src);
 }
 
 void init_cpu_possible(const struct cpumask *src)
 {
-	cpumask_copy(to_cpumask(cpu_possible_bits), src);
+	cpumask_copy(&__cpu_possible_mask, src);
 }
 
 void init_cpu_online(const struct cpumask *src)
 {
-	cpumask_copy(to_cpumask(cpu_online_bits), src);
+	cpumask_copy(&__cpu_online_mask, src);
 }
-- 
2.1.3


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

end of thread, other threads:[~2015-10-06  6:26 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-09-25 18:22 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
2015-09-25 18:22 ` [PATCH 1/5] kernel/cpu.c: change type of cpu_possible_bits and friends Rasmus Villemoes
2015-09-25 18:22 ` [PATCH 2/5] kernel/cpu.c: export __cpu_*_mask Rasmus Villemoes
2015-09-25 18:22 ` [PATCH 3/5] drivers/base/cpu.c: use __cpu_*_mask directly Rasmus Villemoes
2015-10-04 19:09   ` Greg Kroah-Hartman
2015-09-25 18:22 ` [PATCH 4/5] kernel/cpu.c: eliminate cpu_*_mask Rasmus Villemoes
2015-09-28  6:02   ` kbuild test robot
2015-09-28  6:39     ` Rasmus Villemoes
2015-10-05 23:10       ` Rasmus Villemoes
2015-10-06  6:26         ` Michael Ellerman
2015-09-25 18:22 ` [PATCH 5/5] kernel/cpu.c: make set_cpu_* static inlines Rasmus Villemoes
2015-09-27  6:31 ` [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rusty Russell
2015-09-28  6:21   ` Rasmus Villemoes
2015-09-28 21:44     ` Rusty Russell
  -- strict thread matches above, loose matches on Subject: below --
2015-05-06 22:52 Rasmus Villemoes
2015-05-06 22:52 ` [PATCH 1/5] kernel/cpu.c: change type of cpu_possible_bits and friends Rasmus Villemoes

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.