Re: [RFC PATCH v4 5/7] sched, tracing: add to report task state in symbolic chars

From: Steven Rostedt
Date: Wed Aug 02 2023 - 22:49:01 EST


On Thu, 3 Aug 2023 10:38:43 +0800
Ze Gao <zegao2021@xxxxxxxxx> wrote:

> > > +static inline char __trace_sched_switch_state_char(bool preempt,
> > > + unsigned int prev_state,
> > > + struct task_struct *p)
> > > +{
> > > + long state;
> > > +
> > > +#ifdef CONFIG_SCHED_DEBUG
> > > + BUG_ON(p != current);
> >
> > BUG? Why not WARN_ON()?
>
> I directly copied it from __trace_sched_switch_state since they
> are very similar. I had doubt on this too but decided to keep it in
> case people want to be 100% sure that the current task is exactly
> the one that is being switched, otherwise it's a fatal problem for
> scheduler at the point where trace_sched_switch is called.
>
> If you think WARN_ON_ONCE is more appropriate, I can fix both
> in v6.
>
> Thoughts?

Yeah, that BUG_ON is from 2014, and really should not BUG.

I'd fix both.

Thanks!

-- Steve