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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 49065C433EF for ; Thu, 17 Mar 2022 14:20:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235034AbiCQOWF (ORCPT ); Thu, 17 Mar 2022 10:22:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231233AbiCQOWE (ORCPT ); Thu, 17 Mar 2022 10:22:04 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CAEB169B18; Thu, 17 Mar 2022 07:20:48 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1179CB81ECB; Thu, 17 Mar 2022 14:20:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2231C340E9; Thu, 17 Mar 2022 14:20:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647526845; bh=1jUnKiTd1ovbIfeqqvU+XJdp2zp/6es7srgZU1ueVYU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=K/Xy2Izpna9w9dzEslqf7bO8KZu+v9fBTe2zkXFrzLYzjVA2zW8PG2G6ccy2UzuCe +megLNyEoALM3Wc8R31tGQJskEsN8hODtURw7ibV+t4q7ilQhqt4qgn/13I7VIINMS Raevqn7AT3PUjJ6u8el4RlvUW+rE0W0awJW/fJDL0F+20UP/OW2m4wQTbde7j1uh0a ZyAoK4E1eJZOwaMp5kSQAIeN7ZeCJvZPHjrz7ckm6u5LxS/+/OIcijzsnNunJhLgdF aLl9ogG6jaQw2DzprxRfjZwrgMk2aombKs6hJyMAz/BWGJTwtc+L++V4JVOLZ+279E EFOsoMUelAbPg== Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nUqzb-00FCgJ-4z; Thu, 17 Mar 2022 14:20:43 +0000 MIME-Version: 1.0 Date: Thu, 17 Mar 2022 14:20:42 +0000 From: Marc Zyngier To: Pierre Gondois Cc: linux-kernel@vger.kernel.org, Ionela.Voinescu@arm.com, Lukasz.Luba@arm.com, Morten.Rasmussen@arm.com, Dietmar.Eggemann@arm.com, mka@chromium.org, daniel.lezcano@linaro.org, Catalin Marinas , Will Deacon , "Rafael J. Wysocki" , Viresh Kumar , Mark Rutland , Ard Biesheuvel , Fuad Tabba , Valentin Schneider , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: Re: [PATCH v1 1/3] cpufreq: CPPC: Add cppc_cpufreq_search_cpu_data In-Reply-To: <20220317133419.3901736-2-Pierre.Gondois@arm.com> References: <20220317133419.3901736-1-Pierre.Gondois@arm.com> <20220317133419.3901736-2-Pierre.Gondois@arm.com> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <746641141c630dc1d02943d6133a6c8d@kernel.org> X-Sender: maz@kernel.org Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: Pierre.Gondois@arm.com, linux-kernel@vger.kernel.org, Ionela.Voinescu@arm.com, Lukasz.Luba@arm.com, Morten.Rasmussen@arm.com, Dietmar.Eggemann@arm.com, mka@chromium.org, daniel.lezcano@linaro.org, catalin.marinas@arm.com, will@kernel.org, rafael@kernel.org, viresh.kumar@linaro.org, mark.rutland@arm.com, ardb@kernel.org, tabba@google.com, valentin.schneider@arm.com, robh@kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org On 2022-03-17 13:34, Pierre Gondois wrote: > cppc_cpufreq_get_cpu_data() allocates a new struct cppc_cpudata > for the input CPU at each call. > > To search the struct associated with a cpu without allocating > a new one, add cppc_cpufreq_search_cpu_data(). > Also add an early prototype. > > This will be used in a later patch, when generating artificial > performance states to register an artificial Energy Model in the > cppc_cpufreq driver and enable the Energy Aware Scheduler for ACPI > based systems. > > Signed-off-by: Pierre Gondois > --- > drivers/cpufreq/cppc_cpufreq.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/cpufreq/cppc_cpufreq.c > b/drivers/cpufreq/cppc_cpufreq.c > index 82d370ae6a4a..8f950fe72765 100644 > --- a/drivers/cpufreq/cppc_cpufreq.c > +++ b/drivers/cpufreq/cppc_cpufreq.c > @@ -41,6 +41,8 @@ > */ > static LIST_HEAD(cpu_data_list); > > +static struct cppc_cpudata *cppc_cpufreq_search_cpu_data(unsigned int > cpu); > + > static bool boost_supported; > > struct cppc_workaround_oem_info { > @@ -479,6 +481,19 @@ static void cppc_cpufreq_put_cpu_data(struct > cpufreq_policy *policy) > policy->driver_data = NULL; > } > > +static inline struct cppc_cpudata * Why the inline? This is hardly performance critical, and if it is, you want something better than iterating over a list. > +cppc_cpufreq_search_cpu_data(unsigned int cpu) > +{ > + struct cppc_cpudata *iter, *tmp; > + > + list_for_each_entry_safe(iter, tmp, &cpu_data_list, node) { > + if (cpumask_test_cpu(cpu, iter->shared_cpu_map)) > + return iter; > + } > + > + return NULL; > +} > + > static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) > { > unsigned int cpu = policy->cpu; Thanks, M. -- Jazz is not dead. It just smells funny... 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 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 31A55C433F5 for ; Thu, 17 Mar 2022 14:22:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:Content-Type: Content-Transfer-Encoding:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:Cc:To:From :Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qqVH1l2ewbGKSNHjh2UeTg8KG/A/VWuvaj9SNcosr1M=; b=NKZr6jAFEJB7Oeihw3OPsNTD2R hPY70qOpGYzSwCMWJ3BcqI5X3LRKqauGZJK88cyF/FFnd1X1/4QY8P2/VaoCV7rjnqTIrtKD2sVQ3 3vJamuRvZ7jZ0LfW6pp6DXHKf3+eTTxFeP8h9rL8YzXRU867yYgnzzKhCav0mafhL4ZSfi2gBNjVX eBxhuZNRJKoHfrvAwD/DASEL4VhJ7PJytv1cLpVhu35BCFImiEnl1mr7Jr32oue1Hm5mfjuYJHiAt TtzitAiUmaCsYSFKKIimgrgH93hOod6q5jYQxYaeL8n8fg2c4j7eMq2v8StQCaP+/+rKhXEuIM3A5 Vr/j0d9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nUqzl-00GPO2-2O; Thu, 17 Mar 2022 14:20:53 +0000 Received: from ams.source.kernel.org ([145.40.68.75]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nUqzg-00GPN0-Fn for linux-arm-kernel@lists.infradead.org; Thu, 17 Mar 2022 14:20:50 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 1AA71B81ECF; Thu, 17 Mar 2022 14:20:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A2231C340E9; Thu, 17 Mar 2022 14:20:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1647526845; bh=1jUnKiTd1ovbIfeqqvU+XJdp2zp/6es7srgZU1ueVYU=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=K/Xy2Izpna9w9dzEslqf7bO8KZu+v9fBTe2zkXFrzLYzjVA2zW8PG2G6ccy2UzuCe +megLNyEoALM3Wc8R31tGQJskEsN8hODtURw7ibV+t4q7ilQhqt4qgn/13I7VIINMS Raevqn7AT3PUjJ6u8el4RlvUW+rE0W0awJW/fJDL0F+20UP/OW2m4wQTbde7j1uh0a ZyAoK4E1eJZOwaMp5kSQAIeN7ZeCJvZPHjrz7ckm6u5LxS/+/OIcijzsnNunJhLgdF aLl9ogG6jaQw2DzprxRfjZwrgMk2aombKs6hJyMAz/BWGJTwtc+L++V4JVOLZ+279E EFOsoMUelAbPg== Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1nUqzb-00FCgJ-4z; Thu, 17 Mar 2022 14:20:43 +0000 MIME-Version: 1.0 Date: Thu, 17 Mar 2022 14:20:42 +0000 From: Marc Zyngier To: Pierre Gondois Cc: linux-kernel@vger.kernel.org, Ionela.Voinescu@arm.com, Lukasz.Luba@arm.com, Morten.Rasmussen@arm.com, Dietmar.Eggemann@arm.com, mka@chromium.org, daniel.lezcano@linaro.org, Catalin Marinas , Will Deacon , "Rafael J. Wysocki" , Viresh Kumar , Mark Rutland , Ard Biesheuvel , Fuad Tabba , Valentin Schneider , Rob Herring , linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org Subject: Re: [PATCH v1 1/3] cpufreq: CPPC: Add cppc_cpufreq_search_cpu_data In-Reply-To: <20220317133419.3901736-2-Pierre.Gondois@arm.com> References: <20220317133419.3901736-1-Pierre.Gondois@arm.com> <20220317133419.3901736-2-Pierre.Gondois@arm.com> User-Agent: Roundcube Webmail/1.4.13 Message-ID: <746641141c630dc1d02943d6133a6c8d@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: Pierre.Gondois@arm.com, linux-kernel@vger.kernel.org, Ionela.Voinescu@arm.com, Lukasz.Luba@arm.com, Morten.Rasmussen@arm.com, Dietmar.Eggemann@arm.com, mka@chromium.org, daniel.lezcano@linaro.org, catalin.marinas@arm.com, will@kernel.org, rafael@kernel.org, viresh.kumar@linaro.org, mark.rutland@arm.com, ardb@kernel.org, tabba@google.com, valentin.schneider@arm.com, robh@kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220317_072048_852964_1827686D X-CRM114-Status: GOOD ( 23.02 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2022-03-17 13:34, Pierre Gondois wrote: > cppc_cpufreq_get_cpu_data() allocates a new struct cppc_cpudata > for the input CPU at each call. > > To search the struct associated with a cpu without allocating > a new one, add cppc_cpufreq_search_cpu_data(). > Also add an early prototype. > > This will be used in a later patch, when generating artificial > performance states to register an artificial Energy Model in the > cppc_cpufreq driver and enable the Energy Aware Scheduler for ACPI > based systems. > > Signed-off-by: Pierre Gondois > --- > drivers/cpufreq/cppc_cpufreq.c | 15 +++++++++++++++ > 1 file changed, 15 insertions(+) > > diff --git a/drivers/cpufreq/cppc_cpufreq.c > b/drivers/cpufreq/cppc_cpufreq.c > index 82d370ae6a4a..8f950fe72765 100644 > --- a/drivers/cpufreq/cppc_cpufreq.c > +++ b/drivers/cpufreq/cppc_cpufreq.c > @@ -41,6 +41,8 @@ > */ > static LIST_HEAD(cpu_data_list); > > +static struct cppc_cpudata *cppc_cpufreq_search_cpu_data(unsigned int > cpu); > + > static bool boost_supported; > > struct cppc_workaround_oem_info { > @@ -479,6 +481,19 @@ static void cppc_cpufreq_put_cpu_data(struct > cpufreq_policy *policy) > policy->driver_data = NULL; > } > > +static inline struct cppc_cpudata * Why the inline? This is hardly performance critical, and if it is, you want something better than iterating over a list. > +cppc_cpufreq_search_cpu_data(unsigned int cpu) > +{ > + struct cppc_cpudata *iter, *tmp; > + > + list_for_each_entry_safe(iter, tmp, &cpu_data_list, node) { > + if (cpumask_test_cpu(cpu, iter->shared_cpu_map)) > + return iter; > + } > + > + return NULL; > +} > + > static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) > { > unsigned int cpu = policy->cpu; Thanks, M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel