xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] xen/x86: Be more power-efficient when waiting forever
@ 2013-12-02 14:38 Andrew Cooper
  2013-12-02 15:03 ` Jan Beulich
  2013-12-02 15:23 ` Keir Fraser
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Cooper @ 2013-12-02 14:38 UTC (permalink / raw)
  To: Xen-devel; +Cc: George Dunlap, Andrew Cooper, Keir Fraser, Jan Beulich

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 <andrew.cooper3@citrix.com>
CC: Keir Fraser <keir@xen.org>
CC: Jan Beulich <JBeulich@suse.com>
CC: George Dunlap <george.dunlap@eu.citrix.com>

---

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(-)

diff --git a/xen/arch/x86/efi/boot.c b/xen/arch/x86/efi/boot.c
index 0dd935c..602cc12 100644
--- a/xen/arch/x86/efi/boot.c
+++ b/xen/arch/x86/efi/boot.c
@@ -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 */
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index d8b3eac..8c355e5 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -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();
     }
 }
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] xen/x86: Be more power-efficient when waiting forever
  2013-12-02 14:38 [PATCH] xen/x86: Be more power-efficient when waiting forever Andrew Cooper
@ 2013-12-02 15:03 ` Jan Beulich
  2013-12-02 15:06   ` Andrew Cooper
  2013-12-02 15:23 ` Keir Fraser
  1 sibling, 1 reply; 4+ messages in thread
From: Jan Beulich @ 2013-12-02 15:03 UTC (permalink / raw)
  To: Andrew Cooper; +Cc: George Dunlap, Keir Fraser, Xen-devel

>>> On 02.12.13 at 15:38, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
> 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 ...

> --- a/xen/arch/x86/efi/boot.c
> +++ b/xen/arch/x86/efi/boot.c
> @@ -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).

> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xen/x86: Be more power-efficient when waiting forever
  2013-12-02 15:03 ` Jan Beulich
@ 2013-12-02 15:06   ` Andrew Cooper
  0 siblings, 0 replies; 4+ messages in thread
From: Andrew Cooper @ 2013-12-02 15:06 UTC (permalink / raw)
  To: Jan Beulich; +Cc: George Dunlap, Keir Fraser, Xen-devel

On 02/12/13 15:03, Jan Beulich wrote:
>>>> On 02.12.13 at 15:38, Andrew Cooper <andrew.cooper3@citrix.com> wrote:
>> 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 ...
>
>> --- a/xen/arch/x86/efi/boot.c
>> +++ b/xen/arch/x86/efi/boot.c
>> @@ -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).

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

>
>> --- a/xen/arch/x86/traps.c
>> +++ b/xen/arch/x86/traps.c
>> @@ -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
>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] xen/x86: Be more power-efficient when waiting forever
  2013-12-02 14:38 [PATCH] xen/x86: Be more power-efficient when waiting forever Andrew Cooper
  2013-12-02 15:03 ` Jan Beulich
@ 2013-12-02 15:23 ` Keir Fraser
  1 sibling, 0 replies; 4+ messages in thread
From: Keir Fraser @ 2013-12-02 15:23 UTC (permalink / raw)
  To: Andrew Cooper, Xen-devel; +Cc: George Dunlap, Jan Beulich

On 02/12/2013 14:38, "Andrew Cooper" <andrew.cooper3@citrix.com> wrote:

> 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 <andrew.cooper3@citrix.com>
> CC: Keir Fraser <keir@xen.org>
> CC: Jan Beulich <JBeulich@suse.com>
> CC: George Dunlap <george.dunlap@eu.citrix.com>

Acked-by: Keir Fraser <keir@xen.org>

> ---
> 
> 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(-)
> 
> diff --git a/xen/arch/x86/efi/boot.c b/xen/arch/x86/efi/boot.c
> index 0dd935c..602cc12 100644
> --- a/xen/arch/x86/efi/boot.c
> +++ b/xen/arch/x86/efi/boot.c
> @@ -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 */
> diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
> index d8b3eac..8c355e5 100644
> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -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();
>      }
>  }
>  

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-12-02 15:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-02 14:38 [PATCH] xen/x86: Be more power-efficient when waiting forever Andrew Cooper
2013-12-02 15:03 ` Jan Beulich
2013-12-02 15:06   ` Andrew Cooper
2013-12-02 15:23 ` Keir Fraser

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).