constify x86 attribute_group structures.
Subsystems (3)
cover constify x86 attribute_group structures.
attribute_group are not supposed to change at runtime. All functions working with attribute_group provided by <linux/sysfs.h> and 'uncore.h' work with const attribute_group. So mark the non-const structs as const.
Arvind Yadav (7):
[PATCH 1/7] perf: x86: intel: uncore: constify attribute_group structures. [PATCH 2/7] perf: x86: intel: uncore_nhmex: constify attribute_group structures. [PATCH 3/7] perf: x86: intel: uncore_snb: constify attribute_group structures. [PATCH 4/7] perf: x86: intel: uncore_snbep: constify attribute_group structures. [PATCH 5/7] x86: ksysfs: constify attribute_group structures. [PATCH 6/7] x86: therm_throt: constify attribute_group structures. [PATCH 7/7] x86: microcode: constify attribute_group structures.
arch/x86/events/intel/uncore.c | 2 +- arch/x86/events/intel/uncore_nhmex.c | 12 ++++----- arch/x86/events/intel/uncore_snb.c | 6 ++--- arch/x86/events/intel/uncore_snbep.c | 42 ++++++++++++++++---------------- arch/x86/kernel/cpu/mcheck/therm_throt.c | 2 +- arch/x86/kernel/cpu/microcode/core.c | 4 +-- arch/x86/kernel/ksysfs.c | 4 +-- 7 files changed, 36 insertions(+), 36 deletions(-)
Signature · 1 line
1.9.1
PATCH 1/7 perf: x86: intel: uncore: constify attribute_group structures.
attribute_group are not supposed to change at runtime. All functions working with attribute_group provided by 'uncore.h' work with const attribute_group. So mark the non-const structs as const.
File size before:
text data bss dec hex filename
9361 216 88 9665 25c1 arch/x86/events/intel/uncore.o
File size After adding 'const':
text data bss dec hex filename
9393 184 88 9665 25c1 arch/x86/events/intel/uncore.o
--- arch/x86/events/intel/uncore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/events/intel/uncore.c +1 -1
@@ -721,7 +721,7 @@ static ssize_t uncore_get_attr_cpumask(struct device *dev, NULL, }; -static struct attribute_group uncore_pmu_attr_group = { +static const struct attribute_group uncore_pmu_attr_group = { .attrs = uncore_pmu_attrs, };
Signature · 1 line
1.9.1
PATCH 2/7 perf: x86: intel: uncore_nhmex: constify attribute_group structures.
In reply to Arvind Yadavattribute_group are not supposed to change at runtime. All functions working with attribute_group provided by 'uncore.h' work with const attribute_group. So mark the non-const structs as const.
File size before:
text data bss dec hex filename
8236 5992 1 14229 3795 x86/events/intel/uncore_nhmex.o
File size After adding 'const':
text data bss dec hex filename
8620 5608 1 14229 3795 x86/events/intel/uncore_nhmex.o
--- arch/x86/events/intel/uncore_nhmex.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
arch/x86/events/intel/uncore_nhmex.c +6 -6
@@ -272,7 +272,7 @@ static void nhmex_uncore_msr_enable_event(struct intel_uncore_box *box, struct p NULL, }; -static struct attribute_group nhmex_uncore_ubox_format_group = { +static const struct attribute_group nhmex_uncore_ubox_format_group = { .name ="format" , .attrs = nhmex_uncore_ubox_formats_attr, };
@@ -299,7 +299,7 @@ static void nhmex_uncore_msr_enable_event(struct intel_uncore_box *box, struct p NULL, }; -static struct attribute_group nhmex_uncore_cbox_format_group = { +static const struct attribute_group nhmex_uncore_cbox_format_group = { .name ="format" , .attrs = nhmex_uncore_cbox_formats_attr, };
@@ -407,7 +407,7 @@ static void nhmex_bbox_msr_enable_event(struct intel_uncore_box *box, struct per NULL, }; -static struct attribute_group nhmex_uncore_bbox_format_group = { +static const struct attribute_group nhmex_uncore_bbox_format_group = { .name ="format" , .attrs = nhmex_uncore_bbox_formats_attr, };
@@ -484,7 +484,7 @@ static void nhmex_sbox_msr_enable_event(struct intel_uncore_box *box, struct per NULL, }; -static struct attribute_group nhmex_uncore_sbox_format_group = { +static const struct attribute_group nhmex_uncore_sbox_format_group = { .name ="format" , .attrs = nhmex_uncore_sbox_formats_attr, };
@@ -898,7 +898,7 @@ static void nhmex_mbox_msr_enable_event(struct intel_uncore_box *box, struct per NULL, }; -static struct attribute_group nhmex_uncore_mbox_format_group = { +static const struct attribute_group nhmex_uncore_mbox_format_group = { .name ="format" , .attrs = nhmex_uncore_mbox_formats_attr, };
@@ -1163,7 +1163,7 @@ static void nhmex_rbox_msr_enable_event(struct intel_uncore_box *box, struct per NULL, }; -static struct attribute_group nhmex_uncore_rbox_format_group = { +static const struct attribute_group nhmex_uncore_rbox_format_group = { .name ="format" , .attrs = nhmex_uncore_rbox_formats_attr, };
Signature · 1 line
1.9.1
PATCH 3/7 perf: x86: intel: uncore_snb: constify attribute_group structures.
In reply to Arvind Yadavattribute_group are not supposed to change at runtime. All functions working with attribute_group provided by 'uncore.h' work with const attribute_group. So mark the non-const structs as const.
File size before:
text data bss dec hex filename
4158 4792 0 8950 22f6 arch/x86/events/intel/uncore_snb.o
File size After adding 'const':
text data bss dec hex filename
4350 4600 0 8950 22f6 arch/x86/events/intel/uncore_snb.o
--- arch/x86/events/intel/uncore_snb.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/x86/events/intel/uncore_snb.c +3 -3
@@ -130,7 +130,7 @@ static void snb_uncore_msr_exit_box(struct intel_uncore_box *box) NULL, }; -static struct attribute_group snb_uncore_format_group = { +static const struct attribute_group snb_uncore_format_group = { .name ="format" , .attrs = snb_uncore_formats_attr, };
@@ -289,7 +289,7 @@ enum { NULL, }; -static struct attribute_group snb_uncore_imc_format_group = { +static const struct attribute_group snb_uncore_imc_format_group = { .name ="format" , .attrs = snb_uncore_imc_formats_attr, };
@@ -769,7 +769,7 @@ static void nhm_uncore_msr_enable_event(struct intel_uncore_box *box, struct per NULL, }; -static struct attribute_group nhm_uncore_format_group = { +static const struct attribute_group nhm_uncore_format_group = { .name ="format" , .attrs = nhm_uncore_formats_attr, };
Signature · 1 line
1.9.1
PATCH 4/7 perf: x86: intel: uncore_snbep: constify attribute_group structures.
In reply to Arvind Yadavattribute_group are not supposed to change at runtime. All functions working with attribute_group provided by 'uncore.h' work with const attribute_group. So mark the non-const structs as const.
File size before:
text data bss dec hex filename
15137 33528 0 48665 be19 x86/events/intel/uncore_snbep.o
File size After adding 'const':
text data bss dec hex filename
16457 32184 0 48665 be19 x86/events/intel/uncore_snbep.o
--- arch/x86/events/intel/uncore_snbep.c | 42 ++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 21 deletions(-)
arch/x86/events/intel/uncore_snbep.c +21 -21
@@ -603,27 +603,27 @@ static void snbep_uncore_msr_init_box(struct intel_uncore_box *box) { /* end: all zeroes */ }, }; -static struct attribute_group snbep_uncore_format_group = { +static const struct attribute_group snbep_uncore_format_group = { .name ="format" , .attrs = snbep_uncore_formats_attr, }; -static struct attribute_group snbep_uncore_ubox_format_group = { +static const struct attribute_group snbep_uncore_ubox_format_group = { .name ="format" , .attrs = snbep_uncore_ubox_formats_attr, }; -static struct attribute_group snbep_uncore_cbox_format_group = { +static const struct attribute_group snbep_uncore_cbox_format_group = { .name ="format" , .attrs = snbep_uncore_cbox_formats_attr, }; -static struct attribute_group snbep_uncore_pcu_format_group = { +static const struct attribute_group snbep_uncore_pcu_format_group = { .name ="format" , .attrs = snbep_uncore_pcu_formats_attr, }; -static struct attribute_group snbep_uncore_qpi_format_group = { +static const struct attribute_group snbep_uncore_qpi_format_group = { .name ="format" , .attrs = snbep_uncore_qpi_formats_attr, };
@@ -1432,27 +1432,27 @@ static void ivbep_uncore_pci_init_box(struct intel_uncore_box *box) NULL, }; -static struct attribute_group ivbep_uncore_format_group = { +static const struct attribute_group ivbep_uncore_format_group = { .name ="format" , .attrs = ivbep_uncore_formats_attr, }; -static struct attribute_group ivbep_uncore_ubox_format_group = { +static const struct attribute_group ivbep_uncore_ubox_format_group = { .name ="format" , .attrs = ivbep_uncore_ubox_formats_attr, }; -static struct attribute_group ivbep_uncore_cbox_format_group = { +static const struct attribute_group ivbep_uncore_cbox_format_group = { .name ="format" , .attrs = ivbep_uncore_cbox_formats_attr, }; -static struct attribute_group ivbep_uncore_pcu_format_group = { +static const struct attribute_group ivbep_uncore_pcu_format_group = { .name ="format" , .attrs = ivbep_uncore_pcu_formats_attr, }; -static struct attribute_group ivbep_uncore_qpi_format_group = { +static const struct attribute_group ivbep_uncore_qpi_format_group = { .name ="format" , .attrs = ivbep_uncore_qpi_formats_attr, };
@@ -1888,7 +1888,7 @@ int ivbep_uncore_pci_init(void) NULL, }; -static struct attribute_group knl_uncore_ubox_format_group = { +static const struct attribute_group knl_uncore_ubox_format_group = { .name ="format" , .attrs = knl_uncore_ubox_formats_attr, };
@@ -1928,7 +1928,7 @@ int ivbep_uncore_pci_init(void) NULL, }; -static struct attribute_group knl_uncore_cha_format_group = { +static const struct attribute_group knl_uncore_cha_format_group = { .name ="format" , .attrs = knl_uncore_cha_formats_attr, };
@@ -2038,7 +2038,7 @@ static void hswep_cbox_enable_event(struct intel_uncore_box *box, NULL, }; -static struct attribute_group knl_uncore_pcu_format_group = { +static const struct attribute_group knl_uncore_pcu_format_group = { .name ="format" , .attrs = knl_uncore_pcu_formats_attr, };
@@ -2188,7 +2188,7 @@ static void knl_uncore_imc_enable_event(struct intel_uncore_box *box, NULL, }; -static struct attribute_group knl_uncore_irp_format_group = { +static const struct attribute_group knl_uncore_irp_format_group = { .name ="format" , .attrs = knl_uncore_irp_formats_attr, };
@@ -2386,7 +2386,7 @@ int knl_uncore_pci_init(void) NULL, }; -static struct attribute_group hswep_uncore_ubox_format_group = { +static const struct attribute_group hswep_uncore_ubox_format_group = { .name ="format" , .attrs = hswep_uncore_ubox_formats_attr, };
@@ -2440,7 +2440,7 @@ static int hswep_ubox_hw_config(struct intel_uncore_box *box, struct perf_event NULL, }; -static struct attribute_group hswep_uncore_cbox_format_group = { +static const struct attribute_group hswep_uncore_cbox_format_group = { .name ="format" , .attrs = hswep_uncore_cbox_formats_attr, };
@@ -2622,7 +2622,7 @@ static void hswep_uncore_sbox_msr_init_box(struct intel_uncore_box *box) NULL, }; -static struct attribute_group hswep_uncore_sbox_format_group = { +static const struct attribute_group hswep_uncore_sbox_format_group = { .name ="format" , .attrs = hswep_uncore_sbox_formats_attr, };
@@ -3317,7 +3317,7 @@ int bdx_uncore_pci_init(void) NULL, }; -static struct attribute_group skx_uncore_chabox_format_group = { +static const struct attribute_group skx_uncore_chabox_format_group = { .name ="format" , .attrs = skx_uncore_cha_formats_attr, };
@@ -3416,7 +3416,7 @@ static int skx_cha_hw_config(struct intel_uncore_box *box, struct perf_event *ev NULL, }; -static struct attribute_group skx_uncore_iio_format_group = { +static const struct attribute_group skx_uncore_iio_format_group = { .name ="format" , .attrs = skx_uncore_iio_formats_attr, };
@@ -3473,7 +3473,7 @@ static void skx_iio_enable_event(struct intel_uncore_box *box, NULL, }; -static struct attribute_group skx_uncore_format_group = { +static const struct attribute_group skx_uncore_format_group = { .name ="format" , .attrs = skx_uncore_formats_attr, };
@@ -3574,7 +3574,7 @@ void skx_uncore_cpu_init(void) NULL, }; -static struct attribute_group skx_upi_uncore_format_group = { +static const struct attribute_group skx_upi_uncore_format_group = { .name ="format" , .attrs = skx_upi_uncore_formats_attr, };
Signature · 1 line
1.9.1
PATCH 5/7 x86: ksysfs: constify attribute_group structures.
In reply to Arvind Yadavattribute_group are not supposed to change at runtime. All functions working with attribute_group 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
1183 384 0 1567 61f arch/x86/kernel/ksysfs.o
File size After adding 'const':
text data bss dec hex filename
1311 256 0 1567 61f arch/x86/kernel/ksysfs.o
--- arch/x86/kernel/ksysfs.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/ksysfs.c +2 -2
@@ -55,7 +55,7 @@ static ssize_t boot_params_data_read(struct file *fp, struct kobject *kobj, NULL, }; -static struct attribute_group boot_params_attr_group = { +static const struct attribute_group boot_params_attr_group = { .attrs = boot_params_version_attrs, .bin_attrs = boot_params_data_attrs, };
@@ -202,7 +202,7 @@ static ssize_t setup_data_data_read(struct file *fp, NULL, }; -static struct attribute_group setup_data_attr_group = { +static const struct attribute_group setup_data_attr_group = { .attrs = setup_data_type_attrs, .bin_attrs = setup_data_data_attrs, };
Signature · 1 line
1.9.1
PATCH 6/7 x86: therm_throt: constify attribute_group structures.
In reply to Arvind Yadavattribute_group are not supposed to change at runtime. All functions working with attribute_group 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
3586 864 32 4482 1182 x86/kernel/cpu/mcheck/therm_throt.o
File size After adding 'const':
text data bss dec hex filename
3550 928 32 4482 1182 x86/kernel/cpu/mcheck/therm_throt.o
--- arch/x86/kernel/cpu/mcheck/therm_throt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/x86/kernel/cpu/mcheck/therm_throt.c +1 -1
@@ -122,7 +122,7 @@ struct thermal_state { NULL }; -static struct attribute_group thermal_attr_group = { +static const struct attribute_group thermal_attr_group = { .attrs = thermal_throttle_attrs, .name ="thermal_throttle" };
Signature · 1 line
1.9.1
PATCH 7/7 x86: microcode: constify attribute_group structures.
In reply to Arvind Yadavattribute_group are not supposed to change at runtime. All functions working with attribute_group 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
3614 545 1560 5719 1657 x86/kernel/cpu/microcode/core.o
File size After adding 'const':
text data bss dec hex filename
3742 417 1560 5719 1657 x86/kernel/cpu/microcode/core.o
--- arch/x86/kernel/cpu/microcode/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
arch/x86/kernel/cpu/microcode/core.c +2 -2
@@ -561,7 +561,7 @@ static ssize_t pf_show(struct device *dev, NULL }; -static struct attribute_group mc_attr_group = { +static const struct attribute_group mc_attr_group = { .attrs = mc_default_attrs, .name ="microcode" , };
@@ -707,7 +707,7 @@ static int mc_cpu_down_prep(unsigned int cpu) NULL }; -static struct attribute_group cpu_root_microcode_group = { +static const struct attribute_group cpu_root_microcode_group = { .name ="microcode" , .attrs = cpu_root_microcode_attrs, };
Signature · 1 line
1.9.1
Borislav Petkov
maintainerRe: [PATCH 7/7] x86: microcode: constify attribute_group structures.
Quoted 11 lines · Arvind Yadav
attribute_groupare not supposed to change at runtime. All functions working withattribute_groupprovided by <linux/sysfs.h> work with constattribute_group. So mark the non-const structs as const.File size before:
text data bss dec hex filename
3614 545 1560 5719 1657x86/kernel/cpu/microcode/core.oFile size After adding 'const':
text data bss dec hex filename
3742 417 1560 5719 1657x86/kernel/cpu/microcode/core.o
Again, what are those before/after sizes supposed to show?
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Re: [PATCH 7/7] x86: microcode: constify attribute_group structures.
Hi,
Quoted 5 lines · Borislav Petkov
Quoted 4 lines · Arvind Yadav
attribute_groupare not supposed to change at runtime. All functions working withattribute_groupprovided by <linux/sysfs.h> work with constattribute_group. So mark the non-const structs as const.
Quoted 8 lines
Quoted 7 lines
File size before:
text data bss dec hex filename
3614 545 1560 5719 1657x86/kernel/cpu/microcode/core.oFile size After adding 'const':
text data bss dec hex filename
3742 417 1560 5719 1657x86/kernel/cpu/microcode/core.oAgain, what are those before/after sizes supposed to show?
It's just show, how much bytes move from data segment to text segment. ~arvind
Borislav Petkov
maintainerRe: [PATCH 7/7] x86: microcode: constify attribute_group structures.
Quoted 2 lines · Arvind Yadav
It's just show, how much bytes move from data segment to text segment. ~arvind
3614 545 1560 5719 1657 x86/kernel/cpu/microcode/core.o
3614 + 545 = 4159
3742 417 1560 5719 1657 x86/kernel/cpu/microcode/core.o
3742 + 417 = 4159
3742 - 3614 = 128
So 128 bytes moved to text.
I fail to see how this is relevant. Your commit message contains not really relevant info for such a simple change. Rather, it should just be a one-liner:
"Constify attribute_group structs because they don't change at runtime."
That's it.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Re: [PATCH 7/7] x86: microcode: constify attribute_group structures.
Hi,
Quoted 7 lines · Borislav Petkov
Quoted 2 lines · Arvind Yadav
It's just show, how much bytes move from data segment to text segment. ~arvind
3614 545 1560 5719 1657 x86/kernel/cpu/microcode/core.o3614 + 545 = 4159
Quoted 7 lines
3742 417 1560 5719 1657 x86/kernel/cpu/microcode/core.o3742 + 417 = 4159
3742 - 3614 = 128
So 128 bytes moved to text.
Yes,
Quoted 4 lines
I fail to see how this is relevant. Your commit message contains not really relevant info for such a simple change. Rather, it should just be a one-liner:
I have mentioned all this in commit message. I have added below message in patch. Please check my patch.
"attribute_group are not supposed to change at runtime. All functions working with attribute_group provided by <linux/sysfs.h> work with const attribute_group. So mark the non-const structs as const."
Quoted 1 line
"Constify
attribute_groupstructs because they don't change at runtime."
I can add this as subject. But we should avoid lengthy subject. Even checkpatch.pl will through warning.
Quoted 3 lines
That's it.
~arvind
Borislav Petkov
maintainerRe: [PATCH 7/7] x86: microcode: constify attribute_group structures.
Quoted 2 lines · Arvind Yadav
Quoted 1 line
"Constify
attribute_groupstructs because they don't change at runtime."I can add this as subject. But we should avoid lengthy subject.
Are you actually reading what I'm writing to you? I said this should be the commit message, not the subject.
What I'm saying is, shorten your commit message - no need for the irrelevant before/after sizes. I'm not the first reviewer to ask WTF do those things even mean.
Signature · 5 lines
Regards/Gruss,
Boris.
ECO tip #101: Trim your mails when you reply.
--Re: [PATCH 7/7] x86: microcode: constify attribute_group structures.
Hi,
Quoted 10 lines · Borislav Petkov
Quoted 2 lines · Arvind Yadav
Quoted 1 line
"Constify
attribute_groupstructs because they don't change at runtime."I can add this as subject. But we should avoid lengthy subject.
Are you actually reading what I'm writing to you? I said this should be the commit message, not the subject.
What I'm saying is, shorten your commit message - no need for the irrelevant before/after sizes. I'm not the first reviewer to ask WTF do those things even mean.
Thanks :) for your suggestion. I will remove before/after size comparison. and send you back for review.
~arvind