Skip to content

Commit 9ae6ab2

Browse files
Peter ZijlstraIngo Molnar
authored andcommitted
static_call: Update API documentation
Update the comment with the new features. Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Reviewed-by: Steven Rostedt (VMware) <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 026659b commit 9ae6ab2

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

include/linux/static_call.h

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,17 @@
1717
* DECLARE_STATIC_CALL(name, func);
1818
* DEFINE_STATIC_CALL(name, func);
1919
* DEFINE_STATIC_CALL_NULL(name, typename);
20+
* DEFINE_STATIC_CALL_RET0(name, typename);
21+
*
22+
* __static_call_return0;
23+
*
2024
* static_call(name)(args...);
2125
* static_call_cond(name)(args...);
2226
* static_call_update(name, func);
2327
* static_call_query(name);
2428
*
29+
* EXPORT_STATIC_CALL{,_TRAMP}{,_GPL}()
30+
*
2531
* Usage example:
2632
*
2733
* # Start with the following functions (with identical prototypes):
@@ -96,6 +102,33 @@
96102
* To query which function is currently set to be called, use:
97103
*
98104
* func = static_call_query(name);
105+
*
106+
*
107+
* DEFINE_STATIC_CALL_RET0 / __static_call_return0:
108+
*
109+
* Just like how DEFINE_STATIC_CALL_NULL() / static_call_cond() optimize the
110+
* conditional void function call, DEFINE_STATIC_CALL_RET0 /
111+
* __static_call_return0 optimize the do nothing return 0 function.
112+
*
113+
* This feature is strictly UB per the C standard (since it casts a function
114+
* pointer to a different signature) and relies on the architecture ABI to
115+
* make things work. In particular it relies on Caller Stack-cleanup and the
116+
* whole return register being clobbered for short return values. All normal
117+
* CDECL style ABIs conform.
118+
*
119+
* In particular the x86_64 implementation replaces the 5 byte CALL
120+
* instruction at the callsite with a 5 byte clear of the RAX register,
121+
* completely eliding any function call overhead.
122+
*
123+
* Notably argument setup is unconditional.
124+
*
125+
*
126+
* EXPORT_STATIC_CALL() vs EXPORT_STATIC_CALL_TRAMP():
127+
*
128+
* The difference is that the _TRAMP variant tries to only export the
129+
* trampoline with the result that a module can use static_call{,_cond}() but
130+
* not static_call_update().
131+
*
99132
*/
100133

101134
#include <linux/types.h>

0 commit comments

Comments
 (0)