Re: [PATCH 01/15] KVM: PPC: Make register read/write wrappers always work

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Avi Kivity wrote:
> On 03/08/2010 03:53 PM, Alexander Graf wrote:
>>
>>> So do it the other way around.  Always load the registers (of course,
>>> do nothing if already loaded) and then access them in just one way.  I
>>> assume during emulation the registers will always be loaded?
>>>      
>> During emulation we're always in VCPU_RUN, so the vcpu is loaded.
>>
>> Do you mean something like:
>>
>> read_register(num) {
>>    vcpu_load();
>>    read register from PACA(num);
>>    vcpu_put();
>> }
>>
>> ? Does vcpu_load incur overhead when it doesnt' need to do anything?
>>    
>
> If the vcpu is always loaded, this would be redundant, no?
>
> The situation is that a piece of data is in one of two places. 
> Instead of checking and loading it from either, force it to the place
> where it normally is, and load it from there.
>
> So instead of
>
>     if (x)
>         y = p1;
>     else
>         y = p2;
>
> in a zillion places, just do
>
>     force_to_p2(); // the common case anyway
>     y = p2;
>
> which results in cleaner code.  Assuming that you have a common case
> of course.


We're looking at two different ifs here.

1) GPR Inside the PACA or not (volatile vs non-volatile)

This is constant. Volatile registers go to the PACA; non-volatiles go to
the vcpu struct.

2) GPR actually loaded in the PACA

When we're in vcpu_load context the registers in the PACA, when not
they're in the vcpu struct


If you have a really easy and fast way to assure that we're always
inside a vcpu_load context, all is great. I could probably even just put
in a BUG_ON(not in vcpu_load context) and make the callers safe. But
some check needs to be done.


Alex
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux