1 /* Copyright (C) 2009 Red Hat, Inc.
3 * See ../COPYING for licensing terms.
7 #include <linux/mmu_context.h>
8 #include <linux/export.h>
9 #include <linux/sched.h>
11 #include <asm/mmu_context.h>
15 * Makes the calling kernel thread take on the specified
17 * (Note: this routine is intended to be called only
18 * from a kernel thread context)
20 void use_mm(struct mm_struct *mm)
22 struct mm_struct *active_mm;
23 struct task_struct *tsk = current;
27 active_mm = tsk->active_mm;
28 if (active_mm != mm) {
29 atomic_inc(&mm->mm_count);
33 switch_mm(active_mm, mm, tsk);
36 #ifdef finish_arch_post_lock_switch
37 finish_arch_post_lock_switch();
43 EXPORT_SYMBOL_GPL(use_mm);
47 * Reverses the effect of use_mm, i.e. releases the
48 * specified mm context which was earlier taken on
49 * by the calling kernel thread
50 * (Note: this routine is intended to be called only
51 * from a kernel thread context)
53 void unuse_mm(struct mm_struct *mm)
55 struct task_struct *tsk = current;
60 /* active_mm is still 'mm' */
61 enter_lazy_tlb(mm, tsk);
64 EXPORT_SYMBOL_GPL(unuse_mm);