linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Lukasz Luba <lukasz.luba@arm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Vincent Guittot <vincent.guittot@linaro.org>,
	Dietmar Eggemann <dietmar.eggemann@arm.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH AUTOSEL 5.13 65/85] sched/fair: Take thermal pressure into account while estimating energy
Date: Sun,  4 Jul 2021 19:04:00 -0400	[thread overview]
Message-ID: <20210704230420.1488358-65-sashal@kernel.org> (raw)
In-Reply-To: <20210704230420.1488358-1-sashal@kernel.org>

From: Lukasz Luba <lukasz.luba@arm.com>

[ Upstream commit 489f16459e0008c7a5c4c5af34bd80898aa82c2d ]

Energy Aware Scheduling (EAS) needs to be able to predict the frequency
requests made by the SchedUtil governor to properly estimate energy used
in the future. It has to take into account CPUs utilization and forecast
Performance Domain (PD) frequency. There is a corner case when the max
allowed frequency might be reduced due to thermal. SchedUtil is aware of
that reduced frequency, so it should be taken into account also in EAS
estimations.

SchedUtil, as a CPUFreq governor, knows the maximum allowed frequency of
a CPU, thanks to cpufreq_driver_resolve_freq() and internal clamping
to 'policy::max'. SchedUtil is responsible to respect that upper limit
while setting the frequency through CPUFreq drivers. This effective
frequency is stored internally in 'sugov_policy::next_freq' and EAS has
to predict that value.

In the existing code the raw value of arch_scale_cpu_capacity() is used
for clamping the returned CPU utilization from effective_cpu_util().
This patch fixes issue with too big single CPU utilization, by introducing
clamping to the allowed CPU capacity. The allowed CPU capacity is a CPU
capacity reduced by thermal pressure raw value.

Thanks to knowledge about allowed CPU capacity, we don't get too big value
for a single CPU utilization, which is then added to the util sum. The
util sum is used as a source of information for estimating whole PD energy.
To avoid wrong energy estimation in EAS (due to capped frequency), make
sure that the calculation of util sum is aware of allowed CPU capacity.

This thermal pressure might be visible in scenarios where the CPUs are not
heavily loaded, but some other component (like GPU) drastically reduced
available power budget and increased the SoC temperature. Thus, we still
use EAS for task placement and CPUs are not over-utilized.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reviewed-by: Vincent Guittot <vincent.guittot@linaro.org>
Reviewed-by: Dietmar Eggemann <dietmar.eggemann@arm.com>
Link: https://lore.kernel.org/r/20210614191128.22735-1-lukasz.luba@arm.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 kernel/sched/fair.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 190ae8004a22..e807b743353d 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -6620,8 +6620,11 @@ compute_energy(struct task_struct *p, int dst_cpu, struct perf_domain *pd)
 	struct cpumask *pd_mask = perf_domain_span(pd);
 	unsigned long cpu_cap = arch_scale_cpu_capacity(cpumask_first(pd_mask));
 	unsigned long max_util = 0, sum_util = 0;
+	unsigned long _cpu_cap = cpu_cap;
 	int cpu;
 
+	_cpu_cap -= arch_scale_thermal_pressure(cpumask_first(pd_mask));
+
 	/*
 	 * The capacity state of CPUs of the current rd can be driven by CPUs
 	 * of another rd if they belong to the same pd. So, account for the
@@ -6657,8 +6660,10 @@ compute_energy(struct task_struct *p, int dst_cpu, struct perf_domain *pd)
 		 * is already enough to scale the EM reported power
 		 * consumption at the (eventually clamped) cpu_capacity.
 		 */
-		sum_util += effective_cpu_util(cpu, util_running, cpu_cap,
-					       ENERGY_UTIL, NULL);
+		cpu_util = effective_cpu_util(cpu, util_running, cpu_cap,
+					      ENERGY_UTIL, NULL);
+
+		sum_util += min(cpu_util, _cpu_cap);
 
 		/*
 		 * Performance domain frequency: utilization clamping
@@ -6669,7 +6674,7 @@ compute_energy(struct task_struct *p, int dst_cpu, struct perf_domain *pd)
 		 */
 		cpu_util = effective_cpu_util(cpu, util_freq, cpu_cap,
 					      FREQUENCY_UTIL, tsk);
-		max_util = max(max_util, cpu_util);
+		max_util = max(max_util, min(cpu_util, _cpu_cap));
 	}
 
 	return em_cpu_energy(pd->em_pd, max_util, sum_util);
-- 
2.30.2


  parent reply	other threads:[~2021-07-04 23:06 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-04 23:02 [PATCH AUTOSEL 5.13 01/85] spi: Make of_register_spi_device also set the fwnode Sasha Levin
2021-07-04 23:02 ` [PATCH AUTOSEL 5.13 02/85] Add a reference to ucounts for each cred Sasha Levin
2021-07-04 23:02 ` [PATCH AUTOSEL 5.13 03/85] staging: media: rkvdec: fix pm_runtime_get_sync() usage count Sasha Levin
2021-07-04 23:02 ` [PATCH AUTOSEL 5.13 04/85] media: i2c: imx334: fix the pm runtime get logic Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 05/85] media: marvel-ccic: fix some issues when getting pm_runtime Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 06/85] media: mdk-mdp: fix pm_runtime_get_sync() usage count Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 07/85] media: s5p: " Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 08/85] media: am437x: " Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 09/85] media: sh_vou: " Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 10/85] media: mtk-vcodec: fix PM runtime get logic Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 11/85] media: s5p-jpeg: fix pm_runtime_get_sync() usage count Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 12/85] media: sunxi: " Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 13/85] media: sti/bdisp: " Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 14/85] media: exynos4-is: " Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 15/85] media: exynos-gsc: " Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 16/85] spi: spi-loopback-test: Fix 'tx_buf' might be 'rx_buf' Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 17/85] spi: spi-topcliff-pch: Fix potential double free in pch_spi_process_messages() Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 18/85] spi: omap-100k: Fix the length judgment problem Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 19/85] regulator: uniphier: Add missing MODULE_DEVICE_TABLE Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 20/85] sched/core: Initialize the idle task with preemption disabled Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 21/85] hwrng: exynos - Fix runtime PM imbalance on error Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 22/85] crypto: nx - add missing MODULE_DEVICE_TABLE Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 23/85] regmap-i2c: Set regmap max raw r/w from quirks Sasha Levin
2021-07-05 12:09   ` Mark Brown
2021-07-09 14:02     ` Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 24/85] media: sti: fix obj-$(config) targets Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 25/85] sched: Make the idle task quack like a per-CPU kthread Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 26/85] media: cpia2: fix memory leak in cpia2_usb_probe Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 27/85] media: cobalt: fix race condition in setting HPD Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 28/85] media: hevc: Fix dependent slice segment flags Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 29/85] media: pvrusb2: fix warning in pvr2_i2c_core_done Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 30/85] media: imx: imx7_mipi_csis: Fix logging of only error event counters Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 31/85] crypto: qat - check return code of qat_hal_rd_rel_reg() Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 32/85] crypto: qat - remove unused macro in FW loader Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 33/85] crypto: qce: skcipher: Fix incorrect sg count for dma transfers Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 34/85] crypto: ecdh - fix ecdh-nist-p192's entry in testmgr Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 35/85] crypto: ecdh - fix 'ecdh_init' Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 36/85] arm64: perf: Convert snprintf to sysfs_emit Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 37/85] sched/fair: Fix ascii art by relpacing tabs Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 38/85] ima: Don't remove security.ima if file must not be appraised Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 39/85] media: i2c: ov2659: Use clk_{prepare_enable,disable_unprepare}() to set xvclk on/off Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 40/85] media: bt878: do not schedule tasklet when it is not setup Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 41/85] media: em28xx: Fix possible memory leak of em28xx struct Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 42/85] media: hantro: Fix .buf_prepare Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 43/85] media: cedrus: " Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 44/85] media: v4l2-core: Avoid the dangling pointer in v4l2_fh_release Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 45/85] media: bt8xx: Fix a missing check bug in bt878_probe Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 46/85] media: st-hva: Fix potential NULL pointer dereferences Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 47/85] crypto: hisilicon/sec - fixup 3des minimum key size declaration Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 48/85] arm64: entry: don't instrument entry code with KCOV Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 49/85] Makefile: fix GDB warning with CONFIG_RELR Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 50/85] media: dvd_usb: memory leak in cinergyt2_fe_attach Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 51/85] memstick: rtsx_usb_ms: fix UAF Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 52/85] mmc: sdhci-sprd: use sdhci_sprd_writew Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 53/85] mmc: via-sdmmc: add a check against NULL pointer dereference Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 54/85] mmc: sdhci-of-aspeed: Turn down a phase correction warning Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 55/85] spi: meson-spicc: fix a wrong goto jump for avoiding memory leak Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 56/85] spi: meson-spicc: fix memory leak in meson_spicc_probe Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 57/85] regulator: mt6315: Fix checking return value of devm_regmap_init_spmi_ext Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 58/85] crypto: shash - avoid comparing pointers to exported functions under CFI Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 59/85] media: dvb_net: avoid speculation from net slot Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 60/85] media: dvbdev: fix error logic at dvb_register_device() Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 61/85] media: siano: fix device register error path Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 62/85] media: imx-csi: Skip first few frames from a BT.656 source Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 63/85] hwmon: (max31790) Report correct current pwm duty cycles Sasha Levin
2021-07-04 23:03 ` [PATCH AUTOSEL 5.13 64/85] hwmon: (max31790) Fix pwmX_enable attributes Sasha Levin
2021-07-04 23:04 ` Sasha Levin [this message]
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 66/85] perf/x86: Reset the dirty counter to prevent the leak for an RDPMC task Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 67/85] drivers/perf: fix the missed ida_simple_remove() in ddr_perf_probe() Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 68/85] KVM: arm64: Restore PMU configuration on first run Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 69/85] KVM: PPC: Book3S HV: Fix TLB management on SMT8 POWER9 and POWER10 processors Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 70/85] btrfs: fix error handling in __btrfs_update_delayed_inode Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 71/85] btrfs: abort transaction if we fail to update the delayed inode Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 72/85] btrfs: always abort the transaction if we abort a trans handle Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 73/85] btrfs: sysfs: fix format string for some discard stats Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 74/85] btrfs: scrub: fix subpage repair error caused by hard coded PAGE_SIZE Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 75/85] btrfs: make Private2 lifespan more consistent Sasha Levin
2021-07-07 11:10   ` David Sterba
2021-07-08 11:09     ` Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 76/85] btrfs: fix the filemap_range_has_page() call in btrfs_punch_hole_lock_range() Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 77/85] btrfs: don't clear page extent mapped if we're not invalidating the full page Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 78/85] btrfs: disable build on platforms having page size 256K Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 79/85] locking/lockdep: Fix the dep path printing for backwards BFS Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 80/85] lockding/lockdep: Avoid to find wrong lock dep path in check_irq_usage() Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 81/85] KVM: s390: get rid of register asm usage Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 82/85] regulator: mt6358: Fix vdram2 .vsel_mask Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 83/85] regulator: da9052: Ensure enough delay time for .set_voltage_time_sel Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 84/85] media: Fix Media Controller API config checks Sasha Levin
2021-07-04 23:04 ` [PATCH AUTOSEL 5.13 85/85] seccomp: Support atomic "addfd + send reply" Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210704230420.1488358-65-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=dietmar.eggemann@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=peterz@infradead.org \
    --cc=stable@vger.kernel.org \
    --cc=vincent.guittot@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).