On Thu, Feb 06, 2025 at 09:36:41AM +0100, Gabriele Monaco wrote: > > > diff --git a/kernel/sched/core.c b/kernel/sched/core.c > > > index 165c90ba64ea9..fb5f8aa61ef5d 100644 > > > --- a/kernel/sched/core.c > > > +++ b/kernel/sched/core.c > > > @@ -491,6 +491,12 @@ sched_core_dequeue(struct rq *rq, struct > > > task_struct *p, int flags) { } > > > > > > #endif /* CONFIG_SCHED_CORE */ > > > > > > +void trace_set_current_state(int state_value) > > > +{ > > > + trace_sched_set_state_tp(current, current->__state, > > > state_value); > > > +} > > > +EXPORT_SYMBOL(trace_set_current_state); > > > > Urgh, why !?! > > > > Do you mean why exporting it? > At first I was puzzled too (this line is borrowed from Daniel), but the > thing is: set_current_state and friends are macros called by any sort > of code (e.g. modules), this seems the easiest way without messing up > with the current code. > > I'm not sure if it would be cleaner to just drop this function and > define it directly in the header (including also trace/events/sched.h > there). It felt like files including sched shouldn't know about > tracepoints. > > What do you think would be better?
So I would think having the tracepoint in-line would be better. Because as is, everything gets to have this pointless CALL to an empty function. If this were x86_64 only, I would suggest using static_call(), but barring that, the static_branch() already in the tracepoint is the best we can do.