pm: remove useless array definition in cpuidle_structure

Message ID 1320356693-18982-1-git-send-email-rob.lee@linaro.org
State New
Headers show

Commit Message

Rob Nov. 3, 2011, 9:44 p.m.
From: Daniel Lezcano <daniel.lezcano@linaro.org>

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.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Signed-off-by: Robert Lee <rob.lee@linaro.org>
---
 include/linux/cpuidle.h |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

Comments

Deepthi Dharwar Nov. 4, 2011, 12:21 p.m. | #1
On Friday 04 November 2011 03:14 AM, Robert Lee wrote:
> From: Daniel Lezcano <daniel.lezcano@linaro.org>
> 
> 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.
> 
> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> Signed-off-by: Robert Lee <rob.lee@linaro.org>
> ---
>  include/linux/cpuidle.h |    4 ++--
>  1 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
> index b51629e..16f9dce 100644
> --- a/include/linux/cpuidle.h
> +++ b/include/linux/cpuidle.h
> @@ -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)

Tested-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
Reviewed-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
Rafael J. Wysocki Nov. 4, 2011, 10:28 p.m. | #2
Len, Arjan,

On Friday, November 04, 2011, Deepthi Dharwar wrote:
> On Friday 04 November 2011 03:14 AM, Robert Lee wrote:
> > From: Daniel Lezcano <daniel.lezcano@linaro.org>
> > 
> > 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.
> > 
> > Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> > Signed-off-by: Robert Lee <rob.lee@linaro.org>
> > ---
> >  include/linux/cpuidle.h |    4 ++--
> >  1 files changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
> > index b51629e..16f9dce 100644
> > --- a/include/linux/cpuidle.h
> > +++ b/include/linux/cpuidle.h
> > @@ -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)
> 
> Tested-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>
> Reviewed-by: Deepthi Dharwar <deepthi@linux.vnet.ibm.com>

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
Daniel Lezcano Nov. 7, 2011, 6:59 p.m. | #3
On 11/04/2011 11:28 PM, Rafael J. Wysocki wrote:
> Len, Arjan,
>
> On Friday, November 04, 2011, Deepthi Dharwar wrote:
>> On Friday 04 November 2011 03:14 AM, Robert Lee wrote:
>>> From: Daniel Lezcano<daniel.lezcano@linaro.org>
>>>
>>> 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.
>>>
>>> Signed-off-by: Daniel Lezcano<daniel.lezcano@linaro.org>
>>> Signed-off-by: Robert Lee<rob.lee@linaro.org>
>>> ---
>>>   include/linux/cpuidle.h |    4 ++--
>>>   1 files changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
>>> index b51629e..16f9dce 100644
>>> --- a/include/linux/cpuidle.h
>>> +++ b/include/linux/cpuidle.h
>>> @@ -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)
>>
>> Tested-by: Deepthi Dharwar<deepthi@linux.vnet.ibm.com>
>> Reviewed-by: Deepthi Dharwar<deepthi@linux.vnet.ibm.com>
>
> 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

Patch

diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index b51629e..16f9dce 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -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