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 atomic_inc(&mm->mm_count);
32 switch_mm(active_mm, mm, tsk);
40 * Reverses the effect of use_mm, i.e. releases the
41 * specified mm context which was earlier taken on
42 * by the calling kernel thread
43 * (Note: this routine is intended to be called only
44 * from a kernel thread context)
46 void unuse_mm(struct mm_struct *mm)
48 struct task_struct *tsk = current;
52 /* active_mm is still 'mm' */
53 enter_lazy_tlb(mm, tsk);