lkml.org 
[lkml]   [2020]   [Mar]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] KVM: x86: small optimization for is_mtrr_mask calculation
Date
Hi,
Paolo Bonzini <pbonzini@redhat.com> wrote:
>On 05/03/20 03:48, linmiaohe wrote:
>> From: Miaohe Lin <linmiaohe@huawei.com>
>>
>> We can get is_mtrr_mask by calculating (msr - 0x200) % 2 directly.
>> index = (msr - 0x200) / 2;
>> - is_mtrr_mask = msr - 0x200 - 2 * index;
>> + is_mtrr_mask = (msr - 0x200) % 2;
>> if (!is_mtrr_mask)
>> *pdata = vcpu->arch.mtrr_state.var_ranges[index].base;
>> else
>>
>
>If you're going to do that, might as well use ">> 1" for index instead of "/ 2", and "msr & 1" for is_mtrr_mask.
>

Many thanks for suggestion. What do you mean is like this ?

index = (msr - 0x200) >> 1;
is_mtrr_mask = msr & 1;

Thanks again.
\
 
 \ /
  Last update: 2020-03-06 03:07    [W:0.709 / U:0.172 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site