diff options
-rw-r--r-- | tools/Makefile | 5 | ||||
-rw-r--r-- | tools/Rules.mk | 2 | ||||
-rw-r--r-- | tools/memshr/bidir-hash.c | 34 |
3 files changed, 25 insertions, 16 deletions
diff --git a/tools/Makefile b/tools/Makefile index d5cffa2923..388a925d36 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -21,6 +21,7 @@ SUBDIRS-$(VTPM_TOOLS) += vtpm_manager 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-$(CONFIG_IOEMU) += ioemu-dir 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 --git a/tools/Rules.mk b/tools/Rules.mk index 83899d3cbd..53d8aa86ce 100644 --- a/tools/Rules.mk +++ b/tools/Rules.mk @@ -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 --git a/tools/memshr/bidir-hash.c b/tools/memshr/bidir-hash.c index e3e0e15831..6c0dc3d92d 100644 --- a/tools/memshr/bidir-hash.c +++ b/tools/memshr/bidir-hash.c @@ -100,21 +100,31 @@ int __hash_iterator(struct __hash *h, void *d); static void hash_resize(struct __hash *h); -static inline void atomic_add(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 ; addl %1,%0" - :"=m" (*(volatile uint32_t *)v) - :"ir" (i), "m" (*(volatile uint32_t *)v) ); + asm volatile ( + "lock ; incl %0" + : "=m" (*(volatile uint32_t *)v) + : "m" (*(volatile uint32_t *)v) ); } - -static inline void atomic_sub(uint32_t *v, uint32_t i) +static inline void atomic_dec(uint32_t *v) { asm volatile ( - "lock ; subl %1,%0" + "lock ; decl %0" : "=m" (*(volatile uint32_t *)v) - : "ir" (i), "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, __v_t v) 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; |