public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: "Colin King (gmail)" <colin.i.king@gmail.com>
To: Viresh Kumar <viresh.kumar@linaro.org>
Cc: "Rafael J . Wysocki" <rafael@kernel.org>,
	linux-pm@vger.kernel.org, kernel-janitors@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] cpufreq: longhaul: Make array speeds static const
Date: Thu, 3 Nov 2022 14:46:23 +0000	[thread overview]
Message-ID: <4ef07fc6-8faa-7878-2f91-9c9ae90e2f2d@gmail.com> (raw)
In-Reply-To: <20221103143705.6g3geneixpmguaq5@vireshk-i7>

On 03/11/2022 14:37, Viresh Kumar wrote:
> On 03-11-22, 13:21, Colin Ian King wrote:
>> Don't populate the read-only array speeds on the stack but instead
>> make it static. Also makes the object code a little smaller.
> 
> How will that benefit ? I am just looking for a valid answer in commit log.

When the array is non-static there will be some executable code to put 
these values into the array that's on the stack (e.g. at run time). When 
it is static the array is filled at compile time and there is no 
executable code required to populate the array at run time.



> 
>> Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
>> ---
>>   drivers/cpufreq/longhaul.c | 2 +-
>>   1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
>> index 3e000e1a75c6..25f8ef7bac47 100644
>> --- a/drivers/cpufreq/longhaul.c
>> +++ b/drivers/cpufreq/longhaul.c
>> @@ -407,7 +407,7 @@ static int guess_fsb(int mult)
>>   {
>>   	int speed = cpu_khz / 1000;
>>   	int i;
>> -	int speeds[] = { 666, 1000, 1333, 2000 };
>> +	static const int speeds[] = { 666, 1000, 1333, 2000 };
> 
> Why not make it global then ?

Making it static inside the function limits the scope to the function 
and so it's not globally visible. We don't like making stuff global 
unless we really need to.

Colin



      reply	other threads:[~2022-11-03 14:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-03 13:21 [PATCH] cpufreq: longhaul: Make array speeds static const Colin Ian King
2022-11-03 14:15 ` Joe Perches
2022-11-03 14:30   ` Colin King (gmail)
2022-11-03 14:37 ` Viresh Kumar
2022-11-03 14:46   ` Colin King (gmail) [this message]

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=4ef07fc6-8faa-7878-2f91-9c9ae90e2f2d@gmail.com \
    --to=colin.i.king@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rafael@kernel.org \
    --cc=viresh.kumar@linaro.org \
    /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