[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <4ef07fc6-8faa-7878-2f91-9c9ae90e2f2d@gmail.com>
Date: Thu, 3 Nov 2022 14:46:23 +0000
From: "Colin King (gmail)" <colin.i.king@...il.com>
To: Viresh Kumar <viresh.kumar@...aro.org>
Cc: "Rafael J . Wysocki" <rafael@...nel.org>, linux-pm@...r.kernel.org,
kernel-janitors@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] cpufreq: longhaul: Make array speeds static const
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@...il.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
Powered by blists - more mailing lists