Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/xen/xen As noted by rmind@, use the _nv() to fetch ...
details: https://anonhg.NetBSD.org/src/rev/6340a2076e6a
branches: trunk
changeset: 765004:6340a2076e6a
user: jym <jym%NetBSD.org@localhost>
date: Sun May 15 20:58:54 2011 +0000
description:
As noted by rmind@, use the _nv() to fetch the new value. A race is
possible between the decrement and the fetch of the ref counter value,
hence we might call the G/C routine twice. Not good.
Also remove the 'volatile' attribute, refcnt is only use by xbdi_put/_get
and should not be exposed anywhere else (except for initialization).
diffstat:
sys/arch/xen/xen/xbdback_xenbus.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diffs (37 lines):
diff -r 90aae3706979 -r 6340a2076e6a sys/arch/xen/xen/xbdback_xenbus.c
--- a/sys/arch/xen/xen/xbdback_xenbus.c Sun May 15 18:33:33 2011 +0000
+++ b/sys/arch/xen/xen/xbdback_xenbus.c Sun May 15 20:58:54 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: xbdback_xenbus.c,v 1.35 2011/05/15 07:24:15 jym Exp $ */
+/* $NetBSD: xbdback_xenbus.c,v 1.36 2011/05/15 20:58:54 jym Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.35 2011/05/15 07:24:15 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.36 2011/05/15 20:58:54 jym Exp $");
#include <sys/types.h>
#include <sys/param.h>
@@ -144,7 +144,7 @@
grant_handle_t xbdi_ring_handle; /* to unmap the ring */
vaddr_t xbdi_ring_va; /* to unmap the ring */
/* disconnection must be postponed until all I/O is done */
- volatile unsigned int xbdi_refcnt;
+ int xbdi_refcnt;
/*
* State for I/O processing/coalescing follows; this has to
* live here instead of on the stack because of the
@@ -171,8 +171,7 @@
#define xbdi_get(xbdip) atomic_inc_uint(&(xbdip)->xbdi_refcnt)
#define xbdi_put(xbdip) \
do { \
- atomic_dec_uint(&(xbdip)->xbdi_refcnt); \
- if (0 == (xbdip)->xbdi_refcnt) \
+ if (atomic_dec_uint_nv(&(xbdip)->xbdi_refcnt) == 0) \
xbdback_finish_disconnect(xbdip); \
} while (/* CONSTCOND */ 0)
Home |
Main Index |
Thread Index |
Old Index