Anyone?

On Sat, Sep 17, 2022 at 04:28:15PM +0200, Alexander Bluhm wrote:
> Hi,
> 
> Inspired by Taylor's talk at EuroBSDCon I think a memory barrier
> in counters_zero() is missing.  Reading uses two consumer barriers,
> so writing should also have two.
> 
> Following code would have no barrier between writing generation
> number and writing counters.
> 
> counters_leave();
> counters_zero();
> 
> counters_leave() writes to generation number at the end, so
> counters_zero() needs a barrier at the start.
> 
> ok?
> 
> bluhm
> 
> Index: kern/subr_percpu.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/sys/kern/subr_percpu.c,v
> retrieving revision 1.9
> diff -u -p -r1.9 subr_percpu.c
> --- kern/subr_percpu.c        10 Mar 2021 10:21:47 -0000      1.9
> +++ kern/subr_percpu.c        17 Sep 2022 14:17:34 -0000
> @@ -213,6 +213,7 @@ counters_zero(struct cpumem *cm, unsigne
>       unsigned int i;
> 
>       counters = cpumem_first(&cmi, cm);
> +     membar_producer();
>       do {
>               for (i = 0; i < n; i++)
>                       counters[i] = 0;

Reply via email to