Re: [RFC PATCH 09/14] ring_buffer: Initialize completions statically in the benchmark

From: Petr Mladek
Date: Fri Sep 04 2015 - 05:31:51 EST


On Mon 2015-08-03 14:31:09, Steven Rostedt wrote:
> On Tue, 28 Jul 2015 16:39:26 +0200
> Petr Mladek <pmladek@xxxxxxxx> wrote:
>
> > It looks strange to initialize the completions repeatedly.
> >
> > This patch uses static initialization. It simplifies the code
> > and even helps to get rid of two memory barriers.
>
> There was a reason I did it this way and did not use static
> initializers. But I can't recall why I did that. :-/
>
> I'll have to think about this some more.

Heh, the parallel programming is a real fun. I tried to understand
the code in more details and sometimes felt like Duane Dibbley.

Anyway, I found few possible races related to the completions.
One scenario was opened by my previous fix b44754d8262d3aab8429
("ring_buffer: Allow to exit the ring buffer benchmark immediately")

The races can be fixed by the patch below. I still do not see any
scenario where the extra initialization of the two completions
is needed but I am not brave enough to remove it after all ;-)