Skip to content

Commit 4416d2e

Browse files
hcahcaVasily Gorbik
authored andcommitted
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 <imbrenda@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent 9641613 commit 4416d2e

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

arch/s390/mm/fault.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/signal.h>
1616
#include <linux/sched.h>
1717
#include <linux/sched/debug.h>
18+
#include <linux/jump_label.h>
1819
#include <linux/kernel.h>
1920
#include <linux/errno.h>
2021
#include <linux/string.h>
@@ -60,12 +61,12 @@ enum fault_type {
6061
GMAP_FAULT,
6162
};
6263

63-
static unsigned long store_indication __read_mostly;
64+
static DEFINE_STATIC_KEY_FALSE(have_store_indication);
6465

6566
static int __init fault_init(void)
6667
{
6768
if (test_facility(75))
68-
store_indication = 0xc00;
69+
static_branch_enable(&have_store_indication);
6970
return 0;
7071
}
7172
early_initcall(fault_init);
@@ -104,11 +105,13 @@ static unsigned long get_fault_address(struct pt_regs *regs)
104105
return trans_exc_code & __FAIL_ADDR_MASK;
105106
}
106107

107-
static bool fault_is_write(struct pt_regs *regs)
108+
static __always_inline bool fault_is_write(struct pt_regs *regs)
108109
{
109110
unsigned long trans_exc_code = regs->int_parm_long;
110111

111-
return (trans_exc_code & store_indication) == 0x400;
112+
if (static_branch_likely(&have_store_indication))
113+
return (trans_exc_code & 0xc00) == 0x400;
114+
return false;
112115
}
113116

114117
static int bad_address(void *p)

0 commit comments

Comments
 (0)