exec: optimize phys_page_set_level
commitdb94604b20278c1dc227a04e4c564d80230e6c3f
authorPaolo Bonzini <pbonzini@redhat.com>
Thu, 21 May 2015 13:12:29 +0000 (21 15:12 +0200)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 5 Jun 2015 15:09:58 +0000 (5 17:09 +0200)
treee50ac998678fe6af599a7e52054556b978fb9c4a
parente4afbf4fb4d026510700cb40bb72dea9aef14e3b
exec: optimize phys_page_set_level

phys_page_set_level is writing zeroes to a struct that has just been
filled in by phys_map_node_alloc.  Instead, tell phys_map_node_alloc
whether to fill in the page "as a leaf" or "as a non-leaf".

memcpy is faster than struct assignment, which copies each bitfield
individually.  A compiler bug (https://gcc.gnu.org/PR66391), and
small memcpys like this one are special-cased anyway, and optimized
to a register move, so just use the memcpy.

This cuts the cost of phys_page_set_level from 25% to 5% when
booting qboot.

Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
exec.c