c - Traversing `vm_area_struct`'s of a process -
as extension of answer traversing physical pages of process , data here http://www.makelinux.net/ldd3/chp-15-sect-1, had small question. in first answer suggested traverse physical pages of process,
struct vm_area_struct *vma = 0; unsigned long vpage; if (task->mm && task->mm->mmap) (vma = task->mm->mmap; vma; vma = vma->vm_next) (vpage = vma->vm_start; vpage < vma->vm_end; vpage += page_size) unsigned long phys = virt2phys(task->mm, vpage);
and referring example given in second link under heading "15.1.6. virtual memory areas",
# cat /proc/1/maps @ init 08048000-0804e000 r-xp 00000000 03:01 64652 /sbin/init text 0804e000-0804f000 rw-p 00006000 03:01 64652 /sbin/init data 0804f000-08053000 rwxp 00000000 00:00 0 zero-mapped bss 40000000-40015000 r-xp 00000000 03:01 96278 /lib/ld-2.3.2.so text 40015000-40016000 rw-p 00014000 03:01 96278 /lib/ld-2.3.2.so data
now question is, traverse values of vm_start
, vm_end
first area 08048000
, 0804e000
, or 08048000
, 08053000
(one contiguous chunk of memory). should write program , try myself, using data project, , helpful if understand this. want know that, if
08048000-0804e000 r-xp 00000000 03:01 64652 /sbin/init text 0804e000-0804f000 rw-p 00006000 03:01 64652 /sbin/init data 0804f000-08053000 rwxp 00000000 00:00 0 zero-mapped bss
is 1 "module" belonging process, have 1 or multiple vm_area_struct
data structures.
thank you.
it has separate vm_area_struct
each map section. if @ code in fs/proc/task_mmu.c
, functions m_start()
, m_next
, you'll see lines in maps
pseudo-file created iteratively traversing process vma
list. also, note comment on struct vm_area_struct
declaration:
/* * struct defines memory vmm memory area. there 1 of these * per vm-area/task. vm area part of process virtual memory * space has special rule page-fault handlers (ie shared * library, executable area etc). */
clearly, text, data , bss sections have different page-fault handling rules: text can't written @ all. data read-on-first-access, copy-on-write. bss zeroed-on-first-access.
Comments
Post a Comment