]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - mm/mmu_context.c
sched/headers: Prepare to use <linux/rcuupdate.h> instead of <linux/rculist.h> in...
[mirror_ubuntu-hirsute-kernel.git] / mm / mmu_context.c
CommitLineData
3d2d827f
MT
1/* Copyright (C) 2009 Red Hat, Inc.
2 *
3 * See ../COPYING for licensing terms.
4 */
5
6#include <linux/mm.h>
8efd755a 7#include <linux/sched.h>
6e84f315 8#include <linux/sched/mm.h>
3d2d827f 9#include <linux/mmu_context.h>
b95f1b31 10#include <linux/export.h>
3d2d827f
MT
11
12#include <asm/mmu_context.h>
13
14/*
15 * use_mm
16 * Makes the calling kernel thread take on the specified
17 * mm context.
3d2d827f
MT
18 * (Note: this routine is intended to be called only
19 * from a kernel thread context)
20 */
21void use_mm(struct mm_struct *mm)
22{
23 struct mm_struct *active_mm;
24 struct task_struct *tsk = current;
25
26 task_lock(tsk);
27 active_mm = tsk->active_mm;
f68e1480 28 if (active_mm != mm) {
f1f10076 29 mmgrab(mm);
f68e1480
MT
30 tsk->active_mm = mm;
31 }
3d2d827f 32 tsk->mm = mm;
3d2d827f
MT
33 switch_mm(active_mm, mm, tsk);
34 task_unlock(tsk);
a53efe5f
MS
35#ifdef finish_arch_post_lock_switch
36 finish_arch_post_lock_switch();
37#endif
3d2d827f 38
f68e1480
MT
39 if (active_mm != mm)
40 mmdrop(active_mm);
3d2d827f 41}
5da779c3 42EXPORT_SYMBOL_GPL(use_mm);
3d2d827f
MT
43
44/*
45 * unuse_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)
51 */
52void unuse_mm(struct mm_struct *mm)
53{
54 struct task_struct *tsk = current;
55
56 task_lock(tsk);
05af2e10 57 sync_mm_rss(mm);
3d2d827f
MT
58 tsk->mm = NULL;
59 /* active_mm is still 'mm' */
60 enter_lazy_tlb(mm, tsk);
61 task_unlock(tsk);
62}
5da779c3 63EXPORT_SYMBOL_GPL(unuse_mm);