Skip to content

Commit f98db60

Browse files
amlutoIngo Molnar
authored andcommitted
sched/core: Add switch_mm_irqs_off() and use it in the scheduler
By default, this is the same thing as switch_mm(). x86 will override it as an optimization. Signed-off-by: Andy Lutomirski <[email protected]> Reviewed-by: Borislav Petkov <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Thomas Gleixner <[email protected]> Link: http://lkml.kernel.org/r/df401df47bdd6be3e389c6f1e3f5310d70e81b2c.1461688545.git.luto@kernel.org Signed-off-by: Ingo Molnar <[email protected]>
1 parent 8efd755 commit f98db60

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

include/linux/mmu_context.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,16 @@
11
#ifndef _LINUX_MMU_CONTEXT_H
22
#define _LINUX_MMU_CONTEXT_H
33

4+
#include <asm/mmu_context.h>
5+
46
struct mm_struct;
57

68
void use_mm(struct mm_struct *mm);
79
void unuse_mm(struct mm_struct *mm);
810

11+
/* Architectures that care about IRQ state in switch_mm can override this. */
12+
#ifndef switch_mm_irqs_off
13+
# define switch_mm_irqs_off switch_mm
14+
#endif
15+
916
#endif

kernel/sched/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#include <linux/init.h>
3434
#include <linux/uaccess.h>
3535
#include <linux/highmem.h>
36-
#include <asm/mmu_context.h>
36+
#include <linux/mmu_context.h>
3737
#include <linux/interrupt.h>
3838
#include <linux/capability.h>
3939
#include <linux/completion.h>
@@ -2733,7 +2733,7 @@ context_switch(struct rq *rq, struct task_struct *prev,
27332733
atomic_inc(&oldmm->mm_count);
27342734
enter_lazy_tlb(oldmm, next);
27352735
} else
2736-
switch_mm(oldmm, mm, next);
2736+
switch_mm_irqs_off(oldmm, mm, next);
27372737

27382738
if (!prev->mm) {
27392739
prev->active_mm = NULL;
@@ -5274,7 +5274,7 @@ void idle_task_exit(void)
52745274
BUG_ON(cpu_online(smp_processor_id()));
52755275

52765276
if (mm != &init_mm) {
5277-
switch_mm(mm, &init_mm, current);
5277+
switch_mm_irqs_off(mm, &init_mm, current);
52785278
finish_arch_post_lock_switch();
52795279
}
52805280
mmdrop(mm);

0 commit comments

Comments
 (0)