From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.2 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23762C48BE5 for ; Wed, 23 Jun 2021 13:45:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0FC6161075 for ; Wed, 23 Jun 2021 13:45:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231145AbhFWNrz (ORCPT ); Wed, 23 Jun 2021 09:47:55 -0400 Received: from foss.arm.com ([217.140.110.172]:35602 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230206AbhFWNrx (ORCPT ); Wed, 23 Jun 2021 09:47:53 -0400 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A7666ED1; Wed, 23 Jun 2021 06:45:35 -0700 (PDT) Received: from localhost (unknown [10.1.195.40]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 482B93F718; Wed, 23 Jun 2021 06:45:35 -0700 (PDT) Date: Wed, 23 Jun 2021 14:45:33 +0100 From: Ionela Voinescu To: Viresh Kumar Cc: Rafael Wysocki , linux-pm@vger.kernel.org, Vincent Guittot , Qian Cai , linux-kernel@vger.kernel.org Subject: Re: [PATCH V3 2/4] cpufreq: cppc: Pass structure instance by reference Message-ID: <20210623134533.GB12411@arm.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.4 (2018-02-28) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday 21 Jun 2021 at 14:49:35 (+0530), Viresh Kumar wrote: > Don't pass structure instance by value, pass it by reference instead. > Might be best to justify the change a bit :) For me this is a judgement call, and I don't really see the reasons for changing it: we don't care if the structure is modified or not, as we're not reusing the data after the call to cppc_get_rate_from_fbctrs(). More so, in this scenario we might not even want for the called function to modify the counter values. Also there is no further call to a function in cppc_get_rate_from_fbctrs(), that might require references to the fb_ctrs. So what is the reason behind this change? Thanks, Ionela. > Tested-by: Vincent Guittot > Signed-off-by: Viresh Kumar > --- > drivers/cpufreq/cppc_cpufreq.c | 16 ++++++++-------- > 1 file changed, 8 insertions(+), 8 deletions(-) > > diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c > index 35b8ae66d1fb..490175d65082 100644 > --- a/drivers/cpufreq/cppc_cpufreq.c > +++ b/drivers/cpufreq/cppc_cpufreq.c > @@ -373,18 +373,18 @@ static inline u64 get_delta(u64 t1, u64 t0) > } > > static int cppc_get_rate_from_fbctrs(struct cppc_cpudata *cpu_data, > - struct cppc_perf_fb_ctrs fb_ctrs_t0, > - struct cppc_perf_fb_ctrs fb_ctrs_t1) > + struct cppc_perf_fb_ctrs *fb_ctrs_t0, > + struct cppc_perf_fb_ctrs *fb_ctrs_t1) > { > u64 delta_reference, delta_delivered; > u64 reference_perf, delivered_perf; > > - reference_perf = fb_ctrs_t0.reference_perf; > + reference_perf = fb_ctrs_t0->reference_perf; > > - delta_reference = get_delta(fb_ctrs_t1.reference, > - fb_ctrs_t0.reference); > - delta_delivered = get_delta(fb_ctrs_t1.delivered, > - fb_ctrs_t0.delivered); > + delta_reference = get_delta(fb_ctrs_t1->reference, > + fb_ctrs_t0->reference); > + delta_delivered = get_delta(fb_ctrs_t1->delivered, > + fb_ctrs_t0->delivered); > > /* Check to avoid divide-by zero */ > if (delta_reference || delta_delivered) > @@ -415,7 +415,7 @@ static unsigned int cppc_cpufreq_get_rate(unsigned int cpu) > if (ret) > return ret; > > - return cppc_get_rate_from_fbctrs(cpu_data, fb_ctrs_t0, fb_ctrs_t1); > + return cppc_get_rate_from_fbctrs(cpu_data, &fb_ctrs_t0, &fb_ctrs_t1); > } > > static int cppc_cpufreq_set_boost(struct cpufreq_policy *policy, int state) > -- > 2.31.1.272.g89b43f80a514 >