[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging] x86/IO-APIC: Drop function pointers from __ioapic_{read,write}_entry()



commit 245a320ce22752562c2143d0fb406aeb2e334dfb
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Sun Oct 31 00:03:56 2021 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Mon Nov 29 13:53:05 2021 +0000

    x86/IO-APIC: Drop function pointers from __ioapic_{read,write}_entry()
    
    Function pointers are expensive, and the raw parameter is a constant at the
    root of all call trees, meaning that it predicts very well with local branch
    history.
    
    Furthermore, the knock-on effects are quite impressive.
    
      $ ../scripts/bloat-o-meter xen-syms-before xen-syms-after
      add/remove: 0/4 grow/shrink: 3/9 up/down: 459/-823 (-364)
      Function                                     old     new   delta
      __ioapic_write_entry                          73     286    +213
      __ioapic_read_entry                           75     276    +201
      save_IO_APIC_setup                           182     227     +45
      eoi_IO_APIC_irq                              241     229     -12
      disable_IO_APIC                              296     280     -16
      mask_IO_APIC_setup                           272     240     -32
      __io_apic_write                               46       -     -46
      __io_apic_read                                46       -     -46
      io_apic_set_pci_routing                      985     930     -55
      __io_apic_eoi.part                           223     161     -62
      io_apic_write                                 69       -     -69
      io_apic_read                                  69       -     -69
      restore_IO_APIC_setup                        325     253     -72
      ioapic_guest_write                          1413    1333     -80
      clear_IO_APIC_pin                            447     343    -104
      setup_IO_APIC                               5148    4988    -160
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/io_apic.c | 30 ++++++++++++++++++++++--------
 1 file changed, 22 insertions(+), 8 deletions(-)

diff --git a/xen/arch/x86/io_apic.c b/xen/arch/x86/io_apic.c
index c3ad9efac8..1c49a0fe14 100644
--- a/xen/arch/x86/io_apic.c
+++ b/xen/arch/x86/io_apic.c
@@ -235,11 +235,19 @@ union entry_union {
 struct IO_APIC_route_entry __ioapic_read_entry(
     unsigned int apic, unsigned int pin, bool raw)
 {
-    unsigned int (*read)(unsigned int, unsigned int)
-        = raw ? __io_apic_read : io_apic_read;
     union entry_union eu;
-    eu.w1 = (*read)(apic, 0x10 + 2 * pin);
-    eu.w2 = (*read)(apic, 0x11 + 2 * pin);
+
+    if ( raw )
+    {
+        eu.w1 = __io_apic_read(apic, 0x10 + 2 * pin);
+        eu.w2 = __io_apic_read(apic, 0x11 + 2 * pin);
+    }
+    else
+    {
+        eu.w1 = io_apic_read(apic, 0x10 + 2 * pin);
+        eu.w2 = io_apic_read(apic, 0x11 + 2 * pin);
+    }
+
     return eu.entry;
 }
 
@@ -259,12 +267,18 @@ void __ioapic_write_entry(
     unsigned int apic, unsigned int pin, bool raw,
     struct IO_APIC_route_entry e)
 {
-    void (*write)(unsigned int, unsigned int, unsigned int)
-        = raw ? __io_apic_write : io_apic_write;
     union entry_union eu = { .entry = e };
 
-    (*write)(apic, 0x11 + 2*pin, eu.w2);
-    (*write)(apic, 0x10 + 2*pin, eu.w1);
+    if ( raw )
+    {
+        __io_apic_write(apic, 0x11 + 2 * pin, eu.w2);
+        __io_apic_write(apic, 0x10 + 2 * pin, eu.w1);
+    }
+    else
+    {
+        io_apic_write(apic, 0x11 + 2 * pin, eu.w2);
+        io_apic_write(apic, 0x10 + 2 * pin, eu.w1);
+    }
 }
 
 static void ioapic_write_entry(
--
generated by git-patchbot for /home/xen/git/xen.git#staging



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.