public inbox for linux-edac@vger.kernel.org
 help / color / mirror / Atom feed
From: "Colin King (gmail)" <colin.i.king@gmail.com>
To: "Zhuo, Qiuxu" <qiuxu.zhuo@intel.com>,
	"Luck, Tony" <tony.luck@intel.com>,
	Borislav Petkov <bp@alien8.de>, James Morse <james.morse@arm.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Robert Richter <rric@kernel.org>,
	"linux-edac@vger.kernel.org" <linux-edac@vger.kernel.org>
Cc: "kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][next] EDAC, pnd2: Make read-only const array intlv static
Date: Thu, 19 Sep 2024 08:48:16 +0100	[thread overview]
Message-ID: <351a69eb-bdad-46ff-aa8b-ad156de10249@gmail.com> (raw)
In-Reply-To: <CY8PR11MB7134F6951DFF67FDED364FB889632@CY8PR11MB7134.namprd11.prod.outlook.com>

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


  reply	other threads:[~2024-09-19  7:48 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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) [this message]
2024-09-19  8:47     ` Zhuo, Qiuxu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=351a69eb-bdad-46ff-aa8b-ad156de10249@gmail.com \
    --to=colin.i.king@gmail.com \
    --cc=bp@alien8.de \
    --cc=james.morse@arm.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-edac@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=qiuxu.zhuo@intel.com \
    --cc=rric@kernel.org \
    --cc=tony.luck@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox