Re: [PATCH v10 1/2] ring-buffer: Introducing ring-buffer mapping functions

From: Vincent Donnefort
Date: Thu Jan 11 2024 - 04:57:55 EST


[...]

> > > + */
> > > + smp_wmb();
> > > + WRITE_ONCE(cpu_buffer->mapped, 1);
> > > +
> > > + /* Init meta_page values unless the writer did it already */
> > > + cmpxchg(&cpu_buffer->meta_page->entries, 0,
> > > + local_read(&cpu_buffer->entries));
> > > + cmpxchg(&cpu_buffer->meta_page->overrun, 0,
> > > + local_read(&cpu_buffer->overrun));
> > > + cmpxchg(&cpu_buffer->meta_page->subbufs_touched, 0,
> > > + local_read(&cpu_buffer->pages_touched));
> > > + cmpxchg(&cpu_buffer->meta_page->subbufs_lost, 0,
> > > + local_read(&cpu_buffer->pages_lost));
> >
> > Instead of using these cmpxchg, can we move this initialization before
> > smp_wmb()? Thus we can avoid conflict with rb_update_meta_page()
>
> Good point, Not sure why I made this more complicated than it should be.

Ha, I know, that was before v6, where the writer was updating all of that. From
v6 the update has been moved to the irq_rb_work.

>
> >
> > Thank you,
> >
>
> [...]