Reputation: 6853
I would like to write a simple kernel function that iterates over all the vm_area_struct
s that belong to a specific process and mark each one of them as belonging to the heap or not. Assume that I can add a boolean field in the vm_area_struct
that will be set for heap pages and reset for other pages.
I have looked into the mm_struct
, vm_area_struct
, and task_struct
... but found nothing that can help.
Update: I am guessing start_brk and brk have something to do with this?
Upvotes: 0
Views: 322
Reputation: 2144
(Am inserting my last comment as an answer, as the formatting within "Comment" is not that great):
Wrt my prev comment: the relevant code (to look up VMAs of a given PID) seems to be here: fs/proc/task_mmu.c .
And, yes indeed, the "[heap]" is marked by this code snippet from the above src file (kernel ver 3.10.24):
*fs/proc/task_mmu.c:show_map_vma()*
...
if (vma->vm_start <= mm->brk &&
vma->vm_end >= mm->start_brk) {
name = "[heap]";
goto done; }
...
Upvotes: 1