From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C199DC47DA9 for ; Tue, 30 Jan 2024 00:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=GKUkZP0cTTXJELl2haP+nI9j1DkzEC3yAHVX3gECA58=; b=3Tvm0vI4P98yeY b83I85ZD56689a11MtYwouZnMgHEbgvzsczSai3+X3PWxB+SFMUkwvF4kzI57YHt7MoR8qxkVrvfF BjMqB6CjWQ06A7WLQmvQvMn6DaTbGY0x7z+d+P9i0z0aWHAMTWjuI8503pyjUk7LzCkSwGm7QfLKE B8sQMq5Ck8kDaJDNHG4ro/7b2PE8MsWwy4TBgP+iNF4GFVC+C+LsvWNM+7NEyYNKQA5PMw2lqFgnM EI179NJHrsCB+XsLz84J5ooyNL1hQL0z3Qt9MerqhfezXg55RmJ4+Sasoj8H/r72T1a3CpQfW3O95 5zdluA5pN6uCDepxIbbg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUbd6-0000000EepE-33Im; Tue, 30 Jan 2024 00:05:32 +0000 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUbd4-0000000EeoE-0H4c for linux-arm-kernel@lists.infradead.org; Tue, 30 Jan 2024 00:05:31 +0000 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-40eac352733so40940855e9.0 for ; Mon, 29 Jan 2024 16:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=layalina-io.20230601.gappssmtp.com; s=20230601; t=1706573126; x=1707177926; darn=lists.infradead.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=YxbSifhVqIOt2/m5QZSeFQNg25CWOD22Pv4LfmhthMA=; b=zXmBG9ImGY0m6Iie7vbRZshFm39gLVj0O3gKMEXdQpYoMyprkW38yB7ltUQdEcCMaA mgS5rh6RXLh6+Oq6STBoGncKQ6bESgkNvgwFbavFvh2QewVSApScK1oeZRu7HrA7DN2y MC18NI3y/y63xGtGDoirSdz08KSLpS4nrjLVIVx6oafYBXtif1/UsU0eOIcQCxUB3Hye wgIXO+9Zu1EIZ9R+hH1BGa4y/QxXdM+qjN56EygvncRM1zZS+3m+9UQjWFApGtNVtGJA cAOqzNWDBK71Vjy6lG+g1jR2bymE2rl/Y5CxL/5DjSPJQm93g3Ax5fTbmEXkXiREpU5o LI1Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706573126; x=1707177926; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YxbSifhVqIOt2/m5QZSeFQNg25CWOD22Pv4LfmhthMA=; b=KZsIe4tUa/b7/HSKa/xDHQyIt5JXvMLkfmu8uB33wTXN317ioMTt4SmEub7WaDD3nn hiBDb0BCxs3AuFnRF1agGrBIDNmvzn6N60xwuacvHXy2ncBC0Ft+fOtcvi/RLDZBGtUC MtJENH/jO4YwIe0r1v8o3m50k+Bd80B7cM45K8AVdd92/4JYazncc2kRYH5FSxPQtYbx PeiiK/2q1hqM9/864DNW2m9X0s3+fklXEui+04AGMNikuJyYzIhbn9RdAAB0KL4MrsIG SPItkOzTYRadj1vHeWG3Owo45UApj3yl+uin2bzALTbClFLDtfJq2mllKDtjbp92qg9e H9HA== X-Gm-Message-State: AOJu0YzDhnNw/K1niK8wxjWxDyWFWrIP91AZEXGJAdO/RaUHK+vmQVgH c2lbqvHZHSofJvhN0JpWimd+6NnWuBudL6KltkRsSCEbjPuVTMM51iuZKPLeEzM= X-Google-Smtp-Source: AGHT+IEcOm4ToE+OjMANypBdoNmKfiC7rumN1mFFCPVcffivoLtpNe7xAo25vCDii/5hc1czCprBwQ== X-Received: by 2002:a05:600c:4654:b0:40e:b29c:7103 with SMTP id n20-20020a05600c465400b0040eb29c7103mr5917032wmo.8.1706573126220; Mon, 29 Jan 2024 16:05:26 -0800 (PST) Received: from airbuntu ([213.122.231.14]) by smtp.gmail.com with ESMTPSA id n6-20020a05600c500600b0040e3488f16dsm11277752wmr.12.2024.01.29.16.05.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 16:05:25 -0800 (PST) Date: Tue, 30 Jan 2024 00:05:24 +0000 From: Qais Yousef 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 Subject: Re: [PATCH v4 1/5] cpufreq: Add a cpufreq pressure feedback for the scheduler Message-ID: <20240130000524.4dlivtwn427csjj5@airbuntu> References: <20240109164655.626085-1-vincent.guittot@linaro.org> <20240109164655.626085-2-vincent.guittot@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20240109164655.626085-2-vincent.guittot@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240129_160530_345283_002F32FF X-CRM114-Status: GOOD ( 22.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 01/09/24 17:46, 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 > --- > 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 *policy, 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 = cpumask_first(policy->related_cpus); > + max_freq = arch_scale_freq_ref(cpu); > + capped_freq = policy->max; > + > + /* > + * Handle properly the boost frequencies, which should simply clean > + * the cpufreq pressure value. > + */ > + if (max_freq <= capped_freq) { > + pressure = 0; > + } else { > + max_capacity = arch_scale_cpu_capacity(cpu); > + pressure = 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); Is this WRITE_ONCE() required? I don't see why. But assuming I missed something, better pair it with READ_ONCE() in cpufreq_get_pressure()? Beside that, LGTM Reviewed-by: Qais Yousef > +} > + > /** > * 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 = __resolve_freq(policy, policy->max, CPUFREQ_RELATION_H); > trace_cpu_frequency_limits(policy); > > + cpufreq_update_pressure(policy); > + > policy->cached_target_freq = 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 cpufreq_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 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel