Thread (76 messages) 76 messages, 4 authors, 2015-10-12

Re: [PATCH v2 22/25] powerpc32: move xxxxx_dcache_range() functions inline

flat view

From: Joakim Tjernlund <hidden>
Date: 2015-09-22 18:12:32
Also in: lkml

On Tue, 2015-09-22 at 18:51 +0200, Christophe Leroy wrote:
flush/clean/invalidate _dcache_range() functions are all very
similar and are quite short. They are mainly used in __dma_sync()
perf_event locate them in the top 3 consumming functions during
heavy ethernet activity
=20
They are good candidate for inlining, as __dma_sync() does
almost nothing but calling them
=20
Signed-off-by: Christophe Leroy <redacted>
---
New in v2
=20
 arch/powerpc/include/asm/cacheflush.h | 55 +++++++++++++++++++++++++++--
 arch/powerpc/kernel/misc_32.S         | 65 -----------------------------=
------
quoted hunk ↗ jump to hunk
 arch/powerpc/kernel/ppc_ksyms.c       |  2 ++
 3 files changed, 54 insertions(+), 68 deletions(-)
=20
diff --git a/arch/powerpc/include/asm/cacheflush.h b/arch/powerpc/include=
/asm/cacheflush.h
quoted hunk ↗ jump to hunk
index 6229e6b..6169604 100644
--- a/arch/powerpc/include/asm/cacheflush.h
+++ b/arch/powerpc/include/asm/cacheflush.h
@@ -47,12 +47,61 @@ static inline void __flush_dcache_icache_phys(unsigne=
d long physaddr)
 }
 #endif
=20
-extern void flush_dcache_range(unsigned long start, unsigned long stop);
 #ifdef CONFIG_PPC32
-extern void clean_dcache_range(unsigned long start, unsigned long stop);
-extern void invalidate_dcache_range(unsigned long start, unsigned long s=
top);
+/*
+ * Write any modified data cache blocks out to memory and invalidate the=
m.
quoted hunk ↗ jump to hunk
+ * Does not invalidate the corresponding instruction cache blocks.
+ */
+static inline void flush_dcache_range(unsigned long start, unsigned long=
 stop)
quoted hunk ↗ jump to hunk
+{
+	void *addr =3D (void *)(start & ~(L1_CACHE_BYTES - 1));
+	unsigned int size =3D stop - (unsigned long)addr + (L1_CACHE_BYTES - 1)=
;
quoted hunk ↗ jump to hunk
+	unsigned int i;
+
+	for (i =3D 0; i < size >> L1_CACHE_SHIFT; i++, addr +=3D L1_CACHE_BYTES=
)
quoted hunk ↗ jump to hunk
+		dcbf(addr);
+	if (i)
+		mb();	/* sync */
+}
This feels optimized for the uncommon case when there is no invalidation.
I THINK it would be better to bail early and use do { .. } while(--i); inst=
ead.

 Jocke=
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help