memcg: rework usage of stats by soft limit
[safe/jmp/linux-2.6] / mm / mmu_context.c
index fd473b5..0777654 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <linux/mm.h>
 #include <linux/mmu_context.h>
+#include <linux/module.h>
 #include <linux/sched.h>
 
 #include <asm/mmu_context.h>
@@ -26,14 +27,18 @@ void use_mm(struct mm_struct *mm)
 
        task_lock(tsk);
        active_mm = tsk->active_mm;
-       atomic_inc(&mm->mm_count);
+       if (active_mm != mm) {
+               atomic_inc(&mm->mm_count);
+               tsk->active_mm = mm;
+       }
        tsk->mm = mm;
-       tsk->active_mm = mm;
        switch_mm(active_mm, mm, tsk);
        task_unlock(tsk);
 
-       mmdrop(active_mm);
+       if (active_mm != mm)
+               mmdrop(active_mm);
 }
+EXPORT_SYMBOL_GPL(use_mm);
 
 /*
  * unuse_mm
@@ -53,3 +58,4 @@ void unuse_mm(struct mm_struct *mm)
        enter_lazy_tlb(mm, tsk);
        task_unlock(tsk);
 }
+EXPORT_SYMBOL_GPL(unuse_mm);