# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1261997750 0
# Node ID 58dbf27875c5410bcc3aadd00b36d823424a9f2e
# Parent 280ecaf392946218714947c681178659ae14865e
memshr: Must be built on ia64 as well as x86, as blktap depends on it.
Signed-off-by: Keir Fraser <keir.fraser@xxxxxxxxxx>
---
tools/Makefile | 5 ++---
tools/Rules.mk | 2 +-
tools/memshr/bidir-hash.c | 40 +++++++++++++++++++++++++---------------
3 files changed, 28 insertions(+), 19 deletions(-)
diff -r 280ecaf39294 -r 58dbf27875c5 tools/Makefile
--- a/tools/Makefile Mon Dec 28 09:39:23 2009 +0000
+++ b/tools/Makefile Mon Dec 28 10:55:50 2009 +0000
@@ -21,6 +21,7 @@ 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
@@ -34,9 +35,7 @@ SUBDIRS-y += xenpmd
SUBDIRS-y += xenpmd
SUBDIRS-y += libxl
SUBDIRS-y += remus
-
-SUBDIRS-$(CONFIG_X86)$(CONFIG_Linux) += memshr
-SUBDIRS-$(CONFIG_X86)$(CONFIG_Linux) += xenpaging
+SUBDIRS-$(CONFIG_X86) += xenpaging
# These don't cross-compile
ifeq ($(XEN_COMPILE_ARCH),$(XEN_TARGET_ARCH))
diff -r 280ecaf39294 -r 58dbf27875c5 tools/Rules.mk
--- a/tools/Rules.mk Mon Dec 28 09:39:23 2009 +0000
+++ b/tools/Rules.mk Mon Dec 28 10:55:50 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) $(SUBDIRS-yy); do \
+ @set -e; for subdir in $(SUBDIRS) $(SUBDIRS-y); do \
$(MAKE) subdir-$(patsubst subdirs-%,%,$@)-$$subdir; \
done
diff -r 280ecaf39294 -r 58dbf27875c5 tools/memshr/bidir-hash.c
--- a/tools/memshr/bidir-hash.c Mon Dec 28 09:39:23 2009 +0000
+++ b/tools/memshr/bidir-hash.c Mon Dec 28 10:55:50 2009 +0000
@@ -100,21 +100,31 @@ 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)
+#if defined(__ia64__)
+#define ia64_fetchadd4_rel(p, inc) do { \
+ uint64_t ia64_intri_res; \
+ asm volatile ("fetchadd4.rel %0=[%1],%2" \
+ : "=r"(ia64_intri_res) : "r"(p), "i" (inc) \
+ : "memory"); \
+} while (0)
+static inline void atomic_inc(uint32_t *v) { ia64_fetchadd4_rel(v, 1); }
+static inline void atomic_dec(uint32_t *v) { ia64_fetchadd4_rel(v, -1); }
+#else /* __x86__ */
+static inline void atomic_inc(uint32_t *v)
{
asm volatile (
- "lock ; subl %1,%0"
+ "lock ; incl %0"
: "=m" (*(volatile uint32_t *)v)
- : "ir" (i), "m" (*(volatile uint32_t *)v) );
-}
+ : "m" (*(volatile uint32_t *)v) );
+}
+static inline void atomic_dec(uint32_t *v)
+{
+ asm volatile (
+ "lock ; decl %0"
+ : "=m" (*(volatile uint32_t *)v)
+ : "m" (*(volatile uint32_t *)v) );
+}
+#endif
#ifdef BIDIR_USE_STDMALLOC
@@ -811,7 +821,7 @@ int __insert(struct __hash *h, __k_t k,
TWO_BUCKETS_LOCK_WRUNLOCK(h, bltk, k_idx, bltv, v_idx);
/* Book keeping */
- atomic_add(&h->nr_ent, 1);
+ atomic_inc(&h->nr_ent);
HASH_LOCK_RDUNLOCK(h);
@@ -945,7 +955,7 @@ found_again:
*pek = e->__prim_next;
*pev = e->__sec_next;
- atomic_sub(&h->nr_ent, 1);
+ atomic_dec(&h->nr_ent);
nr_ent = h->nr_ent;
/* read min_load still under the hash lock! */
min_load = h->min_load;
@@ -1094,7 +1104,7 @@ found_again:
*pek = e->__prim_next;
*pev = e->__sec_next;
- atomic_sub(&h->nr_ent, 1);
+ atomic_dec(&h->nr_ent);
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
|