• Christian Borntraeger's avatar
    KVM: s390: use simple switch statement as multiplexer · 46b708ea
    Christian Borntraeger authored
    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: default avatarChristian Borntraeger <borntraeger@de.ibm.com>
    Reviewed-by: default avatarCornelia Huck <cornelia.huck@de.ibm.com>
    46b708ea
intercept.c 9.32 KB