Skip to content

Commit cfd9d70

Browse files
committed
ARCv2: mm: TLB Miss optim: SMP builds can cache pgd pointer in mmu scratch reg
ARC700 exception (and intr handling) didn't have auto stack switching thus had to rely on stashing a reg temporarily (to free it up) at a known place in memory, allowing to code up the low level stack switching. This however was not re-entrant in SMP which thus had to repurpose the per-cpu MMU SCRATCH DATA register otherwise used to "cache" the task pdg pointer (vs. reading it from mm struct) The newer HS cores do have auto-stack switching and thus even SMP builds can use the MMU SCRATCH reg as originally intended. This patch fixes the restriction to ARC700 SMP builds only Signed-off-by: Vineet Gupta <[email protected]>
1 parent 7b491c0 commit cfd9d70

File tree

6 files changed

+10
-6
lines changed

6 files changed

+10
-6
lines changed

arch/arc/include/asm/entry-compact.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,15 @@
130130
* to be saved again on kernel mode stack, as part of pt_regs.
131131
*-------------------------------------------------------------*/
132132
.macro PROLOG_FREEUP_REG reg, mem
133-
#ifdef CONFIG_SMP
133+
#ifndef ARC_USE_SCRATCH_REG
134134
sr \reg, [ARC_REG_SCRATCH_DATA0]
135135
#else
136136
st \reg, [\mem]
137137
#endif
138138
.endm
139139

140140
.macro PROLOG_RESTORE_REG reg, mem
141-
#ifdef CONFIG_SMP
141+
#ifndef ARC_USE_SCRATCH_REG
142142
lr \reg, [ARC_REG_SCRATCH_DATA0]
143143
#else
144144
ld \reg, [\mem]

arch/arc/include/asm/mmu.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
#define ARC_REG_SCRATCH_DATA0 0x46c
4141
#endif
4242

43+
#if defined(CONFIG_ISA_ARCV2) || !defined(CONFIG_SMP)
44+
#define ARC_USE_SCRATCH_REG
45+
#endif
46+
4347
/* Bits in MMU PID register */
4448
#define __TLB_ENABLE (1 << 31)
4549
#define __PROG_ENABLE (1 << 30)

arch/arc/include/asm/mmu_context.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ static inline void switch_mm(struct mm_struct *prev, struct mm_struct *next,
144144
*/
145145
cpumask_set_cpu(cpu, mm_cpumask(next));
146146

147-
#ifndef CONFIG_SMP
147+
#ifdef ARC_USE_SCRATCH_REG
148148
/* PGD cached in MMU reg to avoid 3 mem lookups: task->mm->pgd */
149149
write_aux_reg(ARC_REG_SCRATCH_DATA0, next->pgd);
150150
#endif

arch/arc/include/asm/pgtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ static inline void set_pte_at(struct mm_struct *mm, unsigned long addr,
351351
* Thus use this macro only when you are certain that "current" is current
352352
* e.g. when dealing with signal frame setup code etc
353353
*/
354-
#ifndef CONFIG_SMP
354+
#ifdef ARC_USE_SCRATCH_REG
355355
#define pgd_offset_fast(mm, addr) \
356356
({ \
357357
pgd_t *pgd_base = (pgd_t *) read_aux_reg(ARC_REG_SCRATCH_DATA0); \

arch/arc/mm/tlb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ void arc_mmu_init(void)
868868
write_aux_reg(ARC_REG_PID, MMU_ENABLE);
869869

870870
/* In smp we use this reg for interrupt 1 scratch */
871-
#ifndef CONFIG_SMP
871+
#ifdef ARC_USE_SCRATCH_REG
872872
/* swapper_pg_dir is the pgd for the kernel, used by vmalloc */
873873
write_aux_reg(ARC_REG_SCRATCH_DATA0, swapper_pg_dir);
874874
#endif

arch/arc/mm/tlbex.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ ex_saved_reg1:
193193

194194
lr r2, [efa]
195195

196-
#ifndef CONFIG_SMP
196+
#ifdef ARC_USE_SCRATCH_REG
197197
lr r1, [ARC_REG_SCRATCH_DATA0] ; current pgd
198198
#else
199199
GET_CURR_TASK_ON_CPU r1

0 commit comments

Comments
 (0)