Re: [RFC PATCH 1/3] static_call: Add static call infrastructure

From: Steven Rostedt
Date: Sat Nov 10 2018 - 08:09:25 EST


On Sat, 10 Nov 2018 12:58:08 +0100
Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx> wrote:


> > The complaint is on:
> >
> > DEFINE_STATIC_CALL(__tp_func_##name, __tracepoint_iter_##name);
> >
> > And the previous definition is on:
> >
> > DECLARE_STATIC_CALL(__tp_func_##name, __tracepoint_iter_##name); \
> >
>
> Does the DECLARE really need the __ADDRESSABLE? Its purpose is to
> ensure that symbols with static linkage are not optimized away, but
> since the reference is from a header file, the symbol should have
> external linkage anyway.

I applied the following change and it compiled fine:

diff --git a/include/linux/static_call.h b/include/linux/static_call.h
index 90b580b95303..5f8a0f0e77be 100644
--- a/include/linux/static_call.h
+++ b/include/linux/static_call.h
@@ -108,8 +108,6 @@ extern void arch_static_call_poison_tramp(unsigned long insn);
#define DECLARE_STATIC_CALL(key, func) \
extern struct static_call_key key; \
extern typeof(func) STATIC_CALL_TRAMP(key); \
- /* Preserve the ELF symbol so objtool can access it: */ \
- __ADDRESSABLE(key)

#define DEFINE_STATIC_CALL(key, _func) \
DECLARE_STATIC_CALL(key, _func); \
@@ -117,7 +115,9 @@ extern void arch_static_call_poison_tramp(unsigned long insn);
.func = _func, \
.site_mods = LIST_HEAD_INIT(key.site_mods), \
}; \
- ARCH_STATIC_CALL_TEMPORARY_TRAMP(key)
+ ARCH_STATIC_CALL_TEMPORARY_TRAMP(key); \
+ /* Preserve the ELF symbol so objtool can access it: */ \
+ __ADDRESSABLE(key)

#define static_call(key, args...) STATIC_CALL_TRAMP(key)(args)

Thanks!

-- Steve