[Linux kernel memory management] Physical page release (physical page release __free_pages function)





1. Physical page release __free_pages function



The page allocator provides a function to release physical pages __free_pages, which is defined in the linux-4.12\mm\page_alloc.c #4083 location of the Linux kernel source code;


__free_pagesFunction parameter analysis:

struct page *pageThe parameter indicates the virtual space addresspage of the physical page to be freed ;

unsigned int orderThe parameter indicates the "order" of the physical page to be released, that is, the size of the physical page to be released;

Order (Order): the unit of the number of physical pages, nnn -order page blockrefers to2 n 2^n2n consecutive"physical pages";
refer to[Linux Kernel Memory Management] Partner Allocator ① (Partner Allocator Introduction | Page Block, Order | Partner)


__free_pagesFunction source code:

void __free_pages(struct page *page, unsigned int order)
{
    
    
	if (put_page_testzero(page)) {
    
    
		if (order == 0)
			free_hot_cold_page(page, false);
		else
			__free_pages_ok(page, order);
	}
}

Source code path: linux-4.12\mm\page_alloc.c #4083

insert image description here

Guess you like

Origin blog.csdn.net/han1202012/article/details/124457896