[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <351a69eb-bdad-46ff-aa8b-ad156de10249@gmail.com>
Date: Thu, 19 Sep 2024 08:48:16 +0100
From: "Colin King (gmail)" <colin.i.king@...il.com>
To: "Zhuo, Qiuxu" <qiuxu.zhuo@...el.com>, "Luck, Tony" <tony.luck@...el.com>,
Borislav Petkov <bp@...en8.de>, James Morse <james.morse@....com>,
Mauro Carvalho Chehab <mchehab@...nel.org>, Robert Richter
<rric@...nel.org>, "linux-edac@...r.kernel.org" <linux-edac@...r.kernel.org>
Cc: "kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH][next] EDAC, pnd2: Make read-only const array intlv static
On 19/09/2024 08:19, Zhuo, Qiuxu wrote:
>> From: Colin Ian King <colin.i.king@...il.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@...il.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
Powered by blists - more mailing lists