title: Kernel panic - java Tainted error due to UseLargePages
body: <p>I'm running into a weird issue of "Kernel Panic" while trying to use <strong>UseLargePages</strong> as one of the JVM parameters. The moment I try to execute any java command, the OS hangs and I'm forced to re-bbot.I'm using 64 bit CentOS 6.2 (Linux 2.6.32-220.23.1). Here's what I did to set-up the LargePages.</p>
  
  <ul>
  <li>Added the following entries in <strong>/etc/sysctl.conf</strong></li>
  </ul>
  
  <pre><code>
  kernel.shmmax = 4294967296
  vm.nr_hugepages = 2048
  vm.hugetlb_shm_group = 502
  </code></pre>
  
  <ul>
  <li>My jvm is running under root user, so added root as part of this group --> <strong>hugetlb</strong></li>
  <li>Updated <strong>/etc/security/limits.conf</strong> to add the following</li>
  </ul>
  
  <pre><code>
  root            soft    memlock         4194304
  root            hard    memlock         4194304
  </code></pre>
  
  <ul>
  <li>Updated kernel command line to use non-transparent hugepages <strong>transparent_hugepage=never</strong>
  meminfo shows
  <pre><code>
  cat /proc/meminfo | grep Huge
  AnonHugePages:         0 kB
  HugePages_Total:    2048
  HugePages_Free:     2048
  HugePages_Rsvd:        0
  HugePages_Surp:        0
  Hugepagesize:       2048 kB
  </pre></code>
  Finally, I added the "-XX:+UseLargePages" as one of the JVM startup parameters.Now, the moment I run any java command, e.g. "java -version", the OS hangs, I had to resort to a re-boot. Here's a stacktrace from the OS log.</li>
  </ul>
  
  <p><strong>Kernel panic - not syncing: Fatal exception
  Pid: 1790, comm: java Tainted: G      D    ----------------   2.6.32-220.23.1.el6.centos.plus.x86_64 #1</strong></p>
  
  <pre><code>
  Kernel panic - not syncing: Fatal exception
  
  Pid: 1790, comm: java Tainted: G      D    ----------------   2.6.32-220.23.1.el6.centos.plus.x86_64 #1
  
  Call Trace:
   [] ? panic+0x78/0x143
   [] ? xen_restore_fl_direct_end+0x0/0x1
   [] ? _spin_unlock_irqrestore+0x1c/0x20
   [] ? oops_end+0xe4/0x100
   [] ? no_context+0xfb/0x260
   [] ? __alloc_pages_nodemask+0x111/0x940
   [] ? __bad_area_nosemaphore+0x125/0x1e0
   [] ? __raw_callee_save_xen_pmd_val+0x11/0x1e
   [] ? bad_area_nosemaphore+0x13/0x20
   [] ? __do_page_fault+0x31d/0x480
   [] ? __lru_cache_add+0x40/0x90
   [] ? xen_set_pte_at+0xaf/0x170
   [] ? page_add_new_anon_rmap+0x9d/0xf0
   [] ? handle_pte_fault+0x487/0xb50
   [] ? do_page_fault+0x3e/0xa0
   [] ? page_fault+0x25/0x30
   [] ? __unmap_hugepage_range+0x1f2/0x300
   [] ? __unmap_hugepage_range+0xdf/0x300
   [] ? unmap_hugepage_range+0x54/0x90
   [] ? unmap_vmas+0xae7/0xc00
   [] ? release_pages+0x21c/0x250
   [] ? check_events+0x12/0x20
   [] ? xen_force_evtchn_callback+0xd/0x10
   [] ? check_events+0x12/0x20
   [] ? unmap_region+0x91/0x130
   [] ? do_munmap+0x2b6/0x3a0
   [] ? sys_munmap+0x56/0x80
   [] ? system_call_fastpath+0x16/0x1b
  Xen Minimal OS!
  </code></pre>
  
  <p>Not sure what's causing this issue. I'm not an OS expert,so don't have a lot of clue to interpret the log. Everything works if I turn of UseLargePages option by commenting <strong>kernel.shmmax = 4294967296</strong>. The totaly memory of the machine is 15gb. I'm using -<strong>Xmx6144M -XX:MaxPermSize=128m</strong> as JVM memory parameters. Is it something to do with CentOS 6.2 ?</p>
  
  <p>Any pointers will be appreciated.</p>