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

Re: [Xen-devel] [PATCH v2 2/2] xen: add update indicator to vcpu_runstate_info



On 16/06/16 14:36, Jan Beulich wrote:
>>>> On 16.06.16 at 14:11, <JGross@xxxxxxxx> wrote:
>> On 16/06/16 13:15, Jan Beulich wrote:
>>>>>> On 15.06.16 at 13:34, <JGross@xxxxxxxx> wrote:
>>>> +    if ( VM_ASSIST(v->domain, runstate_update_flag) )
>>>> +    {
>>>> +        off = offsetof(struct vcpu_runstate_info, state_entry_time) +
>>>> +              sizeof(v->runstate.state_entry_time) - 1;
>>>> +        if ( has_32bit_shinfo(v->domain) )
>>>> +        {
>>>> +            guest_handle = v->runstate_guest.compat.p;
>>>> +            guest_handle +=
>>>> +                offsetof(struct compat_vcpu_runstate_info, 
>>>> state_entry_time) +
>>>> +                sizeof(v->runstate.state_entry_time) - 1;
>>>
>>> The sizes of the native and compat fields happen to be the same,
>>> but it would be nice if the right field/type could be used here.
>>
>> Hmm, this will require some ugly type casting, but it is probably
>> cleaner.
> 
> Type casting? I would expect you to be able to use
> v->runstate_guest.compat.p->state_entry_time. In fact I think
> you also could get rid of the offsetof() if you used
> &v->runstate_guest.compat.p->state_entry_time for initializing
> guest_handle.

Aah, of course. This can then be simplified even more:

if ( VM_ASSIST(v->domain, runstate_update_flag) )
{
    guest_handle = has_32bit_shinfo(v->domain)
        ? &v->runstate_guest.compat.p->state_entry_time + 1
        : &v->runstate_guest.native.p->state_entry_time + 1;
    guest_handle--;
    v->runstate.state_entry_time |= XEN_RUNSTATE_UPDATE;
    __raw_copy_to_guest(guest_handle,
                 (void *)(&v->runstate.state_entry_time + 1) - 1, 1);
    smp_wmb();
}

This will reduce code size by 25 bytes. :-)


Juergen

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.