From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.175 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796199921; b=NSTG9spGfrkceyaSjkk0eDuE6MNG60eHWSeEUVQ0tO7nAwcwjoLYk4RDk/rLDTRGhiNd bfDOExepCEspOUPVdwiUe079RIZXH4hPSLj7iM/9y91ygzQ5TqR3SkOO36Ll+QaxzbK7h XIPNg3THB1DIUM5sTT5z+FrVmMaxj2w0pfA9a0oObgdRQh5GKIKrkAYhhutmLLdh5byLd Asy01E9uOLK7a6x43BjNQc7O9jwasube26zUlQyTd8Vdk0kRMbl7pw8tpjL9QS980Rmh9 ZafBbT152M2i5df0zK8f9TagHxkYQR72rPD5VEaMA6O/8cqtkP/MGeyUuSy/CUVUhVA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796199921; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:MIME-Version: Content-Transfer-Encoding; bh=XdoB7IhVOW0cRmcr3wZClAktDpGG2AUts3zJAD2syRw=; b=Ol9B4YpRD7Ju6Rd5pxbco+1ZRs4NpIlq81yhFaYHAwRRx1XgFx4jegeyoHJR1+As1nRF 55AR7X9hMLdJr6dAaE6zzkzjJ0ucXzPydK92E/mtEoe0kbgEtGrwZFi1sIWaBP2tMb7pR 46TXYCJ9M1VIwukeRx/lc1yXA2g81AlejKa7FFwXD1jtSwzPpgT4i9CAwZwNXWxri5uJv 3RgXapo/Pj0HITee56P9+dj5bYLosQRnhJSeIIDU0whsK6E1Xvhsv5gNc08iHyfQewKC+ h70K02G2Seb17yiC8SDeyp2Iard4P/tn8LYk9SG69x/MaPvokcWUQq4QUG2bZGqkNFg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=bTyMC6tH; arc=none smtp.remote-ip=74.125.82.175 Received: from mail-dy1-f175.google.com (mail-dy1-f175.google.com [74.125.82.175]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9637606A322 for ; Wed, 2 Dec 2026 08:25:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A9637606A322 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=bTyMC6tH Received: by mail-dy1-f175.google.com with SMTP id 5a478bee46e88-386d36ac055so1181577eec.3 for ; Wed, 02 Dec 2026 00:25:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796199920; x=1796804720; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=XdoB7IhVOW0cRmcr3wZClAktDpGG2AUts3zJAD2syRw=; b=bTyMC6tH2SjiLlTl72akF20YVOviPEH289XkXg27vQKkdy0fe0QmRb+wqiuHYDqbLE zURdXlCXmFpbE4VUDSlBgAtSc/AM+mxx6+9gKW/9quV9TBSyBsrQcdrjUKXAksjVtA+Q hm4ZgGvrvsyY/BnLpshrgrsEDvswlad0r6GfkRSvt14r9ceZuIcxiwr4LtYowvLV37uK Mh0K9C1n/8n+1I1Gf5q/u7GqdUCBOJvSNskovO5aqmYJC+xzcl7fXmjqGjg9TiSjuBFy f3C0kvVsWhxBl4NlE/PXykO1x8FgooqNmE7T6qaEQqLkC0pGShKetXVdsz8Vr46L1/6r B+1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796199920; x=1796804720; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=XdoB7IhVOW0cRmcr3wZClAktDpGG2AUts3zJAD2syRw=; b=OeIBUlzbvyeaNmThnJ6LzzROBdJlW6r0sN7QqrpDUWEbSFhzwHmnGfIzBoi0HarjEP FycQR1hBIMQ2EF9viPBbqRsZlKczDxkYtqtiWF+IbMikU/0IXNjsyVTBQco2pfhpN3v6 ItgQFz7Zs+WTY+qrQqP2p1EfjPmcrPbNQCCDEe6Vl3H8LPvacKz5KqJBY9ASngifstk4 dqgU05oImQabQKQIzwkrXPMOr8xK3PwxhFu+0fAP97LInKwMTmuqbf3nfHEzlMo5HANF PnXR/J1pCDv/mvFdhONpSFhgsks2sB3WPxnm3fqYw3ax+79Mew383LilFcluAOwT0+Si A2JQ== X-Forwarded-Encrypted: i=1; AL+hErEMM3I1nzHaLaL4oKftiWUc/A8dQNH8NR6pf3O6po6Jj4pePR2GMCoy0TbiGtS5aXL1mvX6woES3g==@vger.kernel.org X-Gm-Message-State: APuU4Z/gZqosINXh4iHIDH3Y9tAJi6bG+R14T8K88ZXTqvcRtH93Ya7d 77HZPnd4d0seVUjvvCqK7px1WNOIsxM6L85VvpwT7tKwJJOltYJHKQ6R X-Gm-Gg: AZFdTZfiDgO3+YCsUYSMN2/+8xAzhAlgDDkVB5gxIoamGlF4eATl7n2chA6s4Tp+6Sw rsylxZiEV/cZYrw9PLAnaBWqEXsoitrT92bS2cmcXX7IbJ+pI+Drzc3GfmGQjTDGRfUnU4/+nEA Lx5tP9TeZrP1YxVJWEFuHJjWnaGvhXZwM2/vWtNoiaZq1yQczIztokru6jXKqNvBLizxEg2mw8o 0ujugZCQRbxSydxzRVSa0F32wmRQh2c9N18UyQYCg4/ng3Tr8zNg7zhBxh4gt5kwBuOd7fQSbph tjlgLiRyQ8ChM7MjYNE2WjzBmqXcyduAJOuZqv/Q8xQXvbsAZ5HU1xmjEUmkbo5nwqtVnSKvjiJ mCTnUCU6QILfRtD3mHIO63mWafPsgsSbxhKiCdbG+nk9OYcjepLu6LsFy2HxULLeEdXqKjEA18S nO2CMqko/FYPJ+WRyFuFAiWeLplMZPTBfba3KPLd/yUt9oQFwLsR/+nU/LvugpX2PDM7a08i5JL t4c1DDGEEs4qrqPnZN0U9phw8x2z0VK0vjXPJPga0Glz45cfF38aWUqNidWgOJkvjWjjKPtzGdK 3OeKmkOOOkeF3j5WDd6qQ30NH5JuPNT71ZXsboDdlb+MWHTemTuuHO6Xmfqw5gHfRSocxDHSHZs L3OOcs/QEoF3fvdKI9+PB5gD34uAnjkZdwPzd6rgLTtFeY2PMoX1eoDCbnKx9qgnga5dc6wFUe1 Dh5ctMoXCoi8LuLmkyYK9Qb7jusKBuVecZ7JwEIllpSBgutgVcRi6mbwsda8Xb8wZAZEgkDNLDS 3OU6DUbEFkMH/Y1TMqoIGw= X-Received: by 2002:a05:693c:20cf:20b0:386:c9b4:86e9 with SMTP id 5a478bee46e88-3872e1b7fb2mr3759296eec.2.1796199919592; Wed, 02 Dec 2026 00:25:19 -0800 (PST) Received: from cachyos-aura ([106.222.179.191]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-385666e99fdsm133649418eec.5.2026.12.02.00.25.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2026 00:25:19 -0800 (PST) From: Navon John Lukose To: "Rafael J. Wysocki" , Daniel Lezcano Cc: Christian Loehle , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] cpuidle: teo: Keep the tick when intercepts predict a short idle period Date: Wed, 2 Dec 2026 13:55:11 +0530 Message-ID: <20261202082511.1475746-1-navonjohnlukose@gmail.com> X-Mailer: git-send-email 2.56.1 X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit When the intercepts metrics make teo_select() pick a state shallower than the sleep length allows, the idle duration is expected to be below the target residency of the deeper state that was rejected. Whether or not to stop the tick is still decided from the sleep length though, so if the expected wakeup does not come, the CPU stays in the shallow state with the tick stopped until the next timer. Before commit 21d28cd2fa5f ("cpuidle: teo: Do not call tick_nohz_get_sleep_length() upfront") the middle of the selected state's bin was used as the expected idle duration in that case, which kept the tick for shallow states. Cap duration_ns at the target residency of the shallowest state rejected because of intercepts before using it for the tick decision. On an Arrow Lake-H laptop (HZ=1000, intel_idle _CST states C1/C2/C3 with target residencies of 1/381/3144 us), idle with the display off, psys power drops from 2.23 W to 1.16 W and package C10 residency rises from 38% to 57%. Over five loads waking a task every 1.5-3 ms, psys drops by 0.86 W on average, and for cross-CPU pipe wakeups every 1.5-2 ms the p90 wakeup latency rises by 15-19 us. Fixes: 21d28cd2fa5f ("cpuidle: teo: Do not call tick_nohz_get_sleep_length() upfront") Signed-off-by: Navon John Lukose --- Measured with teo.c built as a module on 7.3, stock and patched, in 8 interleaved 100 s idle rounds and 6 interleaved rounds of each periodic load. menu gets 1.25 W and 67% PC10 at idle on the same machine. C1 residencies longer than one tick go from 522-1398 to 1-4 per minute. C2 can still be entered with the tick stopped, because C3's target residency is above one tick and the pre-6.6 code stopped the tick there as well. That is where the remaining PC10 gap to menu comes from (PC6 16% vs 2%). drivers/cpuidle/governors/teo.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/cpuidle/governors/teo.c b/drivers/cpuidle/governors/teo.c index 735894a1a7f..b8b8b58468c 100644 --- a/drivers/cpuidle/governors/teo.c +++ b/drivers/cpuidle/governors/teo.c @@ -319,6 +319,7 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, int intercept_max_idx = -1; int constraint_idx = 0; int idx0 = 0, idx = -1; + s64 intercept_ns = KTIME_MAX; s64 duration_ns; int i; @@ -419,6 +420,8 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, if (dev->states_usage[i].disable) continue; + /* State idx is rejected, so expect a shorter idle duration. */ + intercept_ns = drv->states[idx].target_residency_ns; idx = i; if (2 * intercept_sum > idx_intercept_sum && i <= intercept_max_idx) @@ -500,6 +503,15 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, return idx; } + /* + * If the candidate state has been selected because of intercepts, the + * idle duration is expected to be below the target residency of the + * shallowest state rejected for this reason, so use that value instead + * of the sleep length when deciding whether or not to stop the tick. + */ + if (duration_ns > intercept_ns) + duration_ns = intercept_ns; + if (!idx) goto out_tick; -- 2.56.1