Releasing a page frame
I'm writting a kernel module that manages memory pages for user space (stack allocations for micro thread).
It seems that I have a bug during the release of a physical page.
The unitest I'm doing is to write for each page at the allocaed memory (allocated with vmalloc), causing initially to page fault, and then call the kernel module to release each page frame. After the release, a write would cause a page fault. Repeating this procedure causes something very cool - when I look at "top" I see that the physical memory keeps increasing (similar to a memory leak) but the virtual memory remains the same. The increase is steady and even passes my actual memory size (got 88 giga for 8 giga memory!!!!!). Nevertheless the application is not crashing, nor use swapping area. This makes me think that this is a counters problem.
So, it seems like that each page fault increases some counters, but my hand made release fails to do that. Actually I only use "pte_clear()" for each page I want to release.
Using "__page_free()" does not solve the problem, and "page_free()" causes a kernel panic.
Does anyone have any idea for a direction I could investigate?
Maybe someone knows some similar driver I could referenc?
Thank you and best regards,
How do you allocate and free the pages now?
Looks like I found the problem.
Apperantly, in a page fault the kernel preforms "inc_mm_counter()".
Because I relaesed the page table entry by myself, this counter keeped increasing for each page fault.
Adding dec_mm_counter() after the pte_clear() seems to solve the issue.
Thanks a lot,
|All times are GMT -5. The time now is 03:49 PM.|