Received: by 2002:aa6:c429:0:b029:98:93ff:f56f with SMTP id g9csp392324lkq; Thu, 3 Dec 2020 06:47:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJyATl7D8IJg+tqQH5zkm/z56YA9odD3dMlCoCjCYHjYiAiCcNj8l3CiE2lYN0GLHgajqAad X-Received: by 2002:a17:906:f87:: with SMTP id q7mr2912789ejj.530.1607006825635; Thu, 03 Dec 2020 06:47:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607006825; cv=none; d=google.com; s=arc-20160816; b=RJgeX4F2hcc288p8ikSKBtigCd2ed02iURIL70MBwrcC6kG1HcazPH4bpNZshcn/x1 mPLJDFwcp++TfSp1+re15cSAYrXVj/hvTR8Xt7/xfcf0FxYmy8NOkhaqDm6V2C60vt2L szD2Eosvra1LVZurnqOQuRNIIuFQHyfpRBSYXhM5MYDQ4+quUDc81/TxHCp3LF17IDMp y8c0lihO82SY0P0IG/Z6HE2y13Zn46U0W70ukKGF8o9hlDkvEAf4qStUxjtu2hZbfXLh Y21j8ruHeb27K2XTRYSGdvD4p1TEwggxlx1CevjMx1w7K5yEbTBHeIIFFTNaiNM9bW8S ydtg== 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=UbGjEkaZE0D9a7AyFWG5aWHAuEZDZ69DNAnE5cwlxJ4=; b=vBnobw0NgCRw0Lu4MdgVLanx2gW2ydzTghsPMR6s6tddfDcHk0f4/9JCfhrrdn2Q0X 6cfJqa2k89cryt1XPULWGUupQO3DWgoggHv/gw/mUSUJDQ0cZMHa9DZA9KrqWOiXG8ZO CN6IEtaD4x2yYMCOxT+WHncK3h2G0pwJ1gj+867xB2IndE5aRX6r27rNq7UkGHw5AhBn 2hX2Yc3vgjXAW2P/SakMahNrIqI0QMwtu42Fq8ULQyugQHMViD7rwxiyg7nc8kYZ2EnP a9UnHIEkiPrxdLtyQe2JztkyuYtKjPgi3Mii58hcKHQYohr1uOy05nKIzSv4gUpEHgbu cwkA== 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 f7si1222476ejx.294.2020.12.03.06.46.42; Thu, 03 Dec 2020 06:47:05 -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 S2436457AbgLCOo7 (ORCPT + 99 others); Thu, 3 Dec 2020 09:44:59 -0500 Received: from mail-oi1-f196.google.com ([209.85.167.196]:34797 "EHLO mail-oi1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389190AbgLCOo6 (ORCPT ); Thu, 3 Dec 2020 09:44:58 -0500 Received: by mail-oi1-f196.google.com with SMTP id s18so2408764oih.1; Thu, 03 Dec 2020 06:44:42 -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=UbGjEkaZE0D9a7AyFWG5aWHAuEZDZ69DNAnE5cwlxJ4=; b=MMm9XfqVXbQOewTedN9LEuYBBbfmB6pdZ6nl21i6o+b4g4erQFbr2WpuAGWOnQ+NYH ijL+JlWMEfxPRTx3ceBhcJsGEQg24N+zd2wiGf27qURagM+v6dmt7r6KY04BE+tMAHcU 0Pe8U+vjNEa51Oq0JKM8iFHUvIUA7IsJJU99dQebylteiizvCHob1QGRvP5iwPeUfXw5 RpKfc/A3tsfMWdcGXx9VDB/0CFdQGF7fD011W0ES2yrc483zD/uiu8epZx0yiFpgWEM6 NJHC5c52UWnHb2KI/HXsKGDS3wJwQilrMOLfm3TBormjBz7FANChJqJo+VcQrEZ7S+1k VTfg== X-Gm-Message-State: AOAM530u1dLZ6WKIiozKgWXXbUGBZCCDsJi+S8qSKV7Lg0ECNzk34pA8 rmP4fK6QIyew4OA1F7vrumgL7ysg8KpP0z4c5GA= X-Received: by 2002:aca:cf4a:: with SMTP id f71mr2085846oig.157.1607006657415; Thu, 03 Dec 2020 06:44:17 -0800 (PST) MIME-Version: 1.0 References: <1817571.2o5Kk4Ohv2@kreacher> <2174134.tL5yAn4CWt@kreacher> <20201203124141.GP3021@hirez.programming.kicks-ass.net> In-Reply-To: <20201203124141.GP3021@hirez.programming.kicks-ass.net> From: "Rafael J. Wysocki" Date: Thu, 3 Dec 2020 15:44:04 +0100 Message-ID: Subject: Re: [RFC][PATCH 1/2] cpufreq: Add special-purpose fast-switching callback for drivers To: Peter Zijlstra Cc: "Rafael J. Wysocki" , Linux PM , LKML , Viresh Kumar , Srinivas Pandruvada , Doug Smythies , Giovanni Gherdovich Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 3, 2020 at 1:42 PM Peter Zijlstra wrote: > > On Mon, Nov 30, 2020 at 07:37:01PM +0100, 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 > > Everything CPPC, which is quite a bit these days. Right, but that is still "some". :-) I can add it to the list of examples, though. > > + /* > > + * ->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, bool busy, > > + unsigned long min_perf, > > + unsigned long target_perf, > > + unsigned long capacity); > > > > I'm not sure @busy makes sense, that's more a hack because @util had a > dip and should remain inside schedutil. So I did it this way, because schedutil would need to store the old value of target_perf for this and intel_pstate already does that. But if a new util_hook is used in this case, the existing space in sg_policy may be used for that. > > @@ -454,6 +455,25 @@ static void sugov_update_single(struct u > > util = sugov_get_util(sg_cpu); > > max = sg_cpu->max; > > util = sugov_iowait_apply(sg_cpu, time, util, max); > > + > > + /* > > + * This code runs under rq->lock for the target CPU, so it won't run > > + * concurrently on two different CPUs for the same target and it is not > > + * necessary to acquire the lock in the fast switch case. > > + */ > > + if (sg_policy->direct_fast_switch) { > > + /* > > + * In this case, any optimizations that can be done are up to > > + * the driver. > > + */ > > + cpufreq_driver_adjust_perf(sg_cpu->cpu, > > + sugov_cpu_is_busy(sg_cpu), > > + map_util_perf(sg_cpu->bw_dl), > > + map_util_perf(util), max); > > + sg_policy->last_freq_update_time = time; > > + return; > > + } > > Instead of adding more branches, would it makes sense to simply set a > whole different util_hook in this case? Looks doable without too much code duplication. Lemme try.