Lines Matching refs:mm
145 static inline int dup_mmap(struct mm_struct * mm) in dup_mmap() argument
150 flush_cache_mm(current->mm); in dup_mmap()
151 mm->locked_vm = 0; in dup_mmap()
152 mm->mmap = NULL; in dup_mmap()
153 mm->mmap_cache = NULL; in dup_mmap()
154 mm->map_count = 0; in dup_mmap()
155 mm->rss = 0; in dup_mmap()
156 mm->cpu_vm_mask = 0; in dup_mmap()
157 mm->swap_address = 0; in dup_mmap()
158 pprev = &mm->mmap; in dup_mmap()
167 list_add(&mm->mmlist, ¤t->mm->mmlist); in dup_mmap()
171 for (mpnt = current->mm->mmap ; mpnt ; mpnt = mpnt->vm_next) { in dup_mmap()
182 tmp->vm_mm = mm; in dup_mmap()
205 spin_lock(&mm->page_table_lock); in dup_mmap()
208 mm->map_count++; in dup_mmap()
209 retval = copy_page_range(mm, current->mm, tmp); in dup_mmap()
210 spin_unlock(&mm->page_table_lock); in dup_mmap()
219 build_mmap_rb(mm); in dup_mmap()
222 flush_tlb_mm(current->mm); in dup_mmap()
230 #define free_mm(mm) (kmem_cache_free(mm_cachep, (mm))) argument
232 static struct mm_struct * mm_init(struct mm_struct * mm) in mm_init() argument
234 atomic_set(&mm->mm_users, 1); in mm_init()
235 atomic_set(&mm->mm_count, 1); in mm_init()
236 init_rwsem(&mm->mmap_sem); in mm_init()
237 mm->page_table_lock = SPIN_LOCK_UNLOCKED; in mm_init()
238 mm->pgd = pgd_alloc(mm); in mm_init()
239 mm->def_flags = 0; in mm_init()
240 if (mm->pgd) in mm_init()
241 return mm; in mm_init()
242 free_mm(mm); in mm_init()
252 struct mm_struct * mm; in mm_alloc() local
254 mm = allocate_mm(); in mm_alloc()
255 if (mm) { in mm_alloc()
256 memset(mm, 0, sizeof(*mm)); in mm_alloc()
257 return mm_init(mm); in mm_alloc()
267 void fastcall __mmdrop(struct mm_struct *mm) in __mmdrop() argument
269 BUG_ON(mm == &init_mm); in __mmdrop()
270 pgd_free(mm->pgd); in __mmdrop()
272 destroy_context(mm); in __mmdrop()
273 free_mm(mm); in __mmdrop()
279 void mmput(struct mm_struct *mm) in mmput() argument
281 if (atomic_dec_and_lock(&mm->mm_users, &mmlist_lock)) { in mmput()
283 if (swap_mm == mm) in mmput()
284 swap_mm = list_entry(mm->mmlist.next, struct mm_struct, mmlist); in mmput()
285 list_del(&mm->mmlist); in mmput()
288 exit_mmap(mm); in mmput()
289 mmdrop(mm); in mmput()
320 struct mm_struct * mm, *oldmm; in copy_mm() local
327 tsk->mm = NULL; in copy_mm()
335 oldmm = current->mm; in copy_mm()
341 mm = oldmm; in copy_mm()
346 mm = allocate_mm(); in copy_mm()
347 if (!mm) in copy_mm()
351 memcpy(mm, oldmm, sizeof(*mm)); in copy_mm()
352 if (!mm_init(mm)) in copy_mm()
355 if (init_new_context(tsk,mm)) in copy_mm()
359 retval = dup_mmap(mm); in copy_mm()
368 copy_segments(tsk, mm); in copy_mm()
371 tsk->mm = mm; in copy_mm()
372 tsk->active_mm = mm; in copy_mm()
376 mmput(mm); in copy_mm()