1 /* Copyright (C) 2009 Red Hat, Inc.
3 * See ../COPYING for licensing terms.
7 #include <linux/sched.h>
8 #include <linux/sched/mm.h>
9 #include <linux/mmu_context.h>
10 #include <linux/export.h>
12 #include <asm/mmu_context.h>
16 * Makes the calling kernel thread take on the specified
18 * (Note: this routine is intended to be called only
19 * from a kernel thread context)
21 void use_mm(struct mm_struct *mm)
23 struct mm_struct *active_mm;
24 struct task_struct *tsk = current;
27 active_mm = tsk->active_mm;
28 if (active_mm != mm) {
33 switch_mm(active_mm, mm, tsk);
35 #ifdef finish_arch_post_lock_switch
36 finish_arch_post_lock_switch();
42 EXPORT_SYMBOL_GPL(use_mm);
46 * Reverses the effect of use_mm, i.e. releases the
47 * specified mm context which was earlier taken on
48 * by the calling kernel thread
49 * (Note: this routine is intended to be called only
50 * from a kernel thread context)
52 void unuse_mm(struct mm_struct *mm)
54 struct task_struct *tsk = current;
59 /* active_mm is still 'mm' */
60 enter_lazy_tlb(mm, tsk);
63 EXPORT_SYMBOL_GPL(unuse_mm);