linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] static_call: Update comment
@ 2021-08-05 15:49 Peter Zijlstra
  2021-08-05 16:07 ` Steven Rostedt
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Peter Zijlstra @ 2021-08-05 15:49 UTC (permalink / raw)
  To: jpoimboe, jbaron, rostedt, ardb; +Cc: linux-kernel, ltykernel


Update the comment with the new features.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
 include/linux/static_call.h | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/include/linux/static_call.h b/include/linux/static_call.h
index fc94faa53b5b..35d28261b12b 100644
--- a/include/linux/static_call.h
+++ b/include/linux/static_call.h
@@ -17,11 +17,17 @@
  *   DECLARE_STATIC_CALL(name, func);
  *   DEFINE_STATIC_CALL(name, func);
  *   DEFINE_STATIC_CALL_NULL(name, typename);
+ *   DEFINE_STATIC_CALL_RET0(name, typename);
+ *
+ *   __static_call_return0;
+ *
  *   static_call(name)(args...);
  *   static_call_cond(name)(args...);
  *   static_call_update(name, func);
  *   static_call_query(name);
  *
+ *   EXPORT_STATIC_CALL{,_TRAMP}{,_GPL}()
+ *
  * Usage example:
  *
  *   # Start with the following functions (with identical prototypes):
@@ -96,6 +102,33 @@
  *   To query which function is currently set to be called, use:
  *
  *   func = static_call_query(name);
+ *
+ *
+ * DEFINE_STATIC_CALL_RET0 / __static_call_return0:
+ *
+ *   Just like how DEFINE_STATIC_CALL_NULL() / static_call_cond() optimize the
+ *   conditional void function call, DEFINE_STAT_CALL_RET0 /
+ *   __static_call_return0 optimize the do nothing return 0 function.
+ *
+ *   This feature is strictly UB per the C standard (since it casts a function
+ *   pointer to a different signature) and relies on the architecture ABI to
+ *   make things work. In particular it relies on Caller Stack cleanup and the
+ *   whole return register being clobbered for short return values. All normal
+ *   CDECL style ABIs conform.
+ *
+ *   In particular the x86_64 implementation replaces the 5 byte CALL
+ *   instruction at the callsite with a 5 byte clear of the RAX register,
+ *   completely eliding any function call overhead.
+ *
+ *   Notably argument setup is unconditional.
+ *
+ *
+ * EXPORT_STATIC_CALL() vs EXPORT_STATIC_CALL_TRAMP():
+ *
+ *   The difference is that the _TRAMP variant tries to only export the
+ *   trampoline with the result that a module can use static_call{,_cond}() but
+ *   not static_call_update().
+ *
  */
 
 #include <linux/types.h>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] static_call: Update comment
  2021-08-05 15:49 [PATCH] static_call: Update comment Peter Zijlstra
@ 2021-08-05 16:07 ` Steven Rostedt
  2021-08-08 18:47 ` Josh Poimboeuf
  2021-08-17 20:13 ` [tip: locking/core] static_call: Update API documentation tip-bot2 for Peter Zijlstra
  2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2021-08-05 16:07 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: jpoimboe, jbaron, ardb, linux-kernel, ltykernel

On Thu, 5 Aug 2021 17:49:54 +0200
Peter Zijlstra <peterz@infradead.org> wrote:

> Update the comment with the new features.
> 
> Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>

Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] static_call: Update comment
  2021-08-05 15:49 [PATCH] static_call: Update comment Peter Zijlstra
  2021-08-05 16:07 ` Steven Rostedt
@ 2021-08-08 18:47 ` Josh Poimboeuf
  2021-08-17 20:13 ` [tip: locking/core] static_call: Update API documentation tip-bot2 for Peter Zijlstra
  2 siblings, 0 replies; 4+ messages in thread
From: Josh Poimboeuf @ 2021-08-08 18:47 UTC (permalink / raw)
  To: Peter Zijlstra; +Cc: jbaron, rostedt, ardb, linux-kernel, ltykernel

On Thu, Aug 05, 2021 at 05:49:54PM +0200, Peter Zijlstra wrote:
> @@ -96,6 +102,33 @@
>   *   To query which function is currently set to be called, use:
>   *
>   *   func = static_call_query(name);
> + *
> + *
> + * DEFINE_STATIC_CALL_RET0 / __static_call_return0:
> + *
> + *   Just like how DEFINE_STATIC_CALL_NULL() / static_call_cond() optimize the
> + *   conditional void function call, DEFINE_STAT_CALL_RET0 /

s/STAT/STATIC/

Otherwise

Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>

-- 
Josh


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [tip: locking/core] static_call: Update API documentation
  2021-08-05 15:49 [PATCH] static_call: Update comment Peter Zijlstra
  2021-08-05 16:07 ` Steven Rostedt
  2021-08-08 18:47 ` Josh Poimboeuf
@ 2021-08-17 20:13 ` tip-bot2 for Peter Zijlstra
  2 siblings, 0 replies; 4+ messages in thread
From: tip-bot2 for Peter Zijlstra @ 2021-08-17 20:13 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: Peter Zijlstra (Intel), Ingo Molnar, Steven Rostedt (VMware),
	Josh Poimboeuf, x86, linux-kernel

The following commit has been merged into the locking/core branch of tip:

Commit-ID:     9ae6ab27f44ee0da47520011afc04218f90e8b12
Gitweb:        https://git.kernel.org/tip/9ae6ab27f44ee0da47520011afc04218f90e8b12
Author:        Peter Zijlstra <peterz@infradead.org>
AuthorDate:    Thu, 05 Aug 2021 17:49:54 +02:00
Committer:     Ingo Molnar <mingo@kernel.org>
CommitterDate: Tue, 17 Aug 2021 19:09:27 +02:00

static_call: Update API documentation

Update the comment with the new features.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/YQwIorQBHEq+s73b@hirez.programming.kicks-ass.net
---
 include/linux/static_call.h | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/include/linux/static_call.h b/include/linux/static_call.h
index fc94faa..3e56a97 100644
--- a/include/linux/static_call.h
+++ b/include/linux/static_call.h
@@ -17,11 +17,17 @@
  *   DECLARE_STATIC_CALL(name, func);
  *   DEFINE_STATIC_CALL(name, func);
  *   DEFINE_STATIC_CALL_NULL(name, typename);
+ *   DEFINE_STATIC_CALL_RET0(name, typename);
+ *
+ *   __static_call_return0;
+ *
  *   static_call(name)(args...);
  *   static_call_cond(name)(args...);
  *   static_call_update(name, func);
  *   static_call_query(name);
  *
+ *   EXPORT_STATIC_CALL{,_TRAMP}{,_GPL}()
+ *
  * Usage example:
  *
  *   # Start with the following functions (with identical prototypes):
@@ -96,6 +102,33 @@
  *   To query which function is currently set to be called, use:
  *
  *   func = static_call_query(name);
+ *
+ *
+ * DEFINE_STATIC_CALL_RET0 / __static_call_return0:
+ *
+ *   Just like how DEFINE_STATIC_CALL_NULL() / static_call_cond() optimize the
+ *   conditional void function call, DEFINE_STATIC_CALL_RET0 /
+ *   __static_call_return0 optimize the do nothing return 0 function.
+ *
+ *   This feature is strictly UB per the C standard (since it casts a function
+ *   pointer to a different signature) and relies on the architecture ABI to
+ *   make things work. In particular it relies on Caller Stack-cleanup and the
+ *   whole return register being clobbered for short return values. All normal
+ *   CDECL style ABIs conform.
+ *
+ *   In particular the x86_64 implementation replaces the 5 byte CALL
+ *   instruction at the callsite with a 5 byte clear of the RAX register,
+ *   completely eliding any function call overhead.
+ *
+ *   Notably argument setup is unconditional.
+ *
+ *
+ * EXPORT_STATIC_CALL() vs EXPORT_STATIC_CALL_TRAMP():
+ *
+ *   The difference is that the _TRAMP variant tries to only export the
+ *   trampoline with the result that a module can use static_call{,_cond}() but
+ *   not static_call_update().
+ *
  */
 
 #include <linux/types.h>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-08-17 20:14 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-05 15:49 [PATCH] static_call: Update comment Peter Zijlstra
2021-08-05 16:07 ` Steven Rostedt
2021-08-08 18:47 ` Josh Poimboeuf
2021-08-17 20:13 ` [tip: locking/core] static_call: Update API documentation tip-bot2 for Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).