title: What is the difference between vmalloc and kmalloc?
body: <p>I've googled around and found most people advocating the use of <code>kmalloc</code>, as you're guaranteed to get contiguous physical blocks of memory. However, it also seems as though <code>kmalloc</code> can fail if a contiguous <strong>physical</strong> block that you want can't be found.<br>
  What are the advantages of having a contiguous block of memory? Specifically, why would I need to have a contiguous <strong>physical</strong> block of memory in a <em>system call</em>? Is there any reason I couldn't just use <code>vmalloc</code>?<br>
  Finally, if I were to allocate memory during the handling of a system call, should I specify <code>GFP_ATOMIC</code>?  Is a system call executed in an atomic context?</p>
  
  <blockquote>
    <p><code>GFP_ATOMIC</code><br>
    The allocation is high-priority and
    does not sleep. This is the flag to
    use in interrupt handlers, bottom
    halves and other situations where you
    cannot sleep.</p>
    
    <p><code>GFP_KERNEL</code>
    This is a normal allocation and might block. This is the flag to use
    in process context code when it is safe to sleep.</p>
  </blockquote>