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=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=ham 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 843EAC47084 for ; Tue, 25 May 2021 09:59:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F09A6140E for ; Tue, 25 May 2021 09:59:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232836AbhEYKBS (ORCPT ); Tue, 25 May 2021 06:01:18 -0400 Received: from foss.arm.com ([217.140.110.172]:54106 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232682AbhEYKBP (ORCPT ); Tue, 25 May 2021 06:01:15 -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 23DBCD6E; Tue, 25 May 2021 02:59:46 -0700 (PDT) Received: from e124901.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D43763F719; Tue, 25 May 2021 02:59:43 -0700 (PDT) Date: Tue, 25 May 2021 11:00:47 +0100 From: Vincent Donnefort To: Peter Zijlstra Cc: rjw@rjwysocki.net, viresh.kumar@linaro.org, vincent.guittot@linaro.org, qperret@google.com, linux-kernel@vger.kernel.org, ionela.voinescu@arm.com, lukasz.luba@arm.com, dietmar.eggemann@arm.com Subject: Re: [PATCH v2 3/3] PM / EM: Skip inefficient OPPs Message-ID: <20210525100047.GB385567@e124901.cambridge.arm.com> References: <1621616064-340235-1-git-send-email-vincent.donnefort@arm.com> <1621616064-340235-4-git-send-email-vincent.donnefort@arm.com> <20210525092137.GA369979@e124901.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210525092137.GA369979@e124901.cambridge.arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, May 25, 2021 at 10:21:37AM +0100, Vincent Donnefort wrote: > On Tue, May 25, 2021 at 10:48:23AM +0200, Peter Zijlstra wrote: > > On Fri, May 21, 2021 at 05:54:24PM +0100, Vincent Donnefort wrote: > > > diff --git a/kernel/sched/cpufreq_schedutil.c b/kernel/sched/cpufreq_schedutil.c > > > index 4f09afd..5a91a2b 100644 > > > --- a/kernel/sched/cpufreq_schedutil.c > > > +++ b/kernel/sched/cpufreq_schedutil.c > > > @@ -10,6 +10,7 @@ > > > > > > #include "sched.h" > > > > > > +#include > > > #include > > > #include > > > > > > @@ -153,6 +154,9 @@ static unsigned int get_next_freq(struct sugov_policy *sg_policy, > > > > > > freq = map_util_freq(util, freq, max); > > > > > > + /* Avoid inefficient performance states */ > > > + freq = em_pd_get_efficient_freq(em_cpu_get(policy->cpu), freq); > > > + > > > if (freq == sg_policy->cached_raw_freq && !sg_policy->need_freq_update) > > > return sg_policy->next_freq; > > > > > > > This seems somewhat unfortunate, it adds a loop over the OPPs only to > > then call into cpufreq to do the exact same thing again :/ > > Indeed, but it would be complicated to avoid the double loop: > > It is possible to register OPPs (and by extension perf_states) for a > frequency for which, the cpufreq table entry is marked with > CPUFREQ_ENTRY_INVALID. It would probably be an issue that would have to be > fixed in the driver, but it is currently allowed. > > More importantly, while resolving the frequency, we also cache the index in > cached_resolved_idx. Some drivers, such as qcom-cpufreq-hw rely on this > value for their fastswitch support. Unless we are ok bringing the cpufreq idx into the Energy Model. But I originally dismissed this idea. I didn't want to bring a such dependency between the two frameworks, especially as the EM can also work with Devfreq. But maybe it's worth it in the end. Any thoughts? > > Notice though, we would iterate over the EM only in the case where the > performance state has found inefficiencies. >