KVM: x86: lapic: Clean up find_highest_vector() and count_vectors()
authorTakuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Wed, 5 Sep 2012 10:30:01 +0000 (19:30 +0900)
committerMarcelo Tosatti <mtosatti@redhat.com>
Wed, 12 Sep 2012 16:38:23 +0000 (13:38 -0300)
commitecba9a52acdf20530d561b7634b80c35c308943a
tree8a8ef1bd20dd24b4181acab240906da6978c117f
parent7de5bdc96c372ab875408c86e0099958dba89f56
KVM: x86: lapic: Clean up find_highest_vector() and count_vectors()

find_highest_vector() and count_vectors():
 - Instead of using magic values, define and use proper macros.

find_highest_vector():
 - Remove likely() which is there only for historical reasons and not
   doing correct branch predictions anymore.  Using such heuristics
   to optimize this function is not worth it now.  Let CPUs predict
   things instead.

 - Stop checking word[0] separately.  This was only needed for doing
   likely() optimization.

 - Use for loop, not while, to iterate over the register array to make
   the code clearer.

Note that we actually confirmed that the likely() did wrong predictions
by inserting debug code.

Acked-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Takuya Yoshikawa <yoshikawa.takuya@oss.ntt.co.jp>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
arch/x86/kvm/lapic.c