Skip to content

Commit a6d27ea

Browse files
Claudio ImbrendaAlexander Gordeev
authored andcommitted
s390/mm: convert pgste locking functions to C
Convert pgste_get_lock() and pgste_set_unlock() to C. There is no real reasons to keep them in assembler. Having them in C makes them more readable and maintainable, and better instructions are used automatically when available. Signed-off-by: Claudio Imbrenda <imbrenda@linux.ibm.com> Acked-by: Alexander Gordeev <agordeev@linux.ibm.com> Reviewed-by: Heiko Carstens <hca@linux.ibm.com> Link: https://lore.kernel.org/r/20231205173252.62305-1-imbrenda@linux.ibm.com Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent 1856475 commit a6d27ea

1 file changed

Lines changed: 10 additions & 19 deletions

File tree

arch/s390/mm/pgtable.c

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -125,32 +125,23 @@ static inline pte_t ptep_flush_lazy(struct mm_struct *mm,
125125

126126
static inline pgste_t pgste_get_lock(pte_t *ptep)
127127
{
128-
unsigned long new = 0;
128+
unsigned long value = 0;
129129
#ifdef CONFIG_PGSTE
130-
unsigned long old;
131-
132-
asm(
133-
" lg %0,%2\n"
134-
"0: lgr %1,%0\n"
135-
" nihh %0,0xff7f\n" /* clear PCL bit in old */
136-
" oihh %1,0x0080\n" /* set PCL bit in new */
137-
" csg %0,%1,%2\n"
138-
" jl 0b\n"
139-
: "=&d" (old), "=&d" (new), "=Q" (ptep[PTRS_PER_PTE])
140-
: "Q" (ptep[PTRS_PER_PTE]) : "cc", "memory");
130+
unsigned long *ptr = (unsigned long *)(ptep + PTRS_PER_PTE);
131+
132+
do {
133+
value = __atomic64_or_barrier(PGSTE_PCL_BIT, ptr);
134+
} while (value & PGSTE_PCL_BIT);
135+
value |= PGSTE_PCL_BIT;
141136
#endif
142-
return __pgste(new);
137+
return __pgste(value);
143138
}
144139

145140
static inline void pgste_set_unlock(pte_t *ptep, pgste_t pgste)
146141
{
147142
#ifdef CONFIG_PGSTE
148-
asm(
149-
" nihh %1,0xff7f\n" /* clear PCL bit */
150-
" stg %1,%0\n"
151-
: "=Q" (ptep[PTRS_PER_PTE])
152-
: "d" (pgste_val(pgste)), "Q" (ptep[PTRS_PER_PTE])
153-
: "cc", "memory");
143+
barrier();
144+
WRITE_ONCE(*(unsigned long *)(ptep + PTRS_PER_PTE), pgste_val(pgste) & ~PGSTE_PCL_BIT);
154145
#endif
155146
}
156147

0 commit comments

Comments
 (0)