Module Name:    src
Committed By:   riastradh
Date:           Thu Feb 23 03:00:53 UTC 2023

Modified Files:
        src/sys/kern: subr_pcq.c

Log Message:
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


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/subr_pcq.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/subr_pcq.c
diff -u src/sys/kern/subr_pcq.c:1.13 src/sys/kern/subr_pcq.c:1.14
--- src/sys/kern/subr_pcq.c:1.13	Mon Feb  8 09:31:05 2021
+++ src/sys/kern/subr_pcq.c	Thu Feb 23 03:00:53 2023
@@ -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 @@ pcq_put(pcq_t *pcq, void *item)
 	 * 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

Reply via email to