Skip to content

Commit 433cd7c

Browse files
Peter Zijlstragregkh
authored andcommitted
static_call: Pull some static_call declarations to the type headers
[ Upstream commit 880cfed ] Some static call declarations are going to be needed on low level header files. Move the necessary material to the dedicated static call types header to avoid inclusion dependency hell. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org> Link: https://lkml.kernel.org/r/20210118141223.123667-4-frederic@kernel.org Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 533c293 commit 433cd7c

3 files changed

Lines changed: 54 additions & 21 deletions

File tree

‎include/linux/static_call.h‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -107,26 +107,10 @@ extern void arch_static_call_transform(void *site, void *tramp, void *func, bool
107107

108108
#define STATIC_CALL_TRAMP_ADDR(name) &STATIC_CALL_TRAMP(name)
109109

110-
/*
111-
* __ADDRESSABLE() is used to ensure the key symbol doesn't get stripped from
112-
* the symbol table so that objtool can reference it when it generates the
113-
* .static_call_sites section.
114-
*/
115-
#define __static_call(name) \
116-
({ \
117-
__ADDRESSABLE(STATIC_CALL_KEY(name)); \
118-
&STATIC_CALL_TRAMP(name); \
119-
})
120-
121110
#else
122111
#define STATIC_CALL_TRAMP_ADDR(name) NULL
123112
#endif
124113

125-
126-
#define DECLARE_STATIC_CALL(name, func) \
127-
extern struct static_call_key STATIC_CALL_KEY(name); \
128-
extern typeof(func) STATIC_CALL_TRAMP(name);
129-
130114
#define static_call_update(name, func) \
131115
({ \
132116
BUILD_BUG_ON(!__same_type(*(func), STATIC_CALL_TRAMP(name))); \
@@ -174,7 +158,6 @@ extern int static_call_text_reserved(void *start, void *end);
174158
}; \
175159
ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name)
176160

177-
#define static_call(name) __static_call(name)
178161
#define static_call_cond(name) (void)__static_call(name)
179162

180163
#define EXPORT_STATIC_CALL(name) \
@@ -207,7 +190,6 @@ struct static_call_key {
207190
}; \
208191
ARCH_DEFINE_STATIC_CALL_NULL_TRAMP(name)
209192

210-
#define static_call(name) __static_call(name)
211193
#define static_call_cond(name) (void)__static_call(name)
212194

213195
static inline
@@ -252,9 +234,6 @@ struct static_call_key {
252234
.func = NULL, \
253235
}
254236

255-
#define static_call(name) \
256-
((typeof(STATIC_CALL_TRAMP(name))*)(STATIC_CALL_KEY(name).func))
257-
258237
static inline void __static_call_nop(void) { }
259238

260239
/*

‎include/linux/static_call_types.h‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <linux/types.h>
66
#include <linux/stringify.h>
7+
#include <linux/compiler.h>
78

89
#define STATIC_CALL_KEY_PREFIX __SCK__
910
#define STATIC_CALL_KEY_PREFIX_STR __stringify(STATIC_CALL_KEY_PREFIX)
@@ -32,4 +33,30 @@ struct static_call_site {
3233
s32 key;
3334
};
3435

36+
#define DECLARE_STATIC_CALL(name, func) \
37+
extern struct static_call_key STATIC_CALL_KEY(name); \
38+
extern typeof(func) STATIC_CALL_TRAMP(name);
39+
40+
#ifdef CONFIG_HAVE_STATIC_CALL
41+
42+
/*
43+
* __ADDRESSABLE() is used to ensure the key symbol doesn't get stripped from
44+
* the symbol table so that objtool can reference it when it generates the
45+
* .static_call_sites section.
46+
*/
47+
#define __static_call(name) \
48+
({ \
49+
__ADDRESSABLE(STATIC_CALL_KEY(name)); \
50+
&STATIC_CALL_TRAMP(name); \
51+
})
52+
53+
#define static_call(name) __static_call(name)
54+
55+
#else
56+
57+
#define static_call(name) \
58+
((typeof(STATIC_CALL_TRAMP(name))*)(STATIC_CALL_KEY(name).func))
59+
60+
#endif /* CONFIG_HAVE_STATIC_CALL */
61+
3562
#endif /* _STATIC_CALL_TYPES_H */

‎tools/include/linux/static_call_types.h‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <linux/types.h>
66
#include <linux/stringify.h>
7+
#include <linux/compiler.h>
78

89
#define STATIC_CALL_KEY_PREFIX __SCK__
910
#define STATIC_CALL_KEY_PREFIX_STR __stringify(STATIC_CALL_KEY_PREFIX)
@@ -32,4 +33,30 @@ struct static_call_site {
3233
s32 key;
3334
};
3435

36+
#define DECLARE_STATIC_CALL(name, func) \
37+
extern struct static_call_key STATIC_CALL_KEY(name); \
38+
extern typeof(func) STATIC_CALL_TRAMP(name);
39+
40+
#ifdef CONFIG_HAVE_STATIC_CALL
41+
42+
/*
43+
* __ADDRESSABLE() is used to ensure the key symbol doesn't get stripped from
44+
* the symbol table so that objtool can reference it when it generates the
45+
* .static_call_sites section.
46+
*/
47+
#define __static_call(name) \
48+
({ \
49+
__ADDRESSABLE(STATIC_CALL_KEY(name)); \
50+
&STATIC_CALL_TRAMP(name); \
51+
})
52+
53+
#define static_call(name) __static_call(name)
54+
55+
#else
56+
57+
#define static_call(name) \
58+
((typeof(STATIC_CALL_TRAMP(name))*)(STATIC_CALL_KEY(name).func))
59+
60+
#endif /* CONFIG_HAVE_STATIC_CALL */
61+
3562
#endif /* _STATIC_CALL_TYPES_H */

0 commit comments

Comments
 (0)