From mboxrd@z Thu Jan 1 00:00:00 1970 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 78F0579F2 for ; Sun, 2 Nov 2025 19:02:55 +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=1762110175; cv=none; b=oWWNW74iT6HvTYicTfQj7BR5M4jZFVL8TqktHVXSeCdqORT4shq74dDfIRCsSI2gg01PBs9C+yR6AN2dI8ACD2SBpcAEgVhoDpB61o5D5Fi2BSuCtJTLlzHeZH/CD3ad4GUQXsR4fsqJ+hnAmqjx2A8qxCuFBN/W7AMLP0/W6Aw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1762110175; c=relaxed/simple; bh=/TUlN+TH6WJ0q+0Ie30VsMDHHu1dmPtj1jh0DZuFiJ8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dK3BUm4gO84OHK82gp68VuuynufNIGhD52F8y31Gc2WIom7N3D5QT7t7FCwBVv/6xy0jS1WsWBAmW+yQGtMSupv90que9LoMpxTRoavJzm+Bv9U6KojNLmey1Q2A7zF7u4m3PZLfB+ORrgdcSb/9klwHtvwnq74zdsVgvN9uCb8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ofwQgdrK; 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="ofwQgdrK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 863CAC4CEF7; Sun, 2 Nov 2025 19:02:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1762110175; bh=/TUlN+TH6WJ0q+0Ie30VsMDHHu1dmPtj1jh0DZuFiJ8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ofwQgdrKItz9pb4A5ph+a9Mtujq+QFJKaYYdNHtWv2LftWmOxWstpr2JaUuIXL9Oy M9UA95kHYOp0jnrZQEHsIAcjc7jpJkLKsGQvfLbycgC7el6keKzPsIT0XI/ixtgBLw JHUHXFFrxghsqk6CHrCALq5n5Zxq7KcWPcF/8zz89SIKud6N+XDbNIELS73EnopqED RFG5Z9Zf/+azR+ldcorCAokkYHYvC2IJ0PmdT45O84En/16R6+7CEqOadO2wTZlmHx fDUlIexj9HjEqASqlYptiN0u1Cu9bkNktBZO0qhbgEnSxfszYwjtDlKtGGF7Bjv6CQ 0P+PD1TxB/Aaw== From: Sasha Levin To: stable@vger.kernel.org Cc: "Rafael J. Wysocki" , Christian Loehle , Sasha Levin Subject: [PATCH 6.6.y 1/2] cpuidle: governors: menu: Rearrange main loop in menu_select() Date: Sun, 2 Nov 2025 14:02:51 -0500 Message-ID: <20251102190252.3557318-1-sashal@kernel.org> X-Mailer: git-send-email 2.51.0 In-Reply-To: <2025110245-mongoose-ravioli-e19d@gregkh> References: <2025110245-mongoose-ravioli-e19d@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Rafael J. Wysocki" [ Upstream commit 17224c1d2574d29668c4879e1fbf36d6f68cd22b ] 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 Reviewed-by: Christian Loehle Link: https://patch.msgid.link/2389215.ElGaqSPkdT@rafael.j.wysocki Stable-dep-of: db86f55bf81a ("cpuidle: governors: menu: Select polling state in some more cases") Signed-off-by: Sasha Levin --- drivers/cpuidle/governors/menu.c | 70 ++++++++++++++++---------------- 1 file changed, 36 insertions(+), 34 deletions(-) diff --git a/drivers/cpuidle/governors/menu.c b/drivers/cpuidle/governors/menu.c index cafe6eed3349f..8e9d9c448f0f8 100644 --- a/drivers/cpuidle/governors/menu.c +++ b/drivers/cpuidle/governors/menu.c @@ -348,45 +348,47 @@ static int menu_select(struct cpuidle_driver *drv, struct cpuidle_device *dev, if (s->exit_latency_ns > latency_req) break; - 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 <= data->next_timer_ns) { - predicted_ns = s->target_residency_ns; - idx = 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 = drv->states[idx].target_residency_ns; - break; - } + if (s->target_residency_ns <= predicted_ns) { + idx = 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 <= data->next_timer_ns) { + predicted_ns = s->target_residency_ns; + idx = i; + break; + } + 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 <= delta_tick) - idx = i; - - return idx; + predicted_ns = drv->states[idx].target_residency_ns; + break; } - idx = 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 <= delta_tick) + idx = i; + + return idx; } if (idx == -1) -- 2.51.0