Re: [PATCH v2 3/4] rcu/kvfree: Move need_offload_krc() out of krcp->lock

From: Uladzislau Rezki
Date: Fri Dec 02 2022 - 08:19:40 EST


On Wed, Nov 30, 2022 at 10:44:55AM -0800, Paul E. McKenney wrote:
> On Wed, Nov 30, 2022 at 01:56:17PM +0100, Uladzislau Rezki wrote:
> > On Tue, Nov 29, 2022 at 03:38:33PM -0800, Paul E. McKenney wrote:
> > > On Tue, Nov 29, 2022 at 04:58:21PM +0100, Uladzislau Rezki (Sony) wrote:
> > > > Currently a need_offload_krc() function requires the krcp->lock
> > > > to be held because krcp->head can not be checked concurrently.
> > > >
> > > > Fix it by updating the krcp->head using WRITE_ONCE() macro so
> > > > it becomes lock-free and safe for readers to see a valid data
> > > > without any locking.
> > >
> > > Don't we also need to use READ_ONCE() for the code loading this krcp->head
> > > pointer? Or do the remaining plain C-language accesses somehow avoid
> > > running concurrently with those new WRITE_ONCE() invocations?
> > >
> > It can be concurrent. I was thinking about it. For some reason i decided
> > to keep readers as a "regular" ones for loading the krcp->head.
> >
> > In this case it might take time for readers to see an updated value
> > as a worst case scenario.
> >
> > So i need to update it or upload one more patch on top of v2. Should
> > i upload a new patch?
>
> Sending an additional patch should be fine. Unless you would rather it
> be folded into one of the existing patches, in which case please start
> with the set that I have queued.
>
Done.

--
Uladzislau Rezki