Re: [PATCH v4 1/5] tracing: Introduce faultable tracepoints

From: Peter Zijlstra
Date: Tue Nov 21 2023 - 11:50:51 EST


On Tue, Nov 21, 2023 at 11:00:13AM -0500, Mathieu Desnoyers wrote:
> On 2023-11-21 10:52, Peter Zijlstra wrote:
> > On Tue, Nov 21, 2023 at 03:46:43PM +0100, Peter Zijlstra wrote:
> >
> > > Why is this such a hard question?
> >
> > Anyway, recapping from IRC:
> >
> > preemptible, SRCU:
> > counter-array based, GP advances by increasing array index
> > and waiting for previous index to drop to 0.
> >
> > notably, a GP can pass while a task is preempted but not within a
> > critical section.
> >
> > SRCU has smp_mb() in the critical sections to improve GP.
>
> Also:
>
> preemptible only allows blocking when priority inheritance is
> guarantees, which excludes doing I/O, and thus page faults.
> Otherwise a long I/O could cause the system to OOM.
>
> SRCU allows all kind of blocking, as long as the entire SRCU
> domain does not mind waiting for a while before readers complete.

Well, no. Fundamentally both SRCU and preemptible (and many other
flavours) are just a counter-array. The non-blocking for preempt comes
from the fact that it is the main global rcu instance and allowing all
that would make GPs too rare and cause you memory trouble.

But that's not because of how it's implemented, but because of it being
the main global instance.

> > tasks:
> > waits for every task to pass schedule()
> >
> > ensures that any pieces of text rendered unreachable before, is
> > actually unused after.
> >
> > tasks-rude:
> > like tasks, but different? build to handle tracing while rcu-idle,
> > even though that was already deemed bad?
> >
> > tasks-tracing-rcu:
> > extention of tasks to have critical-sections ? Should this simply be
> > tasks?
>
> tasks-trace-rcu is meant to allow tasks to block/take a page fault within
> the read-side. It is specialized for tracing and has a single domain. It
> does not need the smp_mb on the read-side, which makes it lower-overhead
> than SRCU.

That's what it's meant for, not what it is.

Turns out that tasks-tracing is a per-task counter based thing, and as
such does not require all tasks to pass through schedule() and does not
imply the tasks flavour (nor the tasks-rude) despite the similarity in
naming.

But now I am again left wondering what the fundamental difference is
between a per-task counter and a per-cpu counter.

At the end of the day, you still have to wait for the thing to hit 0.

So I'm once again confused, ...