title: Traversing `vm_area_struct`'s of a process
body: <p>As an extension of an answer to <a href="https://stackoverflow.com/questions/20868921/traversing-all-the-physical-pages-of-a-process">Traversing all the physical pages of a process</a> and data here <a href="http://www.makelinux.net/ldd3/chp-15-sect-1" rel="nofollow noreferrer">http://www.makelinux.net/ldd3/chp-15-sect-1</a>, I had a small question. In the first answer as suggested to traverse the physical pages of a process, </p>
  
  <pre><code>struct vm_area_struct *vma = 0;
  unsigned long vpage;
  if (task-&gt;mm &amp;&amp; task-&gt;mm-&gt;mmap)
      for (vma = task-&gt;mm-&gt;mmap; vma; vma = vma-&gt;vm_next)
          for (vpage = vma-&gt;vm_start; vpage &lt; vma-&gt;vm_end; vpage += PAGE_SIZE)
              unsigned long phys = virt2phys(task-&gt;mm, vpage);
  </code></pre>
  
  <p>and referring to an example given in the second link under the heading "<strong>15.1.6. Virtual Memory Areas</strong>", which is </p>
  
  <pre><code># cat /proc/1/maps     look at 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
  </code></pre>
  
  <p>Now my question is, as I traverse will the values of <code>vm_start</code> and <code>vm_end</code> for the first area be <code>08048000</code> and <code>0804e000</code>, or will it be <code>08048000</code> and <code>08053000</code> (one contiguous chunk of memory). I should probably write a program and try it myself, but I am using this data for another project, and it would be very helpful if someone could help be understand this. I basically want to know that, if </p>
  
  <pre><code>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
  </code></pre>
  
  <p>is one "module" belonging to the process, does it have one or multiple <code>vm_area_struct</code> data structures. </p>
  
  <p>Thank you.</p>