Commit b141dbac authored by Andrew Jones's avatar Andrew Jones Committed by Paolo Bonzini
Browse files

arm/arm64: speed up spinlocks and atomic ops

spinlock torture tests made it clear that checking mmu_enabled()
every time we call spin_lock is a bad idea. As most tests will
want the MMU enabled the entire time, then we can inline a light
weight "nobody disabled the mmu" check, and bail out early.

Adding a light weight inlined check vs. a compile-time flag
suggested by Paolo.
Signed-off-by: Andrew Jones's avatarAndrew Jones <>
Signed-off-by: default avatarPaolo Bonzini <>
parent c33efcf3
#ifndef __ASMARM_MMU_API_H_
#define __ASMARM_MMU_API_H_
extern pgd_t *mmu_idmap;
extern bool mmu_enabled(void);
extern unsigned int mmu_disabled_cpu_count;
extern bool __mmu_enabled(void);
static inline bool mmu_enabled(void)
return mmu_disabled_cpu_count == 0 || __mmu_enabled();
extern void mmu_enable(pgd_t *pgtable);
extern void mmu_mark_disabled(int cpu);
extern void mmu_disable(void);
......@@ -16,8 +16,9 @@ pgd_t *mmu_idmap;
/* CPU 0 starts with disabled MMU */
static cpumask_t mmu_disabled_cpumask = { {1} };
unsigned int mmu_disabled_cpu_count = 1;
bool mmu_enabled(void)
bool __mmu_enabled(void)
int cpu = current_thread_info()->cpu;
......@@ -31,12 +32,15 @@ void mmu_enable(pgd_t *pgtable)
cpumask_clear_cpu(cpu, &mmu_disabled_cpumask);
if (cpumask_test_and_clear_cpu(cpu, &mmu_disabled_cpumask))
void mmu_mark_disabled(int cpu)
cpumask_set_cpu(cpu, &mmu_disabled_cpumask);
if (!cpumask_test_and_set_cpu(cpu, &mmu_disabled_cpumask))
extern void asm_mmu_disable(void);
Supports Markdown
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