diff mbox

[2/5] xen: ARM: suspend the tick (if in use) when going idle.

Message ID 150114247733.22910.14569496365405374593.stgit@Solace (mailing list archive)
State New, archived
Headers show

Commit Message

Dario Faggioli July 27, 2017, 8:01 a.m. UTC
Since commit 964fae8ac ("cpuidle: suspend/resume scheduler
tick timer during cpu idle state entry/exit"), if a scheduler
has a periodic tick timer, we stop it when going idle.

This, however, is only true for x86. Make it true for ARM as
well.

Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Julien Grall <julien.grall@arm.com>
---
 xen/arch/arm/domain.c |   29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

Comments

Stefano Stabellini July 31, 2017, 8:59 p.m. UTC | #1
On Thu, 27 Jul 2017, Dario Faggioli wrote:
> Since commit 964fae8ac ("cpuidle: suspend/resume scheduler
> tick timer during cpu idle state entry/exit"), if a scheduler
> has a periodic tick timer, we stop it when going idle.
> 
> This, however, is only true for x86. Make it true for ARM as
> well.
> 
> Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>

Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>


> ---
> Cc: Stefano Stabellini <sstabellini@kernel.org>
> Cc: Julien Grall <julien.grall@arm.com>
> ---
>  xen/arch/arm/domain.c |   29 ++++++++++++++++++++---------
>  1 file changed, 20 insertions(+), 9 deletions(-)
> 
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index 2dc8b0a..fce29cb 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -39,6 +39,25 @@
>  
>  DEFINE_PER_CPU(struct vcpu *, curr_vcpu);
>  
> +static void do_idle(void)
> +{
> +    unsigned int cpu = smp_processor_id();
> +
> +    sched_tick_suspend();
> +    /* sched_tick_suspend() can raise TIMER_SOFTIRQ. Process it now. */
> +    process_pending_softirqs();
> +
> +    local_irq_disable();
> +    if ( cpu_is_haltable(cpu) )
> +    {
> +        dsb(sy);
> +        wfi();
> +    }
> +    local_irq_enable();
> +
> +    sched_tick_resume();
> +}
> +
>  void idle_loop(void)
>  {
>      unsigned int cpu = smp_processor_id();
> @@ -52,15 +71,7 @@ void idle_loop(void)
>          if ( unlikely(tasklet_work_to_do(cpu)) )
>              do_tasklet();
>          else
> -        {
> -            local_irq_disable();
> -            if ( cpu_is_haltable(cpu) )
> -            {
> -                dsb(sy);
> -                wfi();
> -            }
> -            local_irq_enable();
> -        }
> +            do_idle();
>  
>          do_softirq();
>          /*
>
Julien Grall Aug. 1, 2017, 8:53 a.m. UTC | #2
Hi Stefano,

On 31/07/2017 21:59, Stefano Stabellini wrote:
> On Thu, 27 Jul 2017, Dario Faggioli wrote:
>> Since commit 964fae8ac ("cpuidle: suspend/resume scheduler
>> tick timer during cpu idle state entry/exit"), if a scheduler
>> has a periodic tick timer, we stop it when going idle.
>>
>> This, however, is only true for x86. Make it true for ARM as
>> well.
>>
>> Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

This patch looks standalone, but please don't commit this patch without 
the rest of the series. Otherwise, we will introduce regression in Xen 
with credit1 as well.

Cheers,
Dario Faggioli Aug. 1, 2017, 9:26 a.m. UTC | #3
On Tue, 2017-08-01 at 09:53 +0100, Julien Grall wrote:
> On 31/07/2017 21:59, Stefano Stabellini wrote:
> > On Thu, 27 Jul 2017, Dario Faggioli wrote:
> > > 
> > > Signed-off-by: Dario Faggioli <dario.faggioli@citrix.com>
> > 
> > Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
> 
> This patch looks standalone, but please don't commit this patch
> without 
> the rest of the series. Otherwise, we will introduce regression in
> Xen 
> with credit1 as well.
> 
I'm not sure I'd call that a "regression". In fact, the current
situation is that the code has a bug, but the absence of this power-
efficiency optimization, on ARM, is covering the bug itself. :-D

Anyway, zero intention to turn this into a terminology bunfight, and,
overall, I even agree with you that it's probably better that this
series go in all-together. :-)

Regards,
Dario
diff mbox

Patch

diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 2dc8b0a..fce29cb 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -39,6 +39,25 @@ 
 
 DEFINE_PER_CPU(struct vcpu *, curr_vcpu);
 
+static void do_idle(void)
+{
+    unsigned int cpu = smp_processor_id();
+
+    sched_tick_suspend();
+    /* sched_tick_suspend() can raise TIMER_SOFTIRQ. Process it now. */
+    process_pending_softirqs();
+
+    local_irq_disable();
+    if ( cpu_is_haltable(cpu) )
+    {
+        dsb(sy);
+        wfi();
+    }
+    local_irq_enable();
+
+    sched_tick_resume();
+}
+
 void idle_loop(void)
 {
     unsigned int cpu = smp_processor_id();
@@ -52,15 +71,7 @@  void idle_loop(void)
         if ( unlikely(tasklet_work_to_do(cpu)) )
             do_tasklet();
         else
-        {
-            local_irq_disable();
-            if ( cpu_is_haltable(cpu) )
-            {
-                dsb(sy);
-                wfi();
-            }
-            local_irq_enable();
-        }
+            do_idle();
 
         do_softirq();
         /*