linux-pm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Lezcano <daniel.lezcano@linaro.org>
To: rjw@rjwysocki.net
Cc: gregory.clement@free-electrons.com, linux-pm@vger.kernel.org,
	linux@armlinux.org.uk, paul.burton@imgtec.com,
	stable@vger.kernel.org, open list <linux-kernel@vger.kernel.org>
Subject: [PATCH] cpuidle: Fix coupled state parameter in cpuidle_enter()
Date: Tue, 17 May 2016 16:54:00 +0200	[thread overview]
Message-ID: <1463496840-2858-1-git-send-email-daniel.lezcano@linaro.org> (raw)

The commit 0b89e9aa2856 rightfully fixed a regression by letting the couple
idle state framework to handle local interrupt enabling when the cpu is
exiting an idle state.

The current code check if the idle state is a coupled one and, if so, it will
let the couple code to enable the interrupt. This way, it can decrement the
ready-count before handling the interrupts. This mechanism prevents the other
cpus to wait for a cpu which is handling interrupts.

But the check is done against the state index returned by the back end driver
'enter' functions which could be different from the initial index passed as
parameter to the cpuidle_enter_state() function.

 entered_state = target_state->enter(dev, drv, index);

 [ ... ]

 if (!cpuidle_state_is_coupled(drv, entered_state))
	local_irq_enable();

 [ ... ]

If the 'index' is referring to a coupled idle state but the 'entered_state'
is *not* coupled, then the interrupts are enabled again. All cpus blocked on
the sync barrier may busy loop longer if the cpu has interrupts to handle
before decrementing the ready-count. Thus consuming more energy than saving.

Fixes: 0b89e9aa2856 "cpuidle: delay enabling interrupts until all coupled CPUs leave idle"
Cc: stable@vger.kernel.org
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/cpuidle/cpuidle.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index f996efc..cd021ed 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -214,7 +214,7 @@ int cpuidle_enter_state(struct cpuidle_device *dev, struct cpuidle_driver *drv,
 		tick_broadcast_exit();
 	}
 
-	if (!cpuidle_state_is_coupled(drv, entered_state))
+	if (!cpuidle_state_is_coupled(drv, index))
 		local_irq_enable();
 
 	diff = ktime_to_us(ktime_sub(time_end, time_start));
-- 
1.9.1

             reply	other threads:[~2016-05-17 14:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-05-17 14:54 Daniel Lezcano [this message]
2016-05-17 14:55 ` [PATCH] cpuidle: Fix coupled state parameter in cpuidle_enter() Daniel Lezcano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1463496840-2858-1-git-send-email-daniel.lezcano@linaro.org \
    --to=daniel.lezcano@linaro.org \
    --cc=gregory.clement@free-electrons.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=paul.burton@imgtec.com \
    --cc=rjw@rjwysocki.net \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).