Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp857300pxb; Thu, 15 Apr 2021 08:11:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzCdb5kzA5AwU+5rMG4WBDy8XydUKW6xUaxCA4pqYC9KSNC/5HqYX7Kfl90SpV/I3m0F75i X-Received: by 2002:a62:7bc3:0:b029:251:20c1:2ed8 with SMTP id w186-20020a627bc30000b029025120c12ed8mr3810388pfc.10.1618499476708; Thu, 15 Apr 2021 08:11:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618499476; cv=none; d=google.com; s=arc-20160816; b=eSXO4RqJJWBXodFfE257qDeIrc3yx229RTrDq2Yo8zAyciJJp/xgLUd9iUtRxnExf0 Z7uJNOzxlnUy+3/RKEyXcuIvQFmJS7uqMb14b/H4jsZ/8r5JgBjIVpBNRDIzo97OGHCY 5I0lTXiTivj1q/E6iBhL3GU6bq1p28J/C2MbR3cTs/nT4Jg2MIiz1gNt7YB/2CDCNM48 MeGohcbLqh5sua1KwJYlMs3cHOVq2effNV9pLxJt1p873Cf2Oq94hL0iNQ21AvAqfMjQ AnbwSauYF2hRJS25uz6aC+NBUwkSidI+lencY6R9q9GFXiQsLFGeA28GvTgId/W0h6rF XDmQ== 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:dkim-signature; bh=wEmeE+nRU2i2HuTEhl2l+nDu4F3N+EEwdYCFM019aAY=; b=DtrBH3J7HuCUImT0qY8blQUPvuUB4RfZAxzrBACP0CtXQnPVL3s2Dci1LwWW8HE+ox O9QTawes86TQ4Xj3VBtll03odH/Hhpm1+JNFSi1KmgeF32gpYM3wKRVgG41VsKowfW1D x2Jsuzt+2Nthc+sFKVlKpiL3XKg9lwO2bDOUDnCvwBF71AVk0PcCnCK4sUc2dXw+mGEB Ue44QV2uCg/86vPK7LnI9bBIFLtqE8cbkDrqPW1pC4ToyuKZ98rU6G+cROzW2jOCGuSr fQplKXsop8JvcEvLvs2AhTRPrAM6pnIuaJ+RFN3s0V0yQoxwo61e6+8rOJFMdp7gSWdU igfw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=A45SPYWV; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x10si3408283pll.145.2021.04.15.08.11.04; Thu, 15 Apr 2021 08:11:16 -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; dkim=pass header.i=@google.com header.s=20161025 header.b=A45SPYWV; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235301AbhDOPJQ (ORCPT + 99 others); Thu, 15 Apr 2021 11:09:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235097AbhDOPAW (ORCPT ); Thu, 15 Apr 2021 11:00:22 -0400 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 09A49C061574 for ; Thu, 15 Apr 2021 07:59:59 -0700 (PDT) Received: by mail-wm1-x329.google.com with SMTP id k4-20020a7bc4040000b02901331d89fb83so433245wmi.5 for ; Thu, 15 Apr 2021 07:59:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=wEmeE+nRU2i2HuTEhl2l+nDu4F3N+EEwdYCFM019aAY=; b=A45SPYWVLdT7S1dswSXWtbcLIKQs4WiHE/Ut3PZ0xIiaRcL3umDmo8P9ZrwTDFF7V6 YDKC6g0b1KhlecjvXgtySFWKVq2QdkQo3ARkALOHZ6iR40y5YaYTHl62khsxLAXngB7c uYneF1Yx836FyhliuVUFQPVgyur9q5JMyd3+Hp3PM8OmyHRFEVJa5x1Y9DGVkVOzcoA1 mAHyIuuYFbu3alcwhnvS5wzJetRQ+vkZSlD+Os/ylplcUuJBtBoQ3zLOLpbgrpaC0zxX zd3u5giUf0USAYnGu5e+saklLbDrHTbUg8euRGtwECxLoaZPeSy2JNm4I5kGH7WDqmWp i8wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=wEmeE+nRU2i2HuTEhl2l+nDu4F3N+EEwdYCFM019aAY=; b=pG9vcaZR6uVWYuBySp4Jli3o8AAQhRO076/fNhFpWorvs6JO04wOlNSAl//hSZbwS2 T6FjkpnbDFfH4YcbiYYpAA2ALWqQzbEM0FgO9v1+3fYhc/k40PlOmNkeQOSQ5T9AfzzA sQFjbnYlabHKEgaxVjviolClnbiPWOGyU25s9fX4DLBfFi7g+53t18d7DYGXHixQSSW6 RX5WCbjwg5ucPi+X3+CxilA8yoRACo3dRtSxgAn18fOQPXZk6hCcbK+naIsUqhEph04Z G715DKKvKLF1TN3aSGkAyr6+lJ3TqR3pV7GuGoSIgVrHl3ZZ6BvWKYDLmEeX4DvNNVMH SxXw== X-Gm-Message-State: AOAM533+bziXh4PtGJCgav5i1Ey8C+wf8wGHSJvLUCvPyerBrhOJ3iv9 JNfQRShaLBu7DWHxZtQ7++rXVmBXdIDA9Q== X-Received: by 2002:a05:600c:3544:: with SMTP id i4mr3497996wmq.38.1618498797586; Thu, 15 Apr 2021 07:59:57 -0700 (PDT) Received: from google.com (105.168.195.35.bc.googleusercontent.com. [35.195.168.105]) by smtp.gmail.com with ESMTPSA id 3sm3820681wma.45.2021.04.15.07.59.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Apr 2021 07:59:57 -0700 (PDT) Date: Thu, 15 Apr 2021 14:59:54 +0000 From: Quentin Perret To: Vincent Donnefort Cc: peterz@infradead.org, rjw@rjwysocki.net, viresh.kumar@linaro.org, vincent.guittot@linaro.org, linux-kernel@vger.kernel.org, ionela.voinescu@arm.com, lukasz.luba@arm.com, dietmar.eggemann@arm.com Subject: Re: [PATCH] PM / EM: Inefficient OPPs detection Message-ID: References: <1617901829-381963-1-git-send-email-vincent.donnefort@arm.com> <1617901829-381963-2-git-send-email-vincent.donnefort@arm.com> <20210415143453.GB391924@e120877-lin.cambridge.arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210415143453.GB391924@e120877-lin.cambridge.arm.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thursday 15 Apr 2021 at 15:34:53 (+0100), Vincent Donnefort wrote: > On Thu, Apr 15, 2021 at 01:16:35PM +0000, Quentin Perret wrote: > > On Thursday 08 Apr 2021 at 18:10:29 (+0100), Vincent Donnefort wrote: > > > --- a/kernel/sched/cpufreq_schedutil.c > > > +++ b/kernel/sched/cpufreq_schedutil.c > > > @@ -10,6 +10,7 @@ > > > > > > #include "sched.h" > > > > > > +#include > > > #include > > > #include > > > > > > @@ -164,6 +165,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); > > > > I remember this was discussed when Douglas sent his patches some time > > ago, but I still find it sad we index the EM table here but still > > re-index the cpufreq frequency table later :/ > > > > Yes in your case this lookup is very inexpensive, but still. EAS relies > > on the EM's table matching cpufreq's accurately, so this second lookup > > still feels rather unnecessary ... > > To get only a single lookup, we would need to bring the inefficiency knowledge > directly to the cpufreq framework. But it has its own limitations: > > The cpufreq driver can have its own resolve_freq() callback, which means that > not all the drivers would benefit from that feature. > > The cpufreq_table can be ordered and accessed in several ways which brings > many combinations that would need to be supported, ending-up with something > much more intrusive. (We can though decide to limit the feature to the low to > high access that schedutil needs). > > As the EM needs schedutil to exist anyway, it seemed to be the right place for > this code. It allows any cpufreq driver to benefit from the feature, simplify a > potential extension for a usage by devfreq devices and as a bonus it speeds-up > energy computing, allowing a more complex Energy Model. I was thinking of something a bit simpler. cpufreq_driver_resolve_freq appears to be used only from schedutil (why is it even then?), so we could just pull it into cpufreq_schedutil.c and just plain skip the call to cpufreq_frequency_table_target if the target freq has been indexed in the EM table -- it should already be matching a real OPP. Thoughts? Quentin