Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4437995pxj; Tue, 25 May 2021 08:02:48 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5H30zmS+4hsplABmkrx5sr2h0ZSbQ3FF/t4QOiVROyYanaFIJil7HIbZ1hDfBZGAjfgW4 X-Received: by 2002:a05:6638:3290:: with SMTP id f16mr31768447jav.49.1621954968083; Tue, 25 May 2021 08:02:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621954968; cv=none; d=google.com; s=arc-20160816; b=ipe/3uvqc56FmMB8NjlChi+4CYx5p7H9sQi4a2dgjdbMX/PPd3qHC5FgQO8/5lP3na pJArVPIw7qIW0osaOosZLIQMmRV7WjMGaAZh4yg7QOGcUxR3aXDhYyCE1u2xn7PdINVh 5epR2hpa4RR6nvbIm0SR5DsQ/QZaFNr/ZLCU3zEchzydpL/ILPmo7wYKkE1JQze304PD G+Bscm4xnxGTfx0FQP1C/aS6Afm2rgYeXMprmmuu+2DODMmcuqbCNC9sA4t8pAR4GlBJ OuBzE617GzGtW1QMOx4HP+nrJdOcgNC9cRcBuyFxjortNfNm60F0crOPYy1se5coxlIO LRtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Mvyhc1JAbUH9hlhl52F9qOzKbiYIu64eYg1ckW/EoYQ=; b=E6AyEPdffjLsQ+/4pF7RQmFJIE/wN+2XuinAiOjdvaX3BdNdSxkjm2jqKpFG6sDAlU rlEiitH7wwJKZCNbNDSzId4BBMrR1OS5VgLlHSCLZh+TUa/2yyOhJPGm0sIXRzmqrGpv phMgUjHvFyLc2VbldLBAy7lUBd1XskG6ybZ+XVi5uWT6zRVwoDPfklsFOsDKcu5xZ5NO AYQlq9E6e/fC8YgQHlGXgrljhyS/lAmCQPI8wcXYIlUnvv3v75hn0ofEH6fDPmFvpxou v8VumCLFlgUxL2EmLbraDOxlg9l/PLlQ0JxoITU+pzpR628V0KhyVdW+EgCZMqo1Wus1 fo/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k7si17318272jaq.89.2021.05.25.08.02.32; Tue, 25 May 2021 08:02:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232816AbhEYKBR (ORCPT + 99 others); Tue, 25 May 2021 06:01:17 -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. >