All of lore.kernel.org
 help / color / mirror / Atom feed
From: Kevin Hilman <khilman@ti.com>
To: Colin Cross <ccross@android.com>
Cc: Len Brown <len.brown@intel.com>,
	Trinabh Gupta <g.trinabh@gmail.com>,
	Deepthi Dharwar <deepthi@linux.vnet.ibm.com>,
	Daniel Lezcano <daniel.lezcano@linaro.org>,
	linux-kernel@vger.kernel.org,
	Amit Kucheria <amit.kucheria@linaro.org>,
	Santosh Shilimkar <santosh.shilimkar@ti.com>,
	linux-tegra@vger.kernel.org, linux-pm@lists.linux-foundation.org,
	linux-omap@vger.kernel.org,
	Arjan van de Ven <arjan@linux.intel.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH 0/3] coupled cpuidle state support
Date: Tue, 13 Mar 2012 16:52:49 -0700	[thread overview]
Message-ID: <8762e8kqi6.fsf@ti.com> (raw)
In-Reply-To: <4F1929E9.7070707@linaro.org> (Daniel Lezcano's message of "Fri, 20 Jan 2012 09:46:33 +0100")

Hi Colin,

On 12/21/2011 01:09 AM, Colin Cross wrote:

> To use coupled cpuidle states, a cpuidle driver must:

[...]

>     Provide a struct cpuidle_state.enter function for each state
>     that affects multiple cpus.  This function is guaranteed to be
>     called on all cpus at approximately the same time.  The driver
>     should ensure that the cpus all abort together if any cpu tries
>     to abort once the function is called.

I've discoved the last sentence above is crucial, and in order to catch
all the corner cases I found it useful to have the struct
cpuidle_coupled in cpuidle.h so that the driver can check ready_count
itself (patch below, on top of $SUBJECT series.)

As you know, on OMAP4, when entering the coupled state, CPU0 has to wait
for CPU1 to enter its low power state before entering itself.  The first
pass at implementing this was to just spin waiting for the powerdomain
of CPU1 to hit off.  That works... most of the time.

If CPU1 wakes up immediately (or before CPU0 starts checking), or more
likely, fails to hit the low-power state because of other hardware
"conditions", CPU0 will end up stuck in the loop waiting for CPU1.

To solve this, in addition to checking the power state of CPU1, I also 
check if (coupled->ready_count != cpumask_weight(&coupled->alive_coupled_cpus)).
If true, it means that CPU1 has already exited/aborted so CPU0 had
better abort as well.

Checking the ready_count seemed like an easy way to do this, but did you
have any other mechanisms in mind for CPUs to communicate that they've
exited/aborted?

Kevin


diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
index bf34d67..16e00cc 100644
--- a/drivers/cpuidle/cpuidle.h
+++ b/drivers/cpuidle/cpuidle.h
@@ -32,15 +32,6 @@ extern void cpuidle_remove_state_sysfs(struct cpuidle_device *device);
 extern int cpuidle_add_sysfs(struct device *dev);
 extern void cpuidle_remove_sysfs(struct device *dev);
 
-/* coupled states */
-struct cpuidle_coupled {
-	spinlock_t lock;
-	int requested_state[NR_CPUS];
-	int ready_count;
-	cpumask_t alive_coupled_cpus;
-	int refcnt;
-};
-
 #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
 bool cpuidle_state_is_coupled(struct cpuidle_device *dev,
 		struct cpuidle_driver *drv, int state);
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 71f2fba..dbc1f2e 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -51,6 +51,15 @@ struct cpuidle_state {
 			int index);
 };
 
+/* coupled states */
+struct cpuidle_coupled {
+	spinlock_t lock;
+	int requested_state[NR_CPUS];
+	int ready_count;
+	cpumask_t alive_coupled_cpus;
+	int refcnt;
+};
+
 /* Idle State Flags */
 #define CPUIDLE_FLAG_TIME_VALID	(0x01) /* is residency time measurable? */
 #define CPUIDLE_FLAG_COUPLED	(0x02) /* state applies to multiple cpus */

WARNING: multiple messages have this Message-ID (diff)
From: khilman@ti.com (Kevin Hilman)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 0/3] coupled cpuidle state support
Date: Tue, 13 Mar 2012 16:52:49 -0700	[thread overview]
Message-ID: <8762e8kqi6.fsf@ti.com> (raw)
In-Reply-To: <4F1929E9.7070707@linaro.org> (Daniel Lezcano's message of "Fri, 20 Jan 2012 09:46:33 +0100")

Hi Colin,

On 12/21/2011 01:09 AM, Colin Cross wrote:

> To use coupled cpuidle states, a cpuidle driver must:

[...]

>     Provide a struct cpuidle_state.enter function for each state
>     that affects multiple cpus.  This function is guaranteed to be
>     called on all cpus at approximately the same time.  The driver
>     should ensure that the cpus all abort together if any cpu tries
>     to abort once the function is called.

I've discoved the last sentence above is crucial, and in order to catch
all the corner cases I found it useful to have the struct
cpuidle_coupled in cpuidle.h so that the driver can check ready_count
itself (patch below, on top of $SUBJECT series.)

As you know, on OMAP4, when entering the coupled state, CPU0 has to wait
for CPU1 to enter its low power state before entering itself.  The first
pass at implementing this was to just spin waiting for the powerdomain
of CPU1 to hit off.  That works... most of the time.

If CPU1 wakes up immediately (or before CPU0 starts checking), or more
likely, fails to hit the low-power state because of other hardware
"conditions", CPU0 will end up stuck in the loop waiting for CPU1.

To solve this, in addition to checking the power state of CPU1, I also 
check if (coupled->ready_count != cpumask_weight(&coupled->alive_coupled_cpus)).
If true, it means that CPU1 has already exited/aborted so CPU0 had
better abort as well.

Checking the ready_count seemed like an easy way to do this, but did you
have any other mechanisms in mind for CPUs to communicate that they've
exited/aborted?

Kevin


diff --git a/drivers/cpuidle/cpuidle.h b/drivers/cpuidle/cpuidle.h
index bf34d67..16e00cc 100644
--- a/drivers/cpuidle/cpuidle.h
+++ b/drivers/cpuidle/cpuidle.h
@@ -32,15 +32,6 @@ extern void cpuidle_remove_state_sysfs(struct cpuidle_device *device);
 extern int cpuidle_add_sysfs(struct device *dev);
 extern void cpuidle_remove_sysfs(struct device *dev);
 
-/* coupled states */
-struct cpuidle_coupled {
-	spinlock_t lock;
-	int requested_state[NR_CPUS];
-	int ready_count;
-	cpumask_t alive_coupled_cpus;
-	int refcnt;
-};
-
 #ifdef CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED
 bool cpuidle_state_is_coupled(struct cpuidle_device *dev,
 		struct cpuidle_driver *drv, int state);
diff --git a/include/linux/cpuidle.h b/include/linux/cpuidle.h
index 71f2fba..dbc1f2e 100644
--- a/include/linux/cpuidle.h
+++ b/include/linux/cpuidle.h
@@ -51,6 +51,15 @@ struct cpuidle_state {
 			int index);
 };
 
+/* coupled states */
+struct cpuidle_coupled {
+	spinlock_t lock;
+	int requested_state[NR_CPUS];
+	int ready_count;
+	cpumask_t alive_coupled_cpus;
+	int refcnt;
+};
+
 /* Idle State Flags */
 #define CPUIDLE_FLAG_TIME_VALID	(0x01) /* is residency time measurable? */
 #define CPUIDLE_FLAG_COUPLED	(0x02) /* state applies to multiple cpus */

  parent reply	other threads:[~2012-03-13 23:52 UTC|newest]

Thread overview: 115+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-21  0:09 [PATCH 0/3] coupled cpuidle state support Colin Cross
2011-12-21  0:09 ` Colin Cross
2011-12-21  0:09 ` Colin Cross
2011-12-21  0:09 ` [PATCH 1/3] cpuidle: refactor out cpuidle_enter_state Colin Cross
2011-12-21  0:09   ` Colin Cross
2011-12-21  0:09   ` Colin Cross
2012-01-04 14:08   ` Jean Pihet
2012-01-04 14:08     ` [linux-pm] " Jean Pihet
2012-01-04 14:08     ` Jean Pihet
2011-12-21  0:09 ` [PATCH 2/3] cpuidle: fix error handling in __cpuidle_register_device Colin Cross
     [not found] ` <1324426147-16735-1-git-send-email-ccross-z5hGa2qSFaRBDgjK7y7TUQ@public.gmane.org>
2011-12-21  0:09   ` Colin Cross
2011-12-21  0:09     ` Colin Cross
2011-12-21  0:09     ` Colin Cross
2011-12-21  0:09 ` [PATCH 3/3] cpuidle: add support for states that affect multiple cpus Colin Cross
2011-12-21  0:09 ` Colin Cross
2011-12-21  0:09   ` Colin Cross
2011-12-21  9:02 ` [PATCH 0/3] coupled cpuidle state support Arjan van de Ven
2011-12-21  9:02   ` Arjan van de Ven
     [not found]   ` <4EF1A0B4.5080307-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2011-12-21  9:40     ` Colin Cross
2011-12-21  9:40       ` Colin Cross
2011-12-21  9:40       ` Colin Cross
2011-12-21  9:44       ` Arjan van de Ven
2011-12-21  9:44         ` Arjan van de Ven
2011-12-21  9:44         ` Arjan van de Ven
2011-12-21  9:55         ` Colin Cross
     [not found]         ` <4EF1AA8A.8060304-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2011-12-21  9:55           ` Colin Cross
2011-12-21  9:55             ` Colin Cross
2011-12-21  9:55             ` Colin Cross
2011-12-21 12:12             ` Arjan van de Ven
2011-12-21 12:12             ` Arjan van de Ven
2011-12-21 12:12               ` Arjan van de Ven
2011-12-21 19:05               ` Colin Cross
2011-12-21 19:05                 ` Colin Cross
2011-12-21 19:05                 ` Colin Cross
2011-12-21 19:36                 ` Arjan van de Ven
     [not found]                 ` <CAMbhsRRnKoR3YPWrZzVynVe+dcuU5v0siYvmp2vbBcS1hquC7Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-12-21 19:36                   ` Arjan van de Ven
2011-12-21 19:36                     ` Arjan van de Ven
2011-12-21 19:36                     ` Arjan van de Ven
2011-12-21 19:42                     ` Colin Cross
2011-12-21 19:42                       ` [linux-pm] " Colin Cross
2011-12-21 19:42                       ` Colin Cross
2011-12-22  8:35                       ` Shilimkar, Santosh
     [not found]                       ` <CAMbhsRSPCo9MSGp57Fv0sRdYUFcdwx8jEz1-CfX8LdKf8X4MVg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-12-22  8:35                         ` [linux-pm] " Shilimkar, Santosh
2011-12-22  8:35                           ` Shilimkar, Santosh
2011-12-22  8:35                           ` Shilimkar, Santosh
2011-12-22  8:53                           ` Arjan van de Ven
2011-12-22  8:53                             ` [linux-pm] " Arjan van de Ven
2011-12-22  8:53                             ` Arjan van de Ven
2011-12-22  9:30                             ` Shilimkar, Santosh
2011-12-22  9:30                               ` Shilimkar, Santosh
2011-12-22  9:30                             ` Shilimkar, Santosh
     [not found]                             ` <4EF2F01E.8060307-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2011-12-22 21:20                               ` [linux-pm] " Colin Cross
2011-12-22 21:20                                 ` Colin Cross
2011-12-22 21:20                                 ` Colin Cross
2011-12-22 21:20                             ` Colin Cross
     [not found]               ` <4EF1CD49.9020800-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
2012-03-14  0:39                 ` Colin Cross
2012-03-14  0:39                   ` Colin Cross
2012-03-14  0:39                   ` Colin Cross
2011-12-21  9:40   ` Colin Cross
2011-12-21  9:02 ` Arjan van de Ven
2012-01-04  0:41 ` Kevin Hilman
2012-01-04  0:41   ` Kevin Hilman
2012-01-04  0:41   ` Kevin Hilman
2012-01-04 17:27   ` Shilimkar, Santosh
2012-01-04 17:27     ` Shilimkar, Santosh
2012-01-04 17:27   ` Shilimkar, Santosh
2012-01-20  8:46 ` Daniel Lezcano
2012-01-20  8:46   ` Daniel Lezcano
2012-01-20  8:46   ` Daniel Lezcano
2012-01-20 20:40   ` Colin Cross
2012-01-20 20:40     ` Colin Cross
2012-01-20 20:40     ` Colin Cross
2012-01-25 14:04     ` Daniel Lezcano
2012-01-25 14:04       ` Daniel Lezcano
2012-01-31 14:13       ` Daniel Lezcano
2012-01-31 14:13         ` Daniel Lezcano
     [not found]     ` <CAMbhsRTbVqV6p0py9NGZrpFPf2yvp-B0dr+o-m7qbdja_-Lfzw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-01-27  8:54       ` [linux-pm] " Vincent Guittot
2012-01-27  8:54         ` Vincent Guittot
2012-01-27  8:54         ` Vincent Guittot
2012-01-27 17:32         ` Colin Cross
2012-01-27 17:32           ` Colin Cross
2012-01-27 17:32           ` Colin Cross
     [not found]           ` <CAMbhsRQYVXTZ2pX4mBrM6=SyGTqn_GY8xsW4rt_e21zerEzctA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-02-01 12:13             ` Vincent Guittot
2012-02-01 12:13               ` Vincent Guittot
2012-02-01 12:13               ` Vincent Guittot
2012-02-01 14:59               ` Lorenzo Pieralisi
2012-02-01 14:59                 ` [linux-pm] " Lorenzo Pieralisi
2012-02-01 14:59                 ` Lorenzo Pieralisi
2012-02-01 17:30                 ` Colin Cross
2012-02-01 17:30                   ` Colin Cross
2012-02-01 17:30                   ` Colin Cross
2012-02-01 18:07                   ` Lorenzo Pieralisi
2012-02-01 18:07                     ` [linux-pm] " Lorenzo Pieralisi
2012-02-01 18:07                     ` Lorenzo Pieralisi
2012-02-03  1:19                     ` Colin Cross
2012-02-03  1:19                       ` [linux-pm] " Colin Cross
2012-02-03  1:19                       ` Colin Cross
2012-03-13 23:52   ` Kevin Hilman [this message]
2012-03-13 23:52     ` Kevin Hilman
     [not found]     ` <8762e8kqi6.fsf-l0cyMroinI0@public.gmane.org>
2012-03-14  0:28       ` Colin Cross
2012-03-14  0:28         ` Colin Cross
2012-03-14  0:28         ` Colin Cross
2012-03-14  0:47         ` Colin Cross
2012-03-14  0:47           ` Colin Cross
2012-03-14  0:47           ` Colin Cross
     [not found]           ` <CAMbhsRRD2bdkcUZvScb-cF05e=R3h69bNVaTPFX4jBKBBOjuMg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-14 14:23             ` [linux-pm] " Kevin Hilman
2012-03-14 14:23               ` Kevin Hilman
2012-03-14 14:23               ` Kevin Hilman
2012-03-14  2:04     ` Arjan van de Ven
2012-03-14  2:04       ` Arjan van de Ven
2012-03-14  2:04       ` Arjan van de Ven
2012-03-14  2:21       ` Colin Cross
2012-03-14  2:21         ` Colin Cross
2012-03-14  2:21         ` Colin Cross
  -- strict thread matches above, loose matches on Subject: below --
2011-12-21  0:09 Colin Cross

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=8762e8kqi6.fsf@ti.com \
    --to=khilman@ti.com \
    --cc=amit.kucheria@linaro.org \
    --cc=arjan@linux.intel.com \
    --cc=ccross@android.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=deepthi@linux.vnet.ibm.com \
    --cc=g.trinabh@gmail.com \
    --cc=len.brown@intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=santosh.shilimkar@ti.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.