Bug 562232

Summary: make module_install fails - depmod cannot allocate memory (reprise)
Product: [openSUSE] openSUSE 11.2 Reporter: Flavio Pasqualin <Flavio>
Component: BasesystemAssignee: Michal Marek <mmarek>
Status: RESOLVED INVALID QA Contact: E-mail List <qa-bugs>
Severity: Normal    
Priority: P5 - None CC: forgotten_qMyteedNxa, jeffm, mmarek
Version: Final   
Target Milestone: ---   
Hardware: 32bit   
OS: openSUSE 11.2   
Whiteboard:
Found By: Community User Services Priority:
Business Priority: Blocker: ---
Marketing QA Status: --- IT Deployment: ---
Bug Depends on: 350896    
Bug Blocks:    

Description Flavio Pasqualin 2009-12-10 16:49:11 UTC
Two previous bug reports are marked as "fixed" but:

DEPMOD2.6.31.5-0.1flavioweb                                                                                                
WARNING: Can't read module /lib/modules/2.6.31.5-0.1-flavioweb/kernel/drivers/ata/libata.ko: Cannot allocate memory             
WARNING: Can't read module /lib/modules/2.6.31.5-0.1-flavioweb/kernel/drivers/ata/pata_rz1000.ko: Cannot allocate memory        
WARNING: Can't read module /lib/modules/2.6.31.5-0.1-flavioweb/kernel/drivers/ata/pata_opti.ko: Cannot allocate memory          
WARNING: Can't read module /lib/modules/2.6.31.5-0.1-flavioweb/kernel/drivers/ata/pata_oldpiix.ko: Cannot allocate memory       
[...]
WARNING: /lib/modules/2.6.31.5-0.1-flavioweb/kernel/drivers/char/scx200_gpio.ko needs unknown symbol scx200_gpio_base           
WARNING: /lib/modules/2.6.31.5-0.1-flavioweb/kernel/drivers/char/scx200_gpio.ko needs unknown symbol scx200_gpio_configure      
WARNING: /lib/modules/2.6.31.5-0.1-flavioweb/kernel/drivers/char/scx200_gpio.ko needs unknown symbol scx200_gpio_shadow         
WARNING: /lib/modules/2.6.31.5-0.1-flavioweb/kernel/drivers/mfd/ucb1400_core.ko needs unknown symbol ac97_bus_type      
[...]
FATAL: Memory allocation failure ../index.c line 133: calloc(sizeof(struct index_node), 1).
make: *** [_modinst_post] Error 1

This happens with: #CONFIG_DEBUG_KERNEL yes
Don't happens with:#CONFIG_DEBUG_KERNEL is not set

I have 512mb ram and 512mb swap. 




+++ This bug was initially created as a clone of Bug #350896 +++

I tried building a vanilla kernel (2.6.24rc6) on my opensuse 10.3 box because i like to compare if an error with 2.6.24rc6-suse-kotd kernel is reproducable with vanilla kernel.

when i do "make modules_install" the process runs for a while and then fails with "Warning: Can`t read module ......: Cannot allocate memory
Fatal: Memory allocation failure depmod.c line 119: malloc(sizeof *new + strlen(name) + 1). 
make: *** [_modinst_post] Error 1

My box has 512MB ram.

I startet make a second time and watched growth of depmod process, and it was around 850MB VSZ, 350MB RSS when it failed.

Any clue why depmod dies with out of memory error ?
Comment 1 Greg Kroah-Hartman 2009-12-10 22:56:42 UTC
Yes, you don't have enough memory to do this with a kernel image that contains all debugging symbols and a very large number of kernel modules.

Either turn off kernel debugging, or don't build all of those kernel modules, or get some more memory for your system.

Anyway, this isn't a kernel error, nothing we can do about it, sorry.
Comment 2 Michal Marek 2009-12-15 15:15:03 UTC
I do care about module-init-tools bugs, though :)
Comment 3 Michal Marek 2009-12-15 15:17:45 UTC
Can you post the output of 'ulimit -a'? If you set some strict limit on virtual memory, then depmod can't do much about it. If that's not the case, please attach the output of
# strace -o strace /sbin/depmod 2.6.31.5-0.1-flavioweb
Comment 4 Flavio Pasqualin 2009-12-15 18:42:59 UTC
Here is 'ulimit -a' output:

ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 3430
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) 379268
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 3430
virtual memory          (kbytes, -v) 729680
file locks                      (-x) unlimited

If you need also 'strace' output tell me, because i must recompile the kernel with "debug_kernel" before...
Comment 5 Michal Marek 2009-12-15 20:51:10 UTC
So you have a limit of about 712MB on virtual memory. How much space do the modules with debuginfo take up? Try
du -sh /lib/modules/2.6.31.5-0.1-flavioweb
If it approaches the 712MB limit, then you need to increase it (depmod doesn't _allocate_ much memory, but it needs to mmap() the *.ko files, which counts as virtual memory usage).
Comment 6 Flavio Pasqualin 2009-12-16 05:14:55 UTC
du -sh /lib/modules/2.6.31.5-0.1-flavioweb
90M     /lib/modules/2.6.31.5-0.1-flavioweb

It's possible that "debug info" on modules take up 622 MB ???

...I have installed also the original modules "default", that have "debug info":

du -sh /lib/modules/2.6.31.5-0.1-default/
910M    /lib/modules/2.6.31.5-0.1-default/

Sig!
Comment 7 Michal Marek 2009-12-16 11:34:19 UTC
(In reply to comment #6)
> du -sh /lib/modules/2.6.31.5-0.1-flavioweb
> 90M     /lib/modules/2.6.31.5-0.1-flavioweb

Now I'm confused. Is this the same kernel that you encountered the bug with or did you rebuild w/o debuginfo in the meantime?


> It's possible that "debug info" on modules take up 622 MB ???

That's indeed possible yes (the 11.2 kernel-default-debuginfo package takes about 850MB). I suggest you just lift the virtual memory limit, depmod won't eat much memory, but it needs to mmap() all the *.ko files.
Comment 8 Flavio Pasqualin 2009-12-16 11:48:47 UTC
(In reply to comment #7)
> (In reply to comment #6)
> > du -sh /lib/modules/2.6.31.5-0.1-flavioweb
> > 90M     /lib/modules/2.6.31.5-0.1-flavioweb
> 
> Now I'm confused. Is this the same kernel that you encountered the bug with or
> did you rebuild w/o debuginfo in the meantime?
> 

It's the same kernel w/o debuginfo.

> I suggest you just lift the virtual memory limit, depmod won't
> eat much memory, but it needs to mmap() all the *.ko files.

So i need a bigger swap partition on disk, or there are some other things to do for lift the virtual memory limit?

Just a curiosity: why installing precompiled kernel and modules from rpms works fine, and not work compiling from source?
Comment 9 Michal Marek 2009-12-16 12:06:58 UTC
(In reply to comment #8)
> (In reply to comment #7)
> > I suggest you just lift the virtual memory limit, depmod won't
> > eat much memory, but it needs to mmap() all the *.ko files.
> 
> So i need a bigger swap partition on disk, or there are some other things to do
> for lift the virtual memory limit?

No, as I wrote, depmod doesn't allocate much memory, but the file mappings count as virtual memory.


> Just a curiosity: why installing precompiled kernel and modules from rpms works
> fine, and not work compiling from source?

Packages have the debuginfo split off into $package-debuginfo.rpm.
Comment 10 Forgotten User qMyteedNxa 2009-12-16 21:10:16 UTC
also have a look at this thread:

http://marc.info/?l=linux-kernel&m=119389053128382&w=2

seems that depmod issue has still not really been adressed!?

i`m curious why any bugreport about this has been closed or set to status "resolved", as it seems this has not really been resolved.

a utility which calculates module dependencies should not consume that large amounts of ram. it`s stupid behaviour, imho.

closing this bugreport will result in another user reporting the same isuse again. 

furthermore, i think throwing ram at bad software behaviour is NO solution. 
have seen that too often, especially with java programmers. ("oh - it does not work? add another 4gb, ram is cheap !)

>Anyway, this isn't a kernel error, nothing we can do about it, sorry.
yes, this is no kernel issue, but it`s a kernel build issue. under what should category/component should this be filed instead?
Comment 11 Michal Marek 2009-12-16 21:18:51 UTC
Care to read the previous comments? depmod (at least in the openSUSE module-init-tools package) allocates a few megabytes of "ram". But it needs to mmap the *.ko files, which adds to the virtual memory usage. Hence if you have a low virtual memory limit (ulimit -v) and compile a kernel with CONFIG_DEBUG_INFO=y, it will easily hit the limit.
Comment 12 Forgotten User qMyteedNxa 2009-12-16 22:01:03 UTC
yes, i have seen that comment, but i don`t understand why the whole bunch of .ko files (actually several thousands if you compile with most module options enabled) needs to be mmapped into virtual memory at the same time. why is that necessary and why to hog the virtual memory subsystem and put that much pressure on it? isn“t there a way to handle this more efficient/elegant?

if a recent kernel depmod needs ~800mb vsz, that`s a LOT if you take into consideration that a typical pc box may have 1-2gb physical ram and the same amount of swap (or less).
Comment 13 Michal Marek 2009-12-16 22:20:41 UTC
One last try: If you mmap a file on disk, it does not affect your ram or swap.
Comment 14 Flavio Pasqualin 2009-12-17 10:58:14 UTC
(In reply to comment #11)
> Care to read the previous comments? depmod (at least in the openSUSE
> module-init-tools package) allocates a few megabytes of "ram". But it needs to
> mmap the *.ko files, which adds to the virtual memory usage. Hence if you have
> a low virtual memory limit (ulimit -v) and compile a kernel with
> CONFIG_DEBUG_INFO=y, it will easily hit the limit.

I understand to add some virtual memory, but i still confused:
if i have a 512mb swap partition and set ulimit -v to "1000000", the -additional- memory where is -stored-?
-Virtual memory- and -swap partition- are the same?
Or i can have a 512mb of swap and 1gb of -virtual memory-?
In my sistem i can have 512mb ram + 512mb of swap, and set -virtual memory- to 1,5gb?

And again: the -debug info- installed with the "kernel-debug-info.rpm" are not "depmodded" and the .ko files "mmapped()"?
Why install a "precomiled kernel-debug-info rpm" works, and compiling the same kernel from source cause the "out of memory"?
What's the difference?

IMHO "add memory" is not a solution but a "work around"...
A more efficient depmod is a solution.
Comment 15 Jeff Mahoney 2009-12-17 15:12:22 UTC
Michal did not suggest adding memory, he suggested changing your limit for virtual memory. They're not the same thing and virtual memory is not just another term for "swap" despite how MacOS and Windows have abused the term.

Virtual memory is the address space associated with a program. Each program has it's own 32/64-bit address space, of which most of it is potentially usable. Much of it never is. It can be used by the program instructions, dynamic memory (like malloc), shared libraries, and mmap. Shared libraries can take up a considerable amount of your address space - but there is usually only a single copy in memory that is shared by all programs that need it. So for an easy example, every program running on your system right now probably uses libc. On my system, that is about 1.4M. I have about 200 processes running on my system, but that library will only ever take a maximum of 1.4 MB of memory.

UNIX systems have a facility called mmap, which gives programmers the ability map files into the address space of the program and access them as if they were loaded from disk into a chunk of memory. The difference is that only the portions that are actually accessed ever get read in from disk. Shared libraries use this and only ever load the parts of the library that are actually needed. This happens automatically when the memory is accessed. So for my libc example where I said it loads a maximum of 1.4 MB, it's actually less than that. There are portions of the library that are needed for compatibility but are hardly ever actually used. That code never gets loaded from disk.

For kernel modules, depmod really only needs the module headers and the symbol table. The debuginfo isn't used and is never loaded. That's why Michal is saying that while the modules on disk take up over 800 MB, depmod only ever allocates a few MB. That's all it's actually using and that's all that has ever been read in from disk.

BUT for sake of argument, lets say it did read everything in, since this seems to be the core of the misunderstanding here. If the system ran low on memory, the memory used by the modules wouldn't get pushed out to swap. Swap is used when the kernel doesn't have any other way to restore the contents of the memory when it's needed again. Since the kernel modules are already on disk, in your file system, it can just reuse the memory without writing anything out and re-read them from the file system when it's needed again. Swap would never be touched.
Comment 16 Flavio Pasqualin 2009-12-17 19:00:26 UTC
Thank you very much Jeff for the exaustive explanation.
Today i learned something new.
I move up the virtual memory limit, and then try again to compile the kernel.
Comment 17 Forgotten User qMyteedNxa 2009-12-20 12:55:00 UTC
i`d also like to thank you jeff for the real good explanation! never read such good one before!