title: Page Fault in Linux Kernel
body: <p>I have few questions after reading <code>Mel Gorman</code>'s book <code>Understanding the Linux Virtual Memory Manager</code>. Section <code>4.3 Process Address Space Descriptor</code> says <code>kernel threads never page fault or access the user space portion. The only exception is page faulting within the vmalloc space</code> . Following are my questions.</p>
  <ol>
  <li><p>kenrel threads never page fault: Does this mean only user space code triggers page fault? If a <code>kmalloc()</code> or <code>vmalloc()</code> is called, will it not page fault? I believe the kernel has to map these to the anon pages. When a write to this pages is performed, a page fault occurs. Is my understanding correct?</p>
  </li>
  <li><p>Why can't kernel threads access user space? Aren't <code>copy_to_user()</code> or <code>copy_from_user()</code> do that?</p>
  </li>
  <li><p><code>Exception is page faulting within vmalloc space</code>: Does that mean <code>vmalloc()</code> triggers a page fault and <code>kmalloc()</code> doesn't ? Why <code>kmalloc()</code> does not page fault? The physical frames to kernel's virtual address need not to be kept as a page table entry?</p>
  </li>
  </ol>