Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/kern pcq(9): Make pcq_put a release operation, in memory...



details:   https://anonhg.NetBSD.org/src/rev/f2210eaa7f72
branches:  trunk
changeset: 373655:f2210eaa7f72
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Feb 23 03:00:53 2023 +0000

description:
pcq(9): Make pcq_put a release operation, in memory ordering.

Otherwise, for example, the following assertion could fail:

        /* publisher */
        nusers = foo->nusers;
        pcq_put(pcq, foo);
        KASSERT(nusers == 0);

        /* user */
        foo = pcq_get(pcq);
        if (foo != NULL)
                atomic_inc_uint(&foo->nusers);

XXX pullup-9
XXX pullup-10

diffstat:

 sys/kern/subr_pcq.c |  9 +++------
 1 files changed, 3 insertions(+), 6 deletions(-)

diffs (30 lines):

diff -r 4b3c3e67b28c -r f2210eaa7f72 sys/kern/subr_pcq.c
--- a/sys/kern/subr_pcq.c       Thu Feb 23 03:00:15 2023 +0000
+++ b/sys/kern/subr_pcq.c       Thu Feb 23 03:00:53 2023 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: subr_pcq.c,v 1.13 2021/02/08 09:31:05 wiz Exp $        */
+/*     $NetBSD: subr_pcq.c,v 1.14 2023/02/23 03:00:53 riastradh Exp $  */
 
 /*-
  * Copyright (c) 2009, 2019 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.13 2021/02/08 09:31:05 wiz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_pcq.c,v 1.14 2023/02/23 03:00:53 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/types.h>
@@ -116,10 +116,7 @@
         * that the caller made to the data item are globally visible
         * before we put it onto the list.
         */
-#ifndef __HAVE_ATOMIC_AS_MEMBAR
-       membar_producer();
-#endif
-       pcq->pcq_items[op] = item;
+       atomic_store_release(&pcq->pcq_items[op], item);
 
        /*
         * Synchronization activity to wake up the consumer will ensure



Home | Main Index | Thread Index | Old Index