Commit 24ad7bda authored by David Gibson's avatar David Gibson Committed by Linus Torvalds

[PATCH] ppc64: handle SLB misses in realmode

Tested on pSeries and iSeries.  Some future plans for VSID allocation may
mean we have to take this out again, but that's a while off yet, and in the
meantime it's a significant speedup.

This patch makes the PPC64 SLB miss handler run in real mode (i.e.  MMU
off) for it's whole duration, on pSeries machines.  Avoiding the rfid used
to turn relocation on saves some 70-80 cycles on Power4 and Power5.  Not
having to save and restore SRR0 and SRR1 saves a few more, and means we
don't need an extra save slot for r3.  Overall there's around a 27% speedup
on Power4.
Signed-off-by: default avatarDavid Gibson <david@gibson.dropbear.id.au>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent dc85e798
...@@ -94,7 +94,6 @@ int main(void) ...@@ -94,7 +94,6 @@ int main(void)
DEFINE(PACASLBCACHE, offsetof(struct paca_struct, slb_cache)); DEFINE(PACASLBCACHE, offsetof(struct paca_struct, slb_cache));
DEFINE(PACASLBCACHEPTR, offsetof(struct paca_struct, slb_cache_ptr)); DEFINE(PACASLBCACHEPTR, offsetof(struct paca_struct, slb_cache_ptr));
DEFINE(PACACONTEXTID, offsetof(struct paca_struct, context.id)); DEFINE(PACACONTEXTID, offsetof(struct paca_struct, context.id));
DEFINE(PACASLBR3, offsetof(struct paca_struct, slb_r3));
#ifdef CONFIG_HUGETLB_PAGE #ifdef CONFIG_HUGETLB_PAGE
DEFINE(PACAHTLBSEGS, offsetof(struct paca_struct, context.htlb_segs)); DEFINE(PACAHTLBSEGS, offsetof(struct paca_struct, context.htlb_segs));
#endif /* CONFIG_HUGETLB_PAGE */ #endif /* CONFIG_HUGETLB_PAGE */
......
...@@ -199,6 +199,7 @@ exception_marker: ...@@ -199,6 +199,7 @@ exception_marker:
#define EX_R12 24 #define EX_R12 24
#define EX_R13 32 #define EX_R13 32
#define EX_SRR0 40 #define EX_SRR0 40
#define EX_R3 40 /* SLB miss saves R3, but not SRR0 */
#define EX_DAR 48 #define EX_DAR 48
#define EX_LR 48 /* SLB miss saves LR, but not DAR */ #define EX_LR 48 /* SLB miss saves LR, but not DAR */
#define EX_DSISR 56 #define EX_DSISR 56
...@@ -421,21 +422,13 @@ DataAccessSLB_Pseries: ...@@ -421,21 +422,13 @@ DataAccessSLB_Pseries:
std r10,PACA_EXSLB+EX_R10(r13) std r10,PACA_EXSLB+EX_R10(r13)
std r11,PACA_EXSLB+EX_R11(r13) std r11,PACA_EXSLB+EX_R11(r13)
std r12,PACA_EXSLB+EX_R12(r13) std r12,PACA_EXSLB+EX_R12(r13)
std r3,PACASLBR3(r13) std r3,PACA_EXSLB+EX_R3(r13)
mfspr r9,SPRG1 mfspr r9,SPRG1
std r9,PACA_EXSLB+EX_R13(r13) std r9,PACA_EXSLB+EX_R13(r13)
mfcr r9 mfcr r9
clrrdi r12,r13,32 /* get high part of &label */
mfmsr r10
mfspr r11,SRR0 /* save SRR0 */
ori r12,r12,(.do_slb_miss)@l
ori r10,r10,MSR_IR|MSR_DR /* DON'T set RI for SLB miss */
mtspr SRR0,r12
mfspr r12,SRR1 /* and SRR1 */ mfspr r12,SRR1 /* and SRR1 */
mtspr SRR1,r10
mfspr r3,DAR mfspr r3,DAR
rfid b .do_slb_miss /* Rel. branch works in real mode */
b . /* prevent speculative execution */
STD_EXCEPTION_PSERIES(0x400, InstructionAccess) STD_EXCEPTION_PSERIES(0x400, InstructionAccess)
...@@ -449,21 +442,13 @@ InstructionAccessSLB_Pseries: ...@@ -449,21 +442,13 @@ InstructionAccessSLB_Pseries:
std r10,PACA_EXSLB+EX_R10(r13) std r10,PACA_EXSLB+EX_R10(r13)
std r11,PACA_EXSLB+EX_R11(r13) std r11,PACA_EXSLB+EX_R11(r13)
std r12,PACA_EXSLB+EX_R12(r13) std r12,PACA_EXSLB+EX_R12(r13)
std r3,PACASLBR3(r13) std r3,PACA_EXSLB+EX_R3(r13)
mfspr r9,SPRG1 mfspr r9,SPRG1
std r9,PACA_EXSLB+EX_R13(r13) std r9,PACA_EXSLB+EX_R13(r13)
mfcr r9 mfcr r9
clrrdi r12,r13,32 /* get high part of &label */
mfmsr r10
mfspr r11,SRR0 /* save SRR0 */
ori r12,r12,(.do_slb_miss)@l
ori r10,r10,MSR_IR|MSR_DR /* DON'T set RI for SLB miss */
mtspr SRR0,r12
mfspr r12,SRR1 /* and SRR1 */ mfspr r12,SRR1 /* and SRR1 */
mtspr SRR1,r10 mfspr r3,SRR0 /* SRR0 is faulting address */
mr r3,r11 /* SRR0 is faulting address */ b .do_slb_miss /* Rel. branch works in real mode */
rfid
b . /* prevent speculative execution */
STD_EXCEPTION_PSERIES(0x500, HardwareInterrupt) STD_EXCEPTION_PSERIES(0x500, HardwareInterrupt)
STD_EXCEPTION_PSERIES(0x600, Alignment) STD_EXCEPTION_PSERIES(0x600, Alignment)
...@@ -609,8 +594,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_SLB) ...@@ -609,8 +594,7 @@ END_FTR_SECTION_IFCLR(CPU_FTR_SLB)
DataAccessSLB_Iseries: DataAccessSLB_Iseries:
mtspr SPRG1,r13 /* save r13 */ mtspr SPRG1,r13 /* save r13 */
EXCEPTION_PROLOG_ISERIES_1(PACA_EXSLB) EXCEPTION_PROLOG_ISERIES_1(PACA_EXSLB)
std r3,PACASLBR3(r13) std r3,PACA_EXSLB+EX_R3(r13)
ld r11,PACALPPACA+LPPACASRR0(r13)
ld r12,PACALPPACA+LPPACASRR1(r13) ld r12,PACALPPACA+LPPACASRR1(r13)
mfspr r3,DAR mfspr r3,DAR
b .do_slb_miss b .do_slb_miss
...@@ -621,10 +605,9 @@ DataAccessSLB_Iseries: ...@@ -621,10 +605,9 @@ DataAccessSLB_Iseries:
InstructionAccessSLB_Iseries: InstructionAccessSLB_Iseries:
mtspr SPRG1,r13 /* save r13 */ mtspr SPRG1,r13 /* save r13 */
EXCEPTION_PROLOG_ISERIES_1(PACA_EXSLB) EXCEPTION_PROLOG_ISERIES_1(PACA_EXSLB)
std r3,PACASLBR3(r13) std r3,PACA_EXSLB+EX_R3(r13)
ld r11,PACALPPACA+LPPACASRR0(r13)
ld r12,PACALPPACA+LPPACASRR1(r13) ld r12,PACALPPACA+LPPACASRR1(r13)
mr r3,r11 ld r3,PACALPPACA+LPPACASRR0(r13)
b .do_slb_miss b .do_slb_miss
MASKABLE_EXCEPTION_ISERIES(0x500, HardwareInterrupt) MASKABLE_EXCEPTION_ISERIES(0x500, HardwareInterrupt)
...@@ -1169,7 +1152,6 @@ _GLOBAL(do_slb_miss) ...@@ -1169,7 +1152,6 @@ _GLOBAL(do_slb_miss)
mflr r10 mflr r10
stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */ stw r9,PACA_EXSLB+EX_CCR(r13) /* save CR in exc. frame */
std r11,PACA_EXSLB+EX_SRR0(r13) /* save SRR0 in exc. frame */
std r10,PACA_EXSLB+EX_LR(r13) /* save LR */ std r10,PACA_EXSLB+EX_LR(r13) /* save LR */
bl .slb_allocate /* handle it */ bl .slb_allocate /* handle it */
...@@ -1177,9 +1159,11 @@ _GLOBAL(do_slb_miss) ...@@ -1177,9 +1159,11 @@ _GLOBAL(do_slb_miss)
/* All done -- return from exception. */ /* All done -- return from exception. */
ld r10,PACA_EXSLB+EX_LR(r13) ld r10,PACA_EXSLB+EX_LR(r13)
ld r3,PACASLBR3(r13) ld r3,PACA_EXSLB+EX_R3(r13)
lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */ lwz r9,PACA_EXSLB+EX_CCR(r13) /* get saved CR */
ld r11,PACA_EXSLB+EX_SRR0(r13) /* get saved SRR0 */ #ifdef CONFIG_PPC_ISERIES
ld r11,PACALPPACA+LPPACASRR0(r13) /* get SRR0 value */
#endif /* CONFIG_PPC_ISERIES */
mtlr r10 mtlr r10
...@@ -1192,8 +1176,10 @@ _GLOBAL(do_slb_miss) ...@@ -1192,8 +1176,10 @@ _GLOBAL(do_slb_miss)
mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */ mtcrf 0x01,r9 /* slb_allocate uses cr0 and cr7 */
.machine pop .machine pop
#ifdef CONFIG_PPC_ISERIES
mtspr SRR0,r11 mtspr SRR0,r11
mtspr SRR1,r12 mtspr SRR1,r12
#endif /* CONFIG_PPC_ISERIES */
ld r9,PACA_EXSLB+EX_R9(r13) ld r9,PACA_EXSLB+EX_R9(r13)
ld r10,PACA_EXSLB+EX_R10(r13) ld r10,PACA_EXSLB+EX_R10(r13)
ld r11,PACA_EXSLB+EX_R11(r13) ld r11,PACA_EXSLB+EX_R11(r13)
......
...@@ -79,7 +79,6 @@ struct paca_struct { ...@@ -79,7 +79,6 @@ struct paca_struct {
u64 exmc[8]; /* used for machine checks */ u64 exmc[8]; /* used for machine checks */
u64 exslb[8]; /* used for SLB/segment table misses u64 exslb[8]; /* used for SLB/segment table misses
* on the linear mapping */ * on the linear mapping */
u64 slb_r3; /* spot to save R3 on SLB miss */
mm_context_t context; mm_context_t context;
u16 slb_cache[SLB_CACHE_ENTRIES]; u16 slb_cache[SLB_CACHE_ENTRIES];
u16 slb_cache_ptr; u16 slb_cache_ptr;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment