Commit Graph

771 Commits

Author SHA1 Message Date
Lucas De Marchi
e6996c5c30 rmmod: route all messages to syslog if told to 2012-11-05 18:32:05 -02:00
Lucas De Marchi
04c26d28be rmmod: prefer ERR over plain fprintf 2012-11-05 18:31:19 -02:00
Lucas De Marchi
9382dbf7aa modinfo: prefer ERR over plain fprintf 2012-11-05 18:31:19 -02:00
Lucas De Marchi
e2f9478faf insmod: prefer ERR over plain fprintf 2012-11-05 17:59:23 -02:00
Lucas De Marchi
96b50d3623 depmod: add depmod prefix to log messages 2012-11-05 02:08:16 -02:00
Lucas De Marchi
a3f16ff704 depmod: remove inline from _log 2012-11-05 02:08:16 -02:00
Lucas De Marchi
8836ff24b4 TODO: update file with tasks 2012-11-05 02:04:44 -02:00
Lucas De Marchi
61c48db360 depmod: prefer ERR and WRN over plain fprintf 2012-11-05 02:01:06 -02:00
Lucas De Marchi
d9a2e15504 modprobe: use ERR() instead of fprintf(stderr, ...) 2012-11-01 13:03:02 -02:00
Lucas De Marchi
d96ae03bd9 modprobe: prefix log messages to stderr with modprobe 2012-11-01 12:46:12 -02:00
Lucas De Marchi
07df56eb24 modprobe: move log function 2012-11-01 12:46:12 -02:00
Lucas De Marchi
86cc1f2328 modprobe: prefix libkmod messages to stderr with modprobe:
When we are logging to stderr we are previously relying on libkmod
sending it to the default location in case we are not asked to log to
syslog. The problem is that modprobe may be used in scripts that don't
want to log to syslog (since they are not daemons, like scripts to
generate initrd) and then it's difficult to know where the message comes
from.

This patch treats only the messages coming from libkmod.
2012-11-01 12:46:03 -02:00
Lucas De Marchi
1e947e3c87 modprobe: use prio_to_str() helper 2012-10-31 22:00:40 -02:00
Lucas De Marchi
4434d8ba36 modprobe: exit in one place 2012-10-31 21:29:54 -02:00
Lucas De Marchi
e4a7352ad3 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 (caaf438cb6 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.
2012-10-30 04:56:59 -02:00
Lucas De Marchi
447eed8c48 depmod: use our copy of modname instead of calling libkmod
In depmod_module_add() we already called kmod_module_get_name() and
copied the string to our struct. Use it instead of calling again and
again the libkmod function.
2012-10-30 04:11:24 -02:00
Lucas De Marchi
ec587f298c depmod: cache dependency_symbol list in struct mod
The overall goal is to coalesce the accesses to a file that is the
backend of a module. This commit addresses the calls to
kmod_module_get_get_dependency_symbols(). Calling it earlier, while we
are iterating the modules allows us to free the struct kmod of each
module much sooner. We are still not freeing it since there are other
places that must be refactored first.

There's a performance penalty of ~2.5% from previous commit.
2012-10-30 04:05:53 -02:00
Lucas De Marchi
7062eca38b depmod: cache info_list in struct mod
The overall goal is to coalesce the accesses to a file that is the
backend of a module. This commit addresses the calls to
kmod_module_get_info(). Calling it earlier, while we are iterating the
modules allows us to free the struct kmod of each module much sooner. We
are still not freeing it since there are other places that must be
refactored first.

A nice side effect is that this commit reduces in ~33% the calls to
malloc(), giving a speedup of ~6% for cold caches (reproduced on only 1
laptop).
2012-10-30 03:24:25 -02:00
Lucas De Marchi
b51ac407c2 depmod: do not create a hole in struct depmod 2012-10-30 02:33:14 -02:00
Lucas De Marchi
caaf438cb6 build-sys: use AS_IF autoconf macro
Just for consistency with the rest.
2012-10-23 10:45:10 -02:00
Sami Kerola
5c61b1491e build-sys: require xsltproc when manpages are enabled
Before this commit the build system failed at late state with
non-helpful message when xsltproc was not available.

Making all in man
  GEN      depmod.d.5
/bin/sh: --nonet: command not found
make[2]: *** [depmod.d.5] Error 127
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
2012-10-22 16:06:04 -02:00
Lucas De Marchi
1eff942e37 libkmod: cache open file for later access
If we are accessing several times the modules and reading some sections
by sucessive calls to the functions below, we are incurring in a penalty
of having to open, parse the header and close the file. For each
function.

	- kmod_module_get_info()
	- kmod_module_get_versions()
	- kmod_module_get_symbols()
	- kmod_module_get_dependency_symbols()

These functions are particularly important to depmod. It calls all of
them, for each module. Moreover there's a huge bottleneck in the open
operation if we are using compression. Every time we open the module we
need to uncompress the file and after getting the information we need we
discard the result. This is clearly shown by profiling depmod with perf
(record + report), using compressed modules:

 64.07%  depmod  libz.so.1.2.7       [.] 0x00000000000074b8                                            ◆
 18.18%  depmod  libz.so.1.2.7       [.] crc32                                                         ▒
  2.42%  depmod  libz.so.1.2.7       [.] inflate                                                       ▒
  1.17%  depmod  libc-2.16.so        [.] __memcpy_ssse3_back                                           ▒
  0.96%  depmod  [kernel.kallsyms]   [k] copy_user_generic_string                                      ▒
  0.89%  depmod  libc-2.16.so        [.] __strcmp_sse42                                                ▒
  0.82%  depmod  [kernel.kallsyms]   [k] hrtimer_interrupt                                             ▒
  0.77%  depmod  libc-2.16.so        [.] _int_malloc                                                   ▒
  0.44%  depmod  kmod-nolib          [.] kmod_elf_get_strings                                          ▒
  0.41%  depmod  kmod-nolib          [.] kmod_elf_get_dependency_symbols                               ▒
  0.37%  depmod  kmod-nolib          [.] kmod_elf_get_section                                          ▒
  0.36%  depmod  kmod-nolib          [.] kmod_elf_get_symbols
  ...

Average of running depmod 5 times, dropping caches between them, in a
slow spinning disk:

Before:   12.25 +- 0.20
After:     8.20 +- 0.21
m-i-t:     9.62 +- 0.27

So this patch leads to an improvement of ~33% over unpatched version,
ending up with 15% speedup over module-init-tools.
2012-10-18 02:09:55 -03:00
Lucas De Marchi
cc833644b2 rmmod: Deprecate --wait option
Remove --wait from usage() and give a message + sleep(10) if user is in
fact using it.
2012-10-17 18:43:17 -03:00
Leandro Pereira
1faec2c134 libkmod-hash: Plug possible memory leak when free_value is defined
Although the hash table implementation allows passing a callback function
to free a value when it is removed from the hash table, hash_del() wasn't
freeing it if it was provided. Now it does.

As a bonus, it now checks if the callback is set in hash_add() as well.
2012-10-12 12:34:27 -03:00
Lucas De Marchi
66f3228d17 libkmod: Add support for '.' in module parameter on kcmdline
Otherwise we fail to parse arguments in kernel command line like
testmodule.testparam=1.5G

Suggested-by: Selim T. Erdogan <selim@alumni.cs.utexas.edu>
2012-10-09 09:56:50 -03:00
Lucas De Marchi
b0c9fc85a2 testsuite: add depmod test for modules.alias
Check if modules.alias is correctly generated from modules.order if we
have compressed modules.
2012-10-04 01:08:13 -03:00
Lucas De Marchi
3e451bfefb testsuite: allow to check generated files
This gives the test cases the ability to supply files that must be
checked after the test is run, rather than just checking stdout/stderr.

This is intended to be used with tools that generate files, like depmod.
It includes a poor's man implementation of a "check for differences in
files". Not really optimized, but it's simple enough and does what it
proposes to.
2012-10-04 01:04:52 -03:00
Lucas De Marchi
88c247f7f1 depmod: fix parsing of modules.order with compressed modules
We now index the modules by uncompressed-relative-path instead of
relative-path. This is because the file modules.order, coming from
kernel, always comes with uncompressed paths. This fixes the issue of
not sorting the aliases correctly due to paths not matching when using
compressed modules.
2012-10-03 16:29:36 -03:00
Dave Reisner
c5b37dba89 build-sys: Remove --with-rootprefix option
This is a broken option that only leads to misery and incompatabilities
with other systems. Kbuild doesn't come close to supporting directories
other than /lib/modules with several targets simply failing without
hacky fixes. Simply remove the option and all traces of it, as it
doesn't make sense in today's world.
2012-10-02 00:27:31 -03:00
Lucas De Marchi
7812d88c95 build-sys: Append -Werror when testing flags
Clang doesn't treat unknown warnings flags as an error, but rather as a
warning. The result is that the detection for whic CFLAGS are supported
by this compiler will not work, since the compilation will succeed.

With this patch we now successfully detect clang doesn't support
-Wlogical-op, as opposed to previous behavior:

	checking if clang supports flag -Wlogical-op in envvar CFLAGS... no

We use this macro only for LDFLAGS and CFLAGS, so it's safe to stash
-Werror there.
2012-09-14 11:37:29 -03:00
Jan Engelhardt
a7fbae0315 NEWS: language corrections 2012-09-13 21:07:13 -03:00
Dave Reisner
1a3fa1a1a5 modinfo: clarify verbiage for field shortcuts
Cleanup the punctuation and grammar in this blurb, specifically pointing
out what these are shortcuts for.
2012-09-08 14:40:37 -04:00
Dave Reisner
86bbd05319 Makefile: remove redundant flags to $(RM)
$(RM) will always expand to 'rm -f' which means we don't need to ignore
errors or pass this flag again.
2012-09-08 14:40:37 -04:00
Dave Reisner
cf814054dd Define rootfs as dependency of check-am
This should actually fix the problem of ensuring that the rootfs is
created every time that 'make check' is run.
2012-09-08 14:40:37 -04:00
Dave Reisner
84afccb91d Revert "build-sys: disable jobserver for rootfs target"
This is bogus and does not work.

This reverts commit 4e7f0f204b.
2012-09-08 14:09:58 -04:00
Lucas De Marchi
d642341777 testsuite: Fix double definition of 64-bits variant
If _FILE_OFFSET_BITS is defined we should not be wrapping these 64
variants, since they are macros in libc.
2012-09-07 15:12:12 -03:00
Lucas De Marchi
4075860264 kmod 10 2012-09-06 16:26:53 -03:00
Lucas De Marchi
85734b2446 Remove test directory
All tests should be in testsuite. The remaining tests in this directory
are not relevant enough to be ported. git log can be consulted if in
future we decide to put them in testsuite.
2012-08-31 06:59:26 -03:00
Lucas De Marchi
8447b865aa TODO: deprecate use of rmmod -w
As discussed with Rusty Russel, it would be nice to remove the related
code from kernel. Deprecate its use on kmod, so people know they
shouldn't be using it.
2012-08-30 14:10:47 -03:00
Lucas De Marchi
36ddee6562 modprobe: Unconditionally use KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY
This fixes a change in behavior regarding kmod and module-init-tools:
when trying to load a module by alias, we should check if it's
blacklisted, regardless of the command line arguments passed.

This was reported by "Dmitry V. Levin <ldv@altlinux.org>".
2012-08-17 09:42:47 -03:00
Lucas De Marchi
6882017f80 libkmod-module: Add KMOD_PROBE_APPLY_BLACKLIST_ALIAS_ONLY flag
With this flag kmod_module_probe_insert_module() check if module is
blacklisted only if it's also an alias. This is needed in order to allow
blacklisting a module by name and effectively blacklisting all its
aliases as module-init-tools was doing.

Before this patch we could load pcspkr module as follows:

	/etc/modprobe.d/test.conf:
		alias yay pcspkr
		blacklist pcspkr

	$ modprobe yay

Now libkmod has support to blacklist "yay" because "pcspkr" is blacklisted.
2012-08-17 09:42:15 -03:00
Martin Pitt
123e8278ed testsuite preload: Factorize into macros, add more stat and open variants
Instead of replicating the same code several times, define and use macros for
the various types of wrapped functions in the testsuite's path.c LD_PRELOAD
wrapper.

Add various __xstat() variants and open64(), which are being used when enabling
large file support.
2012-08-01 20:44:27 -03:00
Lucas De Marchi
f38e68a29c README: let people know they don't need to subscribe
People are afraid to CC the mailing list because they think they need to
subscribe (and a lot of them are already subscribed to too many lists).
2012-07-31 09:58:21 -03:00
Lucas De Marchi
382de85c94 build-sys: add 'man' entry in summary 2012-07-31 09:51:48 -03:00
Colin Walters
8631552d3d build-sys: Add --disable-manpages option
1) Embedded systems often don't want man pages on the
   target; rather than pointlessly building them, then ignoring
   the result, allow just not building them at all
2) When bootstrapping an operating systems, documentation is the
   source of many cyclical dependencies, and allowing it to
   be explicitly disabled is useful for earlier build passes.
2012-07-31 09:45:59 -03:00
Dave Reisner
2077017f11 man/rmmod: specify each option in separate <term> tag 2012-07-26 09:19:56 -03:00
Dave Reisner
e3366d46bf man/depmod: specify each option in separate <term> tag 2012-07-26 09:19:53 -03:00
Dave Reisner
0e581357b6 man/modprobe: specify each option in separate <term> tag 2012-07-25 19:50:56 -04:00
Dave Reisner
ffeccb511c man/modinfo: specify each option in separate <term> tag
This has the end result of comma delimiting equivalent options in the
manpage, similar to many other manuals.
2012-07-25 19:50:04 -04:00
Dave Reisner
ff9909694b man/modinfo: document longopts for field shortcuts 2012-07-25 19:37:49 -04:00