* [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu
@ 2014-08-15 7:01 Chuansheng Liu
2014-08-15 7:01 ` [PATCH 2/3] smp: re-implement the kick_all_cpus_sync() with wake_up_if_idle() Chuansheng Liu
2014-08-15 7:01 ` [PATCH 3/3] cpuidle: Using the kick_all_cpus_sync() to wake up all cpus Chuansheng Liu
0 siblings, 2 replies; 15+ messages in thread
From: Chuansheng Liu @ 2014-08-15 7:01 UTC (permalink / raw)
To: peterz, luto, daniel.lezcano, rjw, mingo
Cc: linux-pm, linux-kernel, changcheng.liu, xiaoming.wang,
souvik.k.chakravarty, Chuansheng Liu
Implementing one new API wake_up_if_idle(), which is used to
wake up the idle CPU.
Suggested-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
---
include/linux/sched.h | 1 +
kernel/sched/core.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 857ba40..3f89ac1 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1024,6 +1024,7 @@ struct sched_domain_topology_level {
extern struct sched_domain_topology_level *sched_domain_topology;
extern void set_sched_topology(struct sched_domain_topology_level *tl);
+extern void wake_up_if_idle(int cpu);
#ifdef CONFIG_SCHED_DEBUG
# define SD_INIT_NAME(type) .name = #type
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 1211575..adf104f 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1620,6 +1620,22 @@ static void ttwu_queue_remote(struct task_struct *p, int cpu)
}
}
+void wake_up_if_idle(int cpu)
+{
+ struct rq *rq = cpu_rq(cpu);
+ unsigned long flags;
+
+ if (set_nr_if_polling(rq->idle)) {
+ trace_sched_wake_idle_without_ipi(cpu);
+ } else {
+ raw_spin_lock_irqsave(&rq->lock, flags);
+ if (rq->curr == rq->idle)
+ smp_send_reschedule(cpu);
+ /* Else cpu is not in idle, do nothing here */
+ raw_spin_unlock_irqrestore(&rq->lock, flags);
+ }
+}
+
bool cpus_share_cache(int this_cpu, int that_cpu)
{
return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/3] smp: re-implement the kick_all_cpus_sync() with wake_up_if_idle()
2014-08-15 7:01 [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu Chuansheng Liu
@ 2014-08-15 7:01 ` Chuansheng Liu
2014-08-15 15:40 ` Andy Lutomirski
2014-08-15 7:01 ` [PATCH 3/3] cpuidle: Using the kick_all_cpus_sync() to wake up all cpus Chuansheng Liu
1 sibling, 1 reply; 15+ messages in thread
From: Chuansheng Liu @ 2014-08-15 7:01 UTC (permalink / raw)
To: peterz, luto, daniel.lezcano, rjw, mingo
Cc: linux-pm, linux-kernel, changcheng.liu, xiaoming.wang,
souvik.k.chakravarty, Chuansheng Liu
Currently using smp_call_function() just woke up the corresponding
cpu, but can not break the polling idle loop.
Here using the new sched API wake_up_if_idle() to implement it.
Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
---
kernel/smp.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/kernel/smp.c b/kernel/smp.c
index aff8aa1..0b647c3 100644
--- a/kernel/smp.c
+++ b/kernel/smp.c
@@ -13,6 +13,7 @@
#include <linux/gfp.h>
#include <linux/smp.h>
#include <linux/cpu.h>
+#include <linux/sched.h>
#include "smpboot.h"
@@ -677,10 +678,6 @@ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
}
EXPORT_SYMBOL(on_each_cpu_cond);
-static void do_nothing(void *unused)
-{
-}
-
/**
* kick_all_cpus_sync - Force all cpus out of idle
*
@@ -694,8 +691,15 @@ static void do_nothing(void *unused)
*/
void kick_all_cpus_sync(void)
{
- /* Make sure the change is visible before we kick the cpus */
- smp_mb();
- smp_call_function(do_nothing, NULL, 1);
+ int cpu;
+
+ preempt_disable();
+ for_each_online_cpu(cpu) {
+ if (cpu == smp_processor_id())
+ continue;
+
+ wake_up_if_idle(cpu);
+ }
+ preempt_enable();
}
EXPORT_SYMBOL_GPL(kick_all_cpus_sync);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/3] cpuidle: Using the kick_all_cpus_sync() to wake up all cpus
2014-08-15 7:01 [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu Chuansheng Liu
2014-08-15 7:01 ` [PATCH 2/3] smp: re-implement the kick_all_cpus_sync() with wake_up_if_idle() Chuansheng Liu
@ 2014-08-15 7:01 ` Chuansheng Liu
1 sibling, 0 replies; 15+ messages in thread
From: Chuansheng Liu @ 2014-08-15 7:01 UTC (permalink / raw)
To: peterz, luto, daniel.lezcano, rjw, mingo
Cc: linux-pm, linux-kernel, changcheng.liu, xiaoming.wang,
souvik.k.chakravarty, Chuansheng Liu
Current latency notify callback has the same function with
kick_all_cpus_sync().
Here use it directly to remove the redundant code.
Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
---
drivers/cpuidle/cpuidle.c | 7 +------
1 file changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index ee9df5e..7827375 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -530,11 +530,6 @@ EXPORT_SYMBOL_GPL(cpuidle_register);
#ifdef CONFIG_SMP
-static void smp_callback(void *v)
-{
- /* we already woke the CPU up, nothing more to do */
-}
-
/*
* This function gets called when a part of the kernel has a new latency
* requirement. This means we need to get all processors out of their C-state,
@@ -544,7 +539,7 @@ static void smp_callback(void *v)
static int cpuidle_latency_notify(struct notifier_block *b,
unsigned long l, void *v)
{
- smp_call_function(smp_callback, NULL, 1);
+ kick_all_cpus_sync();
return NOTIFY_OK;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 2/3] smp: re-implement the kick_all_cpus_sync() with wake_up_if_idle()
2014-08-15 7:01 ` [PATCH 2/3] smp: re-implement the kick_all_cpus_sync() with wake_up_if_idle() Chuansheng Liu
@ 2014-08-15 15:40 ` Andy Lutomirski
2014-08-18 0:12 ` Liu, Chuansheng
0 siblings, 1 reply; 15+ messages in thread
From: Andy Lutomirski @ 2014-08-15 15:40 UTC (permalink / raw)
To: Chuansheng Liu
Cc: Peter Zijlstra, Daniel Lezcano, Rafael J. Wysocki, Ingo Molnar,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Liu, Changcheng, Wang, Xiaoming, Chakravarty, Souvik K
On Fri, Aug 15, 2014 at 12:01 AM, Chuansheng Liu
<chuansheng.liu@intel.com> wrote:
> Currently using smp_call_function() just woke up the corresponding
> cpu, but can not break the polling idle loop.
>
> Here using the new sched API wake_up_if_idle() to implement it.
kick_all_cpus_sync has other callers, and those other callers want the
old behavior. I think this should be a new function.
--Andy
>
> Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
> ---
> kernel/smp.c | 18 +++++++++++-------
> 1 file changed, 11 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/smp.c b/kernel/smp.c
> index aff8aa1..0b647c3 100644
> --- a/kernel/smp.c
> +++ b/kernel/smp.c
> @@ -13,6 +13,7 @@
> #include <linux/gfp.h>
> #include <linux/smp.h>
> #include <linux/cpu.h>
> +#include <linux/sched.h>
>
> #include "smpboot.h"
>
> @@ -677,10 +678,6 @@ void on_each_cpu_cond(bool (*cond_func)(int cpu, void *info),
> }
> EXPORT_SYMBOL(on_each_cpu_cond);
>
> -static void do_nothing(void *unused)
> -{
> -}
> -
> /**
> * kick_all_cpus_sync - Force all cpus out of idle
> *
> @@ -694,8 +691,15 @@ static void do_nothing(void *unused)
> */
> void kick_all_cpus_sync(void)
> {
> - /* Make sure the change is visible before we kick the cpus */
> - smp_mb();
> - smp_call_function(do_nothing, NULL, 1);
> + int cpu;
> +
> + preempt_disable();
> + for_each_online_cpu(cpu) {
> + if (cpu == smp_processor_id())
> + continue;
> +
> + wake_up_if_idle(cpu);
> + }
> + preempt_enable();
> }
> EXPORT_SYMBOL_GPL(kick_all_cpus_sync);
> --
> 1.7.9.5
>
--
Andy Lutomirski
AMA Capital Management, LLC
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH 2/3] smp: re-implement the kick_all_cpus_sync() with wake_up_if_idle()
2014-08-15 15:40 ` Andy Lutomirski
@ 2014-08-18 0:12 ` Liu, Chuansheng
0 siblings, 0 replies; 15+ messages in thread
From: Liu, Chuansheng @ 2014-08-18 0:12 UTC (permalink / raw)
To: Andy Lutomirski
Cc: Peter Zijlstra, Daniel Lezcano, Rafael J. Wysocki, Ingo Molnar,
linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Liu, Changcheng, Wang, Xiaoming, Chakravarty, Souvik K
Hello Andy,
> -----Original Message-----
> From: Andy Lutomirski [mailto:luto@amacapital.net]
> Sent: Friday, August 15, 2014 11:41 PM
> To: Liu, Chuansheng
> Cc: Peter Zijlstra; Daniel Lezcano; Rafael J. Wysocki; Ingo Molnar;
> linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org; Liu, Changcheng;
> Wang, Xiaoming; Chakravarty, Souvik K
> Subject: Re: [PATCH 2/3] smp: re-implement the kick_all_cpus_sync() with
> wake_up_if_idle()
>
> On Fri, Aug 15, 2014 at 12:01 AM, Chuansheng Liu
> <chuansheng.liu@intel.com> wrote:
> > Currently using smp_call_function() just woke up the corresponding
> > cpu, but can not break the polling idle loop.
> >
> > Here using the new sched API wake_up_if_idle() to implement it.
>
> kick_all_cpus_sync has other callers, and those other callers want the
> old behavior. I think this should be a new function.
>
Yes, seems some current users of kick_all_cpus_sync() need IPI indeed,
will try to send out patch V2 with one new function.
^ permalink raw reply [flat|nested] 15+ messages in thread
* [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu
@ 2014-08-18 8:37 Chuansheng Liu
2014-08-21 1:54 ` Daniel Lezcano
` (2 more replies)
0 siblings, 3 replies; 15+ messages in thread
From: Chuansheng Liu @ 2014-08-18 8:37 UTC (permalink / raw)
To: luto, peterz, daniel.lezcano, rjw, mingo
Cc: linux-pm, linux-kernel, changcheng.liu, xiaoming.wang,
souvik.k.chakravarty, chuansheng.liu
Implementing one new API wake_up_if_idle(), which is used to
wake up the idle CPU.
Suggested-by: Andy Lutomirski <luto@amacapital.net>
Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
---
include/linux/sched.h | 1 +
kernel/sched/core.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/include/linux/sched.h b/include/linux/sched.h
index 857ba40..3f89ac1 100644
--- a/include/linux/sched.h
+++ b/include/linux/sched.h
@@ -1024,6 +1024,7 @@ struct sched_domain_topology_level {
extern struct sched_domain_topology_level *sched_domain_topology;
extern void set_sched_topology(struct sched_domain_topology_level *tl);
+extern void wake_up_if_idle(int cpu);
#ifdef CONFIG_SCHED_DEBUG
# define SD_INIT_NAME(type) .name = #type
diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index 1211575..adf104f 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -1620,6 +1620,22 @@ static void ttwu_queue_remote(struct task_struct *p, int cpu)
}
}
+void wake_up_if_idle(int cpu)
+{
+ struct rq *rq = cpu_rq(cpu);
+ unsigned long flags;
+
+ if (set_nr_if_polling(rq->idle)) {
+ trace_sched_wake_idle_without_ipi(cpu);
+ } else {
+ raw_spin_lock_irqsave(&rq->lock, flags);
+ if (rq->curr == rq->idle)
+ smp_send_reschedule(cpu);
+ /* Else cpu is not in idle, do nothing here */
+ raw_spin_unlock_irqrestore(&rq->lock, flags);
+ }
+}
+
bool cpus_share_cache(int this_cpu, int that_cpu)
{
return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
--
1.7.9.5
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu
2014-08-18 8:37 [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu Chuansheng Liu
@ 2014-08-21 1:54 ` Daniel Lezcano
2014-08-21 2:12 ` Liu, Chuansheng
2014-08-21 21:21 ` Andy Lutomirski
2014-09-03 9:51 ` Peter Zijlstra
2 siblings, 1 reply; 15+ messages in thread
From: Daniel Lezcano @ 2014-08-21 1:54 UTC (permalink / raw)
To: Chuansheng Liu, luto, peterz, rjw, mingo
Cc: linux-pm, linux-kernel, changcheng.liu, xiaoming.wang,
souvik.k.chakravarty
On 08/18/2014 10:37 AM, Chuansheng Liu wrote:
> Implementing one new API wake_up_if_idle(), which is used to
> wake up the idle CPU.
Is this patchset tested ? Did you check it solves the issue you were
facing ?
> Suggested-by: Andy Lutomirski <luto@amacapital.net>
> Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
> ---
> include/linux/sched.h | 1 +
> kernel/sched/core.c | 16 ++++++++++++++++
> 2 files changed, 17 insertions(+)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 857ba40..3f89ac1 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1024,6 +1024,7 @@ struct sched_domain_topology_level {
> extern struct sched_domain_topology_level *sched_domain_topology;
>
> extern void set_sched_topology(struct sched_domain_topology_level *tl);
> +extern void wake_up_if_idle(int cpu);
>
> #ifdef CONFIG_SCHED_DEBUG
> # define SD_INIT_NAME(type) .name = #type
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 1211575..adf104f 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1620,6 +1620,22 @@ static void ttwu_queue_remote(struct task_struct *p, int cpu)
> }
> }
>
> +void wake_up_if_idle(int cpu)
> +{
> + struct rq *rq = cpu_rq(cpu);
> + unsigned long flags;
> +
> + if (set_nr_if_polling(rq->idle)) {
> + trace_sched_wake_idle_without_ipi(cpu);
> + } else {
> + raw_spin_lock_irqsave(&rq->lock, flags);
> + if (rq->curr == rq->idle)
> + smp_send_reschedule(cpu);
> + /* Else cpu is not in idle, do nothing here */
> + raw_spin_unlock_irqrestore(&rq->lock, flags);
> + }
> +}
> +
> bool cpus_share_cache(int this_cpu, int that_cpu)
> {
> return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
>
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu
2014-08-21 1:54 ` Daniel Lezcano
@ 2014-08-21 2:12 ` Liu, Chuansheng
2014-08-21 3:48 ` Daniel Lezcano
0 siblings, 1 reply; 15+ messages in thread
From: Liu, Chuansheng @ 2014-08-21 2:12 UTC (permalink / raw)
To: Daniel Lezcano, luto@amacapital.net, peterz@infradead.org,
rjw@rjwysocki.net, mingo@redhat.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Liu, Changcheng, Wang, Xiaoming, Chakravarty, Souvik K
Hello Daniel,
> -----Original Message-----
> From: Daniel Lezcano [mailto:daniel.lezcano@linaro.org]
> Sent: Thursday, August 21, 2014 9:54 AM
> To: Liu, Chuansheng; luto@amacapital.net; peterz@infradead.org;
> rjw@rjwysocki.net; mingo@redhat.com
> Cc: linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org; Liu, Changcheng;
> Wang, Xiaoming; Chakravarty, Souvik K
> Subject: Re: [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the
> idle cpu
>
> On 08/18/2014 10:37 AM, Chuansheng Liu wrote:
> > Implementing one new API wake_up_if_idle(), which is used to
> > wake up the idle CPU.
>
> Is this patchset tested ? Did you check it solves the issue you were
> facing ?
We have done the basic test, and found the cores can exit C0 quickly with this patchset.
Basically once the _TIF_NEED_RESCHED is set, then the poll_idle() can be broken.
Please correct me if something is wrong, thanks.
>
> > Suggested-by: Andy Lutomirski <luto@amacapital.net>
> > Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
> > ---
> > include/linux/sched.h | 1 +
> > kernel/sched/core.c | 16 ++++++++++++++++
> > 2 files changed, 17 insertions(+)
> >
> > diff --git a/include/linux/sched.h b/include/linux/sched.h
> > index 857ba40..3f89ac1 100644
> > --- a/include/linux/sched.h
> > +++ b/include/linux/sched.h
> > @@ -1024,6 +1024,7 @@ struct sched_domain_topology_level {
> > extern struct sched_domain_topology_level *sched_domain_topology;
> >
> > extern void set_sched_topology(struct sched_domain_topology_level *tl);
> > +extern void wake_up_if_idle(int cpu);
> >
> > #ifdef CONFIG_SCHED_DEBUG
> > # define SD_INIT_NAME(type) .name = #type
> > diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> > index 1211575..adf104f 100644
> > --- a/kernel/sched/core.c
> > +++ b/kernel/sched/core.c
> > @@ -1620,6 +1620,22 @@ static void ttwu_queue_remote(struct
> task_struct *p, int cpu)
> > }
> > }
> >
> > +void wake_up_if_idle(int cpu)
> > +{
> > + struct rq *rq = cpu_rq(cpu);
> > + unsigned long flags;
> > +
> > + if (set_nr_if_polling(rq->idle)) {
> > + trace_sched_wake_idle_without_ipi(cpu);
> > + } else {
> > + raw_spin_lock_irqsave(&rq->lock, flags);
> > + if (rq->curr == rq->idle)
> > + smp_send_reschedule(cpu);
> > + /* Else cpu is not in idle, do nothing here */
> > + raw_spin_unlock_irqrestore(&rq->lock, flags);
> > + }
> > +}
> > +
> > bool cpus_share_cache(int this_cpu, int that_cpu)
> > {
> > return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
> >
>
>
> --
> <http://www.linaro.org/> Linaro.org │ Open source software for ARM
> SoCs
>
> Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu
2014-08-21 2:12 ` Liu, Chuansheng
@ 2014-08-21 3:48 ` Daniel Lezcano
0 siblings, 0 replies; 15+ messages in thread
From: Daniel Lezcano @ 2014-08-21 3:48 UTC (permalink / raw)
To: Liu, Chuansheng, luto@amacapital.net, peterz@infradead.org,
rjw@rjwysocki.net, mingo@redhat.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Liu, Changcheng, Wang, Xiaoming, Chakravarty, Souvik K
On 08/21/2014 04:12 AM, Liu, Chuansheng wrote:
> Hello Daniel,
>
>> -----Original Message-----
>> From: Daniel Lezcano [mailto:daniel.lezcano@linaro.org]
>> Sent: Thursday, August 21, 2014 9:54 AM
>> To: Liu, Chuansheng; luto@amacapital.net; peterz@infradead.org;
>> rjw@rjwysocki.net; mingo@redhat.com
>> Cc: linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org; Liu, Changcheng;
>> Wang, Xiaoming; Chakravarty, Souvik K
>> Subject: Re: [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the
>> idle cpu
>>
>> On 08/18/2014 10:37 AM, Chuansheng Liu wrote:
>>> Implementing one new API wake_up_if_idle(), which is used to
>>> wake up the idle CPU.
>>
>> Is this patchset tested ? Did you check it solves the issue you were
>> facing ?
> We have done the basic test, and found the cores can exit C0 quickly with this patchset.
> Basically once the _TIF_NEED_RESCHED is set, then the poll_idle() can be broken.
>
> Please correct me if something is wrong, thanks.
Actually, it was not clear for me if this patch was a proposal or not.
I will review it.
Thanks
-- Daniel
>>> Suggested-by: Andy Lutomirski <luto@amacapital.net>
>>> Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
>>> ---
>>> include/linux/sched.h | 1 +
>>> kernel/sched/core.c | 16 ++++++++++++++++
>>> 2 files changed, 17 insertions(+)
>>>
>>> diff --git a/include/linux/sched.h b/include/linux/sched.h
>>> index 857ba40..3f89ac1 100644
>>> --- a/include/linux/sched.h
>>> +++ b/include/linux/sched.h
>>> @@ -1024,6 +1024,7 @@ struct sched_domain_topology_level {
>>> extern struct sched_domain_topology_level *sched_domain_topology;
>>>
>>> extern void set_sched_topology(struct sched_domain_topology_level *tl);
>>> +extern void wake_up_if_idle(int cpu);
>>>
>>> #ifdef CONFIG_SCHED_DEBUG
>>> # define SD_INIT_NAME(type) .name = #type
>>> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
>>> index 1211575..adf104f 100644
>>> --- a/kernel/sched/core.c
>>> +++ b/kernel/sched/core.c
>>> @@ -1620,6 +1620,22 @@ static void ttwu_queue_remote(struct
>> task_struct *p, int cpu)
>>> }
>>> }
>>>
>>> +void wake_up_if_idle(int cpu)
>>> +{
>>> + struct rq *rq = cpu_rq(cpu);
>>> + unsigned long flags;
>>> +
>>> + if (set_nr_if_polling(rq->idle)) {
>>> + trace_sched_wake_idle_without_ipi(cpu);
>>> + } else {
>>> + raw_spin_lock_irqsave(&rq->lock, flags);
>>> + if (rq->curr == rq->idle)
>>> + smp_send_reschedule(cpu);
>>> + /* Else cpu is not in idle, do nothing here */
>>> + raw_spin_unlock_irqrestore(&rq->lock, flags);
>>> + }
>>> +}
>>> +
>>> bool cpus_share_cache(int this_cpu, int that_cpu)
>>> {
>>> return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
>>>
>>
>>
>> --
>> <http://www.linaro.org/> Linaro.org │ Open source software for ARM
>> SoCs
>>
>> Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
>> <http://twitter.com/#!/linaroorg> Twitter |
>> <http://www.linaro.org/linaro-blog/> Blog
>
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu
2014-08-18 8:37 [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu Chuansheng Liu
2014-08-21 1:54 ` Daniel Lezcano
@ 2014-08-21 21:21 ` Andy Lutomirski
2014-09-03 9:54 ` Peter Zijlstra
2014-09-03 9:51 ` Peter Zijlstra
2 siblings, 1 reply; 15+ messages in thread
From: Andy Lutomirski @ 2014-08-21 21:21 UTC (permalink / raw)
To: Chuansheng Liu
Cc: linux-pm@vger.kernel.org, Rafael J. Wysocki, Daniel Lezcano,
Wang, Xiaoming, Ingo Molnar, Chakravarty, Souvik K,
Liu, Changcheng, Peter Zijlstra, linux-kernel@vger.kernel.org
On Aug 18, 2014 3:52 AM, "Chuansheng Liu" <chuansheng.liu@intel.com> wrote:
>
> Implementing one new API wake_up_if_idle(), which is used to
> wake up the idle CPU.
>
> Suggested-by: Andy Lutomirski <luto@amacapital.net>
> Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
> ---
> include/linux/sched.h | 1 +
> kernel/sched/core.c | 16 ++++++++++++++++
> 2 files changed, 17 insertions(+)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 857ba40..3f89ac1 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1024,6 +1024,7 @@ struct sched_domain_topology_level {
> extern struct sched_domain_topology_level *sched_domain_topology;
>
> extern void set_sched_topology(struct sched_domain_topology_level *tl);
> +extern void wake_up_if_idle(int cpu);
>
> #ifdef CONFIG_SCHED_DEBUG
> # define SD_INIT_NAME(type) .name = #type
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 1211575..adf104f 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1620,6 +1620,22 @@ static void ttwu_queue_remote(struct task_struct *p, int cpu)
> }
> }
>
> +void wake_up_if_idle(int cpu)
> +{
> + struct rq *rq = cpu_rq(cpu);
> + unsigned long flags;
> +
> + if (set_nr_if_polling(rq->idle)) {
> + trace_sched_wake_idle_without_ipi(cpu);
> + } else {
> +
FWIW, adding:
if (rq->curr != rq->idle)
return;
Right here could improve performance on large, mostly non-idle
systems. It would skip the spinlock in most cases.
I don't know whether this code is relevant on systems like that, though.
raw_spin_lock_irqsave(&rq->lock, flags);
> + if (rq->curr == rq->idle)
> + smp_send_reschedule(cpu);
> + /* Else cpu is not in idle, do nothing here */
> + raw_spin_unlock_irqrestore(&rq->lock, flags);
> + }
> +
--Andy
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu
2014-08-18 8:37 [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu Chuansheng Liu
2014-08-21 1:54 ` Daniel Lezcano
2014-08-21 21:21 ` Andy Lutomirski
@ 2014-09-03 9:51 ` Peter Zijlstra
2 siblings, 0 replies; 15+ messages in thread
From: Peter Zijlstra @ 2014-09-03 9:51 UTC (permalink / raw)
To: Chuansheng Liu
Cc: luto, daniel.lezcano, rjw, mingo, linux-pm, linux-kernel,
changcheng.liu, xiaoming.wang, souvik.k.chakravarty
On Mon, Aug 18, 2014 at 04:37:30PM +0800, Chuansheng Liu wrote:
> Implementing one new API wake_up_if_idle(), which is used to
> wake up the idle CPU.
>
> Suggested-by: Andy Lutomirski <luto@amacapital.net>
> Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
> ---
> include/linux/sched.h | 1 +
> kernel/sched/core.c | 16 ++++++++++++++++
> 2 files changed, 17 insertions(+)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 857ba40..3f89ac1 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1024,6 +1024,7 @@ struct sched_domain_topology_level {
> extern struct sched_domain_topology_level *sched_domain_topology;
>
> extern void set_sched_topology(struct sched_domain_topology_level *tl);
> +extern void wake_up_if_idle(int cpu);
>
> #ifdef CONFIG_SCHED_DEBUG
> # define SD_INIT_NAME(type) .name = #type
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 1211575..adf104f 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1620,6 +1620,22 @@ static void ttwu_queue_remote(struct task_struct *p, int cpu)
> }
> }
>
> +void wake_up_if_idle(int cpu)
> +{
> + struct rq *rq = cpu_rq(cpu);
> + unsigned long flags;
> +
> + if (set_nr_if_polling(rq->idle)) {
> + trace_sched_wake_idle_without_ipi(cpu);
> + } else {
> + raw_spin_lock_irqsave(&rq->lock, flags);
> + if (rq->curr == rq->idle)
That needs to be is_idle_task(), there might be other 'idle' tasks than
rq->idle :/
> + smp_send_reschedule(cpu);
> + /* Else cpu is not in idle, do nothing here */
> + raw_spin_unlock_irqrestore(&rq->lock, flags);
> + }
> +}
> +
> bool cpus_share_cache(int this_cpu, int that_cpu)
> {
> return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
> --
> 1.7.9.5
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu
2014-08-21 21:21 ` Andy Lutomirski
@ 2014-09-03 9:54 ` Peter Zijlstra
2014-09-03 9:58 ` Liu, Chuansheng
0 siblings, 1 reply; 15+ messages in thread
From: Peter Zijlstra @ 2014-09-03 9:54 UTC (permalink / raw)
To: Andy Lutomirski
Cc: Chuansheng Liu, linux-pm@vger.kernel.org, Rafael J. Wysocki,
Daniel Lezcano, Wang, Xiaoming, Ingo Molnar,
Chakravarty, Souvik K, Liu, Changcheng,
linux-kernel@vger.kernel.org
On Thu, Aug 21, 2014 at 02:21:51PM -0700, Andy Lutomirski wrote:
> On Aug 18, 2014 3:52 AM, "Chuansheng Liu" <chuansheng.liu@intel.com> wrote:
> > +void wake_up_if_idle(int cpu)
> > +{
> > + struct rq *rq = cpu_rq(cpu);
> > + unsigned long flags;
> > +
> > + if (set_nr_if_polling(rq->idle)) {
> > + trace_sched_wake_idle_without_ipi(cpu);
> > + } else {
> > +
>
> FWIW, adding:
>
> if (rq->curr != rq->idle)
> return;
>
> Right here could improve performance on large, mostly non-idle
> systems. It would skip the spinlock in most cases.
>
!is_idle_task() :-)
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu
2014-09-03 9:54 ` Peter Zijlstra
@ 2014-09-03 9:58 ` Liu, Chuansheng
0 siblings, 0 replies; 15+ messages in thread
From: Liu, Chuansheng @ 2014-09-03 9:58 UTC (permalink / raw)
To: Peter Zijlstra, Andy Lutomirski
Cc: linux-pm@vger.kernel.org, Rafael J. Wysocki, Daniel Lezcano,
Wang, Xiaoming, Ingo Molnar, Chakravarty, Souvik K,
Liu, Changcheng, linux-kernel@vger.kernel.org
> -----Original Message-----
> From: Peter Zijlstra [mailto:peterz@infradead.org]
> Sent: Wednesday, September 03, 2014 5:54 PM
> To: Andy Lutomirski
> Cc: Liu, Chuansheng; linux-pm@vger.kernel.org; Rafael J. Wysocki; Daniel
> Lezcano; Wang, Xiaoming; Ingo Molnar; Chakravarty, Souvik K; Liu, Changcheng;
> linux-kernel@vger.kernel.org
> Subject: Re: [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the
> idle cpu
>
> On Thu, Aug 21, 2014 at 02:21:51PM -0700, Andy Lutomirski wrote:
> > On Aug 18, 2014 3:52 AM, "Chuansheng Liu" <chuansheng.liu@intel.com>
> wrote:
>
> > > +void wake_up_if_idle(int cpu)
> > > +{
> > > + struct rq *rq = cpu_rq(cpu);
> > > + unsigned long flags;
> > > +
> > > + if (set_nr_if_polling(rq->idle)) {
> > > + trace_sched_wake_idle_without_ipi(cpu);
> > > + } else {
> > > +
> >
> > FWIW, adding:
> >
> > if (rq->curr != rq->idle)
> > return;
> >
> > Right here could improve performance on large, mostly non-idle
> > systems. It would skip the spinlock in most cases.
> >
>
> !is_idle_task() :-)
Thanks Peter and Andy, will refine the patches again:)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu
[not found] <1409815075-4180-1-git-send-email-chuansheng.liu@intel.com>
@ 2014-09-04 12:53 ` Daniel Lezcano
2014-09-04 12:59 ` Liu, Chuansheng
0 siblings, 1 reply; 15+ messages in thread
From: Daniel Lezcano @ 2014-09-04 12:53 UTC (permalink / raw)
To: Chuansheng Liu, peterz, luto, rjw, mingo
Cc: linux-pm, linux-kernel, changcheng.liu, xiaoming.wang,
souvik.k.chakravarty
On 09/04/2014 09:17 AM, Chuansheng Liu wrote:
> Implementing one new API wake_up_if_idle(), which is used to
> wake up the idle CPU.
>
> Suggested-by: Andy Lutomirski <luto@amacapital.net>
> Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
Hi Chuanseng,
in the future, please prefix the patches with the version number and a
changelog.
Thanks
-- Daniel
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
> ---
> include/linux/sched.h | 1 +
> kernel/sched/core.c | 19 +++++++++++++++++++
> 2 files changed, 20 insertions(+)
>
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index 857ba40..3f89ac1 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1024,6 +1024,7 @@ struct sched_domain_topology_level {
> extern struct sched_domain_topology_level *sched_domain_topology;
>
> extern void set_sched_topology(struct sched_domain_topology_level *tl);
> +extern void wake_up_if_idle(int cpu);
>
> #ifdef CONFIG_SCHED_DEBUG
> # define SD_INIT_NAME(type) .name = #type
> diff --git a/kernel/sched/core.c b/kernel/sched/core.c
> index 1211575..b818548 100644
> --- a/kernel/sched/core.c
> +++ b/kernel/sched/core.c
> @@ -1620,6 +1620,25 @@ static void ttwu_queue_remote(struct task_struct *p, int cpu)
> }
> }
>
> +void wake_up_if_idle(int cpu)
> +{
> + struct rq *rq = cpu_rq(cpu);
> + unsigned long flags;
> +
> + if (!is_idle_task(rq->curr))
> + return;
> +
> + if (set_nr_if_polling(rq->idle)) {
> + trace_sched_wake_idle_without_ipi(cpu);
> + } else {
> + raw_spin_lock_irqsave(&rq->lock, flags);
> + if (is_idle_task(rq->curr))
> + smp_send_reschedule(cpu);
> + /* Else cpu is not in idle, do nothing here */
> + raw_spin_unlock_irqrestore(&rq->lock, flags);
> + }
> +}
> +
> bool cpus_share_cache(int this_cpu, int that_cpu)
> {
> return per_cpu(sd_llc_id, this_cpu) == per_cpu(sd_llc_id, that_cpu);
>
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 15+ messages in thread
* RE: [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu
2014-09-04 12:53 ` Daniel Lezcano
@ 2014-09-04 12:59 ` Liu, Chuansheng
0 siblings, 0 replies; 15+ messages in thread
From: Liu, Chuansheng @ 2014-09-04 12:59 UTC (permalink / raw)
To: Daniel Lezcano, peterz@infradead.org, luto@amacapital.net,
rjw@rjwysocki.net, mingo@redhat.com
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
Liu, Changcheng, Wang, Xiaoming, Chakravarty, Souvik K
> -----Original Message-----
> From: Daniel Lezcano [mailto:daniel.lezcano@linaro.org]
> Sent: Thursday, September 04, 2014 8:53 PM
> To: Liu, Chuansheng; peterz@infradead.org; luto@amacapital.net;
> rjw@rjwysocki.net; mingo@redhat.com
> Cc: linux-pm@vger.kernel.org; linux-kernel@vger.kernel.org; Liu, Changcheng;
> Wang, Xiaoming; Chakravarty, Souvik K
> Subject: Re: [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the
> idle cpu
>
> On 09/04/2014 09:17 AM, Chuansheng Liu wrote:
> > Implementing one new API wake_up_if_idle(), which is used to
> > wake up the idle CPU.
> >
> > Suggested-by: Andy Lutomirski <luto@amacapital.net>
> > Signed-off-by: Chuansheng Liu <chuansheng.liu@intel.com>
>
> Hi Chuanseng,
>
> in the future, please prefix the patches with the version number and a
> changelog.
>
Thanks your advice, Daniel, will do that next time:)
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2014-09-04 12:59 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-15 7:01 [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu Chuansheng Liu
2014-08-15 7:01 ` [PATCH 2/3] smp: re-implement the kick_all_cpus_sync() with wake_up_if_idle() Chuansheng Liu
2014-08-15 15:40 ` Andy Lutomirski
2014-08-18 0:12 ` Liu, Chuansheng
2014-08-15 7:01 ` [PATCH 3/3] cpuidle: Using the kick_all_cpus_sync() to wake up all cpus Chuansheng Liu
-- strict thread matches above, loose matches on Subject: below --
2014-08-18 8:37 [PATCH 1/3] sched: Add new API wake_up_if_idle() to wake up the idle cpu Chuansheng Liu
2014-08-21 1:54 ` Daniel Lezcano
2014-08-21 2:12 ` Liu, Chuansheng
2014-08-21 3:48 ` Daniel Lezcano
2014-08-21 21:21 ` Andy Lutomirski
2014-09-03 9:54 ` Peter Zijlstra
2014-09-03 9:58 ` Liu, Chuansheng
2014-09-03 9:51 ` Peter Zijlstra
[not found] <1409815075-4180-1-git-send-email-chuansheng.liu@intel.com>
2014-09-04 12:53 ` Daniel Lezcano
2014-09-04 12:59 ` Liu, Chuansheng
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).