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 Use atomic_ops(3) for ref counting.



details:   https://anonhg.NetBSD.org/src/rev/2cddc19f3e07
branches:  trunk
changeset: 764987:2cddc19f3e07
user:      jym <jym%NetBSD.org@localhost>
date:      Sun May 15 07:24:15 2011 +0000

description:
Use atomic_ops(3) for ref counting.

diffstat:

 sys/arch/xen/xen/xbdback_xenbus.c |  15 +++++++--------
 1 files changed, 7 insertions(+), 8 deletions(-)

diffs (52 lines):

diff -r 6c4731f75aff -r 2cddc19f3e07 sys/arch/xen/xen/xbdback_xenbus.c
--- a/sys/arch/xen/xen/xbdback_xenbus.c Sun May 15 01:16:29 2011 +0000
+++ b/sys/arch/xen/xen/xbdback_xenbus.c Sun May 15 07:24:15 2011 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: xbdback_xenbus.c,v 1.34 2011/04/29 22:58:46 jym Exp $      */
+/*      $NetBSD: xbdback_xenbus.c,v 1.35 2011/05/15 07:24:15 jym Exp $      */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.34 2011/04/29 22:58:46 jym Exp $");
+__KERNEL_RCSID(0, "$NetBSD: xbdback_xenbus.c,v 1.35 2011/05/15 07:24:15 jym Exp $");
 
 #include <sys/types.h>
 #include <sys/param.h>
@@ -34,6 +34,7 @@
 #include <sys/malloc.h>
 #include <sys/queue.h>
 #include <sys/kernel.h>
+#include <sys/atomic.h>
 #include <sys/conf.h>
 #include <sys/disk.h>
 #include <sys/disklabel.h>
@@ -143,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 xbdi_refcnt;
+       volatile unsigned int xbdi_refcnt;
        /* 
         * State for I/O processing/coalescing follows; this has to
         * live here instead of on the stack because of the
@@ -167,13 +168,11 @@
        uint xbdi_pendingreqs; /* number of I/O in fly */
 };
 /* Manipulation of the above reference count. */
-/* XXXjld%panix.com@localhost: not MP-safe, and move the i386 asm elsewhere. */
-#define xbdi_get(xbdip) (++(xbdip)->xbdi_refcnt)
+#define xbdi_get(xbdip) atomic_inc_uint(&(xbdip)->xbdi_refcnt)
 #define xbdi_put(xbdip)                                      \
 do {                                                         \
-       __asm volatile("decl %0"                           \
-           : "=m"((xbdip)->xbdi_refcnt) : "m"((xbdip)->xbdi_refcnt)); \
-       if (0 == (xbdip)->xbdi_refcnt)                            \
+       atomic_dec_uint(&(xbdip)->xbdi_refcnt);              \
+       if (0 == (xbdip)->xbdi_refcnt)                       \
                xbdback_finish_disconnect(xbdip);             \
 } while (/* CONSTCOND */ 0)
 



Home | Main Index | Thread Index | Old Index