All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] kernel/cpu.c: eliminate some indirection
@ 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
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ 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

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.

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.

Altogether, bloat-o-meter reports a saving of ~2600 bytes.

Rasmus Villemoes (5):
  kernel/cpu.c: change type of cpu_possible_bits and friends
  kernel/cpu.c: export __cpu_xyz_mask
  drivers/base/cpu.c: use __cpu_xyz_mask directly
  kernel/cpu.c: eliminate cpu_xyz_mask
  kernel/cpu.c: make set_cpu_xyz 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] 8+ messages in thread

* [PATCH 1/5] kernel/cpu.c: change type of cpu_possible_bits and friends
  2015-05-06 22:52 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
@ 2015-05-06 22:52 ` Rasmus Villemoes
  2015-05-06 22:52 ` [PATCH 2/5] kernel/cpu.c: export __cpu_xyz_mask Rasmus Villemoes
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 8+ 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] 8+ messages in thread

* [PATCH 2/5] kernel/cpu.c: export __cpu_xyz_mask
  2015-05-06 22:52 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
  2015-05-06 22:52 ` [PATCH 1/5] kernel/cpu.c: change type of cpu_possible_bits and friends Rasmus Villemoes
@ 2015-05-06 22:52 ` Rasmus Villemoes
  2015-05-06 22:52 ` [PATCH 3/5] drivers/base/cpu.c: use __cpu_xyz_mask directly Rasmus Villemoes
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ 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

Exporting these cpumasks will allow us to remove the extra indirection
through the cpu_xyz_mask variables. It will also allow the set_cpu_xyz
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 27e285b92b5f..1842df8c1d29 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 de38b31b4a3d..852922a793a3 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -755,23 +755,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] 8+ messages in thread

* [PATCH 3/5] drivers/base/cpu.c: use __cpu_xyz_mask directly
  2015-05-06 22:52 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
  2015-05-06 22:52 ` [PATCH 1/5] kernel/cpu.c: change type of cpu_possible_bits and friends Rasmus Villemoes
  2015-05-06 22:52 ` [PATCH 2/5] kernel/cpu.c: export __cpu_xyz_mask Rasmus Villemoes
@ 2015-05-06 22:52 ` Rasmus Villemoes
  2015-05-06 22:52 ` [PATCH 4/5] kernel/cpu.c: eliminate cpu_xyz_mask Rasmus Villemoes
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ 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

The only user of the lvalue-ness of the cpu_xyz_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 f160ea44a86d..f21b08601a19 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -199,7 +199,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,
@@ -208,7 +208,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) \
@@ -216,9 +216,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] 8+ messages in thread

* [PATCH 4/5] kernel/cpu.c: eliminate cpu_xyz_mask
  2015-05-06 22:52 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
                   ` (2 preceding siblings ...)
  2015-05-06 22:52 ` [PATCH 3/5] drivers/base/cpu.c: use __cpu_xyz_mask directly Rasmus Villemoes
@ 2015-05-06 22:52 ` Rasmus Villemoes
  2015-05-06 22:52 ` [PATCH 5/5] kernel/cpu.c: make set_cpu_xyz static inlines Rasmus Villemoes
  2015-06-11  9:31 ` [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
  5 siblings, 0 replies; 8+ 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

Replace the variables cpu_xyz_mask (xyz =
possible,online,present,active) 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 1842df8c1d29..9b609d338d32 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 852922a793a3..f8c273ce6cb9 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -761,23 +761,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] 8+ messages in thread

* [PATCH 5/5] kernel/cpu.c: make set_cpu_xyz static inlines
  2015-05-06 22:52 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
                   ` (3 preceding siblings ...)
  2015-05-06 22:52 ` [PATCH 4/5] kernel/cpu.c: eliminate cpu_xyz_mask Rasmus Villemoes
@ 2015-05-06 22:52 ` Rasmus Villemoes
  2015-06-11  9:31 ` [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
  5 siblings, 0 replies; 8+ 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

Almost all callers of the set_cpu_xyz 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 9b609d338d32..d94294ffeab1 100644
--- a/include/linux/cpumask.h
+++ b/include/linux/cpumask.h
@@ -722,14 +722,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 f8c273ce6cb9..32299ce27d17 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -771,40 +771,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] 8+ messages in thread

* Re: [PATCH 0/5] kernel/cpu.c: eliminate some indirection
  2015-05-06 22:52 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
                   ` (4 preceding siblings ...)
  2015-05-06 22:52 ` [PATCH 5/5] kernel/cpu.c: make set_cpu_xyz static inlines Rasmus Villemoes
@ 2015-06-11  9:31 ` Rasmus Villemoes
  5 siblings, 0 replies; 8+ messages in thread
From: Rasmus Villemoes @ 2015-06-11  9:31 UTC (permalink / raw)
  To: Ingo Molnar; +Cc: Rafael J. Wysocki, Paul E. McKenney, linux-kernel

On Thu, May 07 2015, Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:

> 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.
>
> 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.
>
> Altogether, bloat-o-meter reports a saving of ~2600 bytes.

ping...


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

* [PATCH 1/5] kernel/cpu.c: change type of cpu_possible_bits and friends
  2015-09-25 18:22 Rasmus Villemoes
@ 2015-09-25 18:22 ` Rasmus Villemoes
  0 siblings, 0 replies; 8+ 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] 8+ messages in thread

end of thread, other threads:[~2015-09-25 18:22 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-06 22:52 [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
2015-05-06 22:52 ` [PATCH 1/5] kernel/cpu.c: change type of cpu_possible_bits and friends Rasmus Villemoes
2015-05-06 22:52 ` [PATCH 2/5] kernel/cpu.c: export __cpu_xyz_mask Rasmus Villemoes
2015-05-06 22:52 ` [PATCH 3/5] drivers/base/cpu.c: use __cpu_xyz_mask directly Rasmus Villemoes
2015-05-06 22:52 ` [PATCH 4/5] kernel/cpu.c: eliminate cpu_xyz_mask Rasmus Villemoes
2015-05-06 22:52 ` [PATCH 5/5] kernel/cpu.c: make set_cpu_xyz static inlines Rasmus Villemoes
2015-06-11  9:31 ` [PATCH 0/5] kernel/cpu.c: eliminate some indirection Rasmus Villemoes
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

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.