title: how to get to struct vm_area_struct from struct page
body: <p>Basically, I need to identify the process or task using a page, and accordingly make some decisions regarding whether to allow the page to be swapped out or not. Because the swap module in kernel AFAIK deals with mostly <em>struct page</em>, I was wondering whether there is some existing trick that I am missing. From include/linux/mm_types.h (v >= 2.6), the following comment:</p>
  
  <ul>
  <li>Each physical page in the system has a struct page associated with</li>
  <li>it to keep track of whatever it is we are using the page for at the</li>
  <li>moment. Note that we have no way to track which tasks are using</li>
  <li>a page, though if it is a pagecache page, rmap structures can tell us</li>
  <li>who is mapping it.</li>
  </ul>
  
  <p>suggests we can do this via some physical-to-virtual reverse mappings, but I could not figure out from the rmap functions (in mm/rmap.c) how to achieve what I am looking for.</p>
  
  <p>Thanks in advance for any help, much appreciated.</p>