How to free a page table page
heysid3 at gmail.com
Mon Apr 5 11:39:53 EDT 2021
I'm trying to manage a custom page table list for my toy project.
A basic process of the custom list is to allocate few pages (struct page)
to the list from the buddy allocator and the list will give some pages
when a user process needs page table pages. In contrast, when this
page table pages will return to the list. Finally, when the list is
not needed, all pages will be
delivered to the buddy allocator.
This relationship can be described as:
process - custom list - buddy allocator
My problem is that a user process' page table pages (pud, pmd, pte)
seem to free their
page to the buddy allocator instead of to the custom list. (allocation
works. I've checked it)
I put my custom functions in release_pages / free_unref_page /
but somehow the functions do not work as I intended. (Actually the
functions are not
called so I may choose the wrong functions.)
So, I was wondering whether I intercepted the right functions (three
Also, I have a question about freeing a page-table page.
1. In x86, are all page-table pages released at the end of termination
by using free_pgtables()?
2. In x86, a page-table page can be freed when there is no entry? In
other words, does the Linux kernel
release a page-table page on runtime? If so, what function would do
this kind of task?
I'm trying to find freeing functions, but I can't find them and I'm
not sure when this kind of function is called.
(I'm pretty sure that pte_free / pmd_free / pud_free functions are not
for this case.)
Any help would be greatly appreciated.
More information about the Kernelnewbies