2006-05-09 08:49:08

by Chris Wright

[permalink] [raw]
Subject: [RFC PATCH 22/35] subarch suport for idle loop (NO_IDLE_HZ for Xen)

Paravirtualize the idle loop to explicitly trap to the hypervisor when
blocking, and to use the NO_IDLE_HZ functionality introduced by s390
to inform the rcu subsystem that the CPU is quiescent.

Signed-off-by: Ian Pratt <[email protected]>
Signed-off-by: Christian Limpach <[email protected]>
Signed-off-by: Chris Wright <[email protected]>
---
drivers/xen/Kconfig | 8 ++++++++
include/asm-i386/mach-xen/setup_arch_post.h | 24 ++++++++++++++++++++++++
2 files changed, 32 insertions(+)

--- linus-2.6.orig/drivers/xen/Kconfig
+++ linus-2.6/drivers/xen/Kconfig
@@ -12,6 +12,14 @@ config XEN

if XEN

+config NO_IDLE_HZ
+ bool
+ default y
+ help
+ Switches the regular HZ timer off when the system is going idle.
+ This helps Xen to detect that the Linux system is idle, reducing
+ the overhead of idle systems.
+
config XEN_SHADOW_MODE
bool
default y
--- linus-2.6.orig/include/asm-i386/mach-xen/setup_arch_post.h
+++ linus-2.6/include/asm-i386/mach-xen/setup_arch_post.h
@@ -8,6 +8,11 @@

#include <xen/interface/physdev.h>

+extern void stop_hz_timer(void);
+extern void start_hz_timer(void);
+
+void xen_idle(void);
+
static char * __init machine_specific_memory_setup(void)
{
unsigned long max_pfn = xen_start_info->nr_pages;
@@ -65,4 +70,23 @@ static void __init machine_specific_arch
console_use_vt = 0;
conswitchp = NULL;
}
+
+ pm_idle = xen_idle;
+}
+
+void xen_idle(void)
+{
+ local_irq_disable();
+
+ if (need_resched())
+ local_irq_enable();
+ else {
+ clear_thread_flag(TIF_POLLING_NRFLAG);
+ smp_mb__after_clear_bit();
+ stop_hz_timer();
+ /* Blocking includes an implicit local_irq_enable(). */
+ HYPERVISOR_sched_op(SCHEDOP_block, 0);
+ start_hz_timer();
+ set_thread_flag(TIF_POLLING_NRFLAG);
+ }
}

--


2006-05-09 13:27:08

by Andi Kleen

[permalink] [raw]
Subject: Re: [RFC PATCH 22/35] subarch suport for idle loop (NO_IDLE_HZ for Xen)


> +extern void stop_hz_timer(void);
> +extern void start_hz_timer(void);
> +
> +void xen_idle(void);
> +
> static char * __init machine_specific_memory_setup(void)
> {
> unsigned long max_pfn = xen_start_info->nr_pages;
> @@ -65,4 +70,23 @@ static void __init machine_specific_arch
> console_use_vt = 0;
> conswitchp = NULL;
> }
> +
> + pm_idle = xen_idle;
> +}
> +
> +void xen_idle(void)

I think that should be in some .c file, not a .h

Probably applies to more of your functions too.

-Andi

2006-05-09 15:14:13

by Christian Limpach

[permalink] [raw]
Subject: Re: [RFC PATCH 22/35] subarch suport for idle loop (NO_IDLE_HZ for Xen)

On Tue, May 09, 2006 at 03:21:19PM +0200, Andi Kleen wrote:
>
> > +extern void stop_hz_timer(void);
> > +extern void start_hz_timer(void);
> > +
> > +void xen_idle(void);
> > +
> > static char * __init machine_specific_memory_setup(void)
> > {
> > unsigned long max_pfn = xen_start_info->nr_pages;
> > @@ -65,4 +70,23 @@ static void __init machine_specific_arch
> > console_use_vt = 0;
> > conswitchp = NULL;
> > }
> > +
> > + pm_idle = xen_idle;
> > +}
> > +
> > +void xen_idle(void)
>
> I think that should be in some .c file, not a .h
>
> Probably applies to more of your functions too.

I guess I agree, although I was mostly following the examples in other
mach setup_arch_*.h files.

christian