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

Re: [Xen-devel] [PATCH V2 1/2] xen, libxc: Fine grained control of REP emulation optimizations



On 09/22/2015 06:17 PM, Jan Beulich wrote:
>>>> On 21.09.15 at 15:31, <rcojocaru@xxxxxxxxxxxxxxx> wrote:
>> --- a/xen/arch/x86/hvm/emulate.c
>> +++ b/xen/arch/x86/hvm/emulate.c
>> @@ -514,7 +514,8 @@ static int hvmemul_virtual_to_linear(
>>       * being triggered for repeated writes to a whole page.
>>       */
>>      *reps = min_t(unsigned long, *reps,
>> -                  unlikely(current->domain->arch.mem_access_emulate_enabled)
>> +                  unlikely(current->domain->arch.mem_access_emulate_enabled 
>> &&
>> +                           
>> current->domain->arch.mem_access_emulate_each_rep)
>>                             ? 1 : 4096);
> 
> unlikely() should not wrap compound conditions, or else its effect of
> eliminating mis-predicted branches from the fast path won't be
> achieved. In the case here I wonder though whether you couldn't
> simply test only ->arch.mem_access_emulate_each_rep.

I'll unfold the unlikely().

Testing only ->arch.mem_access_emulate_each_rep is what I had done in
the original patch, however on Andrew Cooper's suggestion I've now gated
this on ->domain->arch.mem_access_emulate_enabled as well.

Otherwise, somebody might set mem_access_emulate_each_rep via its
xc_monitor_*() call, but then after calling xc_monitor_disable() it
would still be in effect, even if the guest is no longer being monitored.

If this is not a problem, I'm happy to check just
->arch.mem_access_emulate_each_rep.

>> --- a/xen/arch/x86/monitor.c
>> +++ b/xen/arch/x86/monitor.c
>> @@ -79,6 +79,12 @@ int monitor_domctl(struct domain *d, struct 
>> xen_domctl_monitor_op *mop)
>>          return 0;
>>      }
>>  
>> +    if ( mop->op == XEN_DOMCTL_MONITOR_OP_EMULATE_EACH_REP )
>> +    {
>> +        d->arch.mem_access_emulate_each_rep = !!mop->event;
>> +        return 0;
>> +    }
> 
> Considering that there's another "if(mop->op == ...)" right above
> this, these two together should become another switch().

Understood.


Thanks,
Razvan

_______________________________________________
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®.