Skip to contentSkip to conversation

KVM: x86: small optimization for is_mtrr_mask calculation

PATCH linmiaohe 2 participants 2 messages Mar 6, 2020 KVM

lore
Share & tools
lore

linmiaohe

author
#0 lore raw
Quoted 5 lines · [email protected] wrote:
Quoted 5 lines · linmiaohe

Hi,
Paolo Bonzini <[email protected]> wrote:
Many thanks for suggestion. What do you mean is like this ?

Quoted 8 lines
Quoted 4 lines
	index = (msr - 0x200) >> 1;
	is_mtrr_mask = msr & 1;

Thanks again.

You realize that the compiler will probably produce exactly the same code, right? As such, it is about making the code easy for the human reader.

Even if it didn't, this code is as far from performance critical as one can possibly get.

Yep, it looks gain little. Thanks.

#1 lore raw
Quoted 10 lines · linmiaohe
Quoted 8 lines · [email protected] wrote:
Quoted 8 lines · linmiaohe

Hi,
Paolo Bonzini <[email protected]> wrote:
Many thanks for suggestion. What do you mean is like this ?

     index = (msr - 0x200) >> 1;
     is_mtrr_mask = msr & 1;
Quoted 7 lines
Quoted 5 lines
Quoted 1 line

Thanks again.

You realize that the compiler will probably produce exactly the same code, right? As such, it is about making the code easy for the human reader.

Even if it didn't, this code is as far from performance critical as one can possibly get.

Yep, it looks gain little. Thanks.

Please post the performance number when you mention optimize XXX later.

Wanpeng