Re: [RFC PATCH 47/86] rcu: select PREEMPT_RCU if PREEMPT

From: Paul E. McKenney
Date: Tue Nov 21 2023 - 10:19:17 EST


On Tue, Nov 21, 2023 at 10:00:59AM -0500, Steven Rostedt wrote:
> On Mon, 20 Nov 2023 21:04:28 -0800
> "Paul E. McKenney" <paulmck@xxxxxxxxxx> wrote:
>
> > How about like this, where "Y" means allowed and "N" means not allowed:
> >
> > Non-Preemptible RCU Preemptible RCU
> >
> > NONE: Y Y
> >
> > VOLUNTARY: Y Y
> >
> > PREEMPT: N Y
> >
> > PREEMPT_RT: N Y
> >
> >
> > We need preemptible RCU for NONE and VOLUNTARY, as you say,
> > to allow CONFIG_PREEMPT_DYNAMIC to continue to work. (OK, OK,
> > CONFIG_PREEMPT_DYNAMIC is no longer, but appears to be unconditional.)
> > But again, I don't see why anyone would want (much less need)
> > non-preemptible RCU in the PREEMPT and PREEMPT_RT cases. And if it is
> > neither wanted nor needed, there is no point in enabling it, much less
> > testing it.
> >
> > Or am I missing a use case in there somewhere?
>
> As Ankur replied, this is just an RFC, not the main goal. I'm talking about
> the end product which will get rid of the PREEMPT_NONE, PREEMPT_VOLUNTARY
> and PREEMPT conifgs, and there will *only* be the PREEMPT_DYNAMIC and
> PREEMPT_RT.
>
> And yes, this is going to be a slow and long processes, to find and fix all
> regressions. I too am concerned about the latency that this may add. I'm
> thinking we could have NEED_RESCHED_LAZY preempt when there is no mutex or
> other semi critical section held (like migrate_disable()).

Indeed. For one thing, you have a lot of work to do to demonstrate
that this would actually be a good thing. For example, what is so
horribly bad about selecting minimal preemption (NONE and/or VOLUNTARY)
at build time???

> Right now, the use of cond_resched() is basically a whack-a-mole game where
> we need to whack all the mole loops with the cond_resched() hammer. As
> Thomas said, this is backwards. It makes more sense to just not preempt in
> areas that can cause pain (like holding a mutex or in an RCU critical
> section), but still have the general kernel be fully preemptable.

Which is quite true, but that whack-a-mole game can be ended without
getting rid of build-time selection of the preemption model. Also,
that whack-a-mole game can be ended without eliminating all calls to
cond_resched().

Additionally, if the end goal is to be fully preemptible as in eventually
eliminating lazy preemption, you have a lot more convincing to do.
For but one example, given the high cost of the additional context
switches that will visit on a number of performance-sensitive workloads.

So what exactly are you guys trying to accomplish here? ;-)

Thanx, Paul