WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] memshr: Build fixes

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] memshr: Build fixes
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 28 Dec 2009 01:45:09 -0800
Delivery-date: Mon, 28 Dec 2009 01:45:08 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1261991656 0
# Node ID 4ad86f682f430428d5f9c7877259b8b951ff95e0
# Parent  98c4b2498415751f97091631907d9d173ac0092f
memshr: Build fixes

 * Build memshr/xenpaging on x86/Linux only
 * Remove dependency on GCC 4.1+ __sync_*() intrinsics.

Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
Signed-off-by: KUWAMURA Shin'ya <kuwa@xxxxxxxxxxxxxx>
---
 tools/Makefile            |    5 +++--
 tools/Rules.mk            |    2 +-
 tools/memshr/bidir-hash.c |   26 +++++++++++++++++++++-----
 3 files changed, 25 insertions(+), 8 deletions(-)

diff -r 98c4b2498415 -r 4ad86f682f43 tools/Makefile
--- a/tools/Makefile    Thu Dec 24 15:59:44 2009 +0000
+++ b/tools/Makefile    Mon Dec 28 09:14:16 2009 +0000
@@ -21,7 +21,6 @@ SUBDIRS-$(VTPM_TOOLS) += vtpm
 SUBDIRS-$(VTPM_TOOLS) += vtpm
 SUBDIRS-y += xenstat
 SUBDIRS-$(CONFIG_Linux) += libaio
-SUBDIRS-$(CONFIG_Linux) += memshr 
 SUBDIRS-$(CONFIG_Linux) += blktap
 SUBDIRS-$(CONFIG_Linux) += blktap2
 SUBDIRS-$(CONFIG_NetBSD) += libaio
@@ -35,7 +34,9 @@ SUBDIRS-y += xenpmd
 SUBDIRS-y += xenpmd
 SUBDIRS-y += libxl
 SUBDIRS-y += remus
-SUBDIRS-y += xenpaging
+
+SUBDIRS-$(CONFIG_X86)$(CONFIG_Linux) += memshr 
+SUBDIRS-$(CONFIG_X86)$(CONFIG_Linux) += xenpaging
 
 # These don't cross-compile
 ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
diff -r 98c4b2498415 -r 4ad86f682f43 tools/Rules.mk
--- a/tools/Rules.mk    Thu Dec 24 15:59:44 2009 +0000
+++ b/tools/Rules.mk    Mon Dec 28 09:14:16 2009 +0000
@@ -64,7 +64,7 @@ INSTALL_PYTHON_PROG = \
        $(CC) $(CPPFLAGS) $(CXXFLAGS) -c -o $@ $<
 
 subdirs-all subdirs-clean subdirs-install: .phony
-       @set -e; for subdir in $(SUBDIRS) $(SUBDIRS-y); do \
+       @set -e; for subdir in $(SUBDIRS) $(SUBDIRS-y) $(SUBDIRS-yy); do \
                $(MAKE) subdir-$(patsubst subdirs-%,%,$@)-$$subdir; \
        done
 
diff -r 98c4b2498415 -r 4ad86f682f43 tools/memshr/bidir-hash.c
--- a/tools/memshr/bidir-hash.c Thu Dec 24 15:59:44 2009 +0000
+++ b/tools/memshr/bidir-hash.c Mon Dec 28 09:14:16 2009 +0000
@@ -75,7 +75,7 @@ struct __hash
                                            * *_tab, tab_size, size_idx, *_load
                                            * (all writes with wrlock)
                                            */
-    volatile uint32_t nr_ent;             /* # entries held in hashtables */
+    uint32_t nr_ent;                      /* # entries held in hashtables */
     struct bucket *key_tab;               /* forward mapping hashtable    */
     struct bucket *value_tab;             /* backward mapping hashtable   */
     struct bucket_lock *key_lock_tab;     /* key table bucket locks       */
@@ -100,6 +100,21 @@ int            __hash_iterator(struct __
                         void *d);
 static void      hash_resize(struct __hash *h);
 
+static inline void atomic_add(uint32_t *v, uint32_t i)
+{
+    asm volatile(
+        "lock ; addl %1,%0"
+        :"=m" (*(volatile uint32_t *)v)
+        :"ir" (i), "m" (*(volatile uint32_t *)v) );
+}
+
+static inline void atomic_sub(uint32_t *v, uint32_t i)
+{
+    asm volatile (
+        "lock ; subl %1,%0"
+        : "=m" (*(volatile uint32_t *)v)
+        : "ir" (i), "m" (*(volatile uint32_t *)v) );
+}
 
 #ifdef BIDIR_USE_STDMALLOC
 
@@ -759,7 +774,6 @@ int __insert(struct __hash *h, __k_t k, 
     struct bucket *bk, *bv;
     struct bucket_lock *bltk, *bltv;
 
-
     /* Allocate new entry before any locks (in case it fails) */
     entry = (struct hash_entry*)
                     alloc_entry(h, sizeof(struct hash_entry));
@@ -797,7 +811,7 @@ int __insert(struct __hash *h, __k_t k, 
     TWO_BUCKETS_LOCK_WRUNLOCK(h, bltk, k_idx, bltv, v_idx);
 
     /* Book keeping */
-    __sync_add_and_fetch(&h->nr_ent, 1);
+    atomic_add(&h->nr_ent, 1);
 
     HASH_LOCK_RDUNLOCK(h);
 
@@ -931,7 +945,8 @@ found_again:
             *pek = e->__prim_next;
             *pev = e->__sec_next;
 
-            nr_ent = __sync_sub_and_fetch(&h->nr_ent, 1);
+            atomic_sub(&h->nr_ent, 1);
+            nr_ent = h->nr_ent;
             /* read min_load still under the hash lock! */
             min_load = h->min_load;
 
@@ -1079,7 +1094,8 @@ found_again:
             *pek = e->__prim_next;
             *pev = e->__sec_next;
 
-            nr_ent = __sync_sub_and_fetch(&h->nr_ent, 1);
+            atomic_sub(&h->nr_ent, 1);
+            nr_ent = h->nr_ent;
             /* read min_load still under the hash lock! */
             min_load = h->min_load;
 

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] memshr: Build fixes, Xen patchbot-unstable <=