// mm_destroy - free mm and mm internal fields void mm_destroy(struct mm_struct *mm) { assert(mm_count(mm) == 0); list_entry_t *list = &(mm->mmap_list), *le; while ((le = list_next(list)) != list) { list_del(le); kfree(le2vma(le, list_link)); //kfree vma } kfree(mm); //kfree mm mm=NULL; }
// mm_destroy - free mm and mm internal fields void mm_destroy(struct mm_struct *mm) { assert(mm_count(mm) == 0); if (mm->mmap_tree != NULL) { rb_tree_destroy(mm->mmap_tree); } list_entry_t *list = &(mm->mmap_list), *le; while ((le = list_next(list)) != list) { list_del(le); vma_destroy(le2vma(le, list_link)); } kfree(mm); }
void exit_mmap(struct mm_struct *mm) { assert(mm != NULL && mm_count(mm) == 0); pde_t *pgdir = mm->pgdir; list_entry_t *list = &(mm->mmap_list), *le = list; while ((le = list_next(le)) != list) { struct vma_struct *vma = le2vma(le, list_link); unmap_range(pgdir, vma->vm_start, vma->vm_end); } while ((le = list_next(le)) != list) { struct vma_struct *vma = le2vma(le, list_link); exit_range(pgdir, vma->vm_start, vma->vm_end); } }
void exit_mmap(struct mm_struct *mm) { assert(mm != NULL && mm_count(mm) == 0); pgd_t *pgdir = mm->pgdir; list_entry_t *list = &(mm->mmap_list), *le = list; while ((le = list_next(le)) != list) { struct vma_struct *vma = le2vma(le, list_link); unmap_range(pgdir, vma->vm_start, vma->vm_end); #ifdef UCONFIG_BIONIC_LIBC vma_unmapfile(vma); #endif //UCONFIG_BIONIC_LIBC } while ((le = list_next(le)) != list) { struct vma_struct *vma = le2vma(le, list_link); exit_range(pgdir, vma->vm_start, vma->vm_end); } }