Article directory
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_pages
Function parameter analysis:
struct page *page
The parameter indicates the virtual space addresspage
of the physical page to be freed ;
unsigned int order
The 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_pages
Function 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