To: andi@firstfloor.org
Cc: linux-numa@vger.kernel.org
Subject: [PATCH] numademo: ia64 version of clearcache()

From: Cliff Wickman <cpw@sgi.com>

Clear caches between numademo runs - ia64 style.
Use the fc instruction to clear cache.
Assuming 128-byte cache lines.

Look right?

Signed-off-by: Cliff Wickman <cpw@sgi.com>
---
 clearcache.c |    7 +++++++
 1 file changed, 7 insertions(+)

Index: numactl-dev/clearcache.c
===================================================================
--- numactl-dev.orig/clearcache.c
+++ numactl-dev/clearcache.c
@@ -63,6 +63,13 @@ void clearcache(unsigned char *mem, unsi
 	cl = ((cl >> 8) & 0xff) * 8;
 	for (i = 0; i < size; i += cl)
 		asm("clflush %0" :: "m" (mem[i]));
+#elif defined(__ia64__)
+        unsigned long cl, endcl;
+        // flush probable 128 byte cache lines (but possibly 64 bytes)
+        cl = (unsigned long)mem;
+        endcl = (unsigned long)(mem + (size-1));
+        for (; cl <= endcl; cl += 64)
+                asm ("fc %0" :: "r"(cl) : "memory" );
 #else
 #warning "Consider adding a clearcache implementation for your architecture"
 	fallback_clearcache();
