Porting a module to a newer Linux kernel: memory cannot be allocated

I have a rather large driver module that I am trying to compile for the latest Linux kernel (3.4.4). I can compile insmodthe same module with the kernel 2.6.27.25. The GCC version is also different, 4.7.0 versus 4.3.0. Please note that this module is quite complex, and I cannot just go through all the code and all the makefiles.

When the module "insert" I get a Cannot allocate memorywith the following traces:

vmap allocation for size 30248960 failed: use vmalloc=<size> to increase size.
vmalloc: allocation failure: 30243566 bytes
insmod: page allocation failure: order:0, mode:0xd2
Pid: 5840, comm: insmod Tainted: G           O 3.4.4-5.fc17.i686 #1
Call Trace:
 [<c092702a>] ? printk+0x2d/0x2f
 [<c04eff8d>] warn_alloc_failed+0xad/0xf0
 [<c05178d9>] __vmalloc_node_range+0x169/0x1d0
 [<c0517994>] __vmalloc_node+0x54/0x60
 [<c0490825>] ? sys_init_module+0x65/0x1d80
 [<c0517a60>] vmalloc+0x30/0x40
 [<c0490825>] ? sys_init_module+0x65/0x1d80
 [<c0490825>] sys_init_module+0x65/0x1d80
 [<c050cda6>] ? handle_mm_fault+0xf6/0x1d0
 [<c0932b30>] ? spurious_fault+0xae/0xae
 [<c0932ce7>] ? do_page_fault+0x1b7/0x450
 [<c093665f>] sysenter_do_call+0x12/0x28
-- clip --

The obvious answer is that the module allocates too much memory:

  • I have no problems with the old version of the kernel, no matter what size this module is
  • , ,
  • , ( ? Linux ).

, .

​​ vmalloc() 30 000 , lsmod 4,800 . ? , - , ? .ko, .

, , . , . , vmalloc() sys_init_module(), init_module() kernel/module.c. . .ko, init_module() .

, , . , , , insmod .

+5
2

, layout_and_allocate, load_module. , , , .
, , , , Linux .

​​ 4.8 , - 30 , , .
, .

(, ) .
, , Linux. , .
- , NR_CPUS.

, nm objdump, . , .

+5

. ​​ , . pr_debug() .c .

:

objcopy -R .debug_aranges \
    -R .debug_info \
    -R .debug_abbrev \
    -R .debug_line \
    -R .debug_frame \
    -R .debug_str \
    -R .debug_loc \
    -R .debug_ranges \
    orignal.ko new.ko

, , "" , , , Fedora.

.

+2

All Articles