Re: [RFC PATCH v2 2/9] tracing/sched: Add IRQ preemption lifecycle tracepoints

From: Gabriele Monaco

Date: Sat Nov 21 2026 - 05:35:23 EST


On Sat, 2026-11-07 at 18:12 +0100, Karl Mehltretter wrote:
...

>  asmlinkage __visible void __sched preempt_schedule_irq(void)
>  {
> + struct task_struct *owner = current;
>   enum ctx_state prev_state;
>  
>   /* Catch callers which need to be fixed */
>   BUG_ON(preempt_count() || !irqs_disabled());
>  
>   prev_state = exception_enter();
> + /* Sample before tracing bookkeeping can change the observed context.
> */

What's this comment for? You're tracing before disabling preemption to schedule,
what bookkeeping?

> + if (trace_sched_irq_preempt_entry_tp_enabled())
> + trace_sched_irq_preempt_entry_tp(owner, preempt_count(),
> irqs_disabled());

I don't think you need to check the static key manually, arguments are expanded
inside the trace_##_tp() after checking it, so you can just trace here.

>  
>   do {
>   preempt_disable();
> @@ -7664,6 +7668,8 @@ asmlinkage __visible void __sched
> preempt_schedule_irq(void)
>   sched_preempt_enable_no_resched();
>   } while (need_resched());
>  
> + if (trace_sched_irq_preempt_exit_tp_enabled())
> + trace_sched_irq_preempt_exit_tp(owner, preempt_count(),
> irqs_disabled());

Does the owner here makes sense? Do you use it as the /initiator/ of the first
switch? Is it only to match it with the entry (although, as you said, it may be
somewhere else, running again, or not running at all).

Thanks,
Gabriele

>   exception_exit(prev_state);
>  }
>