[patch] __syncicache: eliminate D-cache flush

Marcel Moolenaar xcllnt at mac.com
Thu May 21 16:50:01 UTC 2009


All,

I'd like to commit the following change, which basically removes
the D-cache flush from syncicache. This gave me a 6% performance
improvement on my SMP xserve (but YMMV):

Index: sys/powerpc/powerpc/syncicache.c
===================================================================
--- sys/powerpc/powerpc/syncicache.c    (revision 192134)
+++ sys/powerpc/powerpc/syncicache.c    (working copy)
@@ -50,23 +50,14 @@
  void
  __syncicache(void *from, int len)
  {
-       int     l, off;
-       char    *p;
+       char    *p, *lim;

-       off = (u_int)from & (cacheline_size - 1);
-       l = len += off;
-       p = (char *)from - off;
+       p = (char *)((uintptr_t)from & (cacheline_size - 1));
+       lim = (char *)from + len;

-       do {
-               __asm __volatile ("dcbst 0,%0" :: "r"(p));
-               p += cacheline_size;
-       } while ((l -= cacheline_size) > 0);
-       __asm __volatile ("sync");
-       p = (char *)from - off;
-       do {
+       while (p < lim) {
                 __asm __volatile ("icbi 0,%0" :: "r"(p));
                 p += cacheline_size;
-       } while ((len -= cacheline_size) > 0);
+       }
         __asm __volatile ("sync; isync");
  }
-

I tested a make buildworld/buildkernel and a make release. I can't
test the image because I'm having difficulty booting from the CD
(I think that's mostly related to using a serial console and none
of the standard Open Firmware key combinations works).

Can someone try and boot (and preferably go through a real install):
	http://people.freebsd.org/~marcel/8.0-CURRENT-200905-powerpc-disc1.iso

In the mean time, I'll try a make buildworld across NFS to see if
we need to implement cpu_flush_dcache() to compensate...

-- 
Marcel Moolenaar
xcllnt at mac.com





More information about the freebsd-ppc mailing list