Message ID | 20221103132141.79671-1-colin.i.king@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp536725wru; Thu, 3 Nov 2022 06:38:13 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ov1qNCP0plEOfN4XXx4iEjiJkLltln01jMBtNXCKpY5V7e9tMbdM7HgcO1PlRXy2DGf3U X-Received: by 2002:a17:90a:d14a:b0:203:7b4b:6010 with SMTP id t10-20020a17090ad14a00b002037b4b6010mr48960627pjw.237.1667482693258; Thu, 03 Nov 2022 06:38:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667482693; cv=none; d=google.com; s=arc-20160816; b=IDPuhuH2IZkOzu1YBJrKypb2gaRaC2RSNkLiDdLusyeXrQrAyCn4Y7xSDxlWXC1khD ghr2PmguRggHpfF3or+7Uf8AaIBnj8aPfWTJJIK56LwlG611le1m8Z3G2vXB9BJRSXRZ Lzmv7XVflbCp9bRjYM1o60xUvAW4CfhS9H2OAOTCqUYPqy46J76/a5UryLk07JqkP83u a50LDUoncE1IIG07/F9Juv269VDnv36QtnuZIxzYcyC0xyDxZLmtHFhaP5lBnGfcl0OI yWzYikqaDIR+R8EtyyC6z7SL/MatgRKTFDqrBodvF1MdpBYhyvl9dgOtmFQGtMarhPwb y2OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=OY/0Zt8FwX5kTy53FzOKqmm1vtlRPaq+T8e8ZY4Q7eA=; b=DrQkyPG0eVZSTmXncUPZlPVlwBQg03ss9paMqLpmjn07mGCbtMmIFgtWT4E3YF3YqO krYg+UcFuStOQDso2563pfImwYTra8Vnb3DGsvIHDXn49fZl2DT2sKC0erKy9Oq+2lW/ pGOXO2tdpJmS3p+cfI338JmMB5oRl7nOPmvjjf92auiMV1Xh0xXQI1FBq+qT8MgIdui3 o+KUBeZjsV+Rr+RDM1xUSle4pGoBPGy9QdWJ+9JF0mlRqxOm+X7PGCztVITwmU+2pGSD oRWhy1tE2RHCntTvZcCmyg9ce6oiKKl9oUFq8QQxyLgDVlVL0lKHXAH9W0GD6nN71l9i yTLA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cgED+cyh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cd26-20020a056a00421a00b0056e3c566bfasi906477pfb.201.2022.11.03.06.37.59; Thu, 03 Nov 2022 06:38:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cgED+cyh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231667AbiKCNVs (ORCPT <rfc822;yves.mi.zy@gmail.com> + 99 others); Thu, 3 Nov 2022 09:21:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231171AbiKCNVp (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 3 Nov 2022 09:21:45 -0400 Received: from mail-wm1-x32d.google.com (mail-wm1-x32d.google.com [IPv6:2a00:1450:4864:20::32d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1EBBB13E22; Thu, 3 Nov 2022 06:21:44 -0700 (PDT) Received: by mail-wm1-x32d.google.com with SMTP id p16so1119884wmc.3; Thu, 03 Nov 2022 06:21:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=OY/0Zt8FwX5kTy53FzOKqmm1vtlRPaq+T8e8ZY4Q7eA=; b=cgED+cyhzriZDjNBEDDn+Bf3yvyYUXqca6zfBlyWXDuH/fwDwvy6Cypk8fcRgh6WuF WP8Bl4IOtJFJ42X42WO+/nwjv2kXcdPzCoOvcfMDGDb4DJGTJm/6DDfzBCBXyfSgo7pU jhK11V+j61Z6W+6p9j5ccPGHMmVjr6nbI5m5Ss5C1C7twzksF8Ipg+/uFituJfnjIi52 PH/omYypZGZJhKknpfWvT+iHjMm2LqftX59XEgSZwmwG1ZCUR0PnHygSMAS7QEYON1Ge gRuslMzkexi4WohZjS5mbKo0icfhrqby8uLT24WvSFVcfIJgCw4yOFMaNwOMDl3djkBY sPBw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=OY/0Zt8FwX5kTy53FzOKqmm1vtlRPaq+T8e8ZY4Q7eA=; b=dNifVwoXFLXswseqqWmT1giECBOP06G9RVC6nPRgIIQ+lS+ZkyKZpWfAbQprASy0bC sWcAhFEKI63z50hwhaBcYFZowCnX9uwJCpAFB2sfmmGR3yPSrWYZAn1LkeT0QCEFgQTV iv+coxIimNMQ0J5tZL92AgIFhzi0IK/gaYhY3H8RTH0TSMQwbsHYBARWpRuNkWxK4wyC FJE6LHep4iY2nMen29hBxjqMHeUK/Od6/+MGT9ioWx3j47Lz0m4aEywaLYOuf76ydlDY SHnHiZ7AHALNL7ewXHI5vmJOnJlKivzt4muMGnMKEYptVinNLZQlzbm/9W5YiR9hgmCY 1NBQ== X-Gm-Message-State: ACrzQf2pWGFpHkkrhgleBnX7sMfsgTxKNNNIjjtoUMtbwhnceum4887p 9ChK+//10a3+O9NF35oactA= X-Received: by 2002:a1c:2987:0:b0:3c6:c0cc:b4c2 with SMTP id p129-20020a1c2987000000b003c6c0ccb4c2mr18877676wmp.56.1667481702566; Thu, 03 Nov 2022 06:21:42 -0700 (PDT) Received: from localhost (cpc154979-craw9-2-0-cust193.16-3.cable.virginm.net. [80.193.200.194]) by smtp.gmail.com with ESMTPSA id e7-20020a05600c448700b003c64c186206sm1190503wmo.16.2022.11.03.06.21.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Nov 2022 06:21:42 -0700 (PDT) From: Colin Ian King <colin.i.king@gmail.com> To: "Rafael J . Wysocki" <rafael@kernel.org>, Viresh Kumar <viresh.kumar@linaro.org>, linux-pm@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cpufreq: longhaul: Make array speeds static const Date: Thu, 3 Nov 2022 13:21:41 +0000 Message-Id: <20221103132141.79671-1-colin.i.king@gmail.com> X-Mailer: git-send-email 2.38.1 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748482332898824650?= X-GMAIL-MSGID: =?utf-8?q?1748482332898824650?= |
Series |
cpufreq: longhaul: Make array speeds static const
|
|
Commit Message
Colin Ian King
Nov. 3, 2022, 1:21 p.m. UTC
Don't populate the read-only array speeds on the stack but instead
make it static. Also makes the object code a little smaller.
Signed-off-by: Colin Ian King <colin.i.king@gmail.com>
---
drivers/cpufreq/longhaul.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Thu, 2022-11-03 at 13:21 +0000, 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. [] > diff --git 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 }; > int f_max, f_min; > > for (i = 0; i < 4; i++) { style trivia: the loop test is probably better using ARRAY_SIZE for (i = 0; i < ARRAY_SIZE(speeds); i++)
On 03/11/2022 14:15, Joe Perches wrote: > On Thu, 2022-11-03 at 13:21 +0000, 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. > [] >> diff --git 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 }; >> int f_max, f_min; >> >> for (i = 0; i < 4; i++) { > > style trivia: the loop test is probably better using ARRAY_SIZE > > for (i = 0; i < ARRAY_SIZE(speeds); i++) > I'll send a V2 for that. Good idea. Colin
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. > 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 ?
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
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 }; int f_max, f_min; for (i = 0; i < 4; i++) {