]> git.ipfire.org Git - thirdparty/kmod.git/commit
depmod: unref kmod_module once we don't need it anymore
authorLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 30 Oct 2012 05:46:12 +0000 (03:46 -0200)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Tue, 30 Oct 2012 06:56:59 +0000 (04:56 -0200)
commite4a7352ad3c16f0b4b658218d9997e3570a70772
tree3995d24cfb777a9f8d1496754c6d39cffef5c5a3
parent447eed8c489258552942afbba8ea042f99c838e6
depmod: unref kmod_module once we don't need it anymore

Once we read all we need from a module, unref it so any resource taken
by it (including the mmap to access the file in libkmod) will be
dropped. This drastically reduces the number of open file descriptors
and also the memory needed, with no performance penalties. Rather,
there's a small speedup of ~2.6%.

Running depmod in a laptop with 2973 modules and comparing the number of
open file descriptors for kmod-10, before and after the last patches to
depmod (caaf438cb681c5b5b5b3c32e5b6bd12e96993dd7 and HEAD) we have:

Before: 2980 simultaneously open fds
After: 7    simultaneously open fds
kmod-10: 7    simultaneously open fds

So now we have the speedup of caching the file in kmod_module without
the drawback of increasing the number of open file descriptors.
tools/depmod.c