Re: [PATCH v7 3/5] rust: sync: Add abstraction for rcu_barrier()

"Paul E. McKenney" <[email protected]>
Newsgroups org.kernel.vger.linux-media,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-kernel,org.kernel.vger.rcu,org.kernel.vger.rust-for-linux
Message-ID <f680fb1b-ecbc-47b4-a252-b792933bfe3e@paulmck-laptop>
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
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.