summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2019-09-21 12:47:19 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2019-09-21 12:47:19 -0400
commit227c3e9eb5cf3552c2cc83225df6d14adb05f8e8 (patch)
tree529caf68f7c4a670813ecddb718e5118ce3cef70
parent56c631f5aec35117b0b5862a09a447a72dfbd678 (diff)
parent32ee8230b2b06c50f583e14fcd174d7d2edb52f5 (diff)
Merge tag 'compiler-attributes-for-linus-v5.4' of git://github.com/ojeda/linux
Pull asm inline support from Miguel Ojeda: "Make use of gcc 9's "asm inline()" (Rasmus Villemoes): gcc 9+ (and gcc 8.3, 7.5) provides a way to override the otherwise crude heuristic that gcc uses to estimate the size of the code represented by an asm() statement. From the gcc docs If you use 'asm inline' instead of just 'asm', then for inlining purposes the size of the asm is taken as the minimum size, ignoring how many instructions GCC thinks it is. For compatibility with older compilers, we obviously want a #if [understands asm inline] #define asm_inline asm inline #else #define asm_inline asm #endif But since we #define the identifier inline to attach some attributes, we have to use an alternate spelling of that keyword. gcc provides both __inline__ and __inline, and we currently #define both to inline, so they all have the same semantics. We have to free up one of __inline__ and __inline, and the latter is by far the easiest. The two x86 changes cause smaller code gen differences than I'd expect, but I think we do want the asm_inline thing available sooner or later, so this is just to get the ball rolling" * tag 'compiler-attributes-for-linus-v5.4' of git://github.com/ojeda/linux: x86: bug.h: use asm_inline in _BUG_FLAGS definitions x86: alternative.h: use asm_inline for all alternative variants compiler-types.h: add asm_inline definition compiler_types.h: don't #define __inline lib/zstd/mem.h: replace __inline by inline staging: rtl8723bs: replace __inline by inline
-rw-r--r--arch/x86/include/asm/alternative.h14
-rw-r--r--arch/x86/include/asm/bug.h4
-rw-r--r--include/linux/compiler_types.h17
-rw-r--r--init/Kconfig3
-rw-r--r--lib/zstd/mem.h2
5 files changed, 29 insertions, 11 deletions
diff --git a/arch/x86/include/asm/alternative.h b/arch/x86/include/asm/alternative.h
index 094fbc9c0b1c..13adca37c99a 100644
--- a/arch/x86/include/asm/alternative.h
+++ b/arch/x86/include/asm/alternative.h
@@ -201,10 +201,10 @@ static inline int alternatives_text_reserved(void *start, void *end)
201 * without volatile and memory clobber. 201 * without volatile and memory clobber.
202 */ 202 */
203#define alternative(oldinstr, newinstr, feature) \ 203#define alternative(oldinstr, newinstr, feature) \
204 asm volatile (ALTERNATIVE(oldinstr, newinstr, feature) : : : "memory") 204 asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature) : : : "memory")
205 205
206#define alternative_2(oldinstr, newinstr1, feature1, newinstr2, feature2) \ 206#define alternative_2(oldinstr, newinstr1, feature1, newinstr2, feature2) \
207 asm volatile(ALTERNATIVE_2(oldinstr, newinstr1, feature1, newinstr2, feature2) ::: "memory") 207 asm_inline volatile(ALTERNATIVE_2(oldinstr, newinstr1, feature1, newinstr2, feature2) ::: "memory")
208 208
209/* 209/*
210 * Alternative inline assembly with input. 210 * Alternative inline assembly with input.
@@ -218,7 +218,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
218 * Leaving an unused argument 0 to keep API compatibility. 218 * Leaving an unused argument 0 to keep API compatibility.
219 */ 219 */
220#define alternative_input(oldinstr, newinstr, feature, input...) \ 220#define alternative_input(oldinstr, newinstr, feature, input...) \
221 asm volatile (ALTERNATIVE(oldinstr, newinstr, feature) \ 221 asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature) \
222 : : "i" (0), ## input) 222 : : "i" (0), ## input)
223 223
224/* 224/*
@@ -231,18 +231,18 @@ static inline int alternatives_text_reserved(void *start, void *end)
231 */ 231 */
232#define alternative_input_2(oldinstr, newinstr1, feature1, newinstr2, \ 232#define alternative_input_2(oldinstr, newinstr1, feature1, newinstr2, \
233 feature2, input...) \ 233 feature2, input...) \
234 asm volatile(ALTERNATIVE_2(oldinstr, newinstr1, feature1, \ 234 asm_inline volatile(ALTERNATIVE_2(oldinstr, newinstr1, feature1, \
235 newinstr2, feature2) \ 235 newinstr2, feature2) \
236 : : "i" (0), ## input) 236 : : "i" (0), ## input)
237 237
238/* Like alternative_input, but with a single output argument */ 238/* Like alternative_input, but with a single output argument */
239#define alternative_io(oldinstr, newinstr, feature, output, input...) \ 239#define alternative_io(oldinstr, newinstr, feature, output, input...) \
240 asm volatile (ALTERNATIVE(oldinstr, newinstr, feature) \ 240 asm_inline volatile (ALTERNATIVE(oldinstr, newinstr, feature) \
241 : output : "i" (0), ## input) 241 : output : "i" (0), ## input)
242 242
243/* Like alternative_io, but for replacing a direct call with another one. */ 243/* Like alternative_io, but for replacing a direct call with another one. */
244#define alternative_call(oldfunc, newfunc, feature, output, input...) \ 244#define alternative_call(oldfunc, newfunc, feature, output, input...) \
245 asm volatile (ALTERNATIVE("call %P[old]", "call %P[new]", feature) \ 245 asm_inline volatile (ALTERNATIVE("call %P[old]", "call %P[new]", feature) \
246 : output : [old] "i" (oldfunc), [new] "i" (newfunc), ## input) 246 : output : [old] "i" (oldfunc), [new] "i" (newfunc), ## input)
247 247
248/* 248/*
@@ -253,7 +253,7 @@ static inline int alternatives_text_reserved(void *start, void *end)
253 */ 253 */
254#define alternative_call_2(oldfunc, newfunc1, feature1, newfunc2, feature2, \ 254#define alternative_call_2(oldfunc, newfunc1, feature1, newfunc2, feature2, \
255 output, input...) \ 255 output, input...) \
256 asm volatile (ALTERNATIVE_2("call %P[old]", "call %P[new1]", feature1,\ 256 asm_inline volatile (ALTERNATIVE_2("call %P[old]", "call %P[new1]", feature1,\
257 "call %P[new2]", feature2) \ 257 "call %P[new2]", feature2) \
258 : output, ASM_CALL_CONSTRAINT \ 258 : output, ASM_CALL_CONSTRAINT \
259 : [old] "i" (oldfunc), [new1] "i" (newfunc1), \ 259 : [old] "i" (oldfunc), [new1] "i" (newfunc1), \
diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h
index 6804d6642767..facba9bc30ca 100644
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -32,7 +32,7 @@
32 32
33#define _BUG_FLAGS(ins, flags) \ 33#define _BUG_FLAGS(ins, flags) \
34do { \ 34do { \
35 asm volatile("1:\t" ins "\n" \ 35 asm_inline volatile("1:\t" ins "\n" \
36 ".pushsection __bug_table,\"aw\"\n" \ 36 ".pushsection __bug_table,\"aw\"\n" \
37 "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ 37 "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
38 "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \ 38 "\t" __BUG_REL(%c0) "\t# bug_entry::file\n" \
@@ -49,7 +49,7 @@ do { \
49 49
50#define _BUG_FLAGS(ins, flags) \ 50#define _BUG_FLAGS(ins, flags) \
51do { \ 51do { \
52 asm volatile("1:\t" ins "\n" \ 52 asm_inline volatile("1:\t" ins "\n" \
53 ".pushsection __bug_table,\"aw\"\n" \ 53 ".pushsection __bug_table,\"aw\"\n" \
54 "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \ 54 "2:\t" __BUG_REL(1b) "\t# bug_entry::bug_addr\n" \
55 "\t.word %c0" "\t# bug_entry::flags\n" \ 55 "\t.word %c0" "\t# bug_entry::flags\n" \
diff --git a/include/linux/compiler_types.h b/include/linux/compiler_types.h
index b056a40116da..72393a8c1a6c 100644
--- a/include/linux/compiler_types.h
+++ b/include/linux/compiler_types.h
@@ -146,8 +146,17 @@ struct ftrace_likely_data {
146 __inline_maybe_unused notrace 146 __inline_maybe_unused notrace
147#endif 147#endif
148 148
149/*
150 * gcc provides both __inline__ and __inline as alternate spellings of
151 * the inline keyword, though the latter is undocumented. New kernel
152 * code should only use the inline spelling, but some existing code
153 * uses __inline__. Since we #define inline above, to ensure
154 * __inline__ has the same semantics, we need this #define.
155 *
156 * However, the spelling __inline is strictly reserved for referring
157 * to the bare keyword.
158 */
149#define __inline__ inline 159#define __inline__ inline
150#define __inline inline
151 160
152/* 161/*
153 * GCC does not warn about unused static inline functions for -Wunused-function. 162 * GCC does not warn about unused static inline functions for -Wunused-function.
@@ -197,6 +206,12 @@ struct ftrace_likely_data {
197#define asm_volatile_goto(x...) asm goto(x) 206#define asm_volatile_goto(x...) asm goto(x)
198#endif 207#endif
199 208
209#ifdef CONFIG_CC_HAS_ASM_INLINE
210#define asm_inline asm __inline
211#else
212#define asm_inline asm
213#endif
214
200#ifndef __no_fgcse 215#ifndef __no_fgcse
201# define __no_fgcse 216# define __no_fgcse
202#endif 217#endif
diff --git a/init/Kconfig b/init/Kconfig
index f4534c58342d..7020238fd263 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -33,6 +33,9 @@ config CC_HAS_ASM_GOTO
33config TOOLS_SUPPORT_RELR 33config TOOLS_SUPPORT_RELR
34 def_bool $(success,env "CC=$(CC)" "LD=$(LD)" "NM=$(NM)" "OBJCOPY=$(OBJCOPY)" $(srctree)/scripts/tools-support-relr.sh) 34 def_bool $(success,env "CC=$(CC)" "LD=$(LD)" "NM=$(NM)" "OBJCOPY=$(OBJCOPY)" $(srctree)/scripts/tools-support-relr.sh)
35 35
36config CC_HAS_ASM_INLINE
37 def_bool $(success,echo 'void foo(void) { asm inline (""); }' | $(CC) -x c - -c -o /dev/null)
38
36config CC_HAS_WARN_MAYBE_UNINITIALIZED 39config CC_HAS_WARN_MAYBE_UNINITIALIZED
37 def_bool $(cc-option,-Wmaybe-uninitialized) 40 def_bool $(cc-option,-Wmaybe-uninitialized)
38 help 41 help
diff --git a/lib/zstd/mem.h b/lib/zstd/mem.h
index 3a0f34c8706c..93d7a2c377fe 100644
--- a/lib/zstd/mem.h
+++ b/lib/zstd/mem.h
@@ -27,7 +27,7 @@
27/*-**************************************** 27/*-****************************************
28* Compiler specifics 28* Compiler specifics
29******************************************/ 29******************************************/
30#define ZSTD_STATIC static __inline __attribute__((unused)) 30#define ZSTD_STATIC static inline
31 31
32/*-************************************************************** 32/*-**************************************************************
33* Basic Types 33* Basic Types