1 /* Copyright (C) 2009 Red Hat, Inc.
3 * See ../COPYING for licensing terms.
7 #include <linux/mmu_context.h>
8 #include <linux/module.h>
9 #include <linux/sched.h>
11 #include <asm/mmu_context.h>
15 * Makes the calling kernel thread take on the specified
17 * Called by the retry thread execute retries within the
18 * iocb issuer's mm context, so that copy_from/to_user
19 * operations work seamlessly for aio.
20 * (Note: this routine is intended to be called only
21 * from a kernel thread context)
23 void use_mm(struct mm_struct *mm)
25 struct mm_struct *active_mm;
26 struct task_struct *tsk = current;
29 active_mm = tsk->active_mm;
30 if (active_mm != mm) {
31 atomic_inc(&mm->mm_count);
35 switch_mm(active_mm, mm, tsk);
41 EXPORT_SYMBOL_GPL(use_mm);
45 * Reverses the effect of use_mm, i.e. releases the
46 * specified mm context which was earlier taken on
47 * by the calling kernel thread
48 * (Note: this routine is intended to be called only
49 * from a kernel thread context)
51 void unuse_mm(struct mm_struct *mm)
53 struct task_struct *tsk = current;
58 /* active_mm is still 'mm' */
59 enter_lazy_tlb(mm, tsk);
62 EXPORT_SYMBOL_GPL(unuse_mm);