From: ccross@android.com (Colin Cross)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/2] cpuidle: coupled: fix decrementing ready count
Date: Fri, 18 May 2012 11:05:24 -0700 [thread overview]
Message-ID: <1337364324-12171-3-git-send-email-ccross@android.com> (raw)
In-Reply-To: <1337364324-12171-1-git-send-email-ccross@android.com>
cpuidle_coupled_set_not_ready sometimes refuses to decrement the
ready count in order to prevent a race condition. This makes it
unsuitable for use when finished with idle. Add a new function
cpuidle_coupled_set_done that decrements both the ready count and
waiting count, and call it after idle is complete.
Signed-off-by: Colin Cross <ccross@android.com>
---
drivers/cpuidle/coupled.c | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/drivers/cpuidle/coupled.c b/drivers/cpuidle/coupled.c
index b02810a..fc427fa 100644
--- a/drivers/cpuidle/coupled.c
+++ b/drivers/cpuidle/coupled.c
@@ -388,6 +388,21 @@ static void cpuidle_coupled_set_not_waiting(int cpu,
}
/**
+ * cpuidle_coupled_set_done - mark this cpu as leaving the ready loop
+ * @cpu: the current cpu
+ * @coupled: the struct coupled that contains the current cpu
+ *
+ * Marks this cpu as no longer in the ready and waiting loops. Decrements
+ * the waiting count first to prevent another cpu looping back in and seeing
+ * this cpu as waiting just before it exits idle.
+ */
+static void cpuidle_coupled_set_done(int cpu, struct cpuidle_coupled *coupled)
+{
+ cpuidle_coupled_set_not_waiting(cpu, coupled);
+ atomic_sub(MAX_WAITING_CPUS, &coupled->ready_waiting_counts);
+}
+
+/**
* cpuidle_coupled_clear_pokes - spin until the poke interrupt is processed
* @cpu - this cpu
*
@@ -501,8 +516,7 @@ int cpuidle_enter_state_coupled(struct cpuidle_device *dev,
entered_state = cpuidle_enter_state(dev, drv, next_state);
- cpuidle_coupled_set_not_waiting(dev->cpu, coupled);
- cpuidle_coupled_set_not_ready(coupled);
+ cpuidle_coupled_set_done(dev->cpu, coupled);
out:
/*
--
1.7.7.3
next prev parent reply other threads:[~2012-05-18 18:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-05-18 18:05 [PATCH 0/2] bug fixes for coupled cpuidle Colin Cross
2012-05-18 18:05 ` [PATCH 1/2] cpuidle: coupled: fix count of online cpus Colin Cross
2012-05-18 18:05 ` Colin Cross [this message]
2012-05-21 6:44 ` [PATCH 0/2] bug fixes for coupled cpuidle Santosh Shilimkar
2012-05-25 22:38 ` [linux-pm] " Kevin Hilman
2012-06-02 5:50 ` Len Brown
2012-06-05 18:12 ` Kevin Hilman
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=1337364324-12171-3-git-send-email-ccross@android.com \
--to=ccross@android.com \
--cc=linux-arm-kernel@lists.infradead.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).