Skip to content

Commit 0dafe99

Browse files
hcahcaVasily Gorbik
authored andcommitted
s390: Use inline qualifier for all EX_TABLE and ALTERNATIVE inline assemblies
Use asm_inline for all inline assemblies which make use of the EX_TABLE or ALTERNATIVE macros. These macros expand to many lines and the compiler assumes the number of lines within an inline assembly is the same as the number of instructions within an inline assembly. This has an effect on inlining and loop unrolling decisions. In order to avoid incorrect assumptions use asm_inline, which tells the compiler that an inline assembly has the smallest possible size. In order to avoid confusion when asm_inline should be used or not, since a couple of inline assemblies are quite large: the rule is to always use asm_inline whenever the EX_TABLE or ALTERNATIVE macro is used. In specific cases there may be reasons to not follow this guideline, but that should be documented with the corresponding code. Using the inline qualifier everywhere has only a small effect on the kernel image size: add/remove: 0/10 grow/shrink: 19/8 up/down: 1492/-1858 (-366) The only location where this seems to matter is load_unaligned_zeropad() from word-at-a-time.h where the compiler inlines more functions within the dcache code, which is indeed code where performance matters. Suggested-by: Juergen Christ <jchrist@linux.ibm.com> Reviewed-by: Juergen Christ <jchrist@linux.ibm.com> Signed-off-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
1 parent caa3cd5 commit 0dafe99

File tree

20 files changed

+48
-44
lines changed

20 files changed

+48
-44
lines changed

arch/s390/boot/ipl_parm.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ static inline int __diag308(unsigned long subcode, void *addr)
3737
{
3838
union register_pair r1 = { .even = (unsigned long)addr, .odd = 0 };
3939

40-
asm volatile(
40+
asm_inline volatile(
4141
" diag %[r1],%[subcode],0x308\n"
4242
"0:\n"
4343
EX_TABLE(0b, 0b)

arch/s390/boot/physmem_info.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static int __diag260(unsigned long rx1, unsigned long rx2)
6767
rx.odd = rx2;
6868
ry = 0x10; /* storage configuration */
6969
exception = 1;
70-
asm volatile(
70+
asm_inline volatile(
7171
" diag %[rx],%[ry],0x260\n"
7272
"0: lhi %[exc],0\n"
7373
"1:\n"
@@ -105,7 +105,7 @@ static int diag500_storage_limit(unsigned long *max_physmem_end)
105105
{
106106
unsigned long storage_limit;
107107

108-
asm volatile(
108+
asm_inline volatile(
109109
" lghi %%r1,%[subcode]\n"
110110
" lghi %%r2,0\n"
111111
" diag %%r2,%%r4,0x500\n"
@@ -126,7 +126,7 @@ static int tprot(unsigned long addr)
126126
int cc, exception;
127127

128128
exception = 1;
129-
asm volatile(
129+
asm_inline volatile(
130130
" tprot 0(%[addr]),0\n"
131131
"0: lhi %[exc],0\n"
132132
"1:\n"

arch/s390/boot/startup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ static void detect_diag9c(void)
7777
int rc = 1;
7878

7979
cpu = stap();
80-
asm volatile(
80+
asm_inline volatile(
8181
" diag %[cpu],%%r0,0x9c\n"
8282
"0: lhi %[rc],0\n"
8383
"1:\n"
@@ -138,7 +138,7 @@ static int cmma_test_essa(void)
138138
int rc = 1;
139139

140140
/* Test ESSA_GET_STATE */
141-
asm volatile(
141+
asm_inline volatile(
142142
" .insn rrf,0xb9ab0000,%[tmp],%[tmp],%[cmd],0\n"
143143
"0: lhi %[rc],0\n"
144144
"1:\n"

arch/s390/include/asm/cpu_mf.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ static inline int qctri(struct cpumf_ctr_info *info)
171171
{
172172
int rc = -EINVAL;
173173

174-
asm volatile (
174+
asm_inline volatile (
175175
"0: qctri %1\n"
176176
"1: lhi %0,0\n"
177177
"2:\n"
@@ -185,7 +185,7 @@ static inline int lcctl(u64 ctl)
185185
{
186186
int cc;
187187

188-
asm volatile (
188+
asm_inline volatile (
189189
" lcctl %[ctl]\n"
190190
CC_IPM(cc)
191191
: CC_OUT(cc, cc)
@@ -200,7 +200,7 @@ static inline int __ecctr(u64 ctr, u64 *content)
200200
u64 _content;
201201
int cc;
202202

203-
asm volatile (
203+
asm_inline volatile (
204204
" ecctr %[_content],%[ctr]\n"
205205
CC_IPM(cc)
206206
: CC_OUT(cc, cc), [_content] "=d" (_content)

arch/s390/include/asm/diag.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ static inline void diag10_range(unsigned long start_pfn, unsigned long num_pfn)
6666
end_addr = pfn_to_phys(start_pfn + num_pfn - 1);
6767

6868
diag_stat_inc(DIAG_STAT_X010);
69-
asm volatile(
69+
asm_inline volatile(
7070
"0: diag %0,%1,0x10\n"
7171
"1: nopr %%r7\n"
7272
EX_TABLE(0b, 1b)

arch/s390/include/asm/processor.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,11 @@ static __always_inline bool regs_irqs_disabled(struct pt_regs *regs)
416416

417417
static __always_inline void bpon(void)
418418
{
419-
asm volatile(ALTERNATIVE("nop", ".insn rrf,0xb2e80000,0,0,13,0", ALT_SPEC(82)));
419+
asm_inline volatile(
420+
ALTERNATIVE(" nop\n",
421+
" .insn rrf,0xb2e80000,0,0,13,0\n",
422+
ALT_SPEC(82))
423+
);
420424
}
421425

422426
#endif /* __ASSEMBLY__ */

arch/s390/include/asm/uaccess.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ __put_user_##type##_noinstr(unsigned type __user *to, \
147147
{ \
148148
int rc; \
149149
\
150-
asm volatile( \
150+
asm_inline volatile( \
151151
" llilh %%r0,%[spec]\n" \
152152
"0: mvcos %[to],%[from],%[size]\n" \
153153
"1: lhi %[rc],0\n" \
@@ -263,7 +263,7 @@ __get_user_##type##_noinstr(unsigned type *to, \
263263
{ \
264264
int rc; \
265265
\
266-
asm volatile( \
266+
asm_inline volatile( \
267267
" lhi %%r0,%[spec]\n" \
268268
"0: mvcos %[to],%[from],%[size]\n" \
269269
"1: lhi %[rc],0\n" \
@@ -490,7 +490,7 @@ static __always_inline int __cmpxchg_user_key(unsigned long address, void *uval,
490490
_old = ((unsigned int)old & 0xff) << shift;
491491
_new = ((unsigned int)new & 0xff) << shift;
492492
mask = ~(0xff << shift);
493-
asm volatile(
493+
asm_inline volatile(
494494
" spka 0(%[key])\n"
495495
" sacf 256\n"
496496
" llill %[count],%[max_loops]\n"
@@ -538,7 +538,7 @@ static __always_inline int __cmpxchg_user_key(unsigned long address, void *uval,
538538
_old = ((unsigned int)old & 0xffff) << shift;
539539
_new = ((unsigned int)new & 0xffff) << shift;
540540
mask = ~(0xffff << shift);
541-
asm volatile(
541+
asm_inline volatile(
542542
" spka 0(%[key])\n"
543543
" sacf 256\n"
544544
" llill %[count],%[max_loops]\n"
@@ -580,7 +580,7 @@ static __always_inline int __cmpxchg_user_key(unsigned long address, void *uval,
580580
case 4: {
581581
unsigned int prev = old;
582582

583-
asm volatile(
583+
asm_inline volatile(
584584
" spka 0(%[key])\n"
585585
" sacf 256\n"
586586
"0: cs %[prev],%[new],%[address]\n"
@@ -601,7 +601,7 @@ static __always_inline int __cmpxchg_user_key(unsigned long address, void *uval,
601601
case 8: {
602602
unsigned long prev = old;
603603

604-
asm volatile(
604+
asm_inline volatile(
605605
" spka 0(%[key])\n"
606606
" sacf 256\n"
607607
"0: csg %[prev],%[new],%[address]\n"
@@ -622,7 +622,7 @@ static __always_inline int __cmpxchg_user_key(unsigned long address, void *uval,
622622
case 16: {
623623
__uint128_t prev = old;
624624

625-
asm volatile(
625+
asm_inline volatile(
626626
" spka 0(%[key])\n"
627627
" sacf 256\n"
628628
"0: cdsg %[prev],%[new],%[address]\n"

arch/s390/include/asm/word-at-a-time.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ static inline unsigned long load_unaligned_zeropad(const void *addr)
5252
{
5353
unsigned long data;
5454

55-
asm volatile(
55+
asm_inline volatile(
5656
"0: lg %[data],0(%[addr])\n"
5757
"1: nopr %%r7\n"
5858
EX_TABLE_ZEROPAD(0b, 1b, %[data], %[addr])

arch/s390/kernel/cert_store.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static int __diag320(unsigned long subcode, void *addr)
235235
{
236236
union register_pair rp = { .even = (unsigned long)addr, };
237237

238-
asm volatile(
238+
asm_inline volatile(
239239
" diag %[rp],%[subcode],0x320\n"
240240
"0: nopr %%r7\n"
241241
EX_TABLE(0b, 0b)

arch/s390/kernel/diag/diag.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static inline int __diag204(unsigned long *subcode, unsigned long size, void *ad
195195
{
196196
union register_pair rp = { .even = *subcode, .odd = size };
197197

198-
asm volatile(
198+
asm_inline volatile(
199199
" diag %[addr],%[rp],0x204\n"
200200
"0: nopr %%r7\n"
201201
EX_TABLE(0b,0b)
@@ -286,7 +286,7 @@ int diag224(void *ptr)
286286
int rc = -EOPNOTSUPP;
287287

288288
diag_stat_inc(DIAG_STAT_X224);
289-
asm volatile("\n"
289+
asm_inline volatile("\n"
290290
" diag %[type],%[addr],0x224\n"
291291
"0: lhi %[rc],0\n"
292292
"1:\n"

0 commit comments

Comments
 (0)