xen/x86: Be more power-efficient when waiting forever
PATCH 1/1 xen/x86: Be more power-efficient when waiting forever
The effect is unchanged, but the processor will be spending most of its time in the C1 or C1E power state rather than C0.
---
This was discovered while I was playing about in the early_page_fault() handler with the IBM box which was corruption the Xen code section.
There is one final for(;;); loop, but is in common code and immediately following a call to panic(), so is actually dead code and will be cleaned up in v2 of my "noreturn" series at the start of 4.5
George: I am requesting that this get a freeze exception, under the qualification of #2 "An awesome release", given no function change threatening
--- xen/arch/x86/efi/boot.c | 3 ++- xen/arch/x86/traps.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
xen/arch/x86/efi/boot.c +2 -1
@@ -201,7 +201,8 @@ static void __init __attribute__((__noreturn__)) blexit(const CHAR16 *str) efi_bs->FreePages (xsm.addr,PFN_UP (xsm.size)); efi_bs->Exit (efi_ih,EFI_SUCCESS ,0 ,NULL ); -for ( ; ; );/* not reached */ +for ( ; ; )/* not reached */ +halt (); }/* generic routine for printing error messages */
xen/arch/x86/traps.c +2 -1
@@ -1448,7 +1448,8 @@ void __init do_early_page_fault(struct cpu_user_regs *regs)printk ("Stack dump: " );while ( ((long )stk & ((PAGE_SIZE -1 ) & ~(BYTES_PER_LONG -1 ))) !=0 )printk ("%p " ,_p (*stk++)); -for ( ; ; ) ; +for ( ; ; ) +halt (); } }
Signature · 1 line
1.7.10.4
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
There is one final for(;;); loop, but is in common code and immediately following a call to
panic(), so is actually dead code and will be cleaned up in v2 of my "noreturn" series at the start of 4.5
In the context of this, this one ...
xen/arch/x86/efi/boot.c static void __init __attribute__((__noreturn__)) · line 206
Quoted 10 lines
xen/arch/x86/efi/boot.c +2
-1@@ -201,7 +201,8 @@ static void __init __attribute__((__noreturn__)) blexit(const CHAR16 *str) efi_bs->FreePages(xsm.addr, PFN_UP(xsm.size)); efi_bs->Exit (efi_ih,EFI_SUCCESS ,0 ,NULL ); -for ( ; ; );/* not reached */ +for ( ; ; )/* not reached */ +halt ();
... seems pointless (but of course also not wrong).
xen/arch/x86/traps.c void __init do_early_page_fault(struct cpu_user_regs *regs) · line 1452
Quoted 9 lines
xen/arch/x86/traps.c +2
-1@@ -1448,7 +1448,8 @@ void __init do_early_page_fault(struct cpu_user_regs *regs)printk ("Stack dump: " );while ( ((long )stk & ((PAGE_SIZE -1 ) & ~(BYTES_PER_LONG -1 ))) !=0 )printk ("%p " ,_p (*stk++)); -for ( ; ; ) ; +for ( ; ; ) +halt ();
While clearly this one is desirable.
Jan
Quoted 12 lines · Jan Beulich
Quoted 4 lines
Quoted 1 line
Quoted 1 line · Andrew Cooper
There is one final for(;;); loop, but is in common code and immediately following a call to
panic(), so is actually dead code and will be cleaned up in v2 of my "noreturn" series at the start of 4.5In the context of this, this one ...
Quoted 6 lines
xen/arch/x86/efi/boot.c +0
-0@@ -201,7 +201,8 @@ static void __init __attribute__((__noreturn__)) blexit(const CHAR16 *str) efi_bs->FreePages(xsm.addr, PFN_UP(xsm.size));
Quoted 5 lines
xen/arch/x86/efi/boot.c static void __init __attribute__((__noreturn__)) blexit(const CHAR16 *str) · line 205
Quoted 4 lines
xen/arch/x86/efi/boot.c +2
-1efi_bs->Exit (efi_ih,EFI_SUCCESS ,0 ,NULL ); -for ( ; ; );/* not reached */ +for ( ; ; )/* not reached */ +halt ();... seems pointless (but of course also not wrong).
I suppose - I guess all that is needed here is for the compiler to find no way to the end of this function.
I wonder whether an "unreachable()" would suffice? In the optimal case, the compiler should not emit any instructions for it.
~Andrew
Quoted 14 lines
xen/arch/x86/traps.c void __init do_early_page_fault(struct cpu_user_regs *regs) · line 1452
Quoted 10 lines
xen/arch/x86/traps.c +2
-1@@ -1448,7 +1448,8 @@ void __init do_early_page_fault(struct cpu_user_regs *regs)printk ("Stack dump: " );while ( ((long )stk & ((PAGE_SIZE -1 ) & ~(BYTES_PER_LONG -1 ))) !=0 )printk ("%p " ,_p (*stk++)); -for ( ; ; ) ; +for ( ; ; ) +halt ();While clearly this one is desirable.
Jan
Quoted 7 lines · Andrew Cooper
The effect is unchanged, but the processor will be spending most of its time in the C1 or C1E power state rather than C0.
Signed-off-by Andrew Cooper <[email protected]>CC Keir Fraser <[email protected]>CC Jan Beulich <[email protected]>CC George Dunlap <[email protected]>
Quoted 47 lines
---
This was discovered while I was playing about in the
early_page_fault()handler with the IBM box which was corruption the Xen code section.There is one final for(;;); loop, but is in common code and immediately following a call to
panic(), so is actually dead code and will be cleaned up in v2 of my "noreturn" series at the start of 4.5George: I am requesting that this get a freeze exception, under the qualification of #2 "An awesome release", given no function change threatening
--- xen/arch/x86/efi/boot.c | 3 ++- xen/arch/x86/traps.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)xen/arch/x86/efi/boot.c +2
-1@@ -201,7 +201,8 @@ static void __init __attribute__((__noreturn__)) blexit(const CHAR16 *str) efi_bs->FreePages(xsm.addr, PFN_UP(xsm.size)); efi_bs->Exit (efi_ih,EFI_SUCCESS ,0 ,NULL ); -for ( ; ; );/* not reached */ +for ( ; ; )/* not reached */ +halt (); }/* generic routine for printing error messages */
xen/arch/x86/traps.c +2
-1@@ -1448,7 +1448,8 @@ void __init do_early_page_fault(struct cpu_user_regs *regs)printk ("Stack dump: " );while ( ((long )stk & ((PAGE_SIZE -1 ) & ~(BYTES_PER_LONG -1 ))) !=0 )printk ("%p " ,_p (*stk++)); -for ( ; ; ) ; +for ( ; ; ) +halt (); }}