From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=217.140.110.172 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796215057; b=4ziGC1Ku6QcRTrGnBPxOUewJHWQNLn0hSu8K1xsSDwf78Kaz1THgWCIKyJaz6//EjQ0v Ye5Wbk0zzOSGd/TIlgTfwayrUCtdOeq1VLlwOQ2v/5OqB+bvLw1yFD6mAx9t2LlfjfEOk CD0q8V6HfRPy2Sl5jjihVi4BKIkT1+2Xxsldlz0MmbGdZlX/ohkcxOt76c1zh3FkUNR/n GaqsQFy7HpapX4zzJ914WRnKromx+IbeRQ8zPWYhbkPQiA3LjzgpoTC+LPN1foqbxy5d8 0LgJkyqUy1Hflj2iVHW+sCF8+VmASJdroOQJ34yKG3XJ8FOVmFoUW0XU5w1rduCBN/w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796215057; h=DMARC-Filter:Received:Received:DKIM-Signature:Message-ID:Date: MIME-Version:User-Agent:Subject:To:Cc:References:From: Content-Language:In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=M/acipBqTs7Gnv6Co4ljwYF+9WdLb87+2DyvOt6w0pg=; b=ZT3TxngNpv+gh7tCAi/akuCSPipq8D/00oHkgqj0cQgBofCW1pKesMJRfW8h9SQMLF0N qqhIF6tqxOl+mTP1pcGbhoLd9OyF2CxxPSqfhCB/tt+ZwRvADoFUjM+fcVdM2IV+Xtr5B J8TNg3c4KbqMpoXx31wwTcpy8A8/aZHGAX07gcY1WGDFxub1Cr30XnmqDdnQTI0u7rkFA ZZcWgwSmmMnenkIVe7eXOuG0V1p7D785/z0fKSyMjiR+e0i8eqnLPHybmUOPISOgyiPPQ xF/FUMVQTt9J+hPc/9PTZXHnqHHz1c1F2dJWEEmzeVMvaCdXPQdMBAWfj/FAwwO+VZA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=XgU3sFRS; arc=none smtp.remote-ip=217.140.110.172 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3811F606A31A; Wed, 2 Dec 2026 12:37:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 3811F606A31A Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=foss header.b=XgU3sFRS Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 50FE01570; Wed, 2 Dec 2026 04:37:33 -0800 (PST) Received: from [10.0.130.226] (e127648.arm.com [10.0.130.226]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E94143F86F; Wed, 2 Dec 2026 04:37:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1796215056; bh=d3LyPxL4tWaBlFyXbVH7yo8fe6EARJiCp6qnbUVpEVI=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=XgU3sFRS5nXyzQI2qpigCDKagiDJNtPq/64tDK8ZQEZOTIlv1GgrotZvjz3PW7XeZ /ybEua1g80khP3odH6Sfu9okJ13u29aWPGmjpYRf74MTteYPwCOEtakarR5mmXE3DR 4H57s7SkFQyvpyKmXITPDerBDWTlh9f1O0X3x1SU= Message-ID: <6d47fcee-f243-419e-9326-788cc90eeb2c@arm.com> Date: Wed, 2 Dec 2026 12:37:32 +0000 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] cpuidle: teo: Keep the tick when intercepts predict a short idle period To: Navon John Lukose , "Rafael J. Wysocki" , Daniel Lezcano Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org References: <20261202082511.1475746-1-navonjohnlukose@gmail.com> From: Christian Loehle Content-Language: en-US In-Reply-To: <20261202082511.1475746-1-navonjohnlukose@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/2/26 08:25, Navon John Lukose wrote: > 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%). Hi, thanks for the patch, I think it makes sense. Do you mind just dumping the state counts / duration deltas, IMO that would be more readable. > > 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; I did propose something in that direction too, but didn't follow up on it: https://lore.kernel.org/lkml/20240606090050.327614-3-christian.loehle@arm.com/ > + > if (!idx) > goto out_tick; >