x86/hvm: Remove duplicate calls caused by tracing
authorAndrew Cooper <andrew.cooper3@citrix.com>
Fri, 17 Sep 2021 23:32:12 +0000 (00:32 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 21 Sep 2021 18:41:12 +0000 (19:41 +0100)
commit91bac8ad7c062e2779b97649eb0dca9035bc56be
treed0b3beb2b03a1003fdb51b84cbcf738fb6598a53
parente083d753924b954f0185b907001de411a03ca495
x86/hvm: Remove duplicate calls caused by tracing

1) vpic_ack_pending_irq() calls vlapic_accept_pic_intr() twice, once in the
   TRACE_2D() instantiation and once "for real".  Make the call only once.

2) vlapic_accept_pic_intr() similarly calls __vlapic_accept_pic_intr() twice,
   although this is more complicated to disentangle.

   v cannot be NULL because it has already been dereferenced in the function,
   causing the ternary expression to always call __vlapic_accept_pic_intr().
   However, the return expression of the function takes care to skip the call
   if this vCPU isn't the PIC target.  As __vlapic_accept_pic_intr() is far
   from trivial, make the TRACE_2D() semantics match the return semantics by
   only calling __vlapic_accept_pic_intr() when the vCPU is the PIC target.

3) hpet_set_timer() duplicates calls to hpet_tick_to_ns().  Pull the logic out
   which simplifies both the TRACE and create_periodic_time() calls.

4) lapic_rearm() makes multiple calls to vlapic_lvtt_period().  Pull it out
   into a local variable.

vlapic_accept_pic_intr() is called on every VMEntry, so this is a reduction in
VMEntry complexity across the board.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/hvm/hpet.c
xen/arch/x86/hvm/vlapic.c
xen/arch/x86/hvm/vpic.c