linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] kernel: cpu: hotplug: constify attribute_group structures.
@ 2017-06-29 12:10 Arvind Yadav
  2017-06-30 13:10 ` [tip:smp/hotplug] cpu/hotplug: Constify " tip-bot for Arvind Yadav
  2017-07-10  7:14 ` [PATCH] kernel: cpu: hotplug: constify " Sebastian Andrzej Siewior
  0 siblings, 2 replies; 4+ messages in thread
From: Arvind Yadav @ 2017-06-29 12:10 UTC (permalink / raw)
  To: tglx, bigeasy, mingo, anna-maria, boris.ostrovsky, rcochran, torvalds
  Cc: linux-kernel

attribute_groups are not supposed to change at runtime. All functions
working with attribute_groups provided by <linux/sysfs.h> work with const
attribute_group. So mark the non-const structs as const.

File size before:
   text	   data	    bss	    dec	    hex	filename
  12582	  15361	     20	  27963	   6d3b	kernel/cpu.o

File size After adding 'const':
   text	   data	    bss	    dec	    hex	filename
  12710	  15265	     20	  27995	   6d5b	kernel/cpu.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
---
 kernel/cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index 9ae6fbe..45455f9 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1684,7 +1684,7 @@ static ssize_t show_cpuhp_target(struct device *dev,
 	NULL
 };
 
-static struct attribute_group cpuhp_cpu_attr_group = {
+static const struct attribute_group cpuhp_cpu_attr_group = {
 	.attrs = cpuhp_cpu_attrs,
 	.name = "hotplug",
 	NULL
@@ -1716,7 +1716,7 @@ static ssize_t show_cpuhp_states(struct device *dev,
 	NULL
 };
 
-static struct attribute_group cpuhp_cpu_root_attr_group = {
+static const struct attribute_group cpuhp_cpu_root_attr_group = {
 	.attrs = cpuhp_cpu_root_attrs,
 	.name = "hotplug",
 	NULL
-- 
1.9.1

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

* [tip:smp/hotplug] cpu/hotplug: Constify attribute_group structures
  2017-06-29 12:10 [PATCH] kernel: cpu: hotplug: constify attribute_group structures Arvind Yadav
@ 2017-06-30 13:10 ` tip-bot for Arvind Yadav
  2017-07-10  7:14 ` [PATCH] kernel: cpu: hotplug: constify " Sebastian Andrzej Siewior
  1 sibling, 0 replies; 4+ messages in thread
From: tip-bot for Arvind Yadav @ 2017-06-30 13:10 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, hpa, tglx, peterz, torvalds, mingo, arvind.yadav.cs

Commit-ID:  993647a293814dd47ae41d38657fda6e4ab04e33
Gitweb:     http://git.kernel.org/tip/993647a293814dd47ae41d38657fda6e4ab04e33
Author:     Arvind Yadav <arvind.yadav.cs@gmail.com>
AuthorDate: Thu, 29 Jun 2017 17:40:47 +0530
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Fri, 30 Jun 2017 09:34:39 +0200

cpu/hotplug: Constify attribute_group structures

attribute_groups are not supposed to change at runtime. All functions
working with attribute_groups provided by <linux/sysfs.h> work with const
attribute_group.

So mark the non-const structs as const:

File size before:
   text	   data	    bss	    dec	    hex	filename
  12582	  15361	     20	  27963	   6d3b	kernel/cpu.o

File size After adding 'const':
   text	   data	    bss	    dec	    hex	filename
  12710	  15265	     20	  27995	   6d5b	kernel/cpu.o

Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: anna-maria@linutronix.de
Cc: bigeasy@linutronix.de
Cc: boris.ostrovsky@oracle.com
Cc: rcochran@linutronix.de
Link: http://lkml.kernel.org/r/f9079e94e12b36d245e7adbf67d312bc5d0250c6.1498737970.git.arvind.yadav.cs@gmail.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 kernel/cpu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/kernel/cpu.c b/kernel/cpu.c
index d0f5f54..b69c058 100644
--- a/kernel/cpu.c
+++ b/kernel/cpu.c
@@ -1629,7 +1629,7 @@ static struct attribute *cpuhp_cpu_attrs[] = {
 	NULL
 };
 
-static struct attribute_group cpuhp_cpu_attr_group = {
+static const struct attribute_group cpuhp_cpu_attr_group = {
 	.attrs = cpuhp_cpu_attrs,
 	.name = "hotplug",
 	NULL
@@ -1661,7 +1661,7 @@ static struct attribute *cpuhp_cpu_root_attrs[] = {
 	NULL
 };
 
-static struct attribute_group cpuhp_cpu_root_attr_group = {
+static const struct attribute_group cpuhp_cpu_root_attr_group = {
 	.attrs = cpuhp_cpu_root_attrs,
 	.name = "hotplug",
 	NULL

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

* Re: [PATCH] kernel: cpu: hotplug: constify attribute_group structures.
  2017-06-29 12:10 [PATCH] kernel: cpu: hotplug: constify attribute_group structures Arvind Yadav
  2017-06-30 13:10 ` [tip:smp/hotplug] cpu/hotplug: Constify " tip-bot for Arvind Yadav
@ 2017-07-10  7:14 ` Sebastian Andrzej Siewior
  2017-07-10  7:29   ` Arvind Yadav
  1 sibling, 1 reply; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2017-07-10  7:14 UTC (permalink / raw)
  To: Arvind Yadav
  Cc: tglx, mingo, anna-maria, boris.ostrovsky, rcochran, torvalds,
	linux-kernel

On 2017-06-29 17:40:47 [+0530], Arvind Yadav wrote:
> attribute_groups are not supposed to change at runtime. All functions
> working with attribute_groups provided by <linux/sysfs.h> work with const
> attribute_group. So mark the non-const structs as const.
> 
> File size before:
>    text	   data	    bss	    dec	    hex	filename
>   12582	  15361	     20	  27963	   6d3b	kernel/cpu.o
> 
> File size After adding 'const':
>    text	   data	    bss	    dec	    hex	filename
>   12710	  15265	     20	  27995	   6d5b	kernel/cpu.o

While there does not seem to be anything wrong with it, why did the file
grow after the patch was applied?

> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>

Sebastian

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

* Re: [PATCH] kernel: cpu: hotplug: constify attribute_group structures.
  2017-07-10  7:14 ` [PATCH] kernel: cpu: hotplug: constify " Sebastian Andrzej Siewior
@ 2017-07-10  7:29   ` Arvind Yadav
  0 siblings, 0 replies; 4+ messages in thread
From: Arvind Yadav @ 2017-07-10  7:29 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: tglx, mingo, anna-maria, boris.ostrovsky, rcochran, torvalds,
	linux-kernel

Hi Sebastian,


On Monday 10 July 2017 12:44 PM, Sebastian Andrzej Siewior wrote:
> On 2017-06-29 17:40:47 [+0530], Arvind Yadav wrote:
>> attribute_groups are not supposed to change at runtime. All functions
>> working with attribute_groups provided by <linux/sysfs.h> work with const
>> attribute_group. So mark the non-const structs as const.
>>
>> File size before:
>>     text	   data	    bss	    dec	    hex	filename
>>    12582	  15361	     20	  27963	   6d3b	kernel/cpu.o
>>
>> File size After adding 'const':
>>     text	   data	    bss	    dec	    hex	filename
>>    12710	  15265	     20	  27995	   6d5b	kernel/cpu.o
> While there does not seem to be anything wrong with it, why did the file
> grow after the patch was applied?
Yes, You are right. I have added few more changes for some experiment.
Which is increasing size of file. Sorry for that, Correct comparison
is this.
File size before:
    text       data        bss        dec        hex    filename
   12909      15361         20      28290       6e82    kernel/cpu.o

File size After adding 'const':
    text       data        bss        dec        hex    filename
   12973      15297         20      28290       6e82    kernel/cpu.o

I will send updated patch.
>> Signed-off-by: Arvind Yadav <arvind.yadav.cs@gmail.com>
> Sebastian
Thanks
~arvind

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

end of thread, other threads:[~2017-07-10  7:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29 12:10 [PATCH] kernel: cpu: hotplug: constify attribute_group structures Arvind Yadav
2017-06-30 13:10 ` [tip:smp/hotplug] cpu/hotplug: Constify " tip-bot for Arvind Yadav
2017-07-10  7:14 ` [PATCH] kernel: cpu: hotplug: constify " Sebastian Andrzej Siewior
2017-07-10  7:29   ` Arvind Yadav

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).