]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sched: Use trace_call__<tp>() to save a static branch
authorGabriele Monaco <gmonaco@redhat.com>
Wed, 29 Apr 2026 09:41:37 +0000 (11:41 +0200)
committerPeter Zijlstra <peterz@infradead.org>
Tue, 5 May 2026 10:50:50 +0000 (12:50 +0200)
The wrapper functions __trace_set_current_state() and
__trace_set_need_resched() allow the tracepoints to be called from code
outside sched/core.c, those calls are already guarded by a
tracepoint_enabled(<tp>) so there is no need to repeat this check once
again inside the call using trace_<tp>().

Use the new trace_call__<tp>() API to directly call the tracepoint
without check. Those helper functions must be called after the
appropriate check.

Signed-off-by: Gabriele Monaco <gmonaco@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/20260429094227.34087-1-gmonaco@redhat.com
kernel/sched/core.c

index b8871449d3c694b4237e9cb841dc4e302b361eb5..b905805bbcbe4ace262dc482fe774c047d350124 100644 (file)
@@ -537,10 +537,14 @@ sched_core_dequeue(struct rq *rq, struct task_struct *p, int flags) { }
 /* need a wrapper since we may need to trace from modules */
 EXPORT_TRACEPOINT_SYMBOL(sched_set_state_tp);
 
-/* Call via the helper macro trace_set_current_state. */
+/*
+ * Call via the helper macro trace_set_current_state.
+ * Calls to this function MUST be guarded by a
+ * tracepoint_enabled(sched_set_state_tp)
+ */
 void __trace_set_current_state(int state_value)
 {
-       trace_sched_set_state_tp(current, state_value);
+       trace_call__sched_set_state_tp(current, state_value);
 }
 EXPORT_SYMBOL(__trace_set_current_state);
 
@@ -1203,9 +1207,13 @@ static void __resched_curr(struct rq *rq, int tif)
        }
 }
 
+/*
+ * Calls to this function MUST be guarded by a
+ * tracepoint_enabled(sched_set_need_resched_tp)
+ */
 void __trace_set_need_resched(struct task_struct *curr, int tif)
 {
-       trace_sched_set_need_resched_tp(curr, smp_processor_id(), tif);
+       trace_call__sched_set_need_resched_tp(curr, smp_processor_id(), tif);
 }
 EXPORT_SYMBOL_GPL(__trace_set_need_resched);