Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp445939rdd; Tue, 9 Jan 2024 08:50:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQ6voeYsfcQyiLeDL2gLiNpeXxy8esmZC51RCSWugTj8Y0RK5QCAZurR1yX3KrTr2PRaIs X-Received: by 2002:a50:cc88:0:b0:553:6c79:ac7 with SMTP id q8-20020a50cc88000000b005536c790ac7mr3263556edi.9.1704819007053; Tue, 09 Jan 2024 08:50:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704819007; cv=none; d=google.com; s=arc-20160816; b=tvFs2SEmV3kC5/sKN6EHnkk9kNbyZa07tp6C1HogOqUGhQQ9bfA+G2tNstOJC+flSh A0VlmNb0BeFZUOgGfGYdvAguoqsbhbaZwjYtw7ZyCRB/sl5r1XTb8GPusm1eaW1t7YiH GhKBwBeBd2AnZin49L5ZD12fGdpwvwMS5zJisEJZ9MoQll3cQBJWkigkSkp3t425TseR 5cq4sF+zcc/rd7saWq/Zmm8TvKt2JhJIjUrwoNTb1/EMi7003EDjbZTGzjwQF5uOiSyN lnpcN+EJMV3r2NjM33eF8V5BkvS+X1fIg62wefl9IhXCt4uizz2uqWQXzhCMircHNYaG Wf2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=No8KMU8qZ/MBPmmYQ2D3vNYLw4T9zvu4iu2lUnnwn8g=; fh=3DRmZD8DSzgYgzgBG51Lvj0MeXH7f5qrsrWQQJ+r8K0=; b=TTwDjB4BW5TCaqrhuNY/pq18tVk7RY39JOG4f8l0HunqpTrVoAYbgEcyUk/v2n0KyE 4ieuA1du94ZPuPUvseFR2vPPR/eDhKzNSM61dde3QJCp+c9OVCIGLrO8Zf6u6hq8PpQm r4TR1lmGd5FhB9MOP+sE0GXVnfl+DuLLlvUN0kJCJAsqvpDjyMTx09lX+iEPkhORXF5I HRyBqm9P8MrdEglkewuy4q8ngmChlwrC/YaquZJY+zDgVILa4WjtHzddjzdkH/2MKzd4 uu3T7gC305R32WSZV3EPrM4pq68ExBufGzxXD4BK4eEf0YnhS2kxFrFQoy7S/Qypl3YX a9yg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-21132-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21132-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id s26-20020a50ab1a000000b005573c02f5eesi929035edc.472.2024.01.09.08.50.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Jan 2024 08:50:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-21132-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-21132-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-21132-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id C8ACD1F265EE for ; Tue, 9 Jan 2024 16:50:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88AE63A8F1; Tue, 9 Jan 2024 16:49:56 +0000 (UTC) Received: from mail-oo1-f53.google.com (mail-oo1-f53.google.com [209.85.161.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B4CBF38DFE; Tue, 9 Jan 2024 16:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-oo1-f53.google.com with SMTP id 006d021491bc7-5958b9cda7aso104906eaf.0; Tue, 09 Jan 2024 08:49:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704818993; x=1705423793; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=No8KMU8qZ/MBPmmYQ2D3vNYLw4T9zvu4iu2lUnnwn8g=; b=B04inhgZA6LJiRY9ci3vYBs7VaBMmrXH8K3nEX7hbYQEOT2BIgbqNsiQceEeLj+IeG 7Vo+4HSQQaQHlZy0CRcsFEK0h8Z2QM6oXGcZkOCyY5HRBBnLxxLAsesdwYysmxZrs+YT qWd06F4XHQLRHLNVSzFaaFJ6UgwOKqBsV9mFp7U1HNGiVG8pNxY3fFsXDU3EqU2iqJAb m6+3NbEiPFwOMy2n8uFNZpiLYmcEjx3uoCrbyG4Bp/8ShSq7iWU3/FVlCsMvVD+KXl6c gMMspuk9TyjbQgmPjAW5FGr/65DBRI3/GEOzUY4stZloOatldxL4YHY6SGl4EUWYfgfV Xhpg== X-Gm-Message-State: AOJu0Yz6YhBFySeLAn10QHTjv9c1SlGILJuKMGuh/wkYg4P0k2eBkH8N 3h5OcABRITMyxYJGpfkhxCs7rT2ieiTBxEbh7Qw= X-Received: by 2002:a05:6820:d0a:b0:598:8d98:286d with SMTP id ej10-20020a0568200d0a00b005988d98286dmr818427oob.0.1704818993639; Tue, 09 Jan 2024 08:49:53 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240109164655.626085-1-vincent.guittot@linaro.org> <20240109164655.626085-2-vincent.guittot@linaro.org> In-Reply-To: <20240109164655.626085-2-vincent.guittot@linaro.org> From: "Rafael J. Wysocki" Date: Tue, 9 Jan 2024 17:49:42 +0100 Message-ID: Subject: Re: [PATCH v4 1/5] cpufreq: Add a cpufreq pressure feedback for the scheduler To: Vincent Guittot Cc: linux@armlinux.org.uk, catalin.marinas@arm.com, will@kernel.org, sudeep.holla@arm.com, rafael@kernel.org, viresh.kumar@linaro.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, mingo@redhat.com, peterz@infradead.org, juri.lelli@redhat.com, dietmar.eggemann@arm.com, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, vschneid@redhat.com, lukasz.luba@arm.com, rui.zhang@intel.com, mhiramat@kernel.org, daniel.lezcano@linaro.org, amit.kachhap@gmail.com, corbet@lwn.net, gregkh@linuxfoundation.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-doc@vger.kernel.org, qyousef@layalina.io Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Tue, Jan 9, 2024 at 5:47=E2=80=AFPM Vincent Guittot wrote: > > Provide to the scheduler a feedback about the temporary max available > capacity. Unlike arch_update_thermal_pressure, this doesn't need to be > filtered as the pressure will happen for dozens ms or more. > > Signed-off-by: Vincent Guittot Acked-by: Rafael J. Wysocki and I think I've given the tag on this patch already. > --- > drivers/cpufreq/cpufreq.c | 36 ++++++++++++++++++++++++++++++++++++ > include/linux/cpufreq.h | 10 ++++++++++ > 2 files changed, 46 insertions(+) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 44db4f59c4cc..f4eee3d107f1 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -2563,6 +2563,40 @@ int cpufreq_get_policy(struct cpufreq_policy *poli= cy, unsigned int cpu) > } > EXPORT_SYMBOL(cpufreq_get_policy); > > +DEFINE_PER_CPU(unsigned long, cpufreq_pressure); > + > +/** > + * cpufreq_update_pressure() - Update cpufreq pressure for CPUs > + * @policy: cpufreq policy of the CPUs. > + * > + * Update the value of cpufreq pressure for all @cpus in the policy. > + */ > +static void cpufreq_update_pressure(struct cpufreq_policy *policy) > +{ > + unsigned long max_capacity, capped_freq, pressure; > + u32 max_freq; > + int cpu; > + > + cpu =3D cpumask_first(policy->related_cpus); > + max_freq =3D arch_scale_freq_ref(cpu); > + capped_freq =3D policy->max; > + > + /* > + * Handle properly the boost frequencies, which should simply cle= an > + * the cpufreq pressure value. > + */ > + if (max_freq <=3D capped_freq) { > + pressure =3D 0; > + } else { > + max_capacity =3D arch_scale_cpu_capacity(cpu); > + pressure =3D max_capacity - > + mult_frac(max_capacity, capped_freq, max_freq)= ; > + } > + > + for_each_cpu(cpu, policy->related_cpus) > + WRITE_ONCE(per_cpu(cpufreq_pressure, cpu), pressure); > +} > + > /** > * cpufreq_set_policy - Modify cpufreq policy parameters. > * @policy: Policy object to modify. > @@ -2618,6 +2652,8 @@ static int cpufreq_set_policy(struct cpufreq_policy= *policy, > policy->max =3D __resolve_freq(policy, policy->max, CPUFREQ_RELAT= ION_H); > trace_cpu_frequency_limits(policy); > > + cpufreq_update_pressure(policy); > + > policy->cached_target_freq =3D UINT_MAX; > > pr_debug("new min and max freqs are %u - %u kHz\n", > diff --git a/include/linux/cpufreq.h b/include/linux/cpufreq.h > index afda5f24d3dd..b1d97edd3253 100644 > --- a/include/linux/cpufreq.h > +++ b/include/linux/cpufreq.h > @@ -241,6 +241,12 @@ struct kobject *get_governor_parent_kobj(struct cpuf= req_policy *policy); > void cpufreq_enable_fast_switch(struct cpufreq_policy *policy); > void cpufreq_disable_fast_switch(struct cpufreq_policy *policy); > bool has_target_index(void); > + > +DECLARE_PER_CPU(unsigned long, cpufreq_pressure); > +static inline unsigned long cpufreq_get_pressure(int cpu) > +{ > + return per_cpu(cpufreq_pressure, cpu); > +} > #else > static inline unsigned int cpufreq_get(unsigned int cpu) > { > @@ -263,6 +269,10 @@ static inline bool cpufreq_supports_freq_invariance(= void) > return false; > } > static inline void disable_cpufreq(void) { } > +static inline unsigned long cpufreq_get_pressure(int cpu) > +{ > + return 0; > +} > #endif > > #ifdef CONFIG_CPU_FREQ_STAT > -- > 2.34.1 >