powerpc/pseries: Kill all prefetch streams on context switch
authorMichael Neuling <mikey@neuling.org>
Wed, 29 May 2013 19:34:27 +0000 (19:34 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 31 May 2013 22:29:25 +0000 (08:29 +1000)
On context switch, we should have no prefetch streams leak from one
userspace process to another.  This frees up prefetch resources for the
next process.

Based on patch from Milton Miller.

Signed-off-by: Michael Neuling <mikey@neuling.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/ppc_asm.h
arch/powerpc/kernel/entry_64.S

index cea8496091ffbd1cb2437061cb1f7772f3b8bbc3..2f1b6c5f8174f4a4759086f21668dda5c8477b1d 100644 (file)
@@ -523,6 +523,17 @@ END_FTR_SECTION_NESTED(CPU_FTR_HAS_PPR,CPU_FTR_HAS_PPR,946)
 #define PPC440EP_ERR42
 #endif
 
+/* The following stops all load and store data streams associated with stream
+ * ID (ie. streams created explicitly).  The embedded and server mnemonics for
+ * dcbt are different so we use machine "power4" here explicitly.
+ */
+#define DCBT_STOP_ALL_STREAM_IDS(scratch)      \
+.machine push ;                                        \
+.machine "power4" ;                            \
+       lis     scratch,0x60000000@h;           \
+       dcbt    r0,scratch,0b01010;             \
+.machine pop
+
 /*
  * toreal/fromreal/tophys/tovirt macros. 32-bit BookE makes them
  * keep the address intact to be compatible with code shared with
index 0e9095e47b5b0098da33aeb262694fa8d5e0c0ef..246b11c4fe7eda803a4c076c078c5afdcff04590 100644 (file)
@@ -501,6 +501,13 @@ BEGIN_FTR_SECTION
        ldarx   r6,0,r1
 END_FTR_SECTION_IFSET(CPU_FTR_STCX_CHECKS_ADDRESS)
 
+#ifdef CONFIG_PPC_BOOK3S
+/* Cancel all explict user streams as they will have no use after context
+ * switch and will stop the HW from creating streams itself
+ */
+       DCBT_STOP_ALL_STREAM_IDS(r6)
+#endif
+
        addi    r6,r4,-THREAD   /* Convert THREAD to 'current' */
        std     r6,PACACURRENT(r13)     /* Set new 'current' */