Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3468909pxu; Tue, 15 Dec 2020 07:44:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJx2jibjRCuaCdU00VTv/EjLm3Ra080GzAF7hgKey8absl9IbCXVZOKldQwjLgQnS5zCd+AK X-Received: by 2002:a17:906:8292:: with SMTP id h18mr28072370ejx.481.1608047076331; Tue, 15 Dec 2020 07:44:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608047076; cv=none; d=google.com; s=arc-20160816; b=xVOhmToaUSIWO7fBKYJd4Xwpb/Y1x6fhNRqY64Q4oMde5lKFXwVfNiWiiRFUyXDPnX 4yeJhtyzU6wnv0wP/PUwMHRcxE19/HObKDGk9t7cctHZyznGpHQTHZ/y8FV09oGcBRK4 Vyot/ccbEand5Pod9zkdcCjfrpRGfJS5VAuwCrjyl+vf3+zyNH9YeJpTVRbbRAx978f3 G5pNQGWMmITXxDLn4vlTfjP+BEHLa8Fx2ThLV55swzNybl8/hA5l8AaN1fSu9mIssNUJ n3XLAr0fCC8eyFQqjmGZxrHVicXC7Xw3d+FM4sgufAPIYtbPU4AZJyFUYXwnPZYJ6/5+ vnHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version; bh=Hqd4yxV9bNWLklx7MUA8d0AV28BGHOGA0Jz2gfaRP9w=; b=pLhZFuMBx0PA6RtLEhaHr67XZOXFXqDIShQSon2qnE9UYMeROG20d+PNtphqYIBA9o T+2vFR7FuBtCKOhQ7u0KsJX8Kng9nyLC8QiEOrzL14No76cdwNFQcUqcRo6DeHYCVXqc ggpOPS7EBlw9fA5P5RcYXxDqYo0ikj2V3cu6YZAMfVhs/EWJ+ObUHMN9pQgNgSY+x6PP pf+py0mktdkQ8yL0J5w2+m+NAAE1oFqdrsXmvwmLxEDqNcPV3pMHuKzjcax2TC21EWVK dTWvpgpBzq18354f2gYBR4NIIN+jUilZPfPjiZ7CoR6yypLDx2qlKOhkJ1F/jsCq8Hzk rgKA== 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co17si1027098edb.518.2020.12.15.07.44.12; Tue, 15 Dec 2020 07:44:36 -0800 (PST) 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730020AbgLOPjJ (ORCPT + 99 others); Tue, 15 Dec 2020 10:39:09 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:46235 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729389AbgLOPjJ (ORCPT ); Tue, 15 Dec 2020 10:39:09 -0500 Received: by mail-ot1-f68.google.com with SMTP id w3so19724302otp.13; Tue, 15 Dec 2020 07:38:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Hqd4yxV9bNWLklx7MUA8d0AV28BGHOGA0Jz2gfaRP9w=; b=Kz87IhZRtdB6bEZn1ErC6/YpL9tjlawlyN2AJCEdXX0761WPD2divB0lrkdzmZBl03 ggoCWjWim1S8iazYEPeoCn7PN43vXjqHcuB44WH8bK7aGXvHmVF/Z4X5eiOQVwZCHBDM 3fEAOKFdcbPxVXmOFxjQtcE0mDh1OW0xzunU5nTFV6Mydms5Gv/S4hlZuZNxrfVs/AuD wI6WaNVePGfSeQmw8ItZcwqrAnKlcSffooSnO/Fg5oY/E6KH9WyXnh1zmJh+Eew+F2W8 X2gm7aj15oAfuARnC759T9Kh8FiN87svMCEQ7Obw36ykRAmnxCJe/288yK51aohZQT2Q AxRA== X-Gm-Message-State: AOAM533VHmZ7SrTDH47O/DRCqlMGOGiqxvdCiVrszxPmYoUyaN3oxa6m wQEyogbOpImIeIzIEdlbTr0DcaZT6I+22LaZsuQ= X-Received: by 2002:a9d:208a:: with SMTP id x10mr21697142ota.260.1608046708570; Tue, 15 Dec 2020 07:38:28 -0800 (PST) MIME-Version: 1.0 References: <20360841.iInq7taT2Z@kreacher> <146138074.tjdImvNTH2@kreacher> <20201208090207.sz4v43bwvm7yugrb@vireshk-i7> <20201215041636.yfgyswqjslg4hlff@vireshk-i7> In-Reply-To: <20201215041636.yfgyswqjslg4hlff@vireshk-i7> From: "Rafael J. Wysocki" Date: Tue, 15 Dec 2020 16:38:08 +0100 Message-ID: Subject: Re: [PATCH v1 3/4] cpufreq: Add special-purpose fast-switching callback for drivers To: Viresh Kumar Cc: "Rafael J. Wysocki" , Linux PM , LKML , Srinivas Pandruvada , Peter Zijlstra , Doug Smythies , Giovanni Gherdovich Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 15, 2020 at 5:17 AM Viresh Kumar wrote: > > On 08-12-20, 14:32, Viresh Kumar wrote: > > On 07-12-20, 17:35, Rafael J. Wysocki wrote: > > > From: Rafael J. Wysocki > > > > > > First off, some cpufreq drivers (eg. intel_pstate) can pass hints > > > beyond the current target frequency to the hardware and there are no > > > provisions for doing that in the cpufreq framework. In particular, > > > today the driver has to assume that it should not allow the frequency > > > to fall below the one requested by the governor (or the required > > > capacity may not be provided) which may not be the case and which may > > > lead to excessive energy usage in some scenarios. > > > > > > Second, the hints passed by these drivers to the hardware need not be > > > in terms of the frequency, so representing the utilization numbers > > > coming from the scheduler as frequency before passing them to those > > > drivers is not really useful. > > > > > > Address the two points above by adding a special-purpose replacement > > > for the ->fast_switch callback, called ->adjust_perf, allowing the > > > governor to pass abstract performance level (rather than frequency) > > > values for the minimum (required) and target (desired) performance > > > along with the CPU capacity to compare them to. > > > > > > Also update the schedutil governor to use the new callback instead > > > of ->fast_switch if present. > > > > > > Signed-off-by: Rafael J. Wysocki > > > --- > > > > > > Changes with respect to the RFC: > > > - Don't pass "busy" to ->adjust_perf(). > > > - Use a special 'update_util' hook for the ->adjust_perf() case in > > > schedutil (this still requires an additional branch because of the > > > shared common code between this case and the "frequency" one, but > > > IMV this version is cleaner nevertheless). > > > > > > --- > > > drivers/cpufreq/cpufreq.c | 40 ++++++++++++++++++++++++++++++++ > > > include/linux/cpufreq.h | 14 +++++++++++ > > > include/linux/sched/cpufreq.h | 5 ++++ > > > kernel/sched/cpufreq_schedutil.c | 48 +++++++++++++++++++++++++++++++-------- > > > 4 files changed, 98 insertions(+), 9 deletions(-) > > > > > > Index: linux-pm/include/linux/cpufreq.h > > > =================================================================== > > > --- linux-pm.orig/include/linux/cpufreq.h > > > +++ linux-pm/include/linux/cpufreq.h > > > @@ -320,6 +320,15 @@ struct cpufreq_driver { > > > unsigned int index); > > > unsigned int (*fast_switch)(struct cpufreq_policy *policy, > > > unsigned int target_freq); > > > + /* > > > + * ->fast_switch() replacement for drivers that use an internal > > > + * representation of performance levels and can pass hints other than > > > + * the target performance level to the hardware. > > > + */ > > > + void (*adjust_perf)(unsigned int cpu, > > > + unsigned long min_perf, > > > + unsigned long target_perf, > > > + unsigned long capacity); > > > > With this callback in place, do we still need to keep the other stuff we > > introduced recently, like CPUFREQ_NEED_UPDATE_LIMITS ? > > Ping Missed this one, sorry. We still need those things for the other governors.