Bug 677

Summary: insmod is failing on machines with small memory
Product: Busybox Reporter: Ivica Mikec <imikec>
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: enhancement CC: busybox-cvs
Priority: P5    
Version: 1.14.x   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Host: Target:
Build:

Description Ivica Mikec 2009-10-21 20:26:51 UTC
Hi!

insmod is failing on machine with 16Mb memory, while it works fine if the memory is 32Mb. This happens when insmod tries to malloc memory for module and module is big, in my case around 3Mb. Is there any reason why mmap method is removed from insmod? Why can't we add a flag CONFIG_FEATURE_INSMOD_SMALLMEM and use mmap if this one is set, and still use malloc if not?
Comment 1 Denys Vlasenko 2009-11-29 02:10:17 UTC
Implemented as FEATURE_INSMOD_TRY_MMAP:

config FEATURE_INSMOD_TRY_MMAP
        bool "Try to load module from a mmap'ed area"
        default n
        depends on INSMOD || MODPROBE_SMALL
        help
          This option causes module loading code to try to mmap
          module first. If it does not work (for example,
          it does not work for compressed modules), module will be read
          (and unpacked if needed) into a memory block allocated by malloc.

          The only case when mmap works but malloc does not is when
          you are trying to load a big module on a very memory-constrained
          machine. Malloc will momentarily need 2x as much memory as mmap.

          Choosing N saves about 250 bytes of code (on 32-bit x86).


Will be in 1.16.x