Skip to contentSkip to conversation

pm: remove useless array definition in cpuidle_structure

PATCH In review Robert Lee 4 participants 4 messages Nov 3, 2011 – Nov 7, 2011 CPU idle time management framework

lore
Share & tools
lore

Robert Lee

author
#0 lore raw

PATCH 1/1 pm: remove useless array definition in cpuidle_structure

From: Daniel Lezcano <[email protected]>

All the modules name are ro-data, it is never copied to the array.

eg.

static struct cpuidle_driver intel_idle_driver = {
.name = "intel_idle",
.owner = THIS_MODULE,
};

It safe to assign the pointer of this ro-data to a const char *. By this way we save 12 bytes.

---
 include/linux/cpuidle.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/linux/cpuidle.h +2 -2
index b51629e..16f9dce 100644
@@ -117,8 +117,8 @@ static inline int cpuidle_get_last_residency(struct cpuidle_device *dev)
  ****************************/
 
 struct cpuidle_driver {
-	char			name[CPUIDLE_NAME_LEN];
-	struct module 		*owner;
+	const char    *name;
+	struct module *owner;
 };
 
 #ifdef CONFIG_CPU_IDLE
Signature · 1 line
1.7.4.1
Tested-by Reviewed-by on v1 1/1
#1 lore raw
Quoted 25 lines · Robert Lee

From: Daniel Lezcano <[email protected]>

All the modules name are ro-data, it is never copied to the array.

eg.

static struct cpuidle_driver intel_idle_driver = {
.name = "intel_idle",
.owner = THIS_MODULE,
};

It safe to assign the pointer of this ro-data to a const char *. By this way we save 12 bytes.

---
 include/linux/cpuidle.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/linux/cpuidle.h +0 -0
index b51629e..16f9dce 100644

include/linux/cpuidle.h static inline int cpuidle_get_last_residency(struct cpuidle_device *dev) · line 124

Quoted 10 lines
include/linux/cpuidle.h +2 -2
@@ -117,8 +117,8 @@ static inline int cpuidle_get_last_residency(struct cpuidle_device *dev)
  ****************************/
 
 struct cpuidle_driver {
-	char			name[CPUIDLE_NAME_LEN];
-	struct module 		*owner;
+	const char    *name;
+	struct module *owner;
 };
 
 #ifdef CONFIG_CPU_IDLE

This looks good, and makes it fool-proof by not allowing one to tamper the name of the driver. Tested OK on x86 (both Intel idle and ACPI)

#2 lore raw

Len, Arjan,

Quoted 35 lines · Deepthi Dharwar
Quoted 34 lines · Robert Lee

From: Daniel Lezcano <[email protected]>

All the modules name are ro-data, it is never copied to the array.

eg.

static struct cpuidle_driver intel_idle_driver = {
.name = "intel_idle",
.owner = THIS_MODULE,
};

It safe to assign the pointer of this ro-data to a const char *. By this way we save 12 bytes.

---
 include/linux/cpuidle.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
include/linux/cpuidle.h +2 -2
index b51629e..16f9dce 100644
@@ -117,8 +117,8 @@ static inline int cpuidle_get_last_residency(struct cpuidle_device *dev)
  ****************************/
 
 struct cpuidle_driver {
-	char			name[CPUIDLE_NAME_LEN];
-	struct module 		*owner;
+	const char    *name;
+	struct module *owner;
 };
 
Quoted 7 lines

include/linux/cpuidle.h static inline int cpuidle_get_last_residency(struct cpuidle_device *dev) · line 124

Quoted 1 line
include/linux/cpuidle.h +0 -0
 #ifdef CONFIG_CPU_IDLE

This looks good, and makes it fool-proof by not allowing one to tamper the name of the driver. Tested OK on x86 (both Intel idle and ACPI)

This is simple enough for me to push it for 3.2, but I woulnd't like to step on anyone's toes. Please let me know what you think.

Rafael

#3 lore raw
Quoted 43 lines · Rafael J. Wysocki

Len, Arjan,

Quoted 40 lines · Deepthi Dharwar
Quoted 25 lines · Robert Lee

From: Daniel Lezcano<[email protected]>

All the modules name are ro-data, it is never copied to the array.

eg.

static struct cpuidle_driver intel_idle_driver = {
.name = "intel_idle",
.owner = THIS_MODULE,
};

It safe to assign the pointer of this ro-data to a const char *. By this way we save 12 bytes.

---
  include/linux/cpuidle.h |    4 ++--
  1 files changed, 2 insertions(+), 2 deletions(-)
include/linux/cpuidle.h +0 -0
index b51629e..16f9dce 100644

include/linux/cpuidle.h static inline int cpuidle_get_last_residency(struct cpuidle_device *dev) · line 124

Quoted 10 lines
include/linux/cpuidle.h +2 -2
@@ -117,8 +117,8 @@ static inline int cpuidle_get_last_residency(struct cpuidle_device *dev)
   ****************************/
 
  struct cpuidle_driver {
-	char			name[CPUIDLE_NAME_LEN];
-	struct module 		*owner;
+	const char    *name;
+	struct module *owner;
  };
 
  #ifdef CONFIG_CPU_IDLE

This looks good, and makes it fool-proof by not allowing one to tamper the name of the driver. Tested OK on x86 (both Intel idle and ACPI)

Quoted 7 lines
Quoted 2 lines

This is simple enough for me to push it for 3.2, but I woulnd't like to step on anyone's toes. Please let me know what you think.

Rafael

Hi Len,

are you willing to take this patch for 3.2 ?

Thanks

-- Daniel

Signature · 5 lines
 <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog