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

[PATCH] x86/ioapic: Improve code generation for __io_apic_{read, write}()


  • To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
  • Date: Wed, 5 Aug 2020 14:54:18 +0100
  • Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>
  • Delivery-date: Wed, 05 Aug 2020 13:55:34 +0000
  • Ironport-sdr: l3AaX3pjiT/6Ld2AsmG+4tHWQXSR/XNWZW4+dDgDdUU1Icc0YoEKLFli+JVwc4A4R1JExpg5+e v+SbinPt6V1uglH9UOcbhfKVckIrmozfDP7zwSJ7i1qIG7kBVeXR+1loRcuC3FSleKOLHlcjAY PwlOx0KzAXhz/yN7Om0CgixkbxCyUTcqxlefHwoFIL8AHv0riHByA+QoxK6Tp1oeiN3uMPEP0I QuRGV+JEaMO98orYLC/QuiwVNdftxbvXx02B35K2vvFuqKOT+iDUDWGg+fKg30x7KkiJa54FJT a/U=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

The write into REGSEL prevents the optimiser from reusing the address
calculation, forcing it to be calcualted twice.

The calculation itself is quite expensive.  Pull it out into a local varaible.

Bloat-o-meter reports:
  add/remove: 0/0 grow/shrink: 0/26 up/down: 0/-1527 (-1527)

Also correct the register type, which is uint32_t, not int.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
 xen/include/asm-x86/io_apic.h | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/xen/include/asm-x86/io_apic.h b/xen/include/asm-x86/io_apic.h
index daf17d4c3d..cb36e4ca1b 100644
--- a/xen/include/asm-x86/io_apic.h
+++ b/xen/include/asm-x86/io_apic.h
@@ -14,8 +14,8 @@
  */
 
 #define IO_APIC_BASE(idx)                                               \
-    ((volatile int *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx)           \
-                      + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
+    ((volatile uint32_t *)(__fix_to_virt(FIX_IO_APIC_BASE_0 + idx)      \
+                           + (mp_ioapics[idx].mpc_apicaddr & ~PAGE_MASK)))
 
 #define IO_APIC_ID(idx) (mp_ioapics[idx].mpc_apicid)
 
@@ -135,8 +135,10 @@ unsigned int io_apic_gsi_base(unsigned int apic);
 
 static inline unsigned int __io_apic_read(unsigned int apic, unsigned int reg)
 {
-    *IO_APIC_BASE(apic) = reg;
-    return *(IO_APIC_BASE(apic)+4);
+    volatile uint32_t *regs = IO_APIC_BASE(apic);
+
+    regs[0] = reg;
+    return regs[4];
 }
 
 static inline unsigned int io_apic_read(unsigned int apic, unsigned int reg)
@@ -148,8 +150,10 @@ static inline unsigned int io_apic_read(unsigned int apic, 
unsigned int reg)
 
 static inline void __io_apic_write(unsigned int apic, unsigned int reg, 
unsigned int value)
 {
-    *IO_APIC_BASE(apic) = reg;
-    *(IO_APIC_BASE(apic)+4) = value;
+    volatile uint32_t *regs = IO_APIC_BASE(apic);
+
+    regs[0] = reg;
+    regs[4] = value;
 }
 
 static inline void io_apic_write(unsigned int apic, unsigned int reg, unsigned 
int value)
-- 
2.11.0




 


Rackspace

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