Received: by 2002:ab2:69cc:0:b0:1fd:c486:4f03 with SMTP id n12csp359595lqp; Tue, 11 Jun 2024 06:49:29 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWQckBi6YBLwkwm7GgtRTrZbGtkAGrp8YwiA5KRCQyk5rdX3MvCom0txLp85BMnqggyiCm5+6+QyNK1qsipMNTVtXiSRaauflapKS9qLg== X-Google-Smtp-Source: AGHT+IFdavgTfm4JyYNDllqcf0AfyReO8w7vYS0MKD6NuRFXc9+Z3kOBQBh03hUNBy2vQFMcbo7W X-Received: by 2002:a17:902:c112:b0:1f7:1b52:f916 with SMTP id d9443c01a7336-1f71b52f9f8mr40164815ad.23.1718113769135; Tue, 11 Jun 2024 06:49:29 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718113769; cv=pass; d=google.com; s=arc-20160816; b=L7P1PLn1TLcULGrfywgL5ZXLTHd10Pf4gJB9khfFWUvxaNmqvcjuglLmcAp916H1x+ lQOqQHiVbV3sCHibCRiGjER5R9LAXzKQ8ZPUKuiT0cbNswTYtATCbWZ/FtG3SI3AZDvs AtmkNevG13jirHDA06mxaLEPHVEzzV4SxGNLEDboqX6l0alelEsxYIKQqjxpmwDpSTjh ntLbGlcylV5XK7guzjTwPgaTzRN39tJ7HOmGl7RJW9iPfGQ2fY0Sqwo2Hjl1qUvRdRbV 37TaGgDUUcoO60n1t9f2IircrQWTypcMAzb8BFdYrRAgbInxtwhN9FJv/Fr1Reak5YaP rLQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :dkim-signature; bh=MAcDNalbfcX/SooAz1XjppInJxW8mD6aEySBf2LPSno=; fh=OulAyRcWbChX/D1MOIpXxs9EMpmta3/SAvc0feTE2vI=; b=MMAW+wZRibq2v1aj0MwzEC3/+3/f+WN+yrZiB0cFRFGUki8MKrAkT1FNv4XjfkIizD /rRfKgLeIQBAOEPG2BVESJAmAM2ia360E4vUUEQ+qCSmP7frEjLVWEus9+UxkPmsGcVN MlDQGIZk8DDcbc49UAz+vVNXXKRPgvvfOuoY+X2aSp3I+rqPF7E59HxKKDyOICmUpGQq nYGrE2ttQL9pUGq/UG1pFLlVY+TqHKBRVKkIUL9GrGQC+fqE2HTABsRkEP2S9saiuiDP 9zmp4Ws613/+aieEKzHs1l384hpwCjJEODrG6oLImJG33Gf2ROM8gkCMLHbezBcjmjuK cbjw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hdMk31pY; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-209975-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209975-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1f70926fc98si42758795ad.458.2024.06.11.06.49.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 06:49:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-209975-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hdMk31pY; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-209975-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-209975-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id CF272B2164B for ; Tue, 11 Jun 2024 13:37:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1346817CA1B; Tue, 11 Jun 2024 13:37:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hdMk31pY" Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (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 2EBCC1E535 for ; Tue, 11 Jun 2024 13:37:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718113047; cv=none; b=gCfBVGzI2Ga3e09FL4YUIri5XHJjySKc/TC+zneAhdICNWy2fRwt1FkOlQe1Riutv4gYeVdbDbCX/DoNibelIVXUhU8zTAefnr+tUq06q+Lfl/wykn+Q3uHSljJ4tgLWsjRpX0aywxg2wksRWb0VvGcIGdEeV4hbdYIXeqPmqEI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718113047; c=relaxed/simple; bh=uClWVkm9RxsLs+EfbggJIY5JpBEtxoQIUWpWC/sz2K0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=MBSswj7Y1/TpaeXH0zI/j93vdznX/BK3V8UEbxKKOZ8crNlVI+5jFCDRa2sQ7/gGM9fMsghhDHv6ff6VRpbuIf5ApACXPa/OpASrtlpnG00iDgmCv6cMP+c0fM4MNA+De19vPsjIY8C588eJlq0nh80YQJpkBSWQ8jOe4D8eW1w= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=hdMk31pY; arc=none smtp.client-ip=209.85.215.171 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-pg1-f171.google.com with SMTP id 41be03b00d2f7-6e9f52e99c2so2170655a12.1 for ; Tue, 11 Jun 2024 06:37:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718113044; x=1718717844; darn=vger.kernel.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=MAcDNalbfcX/SooAz1XjppInJxW8mD6aEySBf2LPSno=; b=hdMk31pYtLGSlgRi7MR3YBa6zWjH0WJRD7vPxC1b+83+jWvfGz0EaJsnRpjbUETTQS rUYbzhVppsG7ZZfEarzZ+QyC5tqf+SZtRlqIOoJivYURivTH2knTHfaCEw5UU8VCDpNi NRhtZUoe5bcCLoh0I+HzpLya63BuT118p3+rImAKQW+Q7h+DO/8aYGjWrI4nW9QoDTo9 CpL7eOTvkTx2X+ZnLGNwcYTyEzgj/sSJkGoS/sQslc05OUJfNwGvLnSk++tz7XNiQjvT xycnwr3G3GuwTaU8KhRavJK3gkErjJcHP6GSphk9nVzk4w7lU+f/bmfGm5OwC8l9130d cVHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718113044; x=1718717844; h=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=MAcDNalbfcX/SooAz1XjppInJxW8mD6aEySBf2LPSno=; b=n3Rx95UBiR+8vO44CqhU+vIIxjgXsf5p+C8kwdfYm2tlsQjDz0HV6IJ3I1uHtoEnmf Z18SgwEv4uOdBZSaK1nVmRtBGCchjqGixcrvv182g1xc398bat7HnP6JewwwmqJVyjR9 whRBOTlxJ6FrTQWy47R6GjAhplneWRbFeYHul9Gdx+scaAN/SY9nXVh2ehyM7zDU3EIW yDF1uKPkHQZAKxCl3rVAKzAIbdZN8ujkeCOaL+Un+85Fxm0LippiSPLG46Ev4fXxVVGG hGMDguGUGOowpS+1/lxy73jnKXurabtX0+jyqn73N7yli1GfAsMQEpzOjzJqoG5P7+5c 8nqA== X-Forwarded-Encrypted: i=1; AJvYcCVz0eJZp1OAK3k75EwnRT5tMO3odcivonA0unimzWeI1I308lgq6b2Y4lSdHVMeSH2gFyiBnxBoq+ZrOgm8sFSYEwXf/E3DSdJOC7tP X-Gm-Message-State: AOJu0Yxd826FJRiXqMDVUMc+oAcOt9Vy/nIL89HF2vPigyvti5QQiErf zMNwo+uuOLyo/t1lbEkL1OZoSC9lIvw6bFwtEOqwuSCzPdaGdjEWdZ7QMrfdPnVcsBEqxgawxGJ d/ldR7zFYiWwwnu9tFfqx+hO3Y6D3lj9WfSwW2Q== X-Received: by 2002:a17:90a:d397:b0:2c2:bd1a:4f84 with SMTP id 98e67ed59e1d1-2c2bd1a4fb0mr11352008a91.10.1718113044480; Tue, 11 Jun 2024 06:37:24 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240611112413.1241352-1-christian.loehle@arm.com> <20240611112413.1241352-2-christian.loehle@arm.com> In-Reply-To: <20240611112413.1241352-2-christian.loehle@arm.com> From: Vincent Guittot Date: Tue, 11 Jun 2024 15:37:12 +0200 Message-ID: Subject: Re: [PATCHv2 1/3] Revert: "cpuidle: teo: Introduce util-awareness" To: Christian Loehle Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, rafael@kernel.org, qyousef@layalina.io, peterz@infradead.org, daniel.lezcano@linaro.org, ulf.hansson@linaro.org, anna-maria@linutronix.de, kajetan.puchalski@arm.com, lukasz.luba@arm.com, dietmar.eggemann@arm.com Content-Type: text/plain; charset="UTF-8" On Tue, 11 Jun 2024 at 13:24, Christian Loehle wrote: > > This reverts commit 9ce0f7c4bc64d820b02a1c53f7e8dba9539f942b. > > Util-awareness was reported to be too aggressive in selecting shallower > states. Additionally a single threshold was found to not be suitable > for reasoning about sleep length as, for all practical purposes, > almost arbitrary sleep lengths are still possible for any load value. > > Fixes: 9ce0f7c4bc64 ("cpuidle: teo: Introduce util-awareness") > Reported-by: Qais Yousef > Reported-by: Vincent Guittot The spurious wakeups that I reported on my rb5, are gone with this patchset Tested-by: Vincent Guittot > Signed-off-by: Christian Loehle > --- > drivers/cpuidle/governors/teo.c | 100 -------------------------------- > 1 file changed, 100 deletions(-) > > diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c > index 7244f71c59c5..d8554c20cf10 100644 > --- a/drivers/cpuidle/governors/teo.c > +++ b/drivers/cpuidle/governors/teo.c > @@ -104,56 +104,16 @@ > * select the given idle state instead of the candidate one. > * > * 3. By default, select the candidate state. > - * > - * Util-awareness mechanism: > - * > - * The idea behind the util-awareness extension is that there are two distinct > - * scenarios for the CPU which should result in two different approaches to idle > - * state selection - utilized and not utilized. > - * > - * In this case, 'utilized' means that the average runqueue util of the CPU is > - * above a certain threshold. > - * > - * When the CPU is utilized while going into idle, more likely than not it will > - * be woken up to do more work soon and so a shallower idle state should be > - * selected to minimise latency and maximise performance. When the CPU is not > - * being utilized, the usual metrics-based approach to selecting the deepest > - * available idle state should be preferred to take advantage of the power > - * saving. > - * > - * In order to achieve this, the governor uses a utilization threshold. > - * The threshold is computed per-CPU as a percentage of the CPU's capacity > - * by bit shifting the capacity value. Based on testing, the shift of 6 (~1.56%) > - * seems to be getting the best results. > - * > - * Before selecting the next idle state, the governor compares the current CPU > - * util to the precomputed util threshold. If it's below, it defaults to the > - * TEO metrics mechanism. If it's above, the closest shallower idle state will > - * be selected instead, as long as is not a polling state. > */ > > #include > #include > #include > -#include > #include > -#include > #include > > #include "gov.h" > > -/* > - * The number of bits to shift the CPU's capacity by in order to determine > - * the utilized threshold. > - * > - * 6 was chosen based on testing as the number that achieved the best balance > - * of power and performance on average. > - * > - * The resulting threshold is high enough to not be triggered by background > - * noise and low enough to react quickly when activity starts to ramp up. > - */ > -#define UTIL_THRESHOLD_SHIFT 6 > - > /* > * The PULSE value is added to metrics when they grow and the DECAY_SHIFT value > * is used for decreasing metrics on a regular basis. > @@ -188,7 +148,6 @@ struct teo_bin { > * @next_recent_idx: Index of the next @recent_idx entry to update. > * @recent_idx: Indices of bins corresponding to recent "intercepts". > * @tick_hits: Number of "hits" after TICK_NSEC. > - * @util_threshold: Threshold above which the CPU is considered utilized > */ > struct teo_cpu { > s64 time_span_ns; > @@ -198,28 +157,10 @@ struct teo_cpu { > int next_recent_idx; > int recent_idx[NR_RECENT]; > unsigned int tick_hits; > - unsigned long util_threshold; > }; > > static DEFINE_PER_CPU(struct teo_cpu, teo_cpus); > > -/** > - * teo_cpu_is_utilized - Check if the CPU's util is above the threshold > - * @cpu: Target CPU > - * @cpu_data: Governor CPU data for the target CPU > - */ > -#ifdef CONFIG_SMP > -static bool teo_cpu_is_utilized(int cpu, struct teo_cpu *cpu_data) > -{ > - return sched_cpu_util(cpu) > cpu_data->util_threshold; > -} > -#else > -static bool teo_cpu_is_utilized(int cpu, struct teo_cpu *cpu_data) > -{ > - return false; > -} > -#endif > - > /** > * teo_update - Update CPU metrics after wakeup. > * @drv: cpuidle driver containing state data. > @@ -386,7 +327,6 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, > int constraint_idx = 0; > int idx0 = 0, idx = -1; > bool alt_intercepts, alt_recent; > - bool cpu_utilized; > s64 duration_ns; > int i; > > @@ -411,32 +351,6 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, > if (!dev->states_usage[0].disable) > idx = 0; > > - cpu_utilized = teo_cpu_is_utilized(dev->cpu, cpu_data); > - /* > - * If the CPU is being utilized over the threshold and there are only 2 > - * states to choose from, the metrics need not be considered, so choose > - * the shallowest non-polling state and exit. > - */ > - if (drv->state_count < 3 && cpu_utilized) { > - /* > - * If state 0 is enabled and it is not a polling one, select it > - * right away unless the scheduler tick has been stopped, in > - * which case care needs to be taken to leave the CPU in a deep > - * enough state in case it is not woken up any time soon after > - * all. If state 1 is disabled, though, state 0 must be used > - * anyway. > - */ > - if ((!idx && !(drv->states[0].flags & CPUIDLE_FLAG_POLLING) && > - teo_state_ok(0, drv)) || dev->states_usage[1].disable) { > - idx = 0; > - goto out_tick; > - } > - /* Assume that state 1 is not a polling one and use it. */ > - idx = 1; > - duration_ns = drv->states[1].target_residency_ns; > - goto end; > - } > - > /* Compute the sums of metrics for early wakeup pattern detection. */ > for (i = 1; i < drv->state_count; i++) { > struct teo_bin *prev_bin = &cpu_data->state_bins[i-1]; > @@ -560,18 +474,6 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, > if (idx > constraint_idx) > idx = constraint_idx; > > - /* > - * If the CPU is being utilized over the threshold, choose a shallower > - * non-polling state to improve latency, unless the scheduler tick has > - * been stopped already and the shallower state's target residency is > - * not sufficiently large. > - */ > - if (cpu_utilized) { > - i = teo_find_shallower_state(drv, dev, idx, KTIME_MAX, true); > - if (teo_state_ok(i, drv)) > - idx = i; > - } > - > /* > * Skip the timers check if state 0 is the current candidate one, > * because an immediate non-timer wakeup is expected in that case. > @@ -667,11 +569,9 @@ static int teo_enable_device(struct cpuidle_driver *drv, > struct cpuidle_device *dev) > { > struct teo_cpu *cpu_data = per_cpu_ptr(&teo_cpus, dev->cpu); > - unsigned long max_capacity = arch_scale_cpu_capacity(dev->cpu); > int i; > > memset(cpu_data, 0, sizeof(*cpu_data)); > - cpu_data->util_threshold = max_capacity >> UTIL_THRESHOLD_SHIFT; > > for (i = 0; i < NR_RECENT; i++) > cpu_data->recent_idx[i] = -1; > -- > 2.34.1 >