Version:  2.0.40 2.2.26 2.4.37 3.13 3.14 3.15 3.16 3.17 3.18 3.19 4.0 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 4.9 4.10

Linux/mm/mmu_context.c

  1 /* Copyright (C) 2009 Red Hat, Inc.
  2  *
  3  * See ../COPYING for licensing terms.
  4  */
  5 
  6 #include <linux/mm.h>
  7 #include <linux/sched.h>
  8 #include <linux/mmu_context.h>
  9 #include <linux/export.h>
 10 
 11 #include <asm/mmu_context.h>
 12 
 13 /*
 14  * use_mm
 15  *      Makes the calling kernel thread take on the specified
 16  *      mm context.
 17  *      (Note: this routine is intended to be called only
 18  *      from a kernel thread context)
 19  */
 20 void use_mm(struct mm_struct *mm)
 21 {
 22         struct mm_struct *active_mm;
 23         struct task_struct *tsk = current;
 24 
 25         task_lock(tsk);
 26         active_mm = tsk->active_mm;
 27         if (active_mm != mm) {
 28                 atomic_inc(&mm->mm_count);
 29                 tsk->active_mm = mm;
 30         }
 31         tsk->mm = mm;
 32         switch_mm(active_mm, mm, tsk);
 33         task_unlock(tsk);
 34 #ifdef finish_arch_post_lock_switch
 35         finish_arch_post_lock_switch();
 36 #endif
 37 
 38         if (active_mm != mm)
 39                 mmdrop(active_mm);
 40 }
 41 EXPORT_SYMBOL_GPL(use_mm);
 42 
 43 /*
 44  * unuse_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)
 50  */
 51 void unuse_mm(struct mm_struct *mm)
 52 {
 53         struct task_struct *tsk = current;
 54 
 55         task_lock(tsk);
 56         sync_mm_rss(mm);
 57         tsk->mm = NULL;
 58         /* active_mm is still 'mm' */
 59         enter_lazy_tlb(mm, tsk);
 60         task_unlock(tsk);
 61 }
 62 EXPORT_SYMBOL_GPL(unuse_mm);
 63 

This page was automatically generated by LXR 0.3.1 (source).  •  Linux is a registered trademark of Linus Torvalds  •  Contact us