Reputation: 101
I trace Linux source code and find this function: void put_page(struct page *page)
I Googled it and some people say this function use to construct a map from physical frame address to virtual address.
But I trace the put_page
function in mm/swap.c
. The code behavior seems not used for mapping physical to virtual address.
Any one know what this function do?
Upvotes: 4
Views: 5350
Reputation: 6013
A "put_page" will copy the page to transcendent memory and associate it with the type and offset associated with the page.
A "get_page" will copy the page, if found, from transcendent memory into kernel memory, but will NOT remove the page from from transcendent memory.
See the Linux kernel doc: frontswap.txt for details.
Upvotes: 2
Reputation: 26024
I just found this which seems very succinct & useful:
There are two phases of these functions:
- delete the page from lru cache (__page_cache_release)
- freeing the page to memory allocator
Consider the allocation process:
- page is allocated
- page table entries are fixed
- page is added to lru cache.
In the
put_page
functions, page table entries are not handled. So the control path should fix/remove appropriate page table entries depending before calling thes functions.
Upvotes: 1
Reputation: 137557
In the Linux kernel, a function named put_
generally means "freeing" or "releasing" something. (As "put" is the opposite of "get"). From a brief look through the code, it appears that function is called to release a struct page
.
The (related) function put_pages_list
is actually documented:
/**
* put_pages_list() - release a list of pages
* @pages: list of pages threaded on page->lru
*
* Release a list of pages which are strung together on page.lru. Currently
* used by read_cache_pages() and related error recovery code.
*/
To me, this confirms that put_page
"releases" a single struct page
.
Upvotes: 2