Re: [PATCH v3 01/17] tools/rv: Do not skip idle in trace

From: Gabriele Monaco
Date: Wed Jul 16 2025 - 09:14:00 EST


On Wed, 2025-07-16 at 15:08 +0200, Peter Zijlstra wrote:
> > > > > > - if (config_has_id && (config_my_pid == id))
> > > > > > + if (config_my_pid && config_has_id &&
> > > > > > (config_my_pid == id))
> > >
> > > But should we then not write:
> > >
> > > if (config_has_id && (config_my_pid == id))
> >
> > Sorry, got a bit confused, I flipped the two while describing:
> > * -s shows traces from RV but skips from pid-0 (unintended)
> > * omitting -s skips events from RV (correct)
> >
> > If we are running a per-task monitor config_has_id is always true,
> > we pass -s,
> > which makes config_my_pid = 0 (intended /not/ to skip RV).
> > Now when we are about to trace an event from idle (id=0), we skip
> > it, although
> > we really shouldn't.
> > That's why we also needs to check for config_my_pid not being 0.
> >
> > Does it make sense?
>
> Sorta, but would it not make sense to use has_pid := -1 for the
> invalid case, instead of 0, which is a valid pid?

Yeah that's another option, I reckon even cleaner since it's currently
misleading..