Messages in this thread | | | From | linmiaohe <> | Subject | Re: [PATCH] KVM: x86: small optimization for is_mtrr_mask calculation | Date | Fri, 6 Mar 2020 02:05:40 +0000 |
| |
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.
| |