In the old version of Linux, we can traverse VMA like that :
<code>static void walk_vma_range(struct mm_struct *mm, u32 *nr_vma, u32 *nr_pages)
{
struct vm_area_struct *vma = mm->mmap;
u32 i = 0;
mmap_assert_locked(mm);
*nr_pages = 0;
while (vma) {
*nr_pages += (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
i++;
vma = vma->vm_next;
}
*nr_vma = i;
}
</code>
<code>static void walk_vma_range(struct mm_struct *mm, u32 *nr_vma, u32 *nr_pages)
{
struct vm_area_struct *vma = mm->mmap;
u32 i = 0;
mmap_assert_locked(mm);
*nr_pages = 0;
while (vma) {
*nr_pages += (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
i++;
vma = vma->vm_next;
}
*nr_vma = i;
}
</code>
static void walk_vma_range(struct mm_struct *mm, u32 *nr_vma, u32 *nr_pages)
{
struct vm_area_struct *vma = mm->mmap;
u32 i = 0;
mmap_assert_locked(mm);
*nr_pages = 0;
while (vma) {
*nr_pages += (vma->vm_end - vma->vm_start) >> PAGE_SHIFT;
i++;
vma = vma->vm_next;
}
*nr_vma = i;
}
However,now in the version 6.6, I found that the definitions of mm_struct and vm_area_struct don’t include members :mmap and vm_next anymore, which means the old traversal way can’t work.
The new version seems to use something called maple
, can someone give me the new code to traverse?
New contributor
Askemi Wang is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.