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] [IA64] linux/include/linux/hash.h.

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] [IA64] linux/include/linux/hash.h.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Thu, 26 Oct 2006 12:10:59 +0000
Delivery-date: Thu, 26 Oct 2006 05:16:20 -0700
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
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/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/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 awilliam@xxxxxxxxxxx
# Node ID 435e2275ea62428ac60c27b1af585656d67ac6bb
# Parent  c8fa605f131fa9422d90f286445c909e63fd6f7a
[IA64] linux/include/linux/hash.h.

Signed-off-by: Isaku Yamahata <yamahata@xxxxxxxxxxxxx>
---
 xen/include/asm-ia64/linux/README.origin |    1 
 xen/include/asm-ia64/linux/hash.h        |   58 +++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+)

diff -r c8fa605f131f -r 435e2275ea62 xen/include/asm-ia64/linux/README.origin
--- a/xen/include/asm-ia64/linux/README.origin  Sat Oct 14 16:34:41 2006 -0600
+++ b/xen/include/asm-ia64/linux/README.origin  Sat Oct 14 16:42:15 2006 -0600
@@ -7,6 +7,7 @@ bcd.h                   -> linux/include/linux/bcd.h
 bcd.h                  -> linux/include/linux/bcd.h
 bitmap.h               -> linux/include/linux/bitmap.h
 bitops.h               -> linux/include/linux/bitops.h
+hash.h                 -> linux/include/linux/hash.h
 initrd.h               -> linux/include/linux/initrd.h
 jiffies.h              -> linux/include/linux/jiffies.h
 kmalloc_sizes.h                -> linux/include/linux/kmalloc_sizes.h
diff -r c8fa605f131f -r 435e2275ea62 xen/include/asm-ia64/linux/hash.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/include/asm-ia64/linux/hash.h Sat Oct 14 16:42:15 2006 -0600
@@ -0,0 +1,58 @@
+#ifndef _LINUX_HASH_H
+#define _LINUX_HASH_H
+/* Fast hashing routine for a long.
+   (C) 2002 William Lee Irwin III, IBM */
+
+/*
+ * Knuth recommends primes in approximately golden ratio to the maximum
+ * integer representable by a machine word for multiplicative hashing.
+ * Chuck Lever verified the effectiveness of this technique:
+ * http://www.citi.umich.edu/techreports/reports/citi-tr-00-1.pdf
+ *
+ * These primes are chosen to be bit-sparse, that is operations on
+ * them can use shifts and additions instead of multiplications for
+ * machines where multiplications are slow.
+ */
+#if BITS_PER_LONG == 32
+/* 2^31 + 2^29 - 2^25 + 2^22 - 2^19 - 2^16 + 1 */
+#define GOLDEN_RATIO_PRIME 0x9e370001UL
+#elif BITS_PER_LONG == 64
+/*  2^63 + 2^61 - 2^57 + 2^54 - 2^51 - 2^18 + 1 */
+#define GOLDEN_RATIO_PRIME 0x9e37fffffffc0001UL
+#else
+#error Define GOLDEN_RATIO_PRIME for your wordsize.
+#endif
+
+static inline unsigned long hash_long(unsigned long val, unsigned int bits)
+{
+       unsigned long hash = val;
+
+#if BITS_PER_LONG == 64
+       /*  Sigh, gcc can't optimise this alone like it does for 32 bits. */
+       unsigned long n = hash;
+       n <<= 18;
+       hash -= n;
+       n <<= 33;
+       hash -= n;
+       n <<= 3;
+       hash += n;
+       n <<= 3;
+       hash -= n;
+       n <<= 4;
+       hash += n;
+       n <<= 2;
+       hash += n;
+#else
+       /* On some cpus multiply is faster, on others gcc will do shifts */
+       hash *= GOLDEN_RATIO_PRIME;
+#endif
+
+       /* High bits are more random, so use them. */
+       return hash >> (BITS_PER_LONG - bits);
+}
+       
+static inline unsigned long hash_ptr(void *ptr, unsigned int bits)
+{
+       return hash_long((unsigned long)ptr, bits);
+}
+#endif /* _LINUX_HASH_H */

_______________________________________________
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] [IA64] linux/include/linux/hash.h., Xen patchbot-unstable <=