From 4416d2ed816699b8e7491f1e8e8b15f69685af57 Mon Sep 17 00:00:00 2001 From: Heiko Carstens Date: Thu, 12 Oct 2023 09:40:41 +0200 Subject: [PATCH] s390/mm,fault: use static key for store indication Generate slightly better code by using a static key to implement store indication. This allows to get rid of a memory access on the hot path. Reviewed-by: Claudio Imbrenda Signed-off-by: Heiko Carstens Signed-off-by: Vasily Gorbik --- arch/s390/mm/fault.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/arch/s390/mm/fault.c b/arch/s390/mm/fault.c index ba2056b359109..5466a30d1ec4a 100644 --- a/arch/s390/mm/fault.c +++ b/arch/s390/mm/fault.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -60,12 +61,12 @@ enum fault_type { GMAP_FAULT, }; -static unsigned long store_indication __read_mostly; +static DEFINE_STATIC_KEY_FALSE(have_store_indication); static int __init fault_init(void) { if (test_facility(75)) - store_indication = 0xc00; + static_branch_enable(&have_store_indication); return 0; } early_initcall(fault_init); @@ -104,11 +105,13 @@ static unsigned long get_fault_address(struct pt_regs *regs) return trans_exc_code & __FAIL_ADDR_MASK; } -static bool fault_is_write(struct pt_regs *regs) +static __always_inline bool fault_is_write(struct pt_regs *regs) { unsigned long trans_exc_code = regs->int_parm_long; - return (trans_exc_code & store_indication) == 0x400; + if (static_branch_likely(&have_store_indication)) + return (trans_exc_code & 0xc00) == 0x400; + return false; } static int bad_address(void *p) -- 2.30.2