title: Is there a size limit for kernel module in linux?
body: <p>I have a problem loading a kernel module, there is a large data structure, around the size of 2Gb of memory - whether I preallocate the table (so that it shows in .bss when I do <code>size -A module.ko</code> or try to <code>vmalloc()</code> it at load time, the module loading fails with <code>insmod: error inserting 'module.ko': -1 Cannot allocate memory</code>.</p>
  
  <p>I tried debugging the problem on usermode linux, but I get a bunch of segfaults (that can be continued in gdb, but end up with a console message <code>overflow in relocation type 10 val &lt;value in the ball park of 6G&gt;</code> and <code>'module' likely not compiled with -mcmodel=kernel</code>. I assume that with <code>Kbuild</code> the <code>-mcmodel</code> should be right, right?</p>
  
  <p>So the questions are:</p>
  
  <ol>
  <li>Is there a generic 2G limit for linux kernel module size?</li>
  <li>Is there a specific 2G limit for kernel modules in usernode linux (I <em>think</em> that in past I've noticed that a large kernel module needs a clean, continuous block of memory...) </li>
  <li>Can I specify <code>-mcmodel=large</code> for a kernel module and expect it to work?</li>
  </ol>
  
  <p>I've tried this on debian squeeze, 64-bit, 2.6.32-5-amd64 (host) with 8Gb of memory and 2.6.32 in uml with 4G memory, so this should <strong>not</strong> be an ordinary out of memory problem.</p>
  
  <p><strong>Extra credit for working around the limit, if such limit exists :)</strong></p>