Reputation: 423
Basically I have a program that can find all the VMA's of a process, but I would like to look at the pages in the page table for that process as well. I'm stumped. I know that the task_struct for the process has a field
pgd_t *pgd; /* page global directory */
Is that just an array of indexes to ALL of the pages?
I found this function inside of "/mm/memory.c"
/*
* Do a quick page-table lookup for a single page.
*/
struct page *follow_page(struct vm_area_struct *vma, unsigned long address,
unsigned int flags)
I can pass it a VMA, but I am unsure about what the address and flags should be. Or perhaps this isn't what I want? Any advice?
Upvotes: 0
Views: 2426
Reputation: 2261
It sounds like you want to do a rudimentary page walk.
Given a pgd
, you can iterate through the entries looking for valid pud
's, then iterate through the pud
's and so on.
One way to do this is using the following:
// iterate through your address space
for (i = 0; i < PAGE_SIZE / sizeof(*pud); i++) {
pud = pud_offset(pgd, PUD_SIZE * i);
// Check if the pud is valid
if (pud_none(*pud) || pud_bad(*pud))
continue;
// And so on
}
Upvotes: 2