From nobody Sat Oct 4 19:15:57 2025 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2401D212571; Wed, 13 Aug 2025 10:30:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755081032; cv=none; b=CxYcYUoCcgqTFqzYGssHIpAFvHdG5DHYm3EGhfwCFZ3aFMt4DZSknEHibWDzOEGkbpQtYe08qmCCNplFOBIaOJ4o8wS1CS5tPY4/Z+cRFUg3I8wuBGuH3xaUYHJXUr0QES1J75Q0qaRlyKEgHqwsKTZC1eAtNoKmgjretLz3lX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1755081032; c=relaxed/simple; bh=V6sdFzKvrJKraeJ9IEPdOHZgCdgzOGqx1ymqb6IrMg4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=p2tPsYSCijrXAys6uB87/zdl2cxAiZm65UeqeSxFVcoIHz4ZWaAYIRXgON3HC+rSKG7oHA+DVBWw6JBZ/4DZ0f1rDp7Xc+efTgkW53guuBxxBzdAY2vdvdw1WyrIUhVRSl3zLn5WBiPw/cCabHN3W4uz1ajjo8g2vNyFJmopdbY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UZWM9EUA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UZWM9EUA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id AF4D7C4CEEB; Wed, 13 Aug 2025 10:30:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1755081031; bh=V6sdFzKvrJKraeJ9IEPdOHZgCdgzOGqx1ymqb6IrMg4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UZWM9EUAIN03F8InYrZ/c8Yey+pp8uMrCyi4sVnzrtFrOA5ZyBD/I1hKzysTFbQyo iI3poOPgKStK4msU/SgZTNobQ5f+6tW1gq5FvL+SEXli0va2x5ZMHXH0NIstkyCkdg sEOgaggtstHBMxsiZM64yuT1HmYuEEYIFGyP1bFHD7FHrHYfUHHzAfnr88wCxKtLL0 KXgInkeC3oouyJT/rraWDp6FY3Fx7nmN6qHlSZyVg2SLfI8VJ6fBRvHzN8khTlpeUI DWctk6VtepRdTsE55cd39KvDaBBKAu9HeFNQZqygcYsgj36FEBSZU9GzGeNdoXdLej C9sDXj4K0tMxg== From: "Rafael J. Wysocki" To: Linux PM Cc: Frederic Weisbecker , LKML , Peter Zijlstra , Christian Loehle Subject: [PATCH v1 2/3] cpuidle: governors: menu: Rearrange main loop in menu_select() Date: Wed, 13 Aug 2025 12:26:35 +0200 Message-ID: <2389215.ElGaqSPkdT@rafael.j.wysocki> Organization: Linux Kernel Development In-Reply-To: <2804546.mvXUDI8C0e@rafael.j.wysocki> References: <2804546.mvXUDI8C0e@rafael.j.wysocki> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Rafael J. Wysocki Reduce the indentation level in the main loop of menu_select() by rearranging some checks and assignments in it. No intentional functional impact. Signed-off-by: Rafael J. Wysocki Acked-by: Frederic Weisbecker Reviewed-by: Christian Loehle --- drivers/cpuidle/governors/menu.c | 72 ++++++++++++++++++++--------------= ----- 1 file changed, 37 insertions(+), 35 deletions(-) --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -314,45 +314,47 @@ if (s->exit_latency_ns > latency_req) break; =20 - if (s->target_residency_ns > predicted_ns) { - /* - * Use a physical idle state, not busy polling, unless - * a timer is going to trigger soon enough. - */ - if ((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) && - s->target_residency_ns <=3D data->next_timer_ns) { - predicted_ns =3D s->target_residency_ns; - idx =3D i; - break; - } - if (predicted_ns < TICK_NSEC) - break; - - if (!tick_nohz_tick_stopped()) { - /* - * If the state selected so far is shallow, - * waking up early won't hurt, so retain the - * tick in that case and let the governor run - * again in the next iteration of the loop. - */ - predicted_ns =3D drv->states[idx].target_residency_ns; - break; - } + if (s->target_residency_ns <=3D predicted_ns) { + idx =3D i; + continue; + } + + /* + * Use a physical idle state, not busy polling, unless a timer + * is going to trigger soon enough. + */ + if ((drv->states[idx].flags & CPUIDLE_FLAG_POLLING) && + s->target_residency_ns <=3D data->next_timer_ns) { + predicted_ns =3D s->target_residency_ns; + idx =3D i; + break; + } =20 + if (predicted_ns < TICK_NSEC) + break; + + if (!tick_nohz_tick_stopped()) { /* - * If the state selected so far is shallow and this - * state's target residency matches the time till the - * closest timer event, select this one to avoid getting - * stuck in the shallow one for too long. + * If the state selected so far is shallow, waking up + * early won't hurt, so retain the tick in that case and + * let the governor run again in the next iteration of + * the idle loop. */ - if (drv->states[idx].target_residency_ns < TICK_NSEC && - s->target_residency_ns <=3D delta_tick) - idx =3D i; - - return idx; + predicted_ns =3D drv->states[idx].target_residency_ns; + break; } =20 - idx =3D i; + /* + * If the state selected so far is shallow and this state's + * target residency matches the time till the closest timer + * event, select this one to avoid getting stuck in the shallow + * one for too long. + */ + if (drv->states[idx].target_residency_ns < TICK_NSEC && + s->target_residency_ns <=3D delta_tick) + idx =3D i; + + return idx; } =20 if (idx =3D=3D -1)