From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=74.125.82.170 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796199921; b=L3zbIJT3Cj8s1wjin4Roiji4h5JBj9b0stUROSF84tFQZZEBiXSj1x/KT0C9nlhAvDBt UtSohZpvNV+pX6NuE0L+RlYCfXi/2e6YefXMVC+eFlEj1UBGvr4xeS9mKP6BQ/BpSVnRQ /a67UxEinotS5642hrH9WrV3+nWnG3oDscTpRIfXhEhJwQ0qTgb6GtH9aqH4lQiaknujn i/Dz17M0zQFnVT2GjcahjNj95KWKOGWdkPSSWlYhtB7cCx0/oZpBvbYTEOZwa4BY9xEuu BEoBm8WF6IrTfEYXpRGYv8H2zAnheRFE0YtSCfXureppwAGcwJNFfPy0p1HnoUtEBLg== 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=OjhQf+BLkF5COt5ABJuKBneClxiDE75RZdMoeMBeEcadv0N2QIaFUni6qgmzUCG3vtVV ns9yyc6prLSPDFFRhxI3sZ21IqTzIh66l66e93JodeXn8FzXkyfW0bDVw/DJn5QZW8vXa WsbumBXHFCDaOypHgWxtY7I1NBaQJLGO3pPwNBWF5j2BSnlubXNKv/rx6qLgLWpWK4pef ky4J2XusjrWVKpd7mbDCrcgYqgNb523eO9++tkWpKhxm4+pEe2CDYydg/qkKIHcZLfAjA 1mlzJg2TNlVxQz3kfDhYgHuaUZ8w8UPDmsxL3PSR1W9zxmEDb2j4P52chAi7OAu2psA== 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.170 Received: from mail-dy1-f170.google.com (mail-dy1-f170.google.com [74.125.82.170]) (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 BB0EF606A323 for ; Wed, 2 Dec 2026 08:25:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org BB0EF606A323 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-f170.google.com with SMTP id 5a478bee46e88-35159e0092aso1350717eec.2 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=Ivob7cEtZrHw0y99nkr+NvX62zv1Tj7XGwMTOrEJwcv5pYsf+/jP0IN9zSMzxezayi j4680CSZb07ghgkrVrLAzJ2oBhXm8S/YZD/++JTxF81NzfjdtR8iPCtPkvtdsvJIXXIs Ne4or4821F0Uc6Qut/xN+lQPYkbZC3qWH2KcK3AJRDAt6uxyNvpPUDpMD3tV8qB5z8gM +W9UXOMfC+mCgZFdQaZGrkmwmYmcdL9FhuQy7bJoPmly2O6iRZfc5OpwwQrqJw8YOnu/ x1YErm+zxfaoSZP1VdvoWaj+opKrKnvzlGED31tl+sETcXHzPlPjBgRczw8o+8QXVgK8 DjUw== X-Forwarded-Encrypted: i=1; AL+hErHVr8TJp9oUByOB31HdoxLbWo39dn9rnWedm32FWLLYvy/oJUSgGjXD41/6e0EudNYw1LPzfQmb160xZAk=@vger.kernel.org X-Gm-Message-State: APuU4Z9E9evM7fFPchynu2hIZpUdQjck1C1Rr+FouaWd9HjjZhrcwf5K apwrZqr60W2pyzB4ePaFieAjZ5OMhgA5zY0HMwDHLRA31zdQ7KAGVh6PzJOEKvTqyhI= X-Gm-Gg: AZFdTZeLkNfDBmwKcY/GQNK4cv70K0hyu3oQAIbRWloZEl123iN9h5yfmuCYnRg/8NH pZ0vQ0Ya6O0NxR1wbdpvgH2gTgYhbVROjnzMI7CLLKjc1lPHglaBr+Hy2OhGech1gUwCKC+2f59 xQB1QpKm76zGQu4H3iQky9MsTD/idU5lKnxT9zaALgx4B1Gr8HuROkXnolyubWymz/9w69GVkIg pW9Jb8AeXUNl8Nc+YQKqOZeRR173aN1ix9O7sSR2WR8eAcg3QWNrVKgvMz6gH4OBKQFddJpDqbG hHakUjv3brMXoWbxbkusor0nYi2bj0wtkgEnVp5nVNJIyWJ6iQrZEzbzwsMJ2PdWTjG1WZGB3HK wYurVFygyBxxOsMe/YMmINZa47OptZr1lseuqN/Ij2Kq8KEONrQ6YgXvPqDjarfZ8wuhaqJuy4Q xJ4dCLvACn7NH88cZEPswqe3RXqPB66oIuaBb+6ItrYbCjFXgXrseyavNQScFzsn3LHcuQQONRB rMpBe8C3AfXNYk3BLs51McPsNGrs6sGmixvB4nyoml915F8O6E2BAl2RX6P16LFmeu10Y0hMa6C 5nsjxuDXIJVKA2deL/QYFiayy8sGtpxS2CFNu2AnOsbHID1wKo14YyZdRyTHJsayKsKyQT7nIzs fETbpJQ9XrQ2V9pMVvLosUMyn/72t9hPjZS3LCcdGWJHHt90jiMyp8gd8SIB7YP9ZSDevN6CpTM hbC1ynDy3SabQzmamvdYNpzt+aBR2zk3accxnFgAuUFoJE/YgQvkk9c720Y1XHOxyy03F5OfH3J Jv3AHrL7ObMHxOFKqKb028= 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-kernel@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