Freeing Memory

Two functions return memory to the kernel — vfree for areas allocated by vmalloc and vmalloc_32, and vunmap for mappings created using vmap or ioremap. Both lead back to vunmap.

mm/vmalloc.c void vunmap(void *addr, int deallocate_pages)

addr indicates the start address of the area to be freed, and deallocate_pages specifies whether the physical pages associated with the area are to be returned to the buddy system. vfree sets the parameter to 1, whereas vunmap sets it to 0 because in this case only the mappings are removed but the associated physical pages are not returned to the buddy system. Figure 3-40 shows the code flow diagram for vunmap.

__vunmap remove_vm_area remove_vm_area

Find areas

unmap_vm_area

deallocate_pages set?

__free_pages|—

Á

Free kernel data structures

Continue reading here: Figure 34G Code flow diagram for vunmap

Was this article helpful?

0 0