* [PATCH][next] EDAC, pnd2: Make read-only const array intlv static
@ 2024-09-12 13:17 Colin Ian King
2024-09-19 7:19 ` Zhuo, Qiuxu
0 siblings, 1 reply; 4+ messages in thread
From: Colin Ian King @ 2024-09-12 13:17 UTC (permalink / raw)
To: Tony Luck, Borislav Petkov, James Morse, Mauro Carvalho Chehab,
Robert Richter, linux-edac
Cc: kernel-janitors, linux-kernel
Don't populate the const read-only array intlv on the stack at
run time, instead make it static.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
drivers/edac/pnd2_edac.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/edac/pnd2_edac.c b/drivers/edac/pnd2_edac.c
index f93f2f2b1cf2..af14c8a3279f 100644
--- a/drivers/edac/pnd2_edac.c
+++ b/drivers/edac/pnd2_edac.c
@@ -372,7 +372,7 @@ static int gen_asym_mask(struct b_cr_slice_channel_hash *p,
struct b_cr_asym_mem_region1_mchbar *as1,
struct b_cr_asym_2way_mem_region_mchbar *as2way)
{
- const int intlv[] = { 0x5, 0xA, 0x3, 0xC };
+ static const int intlv[] = { 0x5, 0xA, 0x3, 0xC };
int mask = 0;
if (as2way->asym_2way_interleave_enable)
@@ -489,7 +489,7 @@ static int dnv_get_registers(void)
*/
static int get_registers(void)
{
- const int intlv[] = { 10, 11, 12, 12 };
+ static const int intlv[] = { 10, 11, 12, 12 };
if (RD_REG(&tolud, b_cr_tolud_pci) ||
RD_REG(&touud_lo, b_cr_touud_lo_pci) ||
--
2.39.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* RE: [PATCH][next] EDAC, pnd2: Make read-only const array intlv static
2024-09-12 13:17 [PATCH][next] EDAC, pnd2: Make read-only const array intlv static Colin Ian King
@ 2024-09-19 7:19 ` Zhuo, Qiuxu
2024-09-19 7:48 ` Colin King (gmail)
0 siblings, 1 reply; 4+ messages in thread
From: Zhuo, Qiuxu @ 2024-09-19 7:19 UTC (permalink / raw)
To: Colin Ian King, Luck, Tony, Borislav Petkov, James Morse,
Mauro Carvalho Chehab, Robert Richter, linux-edac@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
> From: Colin Ian King <colin.i.king@gmail.com>
> [...]
> Subject: [PATCH][next] EDAC, pnd2: Make read-only const array intlv static
>
> Don't populate the const read-only array intlv on the stack at run time, instead
> make it static.
>
> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
> ---
> drivers/edac/pnd2_edac.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/edac/pnd2_edac.c b/drivers/edac/pnd2_edac.c index
> f93f2f2b1cf2..af14c8a3279f 100644
> --- a/drivers/edac/pnd2_edac.c
> +++ b/drivers/edac/pnd2_edac.c
> @@ -372,7 +372,7 @@ static int gen_asym_mask(struct
> b_cr_slice_channel_hash *p,
> struct b_cr_asym_mem_region1_mchbar *as1,
> struct b_cr_asym_2way_mem_region_mchbar
> *as2way) {
> - const int intlv[] = { 0x5, 0xA, 0x3, 0xC };
> + static const int intlv[] = { 0x5, 0xA, 0x3, 0xC };
> int mask = 0;
>
> if (as2way->asym_2way_interleave_enable)
> @@ -489,7 +489,7 @@ static int dnv_get_registers(void)
> */
> static int get_registers(void)
> {
> - const int intlv[] = { 10, 11, 12, 12 };
> + static const int intlv[] = { 10, 11, 12, 12 };
>
I didn't see the why and the benefits of these changes.
Could you elaborate more?
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH][next] EDAC, pnd2: Make read-only const array intlv static
2024-09-19 7:19 ` Zhuo, Qiuxu
@ 2024-09-19 7:48 ` Colin King (gmail)
2024-09-19 8:47 ` Zhuo, Qiuxu
0 siblings, 1 reply; 4+ messages in thread
From: Colin King (gmail) @ 2024-09-19 7:48 UTC (permalink / raw)
To: Zhuo, Qiuxu, Luck, Tony, Borislav Petkov, James Morse,
Mauro Carvalho Chehab, Robert Richter, linux-edac@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
On 19/09/2024 08:19, Zhuo, Qiuxu wrote:
>> From: Colin Ian King <colin.i.king@gmail.com>
>> [...]
>> Subject: [PATCH][next] EDAC, pnd2: Make read-only const array intlv static
>>
>> Don't populate the const read-only array intlv on the stack at run time, instead
>> make it static.
>>
>> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
>> ---
>> drivers/edac/pnd2_edac.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/edac/pnd2_edac.c b/drivers/edac/pnd2_edac.c index
>> f93f2f2b1cf2..af14c8a3279f 100644
>> --- a/drivers/edac/pnd2_edac.c
>> +++ b/drivers/edac/pnd2_edac.c
>> @@ -372,7 +372,7 @@ static int gen_asym_mask(struct
>> b_cr_slice_channel_hash *p,
>> struct b_cr_asym_mem_region1_mchbar *as1,
>> struct b_cr_asym_2way_mem_region_mchbar
>> *as2way) {
>> - const int intlv[] = { 0x5, 0xA, 0x3, 0xC };
>> + static const int intlv[] = { 0x5, 0xA, 0x3, 0xC };
>> int mask = 0;
>>
>> if (as2way->asym_2way_interleave_enable)
>> @@ -489,7 +489,7 @@ static int dnv_get_registers(void)
>> */
>> static int get_registers(void)
>> {
>> - const int intlv[] = { 10, 11, 12, 12 };
>> + static const int intlv[] = { 10, 11, 12, 12 };
>>
>
> I didn't see the why and the benefits of these changes.
> Could you elaborate more?
The non-const construct will generate code to put the array on the stack
and this occurs on each call, so there is a small amount of extra object
code overhead to do this at run time. Making it static will put the data
into a data section so there is run-time penalty. So this change
potentially shrinks the object code and run time overhead a very small
amount.
Colin
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH][next] EDAC, pnd2: Make read-only const array intlv static
2024-09-19 7:48 ` Colin King (gmail)
@ 2024-09-19 8:47 ` Zhuo, Qiuxu
0 siblings, 0 replies; 4+ messages in thread
From: Zhuo, Qiuxu @ 2024-09-19 8:47 UTC (permalink / raw)
To: Colin King (gmail), Luck, Tony, Borislav Petkov, James Morse,
Mauro Carvalho Chehab, Robert Richter, linux-edac@vger.kernel.org
Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org
> From: Colin King (gmail) <colin.i.king@gmail.com>
> [...]
> >> - const int intlv[] = { 10, 11, 12, 12 };
> >> + static const int intlv[] = { 10, 11, 12, 12 };
> >>
> >
> > I didn't see the why and the benefits of these changes.
> > Could you elaborate more?
>
> The non-const construct will generate code to put the array on the stack and
Typo?
s/non-const/non-static/
> this occurs on each call, so there is a small amount of extra object code
> overhead to do this at run time. Making it static will put the data into a data
> section so there is run-time penalty. So this change potentially shrinks the
> object code and run time overhead a very small amount.
>
Thanks!
As these are not in hot paths, there should be no measurable performance difference.
But, I do see that the text size is reduced by 12 bytes [1] after these changes.
Could you add a short description of this benefit in the commit message?
Other than that,
Reviewed-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
[1] $ size pnd2_edac.o.*
text data bss dec hex filename
15632 264 1384 17280 4380 pnd2_edac.o.new
15644 264 1384 17292 438c pnd2_edac.o.old
- Qiuxu
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-09-19 8:48 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-12 13:17 [PATCH][next] EDAC, pnd2: Make read-only const array intlv static Colin Ian King
2024-09-19 7:19 ` Zhuo, Qiuxu
2024-09-19 7:48 ` Colin King (gmail)
2024-09-19 8:47 ` Zhuo, Qiuxu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox