public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix msr register allocation
@ 2007-07-30 15:25 Glauber de Oliveira Costa
  2007-07-30 15:37 ` Björn Steinbrink
  0 siblings, 1 reply; 4+ messages in thread
From: Glauber de Oliveira Costa @ 2007-07-30 15:25 UTC (permalink / raw)
  To: linux-kernel, akpm

Since the value in ret will go through a return statement,
it does not need to be put in eax register directly. Instead,
we let the compiler do his job and choose what to do with it,
potentially getting a better register allocation.
    
Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>

diff --git a/include/asm-i386/msr.h b/include/asm-i386/msr.h
index df21ea0..cc4263c 100644
--- a/include/asm-i386/msr.h
+++ b/include/asm-i386/msr.h
@@ -54,7 +54,7 @@ static inline int native_write_msr_safe(unsigned int msr,
 		     "   .align 4\n\t"
 		     "   .long 	2b,3b\n\t"
 		     ".previous"
-		     : "=a" (err)
+		     : "=r" (err)
 		     : "c" (msr), "0" ((u32)val), "d" ((u32)(val>>32)),
 		       "i" (-EFAULT));
 	return err;



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

* Re: [PATCH] Fix msr register allocation
  2007-07-30 15:25 [PATCH] Fix msr register allocation Glauber de Oliveira Costa
@ 2007-07-30 15:37 ` Björn Steinbrink
  2007-07-30 16:35   ` Glauber de Oliveira Costa
  0 siblings, 1 reply; 4+ messages in thread
From: Björn Steinbrink @ 2007-07-30 15:37 UTC (permalink / raw)
  To: Glauber de Oliveira Costa; +Cc: linux-kernel, akpm

On 2007.07.30 12:25:54 -0300, Glauber de Oliveira Costa wrote:
> Since the value in ret will go through a return statement,
                     ^^^
You mean "err" I guess?

> it does not need to be put in eax register directly. Instead,
> we let the compiler do his job and choose what to do with it,
> potentially getting a better register allocation.
>     
> Signed-off-by: Glauber de Oliveira Costa <gcosta@redhat.com>
> 
> diff --git a/include/asm-i386/msr.h b/include/asm-i386/msr.h
> index df21ea0..cc4263c 100644
> --- a/include/asm-i386/msr.h
> +++ b/include/asm-i386/msr.h
> @@ -54,7 +54,7 @@ static inline int native_write_msr_safe(unsigned int msr,
>  		     "   .align 4\n\t"
>  		     "   .long 	2b,3b\n\t"
>  		     ".previous"
> -		     : "=a" (err)
> +		     : "=r" (err)
>  		     : "c" (msr), "0" ((u32)val), "d" ((u32)(val>>32)),
>  		       "i" (-EFAULT));
>  	return err;

Note that the EAX output constraint is re-used in the input section for
(u32)val, i.e. the lower half of the value to be written. And "wrmsr"
needs that in EAX, so you cannot change the output constraint without
touching the input constraint.

Also, I do not see how the compiler could do any better than having the
return value already in EAX, but that doesn't really mean anything ;-)

Björn

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

* Re: [PATCH] Fix msr register allocation
  2007-07-30 15:37 ` Björn Steinbrink
@ 2007-07-30 16:35   ` Glauber de Oliveira Costa
  2007-07-30 19:59     ` Andi Kleen
  0 siblings, 1 reply; 4+ messages in thread
From: Glauber de Oliveira Costa @ 2007-07-30 16:35 UTC (permalink / raw)
  To: Björn Steinbrink; +Cc: linux-kernel, akpm

On Mon, 2007-07-30 at 17:37 +0200, Björn Steinbrink wrote:
> On 2007.07.30 12:25:54 -0300, Glauber de Oliveira Costa wrote:
> > Since the value in ret will go through a return statement,
>                      ^^^
> You mean "err" I guess?
Yeah, you're right.

> Note that the EAX output constraint is re-used in the input section for
> (u32)val, i.e. the lower half of the value to be written. And "wrmsr"
> needs that in EAX, so you cannot change the output constraint without
> touching the input constraint.
Right again. Will send a new patch that also changes the input constraint.

> Also, I do not see how the compiler could do any better than having the
> return value already in EAX, but that doesn't really mean anything ;-)

Yet, we should only force the compiler to a particular choice when we 
have to, IMHO. So, unless anyone gives another reason not to, I will
send another patch with your warnings fixed.




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

* Re: [PATCH] Fix msr register allocation
  2007-07-30 16:35   ` Glauber de Oliveira Costa
@ 2007-07-30 19:59     ` Andi Kleen
  0 siblings, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2007-07-30 19:59 UTC (permalink / raw)
  To: Glauber de Oliveira Costa; +Cc: Björn Steinbrink, linux-kernel, akpm

Glauber de Oliveira Costa <gcosta@redhat.com> writes:

> > Note that the EAX output constraint is re-used in the input section for
> > (u32)val, i.e. the lower half of the value to be written. And "wrmsr"
> > needs that in EAX, so you cannot change the output constraint without
> > touching the input constraint.
> Right again. Will send a new patch that also changes the input constraint.

Please also "fix" the subject then. You can only fix something that's broken,
but this isn't.

-Andi

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

end of thread, other threads:[~2007-07-30 19:04 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-30 15:25 [PATCH] Fix msr register allocation Glauber de Oliveira Costa
2007-07-30 15:37 ` Björn Steinbrink
2007-07-30 16:35   ` Glauber de Oliveira Costa
2007-07-30 19:59     ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox