History

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.

Heiko Carstens committed 1 year ago

Commit 0dafe991 parent caa3cd520 files · +48 −44Browse files

Unified · Split

20 files
  1. arch/s390/boot/ipl_parm.c +1 −1
  2. arch/s390/boot/physmem_info.c +3 −3
  3. arch/s390/boot/startup.c +2 −2
  4. arch/s390/include/asm/cpu_mf.h +3 −3
  5. arch/s390/include/asm/diag.h +1 −1
  6. arch/s390/include/asm/processor.h +5 −1
  7. arch/s390/include/asm/uaccess.h +7 −7
  8. arch/s390/include/asm/word-at-a-time.h +1 −1
  9. arch/s390/kernel/cert_store.c +1 −1
  10. arch/s390/kernel/diag/diag.c +2 −2
  11. arch/s390/kernel/ipl.c +1 −1
  12. arch/s390/kernel/traps.c +1 −1
  13. arch/s390/mm/pfault.c +2 −2
  14. arch/s390/pci/pci_clp.c +2 −2
  15. arch/s390/pci/pci_insn.c +6 −6
  16. arch/s390/pci/pci_mmio.c +3 −3
  17. drivers/s390/block/dasd_diag.c +1 −1
  18. drivers/s390/char/diag_ftp.c +1 −1
  19. drivers/s390/char/sclp.h +1 −1
  20. drivers/s390/cio/ioasm.c +4 −4
arch/s390/boot/ipl_parm.c+1−1
@@ -37,7 +37,7 @@ static inline int __diag308(unsigned long subcode, void *addr) · 36 unmodified lines
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+3−3
@@ -67,7 +67,7 @@ static int __diag260(unsigned long rx1, unsigned long rx2) · 66 unmodified lines
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) · 31 unmodified lines
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) · 14 unmodified lines
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+2−2
@@ -77,7 +77,7 @@ static void detect_diag9c(void) · 76 unmodified lines
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) · 54 unmodified lines
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+3−3
@@ -171,7 +171,7 @@ static inline int qctri(struct cpumf_ctr_info *info) · 170 unmodified lines
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) · 7 unmodified lines
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) · 8 unmodified lines
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+1−1
@@ -66,7 +66,7 @@ static inline void diag10_range(unsigned long start_pfn, unsigned long num_pfn) · 65 unmodified lines
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+5−1
@@ -416,7 +416,11 @@ static __always_inline bool regs_irqs_disabled(struct pt_regs *regs) · 415 unmodified lines
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+7−7
@@ -147,7 +147,7 @@ __put_user_##type##_noinstr(unsigned type __user *to, \ · 146 unmodified lines
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, \ · 109 unmodified lines
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, · 220 unmodified lines
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, · 41 unmodified lines
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, · 35 unmodified lines
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, · 14 unmodified lines
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, · 14 unmodified lines
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+1−1
@@ -52,7 +52,7 @@ static inline unsigned long load_unaligned_zeropad(const void *addr) · 51 unmodified lines
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+1−1
@@ -235,7 +235,7 @@ static int __diag320(unsigned long subcode, void *addr) · 234 unmodified lines
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+2−2
@@ -195,7 +195,7 @@ static inline int __diag204(unsigned long *subcode, unsigned long size, void *ad · 194 unmodified lines
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) · 84 unmodified lines
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"
arch/s390/kernel/ipl.c+1−1
@@ -186,7 +186,7 @@ static inline int __diag308(unsigned long subcode, unsigned long addr) · 185 unmodified lines
186186
187187 r1.even = addr;
188188 r1.odd = 0;
189− asm volatile(
189+ asm_inline volatile(
190190 " diag %[r1],%[subcode],0x308\n"
191191 "0: nopr %%r7\n"
192192 EX_TABLE(0b,0b)
arch/s390/kernel/traps.c+1−1
@@ -257,7 +257,7 @@ static void __init test_monitor_call(void) · 256 unmodified lines
257257
258258 if (!IS_ENABLED(CONFIG_BUG))
259259 return;
260− asm volatile(
260+ asm_inline volatile(
261261 " mc 0,0\n"
262262 "0: xgr %0,%0\n"
263263 "1:\n"
arch/s390/mm/pfault.c+2−2
@@ -56,7 +56,7 @@ int __pfault_init(void) · 55 unmodified lines
5656 if (pfault_disable)
5757 return rc;
5858 diag_stat_inc(DIAG_STAT_X258);
59− asm volatile(
59+ asm_inline volatile(
6060 " diag %[refbk],%[rc],0x258\n"
6161 "0: nopr %%r7\n"
6262 EX_TABLE(0b, 0b)
@@ -78,7 +78,7 @@ void __pfault_fini(void) · 15 unmodified lines
7878 if (pfault_disable)
7979 return;
8080 diag_stat_inc(DIAG_STAT_X258);
81− asm volatile(
81+ asm_inline volatile(
8282 " diag %[refbk],0,0x258\n"
8383 "0: nopr %%r7\n"
8484 EX_TABLE(0b, 0b)
arch/s390/pci/pci_clp.c+2−2
@@ -56,7 +56,7 @@ static inline int clp_get_ilp(unsigned long *ilp) · 55 unmodified lines
5656 int cc, exception;
5757
5858 exception = 1;
59− asm volatile (
59+ asm_inline volatile (
6060 " .insn rrf,0xb9a00000,%[mask],%[cmd],8,0\n"
6161 "0: lhi %[exc],0\n"
6262 "1:\n"
@@ -79,7 +79,7 @@ static __always_inline int clp_req(void *data, unsigned int lps) · 16 unmodified lines
7979 u64 ignored;
8080
8181 exception = 1;
82− asm volatile (
82+ asm_inline volatile (
8383 " .insn rrf,0xb9a00000,%[ign],%[req],0,%[lps]\n"
8484 "0: lhi %[exc],0\n"
8585 "1:\n"
arch/s390/pci/pci_insn.c+6−6
@@ -160,7 +160,7 @@ static inline int ____pcilg(u64 *data, u64 req, u64 offset, u8 *status) · 159 unmodified lines
160160 u64 __data;
161161
162162 exception = 1;
163− asm volatile (
163+ asm_inline volatile (
164164 " .insn rre,0xb9d20000,%[data],%[req_off]\n"
165165 "0: lhi %[exc],0\n"
166166 "1:\n"
@@ -229,7 +229,7 @@ static inline int __pcilg_mio(u64 *data, u64 ioaddr, u64 len, u8 *status) · 62 unmodified lines
229229 u64 __data;
230230
231231 exception = 1;
232− asm volatile (
232+ asm_inline volatile (
233233 " .insn rre,0xb9d60000,%[data],%[ioaddr_len]\n"
234234 "0: lhi %[exc],0\n"
235235 "1:\n"
@@ -267,7 +267,7 @@ static inline int __pcistg(u64 data, u64 req, u64 offset, u8 *status) · 31 unmodified lines
267267 int cc, exception;
268268
269269 exception = 1;
270− asm volatile (
270+ asm_inline volatile (
271271 " .insn rre,0xb9d00000,%[data],%[req_off]\n"
272272 "0: lhi %[exc],0\n"
273273 "1:\n"
@@ -321,7 +321,7 @@ static inline int __pcistg_mio(u64 data, u64 ioaddr, u64 len, u8 *status) · 47 unmodified lines
321321 int cc, exception;
322322
323323 exception = 1;
324− asm volatile (
324+ asm_inline volatile (
325325 " .insn rre,0xb9d40000,%[data],%[ioaddr_len]\n"
326326 "0: lhi %[exc],0\n"
327327 "1:\n"
@@ -356,7 +356,7 @@ static inline int __pcistb(const u64 *data, u64 req, u64 offset, u8 *status) · 28 unmodified lines
356356 int cc, exception;
357357
358358 exception = 1;
359− asm volatile (
359+ asm_inline volatile (
360360 " .insn rsy,0xeb00000000d0,%[req],%[offset],%[data]\n"
361361 "0: lhi %[exc],0\n"
362362 "1:\n"
@@ -410,7 +410,7 @@ static inline int __pcistb_mio(const u64 *data, u64 ioaddr, u64 len, u8 *status) · 47 unmodified lines
410410 int cc, exception;
411411
412412 exception = 1;
413− asm volatile (
413+ asm_inline volatile (
414414 " .insn rsy,0xeb00000000d4,%[len],%[ioaddr],%[data]\n"
415415 "0: lhi %[exc],0\n"
416416 "1:\n"
arch/s390/pci/pci_mmio.c+3−3
@@ -34,7 +34,7 @@ static inline int __pcistb_mio_inuser( · 33 unmodified lines
3434 int cc, exception;
3535
3636 exception = 1;
37− asm volatile (
37+ asm_inline volatile (
3838 " sacf 256\n"
3939 "0: .insn rsy,0xeb00000000d4,%[len],%[ioaddr],%[src]\n"
4040 "1: lhi %[exc],0\n"
@@ -64,7 +64,7 @@ static inline int __pcistg_mio_inuser( · 23 unmodified lines
6464 * address space. pcistg then uses the user mappings.
6565 */
6666 exception = 1;
67− asm volatile (
67+ asm_inline volatile (
6868 " sacf 256\n"
6969 "0: llgc %[tmp],0(%[src])\n"
7070 "4: sllg %[val],%[val],8\n"
@@ -211,7 +211,7 @@ static inline int __pcilg_mio_inuser( · 140 unmodified lines
211211 * user address @dst
212212 */
213213 exception = 1;
214− asm volatile (
214+ asm_inline volatile (
215215 " sacf 256\n"
216216 "0: .insn rre,0xb9d60000,%[val],%[ioaddr_len]\n"
217217 "1: lhi %[exc],0\n"
drivers/s390/block/dasd_diag.c+1−1
@@ -76,7 +76,7 @@ static inline int __dia250(void *iob, int cmd) · 75 unmodified lines
7676 } addr_type;
7777
7878 exception = 1;
79− asm volatile(
79+ asm_inline volatile(
8080 " diag %[rx],%[cmd],0x250\n"
8181 "0: lhi %[exc],0\n"
8282 "1:\n"
drivers/s390/char/diag_ftp.c+1−1
@@ -106,7 +106,7 @@ static int diag_ftp_2c4(struct diag_ftp_ldfpl *fpl, · 105 unmodified lines
106106 int rc;
107107
108108 diag_stat_inc(DIAG_STAT_X2C4);
109− asm volatile(
109+ asm_inline volatile(
110110 " diag %[addr],%[cmd],0x2c4\n"
111111 "0: j 2f\n"
112112 "1: la %[rc],%[err]\n"
drivers/s390/char/sclp.h+1−1
@@ -318,7 +318,7 @@ static inline int sclp_service_call(sclp_cmdw_t command, void *sccb) · 317 unmodified lines
318318 int cc, exception;
319319
320320 exception = 1;
321− asm volatile(
321+ asm_inline volatile(
322322 "0: .insn rre,0xb2200000,%[cmd],%[sccb]\n" /* servc */
323323 "1: lhi %[exc],0\n"
324324 "2:\n"
drivers/s390/cio/ioasm.c+4−4
@@ -22,7 +22,7 @@ static inline int __stsch(struct subchannel_id schid, struct schib *addr) · 21 unmodified lines
2222 int ccode, exception;
2323
2424 exception = 1;
25− asm volatile(
25+ asm_inline volatile(
2626 " lgr 1,%[r1]\n"
2727 " stsch %[addr]\n"
2828 "0: lhi %[exc],0\n"
@@ -52,7 +52,7 @@ static inline int __msch(struct subchannel_id schid, struct schib *addr) · 23 unmodified lines
5252 int ccode, exception;
5353
5454 exception = 1;
55− asm volatile(
55+ asm_inline volatile(
5656 " lgr 1,%[r1]\n"
5757 " msch %[addr]\n"
5858 "0: lhi %[exc],0\n"
@@ -106,7 +106,7 @@ static inline int __ssch(struct subchannel_id schid, union orb *addr) · 47 unmodified lines
106106 int ccode, exception;
107107
108108 exception = 1;
109− asm volatile(
109+ asm_inline volatile(
110110 " lgr 1,%[r1]\n"
111111 " ssch %[addr]\n"
112112 "0: lhi %[exc],0\n"
@@ -178,7 +178,7 @@ int chsc(void *chsc_area) · 65 unmodified lines
178178 int cc, exception;
179179
180180 exception = 1;
181− asm volatile(
181+ asm_inline volatile(
182182 " .insn rre,0xb25f0000,%[chsc_area],0\n"
183183 "0: lhi %[exc],0\n"
184184 "1:\n"

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t