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