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 0618CC4332F for ; Thu, 14 Dec 2023 00:41:38 +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:MIME-Version:References:In-Reply-To: Date:To:From:Subject:Message-ID:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=s89Gjnfkl5w9vdlh9SBDQb1YmEiCmg6wujAiGxEBLR8=; b=C5wu6/sc8hqNuk ofgb8C16hTrV1Jokhfi7q+HFHToG2J8XkQ5hMj5KcpXwcdkGaKCvpEe84U9LxHvB4Q3XXXSpm8/jP tioaFfdvSXDPOS0OWfqt+/52bDDixevceMh1xN+N+WMvbDb7NGWCxG9bsVTpvJrnP4qiOuK6YB+P7 g5bwnBtHyC3BX5ciOKlAYP+OmHuNLX3IKpyklrfHwROdccK7tYqymNaN8Sl05Kpb8gpy5pZFunYDw IVK+BMOXqa4O8ZWxRzdeAhWAV6iq7gXswOOfHwSSUgnsdmZtxJnOxQT+GK9bMPkv6S64btMHFFmw7 VbXhWFKGpDuQFQ0jk9GA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rDZmp-00GM8w-2n; Thu, 14 Dec 2023 00:41:11 +0000 Received: from mgamail.intel.com ([192.55.52.88]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rDZmn-00GM83-1n for linux-arm-kernel@lists.infradead.org; Thu, 14 Dec 2023 00:41:10 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702514469; x=1734050469; h=message-id:subject:from:to:date:in-reply-to:references: content-transfer-encoding:mime-version; bh=k1qSf+lV25zr0Dwp3/EooJ11sf1fNhwipYU+ucC77pE=; b=KqlmoFjB6CILmptBNGGUWoS+Q3CCZCh5WvdPMo+dImMoL3X+NPVauwfR 92aCkFhXUssvx9dRWOl/9Q+1TEvFnkg/6UQNMtdYSKQD7EeDJENSn+5sA cemDB89KixyHlja5UYC24autWZukr5rmngKanIoRpzNfRDP68KPiBkQSX QzSpJtC0Qh9iB7J9xVrPJBvz3nDMOj7EWe7s1dOHWM4z7x+yt/5gNCFPj IDwIiwNChVKPOW9hW4m4KQ4Gxrxiqbz1Cc2eZq/fWlxnl25QLw6+gQDeI MVd2pN8zPg0nCgCn8CZWncgtH+iHBHjeU1uSSS4Zaa/hPcQ/uJ5yaA03e A==; X-IronPort-AV: E=McAfee;i="6600,9927,10923"; a="426180850" X-IronPort-AV: E=Sophos;i="6.04,274,1695711600"; d="scan'208";a="426180850" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2023 16:41:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10923"; a="947367819" X-IronPort-AV: E=Sophos;i="6.04,274,1695711600"; d="scan'208";a="947367819" Received: from wanghuan-mobl1.amr.corp.intel.com (HELO [10.212.178.119]) ([10.212.178.119]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Dec 2023 16:41:04 -0800 Message-ID: <2e8807b68133f4b3a72227122a9d9a05f3fbf9d8.camel@linux.intel.com> Subject: Re: [PATCH 1/4] cpufreq: Add a cpufreq pressure feedback for the scheduler From: Tim Chen To: Vincent Guittot , 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, 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 Date: Wed, 13 Dec 2023 16:41:04 -0800 In-Reply-To: <20231212142730.998913-2-vincent.guittot@linaro.org> References: <20231212142730.998913-1-vincent.guittot@linaro.org> <20231212142730.998913-2-vincent.guittot@linaro.org> User-Agent: Evolution 3.44.4 (3.44.4-2.fc36) MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231213_164109_642585_CA41F7D3 X-CRM114-Status: GOOD ( 20.64 ) 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 Tue, 2023-12-12 at 15:27 +0100, 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 | 48 +++++++++++++++++++++++++++++++++++++++ > include/linux/cpufreq.h | 10 ++++++++ > 2 files changed, 58 insertions(+) > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > index 44db4f59c4cc..7d5f71be8d29 100644 > --- a/drivers/cpufreq/cpufreq.c > +++ b/drivers/cpufreq/cpufreq.c > @@ -2563,6 +2563,50 @@ int cpufreq_get_policy(struct cpufreq_policy *policy, unsigned int cpu) > } > EXPORT_SYMBOL(cpufreq_get_policy); > > +DEFINE_PER_CPU(unsigned long, cpufreq_pressure); > +EXPORT_PER_CPU_SYMBOL_GPL(cpufreq_pressure); > + > +/** > + * cpufreq_update_pressure() - Update cpufreq pressure for CPUs > + * @cpus : The related CPUs for which max capacity has been reduced > + * @capped_freq : The maximum allowed frequency that CPUs can run at > + * > + * Update the value of cpufreq pressure for all @cpus in the mask. The > + * cpumask should include all (online+offline) affected CPUs, to avoid > + * operating on stale data when hot-plug is used for some CPUs. The > + * @capped_freq reflects the currently allowed max CPUs frequency due to > + * freq_qos capping. It might be also a boost frequency value, which is bigger > + * than the internal 'capacity_freq_ref' max frequency. In such case the > + * pressure value should simply be removed, since this is an indication that > + * there is no capping. The @capped_freq must be provided in kHz. > + */ > +static void cpufreq_update_pressure(const struct cpumask *cpus, > + unsigned long capped_freq) > +{ > + unsigned long max_capacity, capacity, pressure; > + u32 max_freq; > + int cpu; > + > + cpu = cpumask_first(cpus); > + max_capacity = arch_scale_cpu_capacity(cpu); > + max_freq = arch_scale_freq_ref(cpu); > + > + /* > + * Handle properly the boost frequencies, which should simply clean > + * the thermal pressure value. > + */ > + if (max_freq <= capped_freq) > + capacity = max_capacity; > + else > + capacity = mult_frac(max_capacity, capped_freq, max_freq); > + > + pressure = max_capacity - capacity; > + > + > + for_each_cpu(cpu, cpus) > + WRITE_ONCE(per_cpu(cpufreq_pressure, cpu), pressure); Seems like the pressure value computed from the first CPU applies to all CPU. Will this be valid for non-homogeneous CPUs that could have different max_freq and max_capacity? Tim _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel