]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
KVM: x86 emulator: Avoid clearing the whole decode_cache
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Wed, 25 May 2011 02:09:38 +0000 (11:09 +0900)
committerAvi Kivity <avi@redhat.com>
Tue, 12 Jul 2011 08:45:09 +0000 (11:45 +0300)
commitb5c9ff731f3cee5a2f2d7154f48f8006b48eb66d
treebbea807577dd211bf52eca8397c6630f0bc7a01d
parentadf52235b4082e67f31bf1fba36f1dce312633d6
KVM: x86 emulator: Avoid clearing the whole decode_cache

During tracing the emulator, we noticed that init_emulate_ctxt()
sometimes took a bit longer time than we expected.

This patch is for mitigating the problem by some degree.

By looking into the function, we soon notice that it clears the whole
decode_cache whose size is about 2.5K bytes now.  Furthermore, most of
the bytes are taken for the two read_cache arrays, which are used only
by a few instructions.

Considering the fact that we are not assuming the cache arrays have
been cleared when we store actual data, we do not need to clear the
arrays: 2K bytes elimination.  In addition, we can avoid clearing the
fetch_cache and regs arrays.

This patch changes the initialization not to clear the arrays.

On our 64-bit host, init_emulate_ctxt() becomes 0.3 to 0.5us faster with
this patch applied.

Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Cc: Gleb Natapov <gleb@redhat.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/include/asm/kvm_emulate.h
arch/x86/kvm/x86.c