[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 2/2] x86/irq: Improve local_irq_restore() code generation and performance
- To: Xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxxx>
- From: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
- Date: Mon, 20 Feb 2023 19:47:02 +0000
- Authentication-results: esa6.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
- Cc: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Jan Beulich <JBeulich@xxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>
- Delivery-date: Mon, 20 Feb 2023 19:47:34 +0000
- Ironport-data: A9a23:pLOcRKowHzvlRUst5zmcGuqzJU5eBmIOZRIvgKrLsJaIsI4StFCzt garIBmFPvaJZWLwfot1Pojk9BkGu5/RzdBqTwpl+C82E3sR85uZCYyVIHmrMnLJJKUvbq7FA +Y2MYCccZ9uHhcwgj/3b9ANeFEljfngqoLUUbKCYWYpA1c/Ek/NsDo788YhmIlknNOlNA2Ev NL2sqX3NUSsnjV5KQr40YrawP9UlKm06WxwUmAWP6gR5weEzSFNVvrzGInqR5fGatgMdgKFb 76rIIGRpgvx4xorA9W5pbf3GmVirmn6ZFXmZtJ+AsBOszAazsAA+v9T2Mk0MC+7vw6hjdFpo OihgLTrIesf0g8gr8xGO/VQO3kW0aSrY9YrK1Dn2SCY5xWun3cBX5yCpaz5VGEV0r8fPI1Ay RAXAAkqR06uod66+ZW+QchghPglLca2f7pK7xmMzRmBZRonaZXKQqGM7t5ExjYgwMtJGJ4yZ eJAN2ApNk6ZJUQSZBFOUslWcOSA3xETdxVxrl6PqLVxyG/U1AFri5DmMcbPe8zMTsJQ9qqdj jOZpjuoXExKXDCZ4SulyFacvdHupxrQCYECTOT/1dBx2nTGkwT/DzVJDADm8JFVkHWWRNZ3O 0ESvC00osAa5EGtC9XwQRC8iHqFpQIHHcpdFfUg7wOAwbaS5ByWbkAmZDNcbN0ttOctWCcnk FSOmrvU6SdH6ePPDyjHr/HN8G30YHJORYMfWcMaZTIiyofOhr0/tzXKRfdvEpKzj9KoWgill lhmsxMCr7kUiMcK0YCy8lbGny+gq/D1c+Il2unEdjn7t10kPeZJc6TtsAGGtqgYcO51W3Hb5 BA5d96iAPfi5H1nvAiEW60zEb6g/J5p2xWM0Ac0T/HNG9lAkkNPnLy8AhkkeS+F0e5eI1cFh XM/XisIvfdu0IOCN/MfXm5II51CIVLcPdrkTOvISdFFf4J8cgSKlAk3OxHOjjm9yBhzyPpnU Xt+TSpLJSxHYZmLMRLsH7tNuVPV7n1WKZzvqWDTkE38jOv2iI+9QrYZKlqeBt3VH4vdyDg5B +13bpPQoz0GCb2WX8Ui2dJLRbz8BSRhVM+eRg0+XrLrHzeK70l7VaaBnON+J90890mX/8+Rl kyAtoZj4AKXrRX6xc+iMxiPtJuHsU5DkE8G
- Ironport-hdrordr: A9a23:5+eu96tj6q3WnvMJZVjhrGNG7skDttV00zEX/kB9WHVpm6yj+v xG/c5rsCMc7Qx6ZJhOo7+90cW7L080lqQFg7X5X43DYOCOggLBQL2KhbGI/9SKIVycygcy78 Zdm6gVMqyLMXFKyfzUzSP9OewGqeP3lJxBh43lvgpQpdcBUdAd0+97YDzrbXGfXGN9dP0E/A L33Ls9m9KnE05nCPhSVhE+LpH+T8SgruOfXSI7
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
POPF is a horribly expensive instruction, while STI is an optimised fastpath.
Switching POPF for a conditional branch and STI caused an 8% perf improvement
in various linux measurements. While I don't expect the change to be that
dramatic in Xen, there will be an improvement.
Furthermore, there is the following code generation improvement:
add/remove: 0/0 grow/shrink: 3/52 up/down: 52/-966 (-914)
owing to not needing to opencode the restriction to just IF in asm.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
CC: Wei Liu <wl@xxxxxxx>
---
xen/arch/x86/include/asm/system.h | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git a/xen/arch/x86/include/asm/system.h
b/xen/arch/x86/include/asm/system.h
index 65e63de69a67..4be235472ecd 100644
--- a/xen/arch/x86/include/asm/system.h
+++ b/xen/arch/x86/include/asm/system.h
@@ -267,13 +267,8 @@ static inline unsigned long
array_index_mask_nospec(unsigned long index,
})
#define local_irq_restore(x) \
({ \
- BUILD_BUG_ON(sizeof(x) != sizeof(long)); \
- asm volatile ( "pushfq\n\t" \
- "andq %0, (%%rsp)\n\t" \
- "orq %1, (%%rsp)\n\t" \
- "popfq" \
- : : "i?r" ( ~X86_EFLAGS_IF ), \
- "ri" ( (x) & X86_EFLAGS_IF ) ); \
+ if ( (x) & X86_EFLAGS_IF ) \
+ local_irq_enable(); \
})
static inline int local_irq_is_enabled(void)
--
2.30.2
|