KVM: s390: use simple switch statement as multiplexer
authorChristian Borntraeger <borntraeger@de.ibm.com>
Thu, 23 Jul 2015 13:24:03 +0000 (15:24 +0200)
committerChristian Borntraeger <borntraeger@de.ibm.com>
Thu, 29 Oct 2015 14:59:11 +0000 (15:59 +0100)
commit46b708ea875f14f5496109df053624199f3aae87
tree53c5d21b613a97aaf98f087f549a3c517fa2a31c
parent58c383c62e1a4379cee531b56e4293211f2d5ded
KVM: s390: use simple switch statement as multiplexer

We currently do some magic shifting (by exploiting that exit codes
are always a multiple of 4) and a table lookup to jump into the
exit handlers. This causes some calculations and checks, just to
do an potentially expensive function call.

Changing that to a switch statement gives the compiler the chance
to inline and dynamically decide between jump tables or inline
compare and branches. In addition it makes the code more readable.

bloat-o-meter gives me a small reduction in code size:

add/remove: 0/7 grow/shrink: 1/1 up/down: 986/-1334 (-348)
function                                     old     new   delta
kvm_handle_sie_intercept                      72    1058    +986
handle_prog                                  704     696      -8
handle_noop                                   54       -     -54
handle_partial_execution                      60       -     -60
intercept_funcs                              120       -    -120
handle_instruction                           198       -    -198
handle_validity                              210       -    -210
handle_stop                                  316       -    -316
handle_external_interrupt                    368       -    -368

Right now my gcc does conditional branches instead of jump tables.
The inlining seems to give us enough cycles as some micro-benchmarking
shows minimal improvements, but still in noise.

Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
arch/s390/kvm/intercept.c