Allow the kernel to poll in the idle loop
PATCH 1/1 Allow the kernel to poll in the idle loop
Hi
The attached patch implements the idle=poll option in the kernel when running on Xen. This causes the kernel to use a polling loop rather than hypercall down to block. I have found this useful to profile the amount of sleep cycles when using xenoprof, there may be other uses.
Thanks
-Amitabha
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Had attached the patch as a binary stream by mistake (default for my mail client). Not sure if thats acceptable for the Xen list. Fixed it.
-Amitabha
Quoted 7 lines · Amitabha Roy
Hi
The attached patch implements the idle=poll option in the kernel when running on Xen. This causes the kernel to use a polling loop rather than hypercall down to block. I have found this useful to profile the amount of sleep cycles when using xenoprof, there may be other uses.
Quoted 7 lines
Thanks
-AmitabhaSigned-off-by Amitabha Roy <[email protected]>
# HG changeset patch
# User [email protected]
# Date 1167640405 -19800
# Node ID 3aeb6af71f7bbc38cf0131840a21d0ee715123f1
# Parent bec95280b565d0e9d6a58480ed17b0963f180e1b
Allow the kernel to use a poll mechanism when idle=poll is specified on the command line.
linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c +33 -4
@@ -101,7 +101,21 @@ void enable_hlt(void)EXPORT_SYMBOL (enable_hlt); -/* XXX XEN doesn't use default_idle(), poll_idle(). Use xen_idle() instead. */ +/* Xen will use either xen_idle() or poll_idle() */ +static void poll_idle (void ) +{ +local_irq_enable (); + + asmvolatile ( +"2:" +"testl %0, %1;" +"rep; nop;" +"je 2b;" + : :"i" (_TIF_NEED_RESCHED),"m" (current_thread_info ()->flags)); +} + + +void xen_idle (void ) {local_irq_disable ();
@@ -162,7 +176,7 @@ void cpu_idle(void)play_dead ();__get_cpu_var (irq_stat).idle_timestamp = jiffies; -xen_idle (); +pm_idle (); }preempt_enable_no_resched ();schedule ();
@@ -198,8 +212,23 @@ void cpu_idle_wait(void) }EXPORT_SYMBOL_GPL (cpu_idle_wait); -/* XXX XEN doesn't use mwait_idle(), select_idle_routine(), idle_setup(). */ -/* Always use xen_idle() instead. */ +/* XEN does idle_setup() to decide if the kernel should poll or call into +* the hypervisor when it has nothing else to do +.*/ + +static int __init idle_setup (char * str){ +if (!strncmp (str,"poll" ,4 )){ +printk ("Using polling idle threads. \n" ); + pm_idle=poll_idle; + } +else { + pm_idle=xen_idle; + } +return 1 ; +} + +__setup ("idle=" , idle_setup); +void __devinit select_idle_routine (const struct cpuinfo_x86 *c) {}void show_regs (struct pt_regs * regs)
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Bug fix to the patch :-$. Need to take care of the case where there is no poll= option on the command line in which case we need to default to xen_idle.
These are the final set of patches. Is anyone interested in having these ? Then I can also work on and send out a similar patch for x86_64.
Thanks
-Amitabha
Quoted 24 lines · Amitabha Roy
Had attached the patch as a binary stream by mistake (default for my mail client). Not sure if thats acceptable for the Xen list. Fixed it.
-Amitabha
Quoted 14 lines · Amitabha Roy
Hi
The attached patch implements the idle=poll option in the kernel when running on Xen. This causes the kernel to use a polling loop rather than hypercall down to block. I have found this useful to profile the amount of sleep cycles when using xenoprof, there may be other uses.
Thanks
-AmitabhaSigned-off-by Amitabha Roy <[email protected]>
# HG changeset patch
# User [email protected]
# Date 1167640405 -19800
# Node ID 3aeb6af71f7bbc38cf0131840a21d0ee715123f1
# Parent bec95280b565d0e9d6a58480ed17b0963f180e1b
Allow the kernel to use a poll mechanism when idle=poll is specified on the command line.
linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c +33 -4
@@ -101,7 +101,21 @@ void enable_hlt(void)EXPORT_SYMBOL (enable_hlt); -/* XXX XEN doesn't use default_idle(), poll_idle(). Use xen_idle() instead. */ +/* Xen will use either xen_idle() or poll_idle() */ +static void poll_idle (void ) +{ +local_irq_enable (); + + asmvolatile ( +"2:" +"testl %0, %1;" +"rep; nop;" +"je 2b;" + : :"i" (_TIF_NEED_RESCHED),"m" (current_thread_info ()->flags)); +} + + +void xen_idle (void ) {local_irq_disable ();
@@ -162,7 +176,7 @@ void cpu_idle(void)play_dead ();__get_cpu_var (irq_stat).idle_timestamp = jiffies; -xen_idle (); +pm_idle (); }preempt_enable_no_resched ();schedule ();
@@ -198,8 +212,23 @@ void cpu_idle_wait(void) }EXPORT_SYMBOL_GPL (cpu_idle_wait); -/* XXX XEN doesn't use mwait_idle(), select_idle_routine(), idle_setup(). */ -/* Always use xen_idle() instead. */ +/* XEN does idle_setup() to decide if the kernel should poll or call into +* the hypervisor when it has nothing else to do +.*/ + +static int __init idle_setup (char * str){ +if (!strncmp (str,"poll" ,4 )){ +printk ("Using polling idle threads. \n" ); + pm_idle=poll_idle; + } +else { + pm_idle=xen_idle; + } +return 1 ; +} + +__setup ("idle=" , idle_setup); +void __devinit select_idle_routine (const struct cpuinfo_x86 *c) {}void show_regs (struct pt_regs * regs)
# HG changeset patch
# User [email protected]
# Date 1167726687 -19800
# Node ID 5b721478d64ba6a5cc56e6a9e3e1b7a501616275
# Parent 3aeb6af71f7bbc38cf0131840a21d0ee715123f1
Implement the poll=idle option, default to xen_idle if nothing is specified
linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c +5 -1
@@ -229,7 +229,11 @@ static int __init idle_setup (char * str__setup ("idle=" , idle_setup); -void __devinit select_idle_routine (const struct cpuinfo_x86 *c) {} +void __devinit select_idle_routine (const struct cpuinfo_x86 *c) { +if (!pm_idle){ + pm_idle=xen_idle; + } +}void show_regs (struct pt_regs * regs) {
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 7 lines · Amitabha Roy
Bug fix to the patch :-$. Need to take care of the case where there is no poll= option on the command line in which case we need to default to
xen_idle.These are the final set of patches. Is anyone interested in having these ? Then I can also work on and send out a similar patch for
x86_64.
Can you please produce one single patch that does everything needed for both i386 and x86/64? We will take the patch if you produce it.
-- Keir
Quoted 5 lines · Keir Fraser
On 2/1/07 08:41, "Amitabha Roy" <[email protected]> wrote:
Can you please produce one single patch that does everything needed for both i386 and x86/64? We will take the patch if you produce it.
Done. The combined i386 and x86_64 patch is attached.
Thanks
-Amitabha
# HG changeset patch
# User [email protected]
# Date 1167751141 -19800
# Node ID 7b571c2e65eb86e73f7a2c8cb67e8acb2d129d82 # Parent 711c31232d71608fe4ea9f4f22ca2620d3faf8ff Added support for idle=poll kernel option.
linux-2.6-xen-sparse/arch/i386/kernel/process-xen.c +38 -5
@@ -101,7 +101,21 @@ void enable_hlt(void)EXPORT_SYMBOL (enable_hlt); -/* XXX XEN doesn't use default_idle(), poll_idle(). Use xen_idle() instead. */ +/* Xen will use either xen_idle() or poll_idle() */ +static void poll_idle (void ) +{ +local_irq_enable (); + + asmvolatile ( +"2:" +"testl %0, %1;" +"rep; nop;" +"je 2b;" + : :"i" (_TIF_NEED_RESCHED),"m" (current_thread_info ()->flags)); +} + + +void xen_idle (void ) {local_irq_disable ();
@@ -162,7 +176,7 @@ void cpu_idle(void)play_dead ();__get_cpu_var (irq_stat).idle_timestamp = jiffies; -xen_idle (); +pm_idle (); }preempt_enable_no_resched ();schedule ();
@@ -198,9 +212,28 @@ void cpu_idle_wait(void) }EXPORT_SYMBOL_GPL (cpu_idle_wait); -/* XXX XEN doesn't use mwait_idle(), select_idle_routine(), idle_setup(). */ -/* Always use xen_idle() instead. */ -void __devinit select_idle_routine (const struct cpuinfo_x86 *c) {} +/* XEN does idle_setup() to decide if the kernel should poll or call into +* the hypervisor when it has nothing else to do +.*/ + +static int __init idle_setup (char * str){ +if (!strncmp (str,"poll" ,4 )){ +printk ("Using polling idle threads. \n" ); + pm_idle=poll_idle; + } +else { + pm_idle=xen_idle; + } +return 1 ; +} + +__setup ("idle=" , idle_setup); + +void __devinit select_idle_routine (const struct cpuinfo_x86 *c) { +if (!pm_idle){ + pm_idle=xen_idle; + } +}void show_regs (struct pt_regs * regs) {
linux-2.6-xen-sparse/arch/x86_64/kernel/process-xen.c +39 -5
62 lines not on this page · raw message
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel