Re: [PATCH v7 3/5] rust: sync: Add abstraction for rcu_barrier()
From: Paul E. McKenney
Date: Wed Jul 29 2026 - 15:06:39 EST
On Wed, Jul 29, 2026 at 07:47:46PM +0100, Gary Guo wrote:
> On Wed Jul 29, 2026 at 6:18 PM BST, Paul E. McKenney wrote:
> > On Wed, Jul 29, 2026 at 11:45:40AM +0200, Philipp Stanner wrote:
> >> rcu_barrier() is a frequently used C function which is always safe to be
> >> called.
> >
> > Just checking... Here "always safe" means only from task level, with BH,
> > preemption, and interrupts all enabled, correct?
> >
> > In contrast, if you do this:
> >
> > preempt_disable();
> > rcu_barrier();
> > preempt_enable();
> >
> > the results won't be safe.
>
> This is same for all sleepable functions. In order to avoid having to mark all
> sleeping function unsafe, we've decided that sleeping from non-preemptable
> context is "safe", but is a bug regardless.
Got it, thank you!
I tried to resist parameterizing "safe" over things like execution
contexts, but obviously failed to do so. Besides, there is a name for
that sort of thing, and that name is "precondition". ;-)
Adding Julia Lawall on CC based on her recent work with preconditions,
which might be an act of kindness or of vandalism. You guys get to
decide. ;-)
Thanx, Paul