Lucas De Marchi [Wed, 17 Jul 2013 05:26:47 +0000 (02:26 -0300)]
README: Move items from TODO
Put the differences between kmod and module-init-tools in the README
file so it's more visible.
Tom Gundersen [Sun, 14 Jul 2013 13:13:34 +0000 (15:13 +0200)]
static-nodes: create parent directories of output file
Allows us to drop call to "mkdir -p" from the systemd service file.
Lucas De Marchi [Mon, 15 Jul 2013 05:05:52 +0000 (02:05 -0300)]
util: Add mkdir_parents()
Like mkdir_p, but discards the leaf, creating the parent directories.
Lucas De Marchi [Mon, 15 Jul 2013 04:58:44 +0000 (01:58 -0300)]
util: Add len arg to mkdir_p()
Tom Gundersen [Sun, 14 Jul 2013 13:13:33 +0000 (15:13 +0200)]
static-nodes: don't fail if modules.devname not found
In containers/VM's/initrd one might not have installed any modules and
accompanying modules.devname Don't fail if this is the case, just warn.
When used in systemd this means we don't get a failing unit on booting
containers.
Lucas De Marchi [Mon, 15 Jul 2013 04:41:19 +0000 (01:41 -0300)]
util: Add mkdir_p implementation from testsuite
Lucas De Marchi [Mon, 15 Jul 2013 04:21:27 +0000 (01:21 -0300)]
testsuite: Fix mkdir_p corner cases
- Fix infinite loop when path is relative
- Fix not considering EEXIST as a success
- General refactor to mkdir_p so it never calls mkdir for an existing
dir (given no one creates it from outside)
Lucas De Marchi [Thu, 4 Jul 2013 19:13:11 +0000 (16:13 -0300)]
Use "-internal" suffix instead of "-private"
Lucas De Marchi [Thu, 4 Jul 2013 19:01:55 +0000 (16:01 -0300)]
tools: Do not link dynamically with libkmod
Instead of linking dynamically with libkmod, use libkmod-private.la. We
disallow creating a static libkmod because we can't hide symbols there
and it cause problems with external programs. However this should not
prevent users that are only interested in the tools we provide not being
able to ship only them keeping the library alone.
Other projects also do this to allow our tools to use certain functions
that should not be used outside of the project.
Lucas De Marchi [Wed, 3 Jul 2013 15:42:04 +0000 (12:42 -0300)]
kmod 14
Lucas De Marchi [Wed, 3 Jul 2013 00:03:20 +0000 (21:03 -0300)]
tools: Use test/kmod instead of kmod-nolib
The reason to have a kmod-nolib binary is that we need to call kmod on
test cases (or a symlink to it) and for testing things in tree. Since
we are using libtool if we are dinamically linking to libkmod what we
end up having is a shell script that (depending on the version *)
changes argv[0] to contain an "lt-" prefix. Since this screws with our
compat stuff, we had a kmod-nolib that links statically.
This all workaround works fine iff we are using one of the compat
commands, i.e. we are using the symlinks insmod, rmmod, modprobe, etc.
However if we are actually trying the kmod binary, this doesn't work
because we can't create a kmod symlink since there's already a kmod
binary.
So, completely give up on libtool fixing their mess. Now we create a
tool/test/ directory and the symlinks and kmod is put there.
* http://lists.gnu.org/archive/html/bug-libtool/2011-12/msg00023.html
Lucas De Marchi [Tue, 2 Jul 2013 02:00:20 +0000 (23:00 -0300)]
static-nodes: Better -f option description
Lucas De Marchi [Thu, 6 Jun 2013 14:43:19 +0000 (11:43 -0300)]
build-sys: do not allow --enable static
Do the same as done in systemd by Cristian Rodríguez
<crrodriguez@opensuse.org>. We use private symbols, not namespaced. So
don't pretend we support static linking.
Lucas De Marchi [Tue, 30 Apr 2013 03:21:21 +0000 (00:21 -0300)]
Add travis-ci config file
Experiment with a build bot.
Jan Luebbe [Thu, 2 May 2013 14:47:12 +0000 (16:47 +0200)]
libkmod: Avoid calling syscall() with -1
At least in qemu 1.4.1 for vexpress/arm-cortexa9, this resulted in an
illegal instruction error. Solve that by returning an error when
__NR_finit_module is -1.
Lucas De Marchi [Sat, 11 May 2013 03:50:32 +0000 (00:50 -0300)]
Revert "missing: Don't call syscall() with syscallno == -1"
This reverts commit
38829712e5c411bc250aeae142fc6bf06e794d58. It fixes
the problem, but it breaks the testsuite for those who don't have
__NR_finit_module. The testsuite would have to make the same check.
Instead, I'm reverting this change and I'm going to apply another patch
from Jan Luebbe who got this right from the beginning.
Chengwei Yang [Sat, 4 May 2013 09:07:03 +0000 (17:07 +0800)]
Add document for exported enums
There are several exported enums by libkmod without document, this patch
mainly added documentation for below enums like the way kmod_resources
be documented in.
* kmod_index
* kmod_remove
* kmod_insert
* kmod_probe
* kmod_filter
* kmod_module_initstate
This is not the best way to document these exported enums, however, it's
the simple way due to gtkdoc limits. It doesn't support export plain
enum like below: see https://bugzilla.gnome.org/show_bug.cgi?id=657444
---------8<-------head.h--------------8<-----------
...
enum foo {
...
};
...
---------8<-------end of head.h-------8<-----------
---------8<-------source.c------------8<-----------
...
/**
* document for foo here
*/
...
typedef enum foo foo;
...
---------8<-------end of source.c-----8<----------
Chengwei Yang [Sat, 4 May 2013 09:07:02 +0000 (17:07 +0800)]
Several minor fixes for documentation
Johannes Berg [Thu, 2 May 2013 13:23:28 +0000 (15:23 +0200)]
modprobe: don't check refcount with remove command
The modprobe.d (5) documentation for the "install" command
states that you could specify
install fred /sbin/modprobe barney; /sbin/modprobe --ignore-install fred
This makes some sense, but then the loading of "barney" is
hidden from the user who did only "modprobe fred". Thus,
it seems it should be possible to be able to unload the
"fred" module with "modprobe -r fred" by configuring the
"barney" module to also be removed:
remove fred /sbin/rmmod barney fred
(or similar.)
Make this possible by not checking the refcount when an
unload command was configured.
Reported-by: David Spinadel <david.spinadel@intel.com>
Lucas De Marchi [Thu, 2 May 2013 16:22:57 +0000 (13:22 -0300)]
missing: Don't call syscall() with syscallno == -1
Reported-by: Jean-Francis Roy <jeanfrancis@funtoo.org>
Reported-by: Jan Luebbe <jlu@pengutronix.de>
Lucas De Marchi [Tue, 30 Apr 2013 15:34:55 +0000 (12:34 -0300)]
Fix coding style
Either with space or without, not a mix of both.
Lucas De Marchi [Tue, 30 Apr 2013 15:34:23 +0000 (12:34 -0300)]
TODO: Add some entries
Lucas De Marchi [Wed, 24 Apr 2013 00:21:00 +0000 (21:21 -0300)]
libkmod-index: Return early if readroot failed
Lucas De Marchi [Tue, 23 Apr 2013 23:47:28 +0000 (20:47 -0300)]
libkmod-module: Don't pass NULL ctx to kmod_log
Lucas De Marchi [Tue, 23 Apr 2013 23:33:13 +0000 (20:33 -0300)]
libkmod-module: Don't pass NULL pointer to memcpy
When passing n=0, don't pass a NULL pointer, but instead pass anything
else (like the pointer to the start of the string).
Lucas De Marchi [Sun, 21 Apr 2013 19:33:54 +0000 (16:33 -0300)]
build-sys: Add AM_V_XSLT to rule creating man pages
Lucas De Marchi [Sun, 21 Apr 2013 19:16:18 +0000 (16:16 -0300)]
Add format attribute and fix issues
Add __attribute__((format)) to log_filep() and _show() functions, fixing
the bugs they found in the source code.
For functions that receive va_list instead of being variadic functions
we put 0 in the last argument, so at least the string is checked and we
get warnings of -Wformat-nonliteral type. So, it's better than adding a
pragma here to shut up the warning.
Lucas De Marchi [Fri, 19 Apr 2013 22:08:43 +0000 (19:08 -0300)]
static-nodes: Fix indentation
kmod uses tab instead of spaces and tries to honour 80chr limit, when
that doesn't worsen the readability.
Tom Gundersen [Fri, 19 Apr 2013 21:53:35 +0000 (23:53 +0200)]
static-nodes: tmpfiles - also create parents directories of device nodes
Before:
c /dev/cpu/microcode 0600 - - - 10:184
c /dev/fuse 0600 - - - 10:229
c /dev/btrfs-control 0600 - - - 10:234
c /dev/loop-control 0600 - - - 10:237
c /dev/snd/timer 0600 - - - 116:33
After:
d /dev/cpu 0755 - - -
c /dev/cpu/microcode 0600 - - - 10:184
c /dev/fuse 0600 - - - 10:229
c /dev/btrfs-control 0600 - - - 10:234
c /dev/loop-control 0600 - - - 10:237
d /dev/snd 0755 - - -
c /dev/snd/timer 0600 - - - 116:33
Lucas De Marchi [Wed, 17 Apr 2013 03:54:17 +0000 (00:54 -0300)]
kmod: It's an error not to have modules.devname
This file is created by depmod even if there's no node. In this case it
will be empty.
Previously 'kmod static-nodes' was segfaulting due to passing in==NULL
to fgets.
Also show the error message with %m.
Tom Gundersen [Tue, 16 Apr 2013 20:39:55 +0000 (22:39 +0200)]
tools: add static-nodes tool
This tool reads modules.devname from the current kernel directory and outputs
the information. By default in a human-readable format, and optionally in
machine-readable formats.
For now only the tmpfiles.d(5) format is supported, but more could easily be
added in the future if there is a need.
This means nothing but kmod needs to reads the private files under
/lib/modules/. In particular systemd-udevd can stop reading modules.devname.
Tools that used to read /lib/modules/`uname -r`/modules.devname directly, can
now move to reading 'kmod static-nodes devname'.
Lucas De Marchi [Mon, 15 Apr 2013 17:14:07 +0000 (14:14 -0300)]
Use static assertions for sizeof checks
Lucas De Marchi [Mon, 15 Apr 2013 17:09:05 +0000 (14:09 -0300)]
Use _Static_assert
Both GCC and clang already supports C11's _Static_assert, so use it
instead of defining our own macro.
Lucas De Marchi [Fri, 12 Apr 2013 04:24:30 +0000 (01:24 -0300)]
testsuite: errno is a positive number
Lucas De Marchi [Tue, 9 Apr 2013 23:20:38 +0000 (20:20 -0300)]
TODO: update and reorder
Lucas De Marchi [Tue, 9 Apr 2013 22:35:32 +0000 (19:35 -0300)]
kmod 13
Lucas De Marchi [Tue, 9 Apr 2013 14:59:33 +0000 (11:59 -0300)]
build-sys: Always enable parallel tests
Automake < 1.13 doesn't enable parallel tests by default, so add it to our
automake options.
Lucas De Marchi [Tue, 9 Apr 2013 14:54:05 +0000 (11:54 -0300)]
testsuite: Fix checking __sysno
Use an if instead of a case statemente. If __NR_finit_module is not
defined in system headers we define it to -1, causing a "duplicate case
value" error. Yet, we don't want to actually call our finit_module()
function if -1 is passed.
This also fix errno being set with negative value.
Lucas De Marchi [Tue, 9 Apr 2013 08:21:42 +0000 (05:21 -0300)]
testsuite: Wrap syscall() to get calls to finit_module()
When we don't have finit_module() in libc (most likely because as of
today glibc didn't add it yet), we end up using
syscall(__NR_finit_module, ...). In this case we would not wrap the
function in the testsuite and thus having some tests failing:
TESTSUITE: ERR: could not insert module: Operation not permitted
This implementation relies on the fact that this is the only caller of
syscall(2), because we can't call libc's syscall(). There's an abort()
in place to be future safe: as soon as we need more calls to syscall(),
we can detect (and decide what to do).
Now we have all tests passing in the testsuite again.
Lucas De Marchi [Tue, 9 Apr 2013 07:16:57 +0000 (04:16 -0300)]
libkmod: Move finit_module() definition to missing.h
Check for finit_module() and don't use our own static inline function if
there's such function in libc (or another lib).
In testsuite we need to unconditionally define HAVE_FINIT_MODULE because
we want to override this function, and never use the static inline one
in missing.h
Lucas De Marchi [Tue, 9 Apr 2013 07:00:20 +0000 (04:00 -0300)]
libkmod: Add missing definitions
Depending on kernel header and simply not passing the flags in
finit_module() if this header is not found is not good.
Add a missing.h header in which stuff like this should be added.
Cristian Rodríguez [Mon, 11 Feb 2013 18:07:52 +0000 (15:07 -0300)]
libkmod: Use secure_getenv if available
"The secure_getenv() function is intended for use in general-purpose
libraries to avoid vulnerabilities that could occur if set-user-ID or
set-group-ID programs accidentally trusted the environment."
Lucas De Marchi [Thu, 21 Mar 2013 05:33:25 +0000 (02:33 -0300)]
modprobe: Fix assertion on --show-depends with bogus config file
Putting something like "alias psmouse
deadbeef" is a hackish way to
blacklist a module. While I don't encourage doing so, let's not explode
if we fiund such config files.
A small difference from the behavior of module-init-tools: we exit with
0 instead of 1.
Lucas De Marchi [Thu, 21 Mar 2013 05:24:07 +0000 (02:24 -0300)]
testsuite: Add test to check if modprobe explodes on bogus config
Put this one /etc/modprobe.d/bougs.conf:
alias psmouse deaddood
`modprobe --show-depends --quiet psmouse` explodes in an assertion
(unless you have a module named deaddood). Some people and initrd's use
"alias psmouse off" to disable a module instead of blacklisting it or
adding a install rule.
Add a test with expected_fail == true before fixing this.
Lucas De Marchi [Thu, 21 Mar 2013 05:22:15 +0000 (02:22 -0300)]
testsuite: Exit with success on signal if test has expected_fail=true
Lucas De Marchi [Tue, 19 Mar 2013 20:44:59 +0000 (17:44 -0300)]
libkmod-util: Add missing include file
Fix compilation issue with musl-libc:
CC libkmod/libkmod-list.lo
In file included from libkmod/libkmod-private.h:183:0,
from libkmod/libkmod-list.c:24:
libkmod/libkmod-util.h:33:45: warning: 'struct stat' declared inside parameter list [enabled by default]
libkmod/libkmod-util.h:33:45: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
Josh Boyer [Fri, 15 Mar 2013 17:43:40 +0000 (13:43 -0400)]
rmmod: Teach rmmod about builtin modules
Currently modprobe -r will fail if a module is built in and report that it
is built in. rmmod calls the same function to determine state but doesn't
handle the KMOD_MODULE_BUILTIN return code. This leads to confusing errors
like this:
libkmod: kmod_module_get_holders: could not open '/sys/module/loop/holders': No such file or directory
Error: Module loop is in use
Fix this so that it actually reports the correct problem to the user.
Kees Cook [Mon, 18 Feb 2013 20:02:34 +0000 (12:02 -0800)]
libkmod: fix address argument to mmap calls
The first argument to mmap should be "NULL" instead of "0".
Kees Cook [Mon, 18 Feb 2013 20:02:33 +0000 (12:02 -0800)]
testsuite: handle finit_module
This adds the finit_module logic to the testsuite.
Kees Cook [Mon, 18 Feb 2013 20:02:32 +0000 (12:02 -0800)]
libkmod: add finit_module logic
When a module is being loaded directly from disk (no compression, etc),
pass the file descriptor to the new finit_module() syscall. If the
finit_module syscall is exported by the kernel syscall headers, use it.
Additionally, if the kernel's module.h file is available, map kmod flags
to finit_module flags.
Michal Marek [Wed, 16 Jan 2013 20:04:00 +0000 (21:04 +0100)]
testsuite: Add modinfo test for module signatures
Michal Marek [Wed, 16 Jan 2013 08:52:01 +0000 (09:52 +0100)]
libkmod: Return module signature information in kmod_module_get_info()
If the module is built with CONFIG_MODULE_SIG, add the the signer's
name, hexadecimal key id and hash algorithm to the list returned in
kmod_module_get_info(). The modinfo output then looks like this:
filename: /home/mmarek/kmod/testsuite/rootfs-pristine/test-modinfo/ext4-x86_64-sha256.ko
license: GPL
description: Fourth Extended Filesystem
author: Remy Card, Stephen Tweedie, Andrew Morton, Andreas Dilger, Theodore Ts'o and others
alias: ext3
alias: ext2
depends: mbcache,jbd2
intree: Y
vermagic: 3.7.0 SMP mod_unload
signer: Magrathea: Glacier signing key
sig_key: E3:C8:FC:A7:3F:B3:1D:DE:84:81:EF:38:E3:4C:DE:4B:0C:FD:1B:F9
sig_hashalgo: sha256
The signature algorithm (RSA) and key identifier type (X509) are not
displayed, because they are constant information for every signed
module. But it would be trivial to add this. Note: No attempt is made at
verifying the signature, I don't think that modinfo is the right tool
for this.
Michal Marek [Wed, 16 Jan 2013 16:51:57 +0000 (17:51 +0100)]
libkmod-module: Do not free the list in kmod_module_info_append
In error case, just return NULL and let the caller free the list.
Lucas De Marchi [Wed, 16 Jan 2013 13:27:21 +0000 (11:27 -0200)]
Update copyright notices
Michal Marek [Wed, 16 Jan 2013 09:18:17 +0000 (10:18 +0100)]
libkmod-module: Add helper for building the module info list
Lucas De Marchi [Tue, 15 Jan 2013 20:03:55 +0000 (18:03 -0200)]
gitignore: ignore files generated by Automake's testsuite
These files are generated by Automake 1.13 when running the testsuite.
Lucas De Marchi [Tue, 8 Jan 2013 01:08:46 +0000 (23:08 -0200)]
man: fix lib dir in which we look for config
Thanks to William Hubbs <w.d.hubbs@gmail.com> for spotting the bug.
Andrey Mazo [Wed, 12 Dec 2012 12:39:18 +0000 (16:39 +0400)]
depmod: fix builtin symbols resolution when the prefix symbol is set
When the prefix symbol is set, take it into account while adding symbols
from System.map file by skipping it before "__ksymtab_" comparison.
Also, prevent inserted fake symbols (like "__this_module") from being
wrongly truncated from beginning.
Andrey Mazo [Wed, 12 Dec 2012 12:36:58 +0000 (16:36 +0400)]
depmod: --symbol-prefix actually requires an argument
-P requires and uses an argument but its long counterpart --symbol-prefix does not:
depmod: option '--symbol-prefix' doesn't allow an argument
Lucas De Marchi [Wed, 5 Dec 2012 03:39:17 +0000 (01:39 -0200)]
kmod 12
Lucas De Marchi [Wed, 28 Nov 2012 16:26:23 +0000 (14:26 -0200)]
depmod: fix checking file extension
In depfile_up_to_date_dir() we need to check if name has a kmod
extension. "path" variable there will be the directory name, which
doesn't contain an extension.
Without this, "depmod -A" returns that the modules.dep is up to date,
even if it isn't.
In depmod_modules_search_file() it's pointless to compare the basename,
so pass only the name to be checked.
Lucas De Marchi [Wed, 28 Nov 2012 16:25:50 +0000 (14:25 -0200)]
Use bool instead of int
Also change the last field initializer in array to be empty.
Aleksey Makarov [Wed, 28 Nov 2012 03:44:00 +0000 (10:44 +0700)]
fix is_module_filename()
modinfo fails if there is a ".ko" substring in the path to the module
Lucas De Marchi [Wed, 21 Nov 2012 22:17:25 +0000 (20:17 -0200)]
libkmod-module: mangle the section header, not the section
When we are told to remove the "__versions" section we were mangling
that section instead of tweaking the SHF_ALLOC flag in its header.
Lucas De Marchi [Wed, 21 Nov 2012 20:34:50 +0000 (18:34 -0200)]
libkmod-module: Remove key+value vermagic from .modinfo section
When told to force load a module, we were removing only the value of
vermagic instead of the complete entry.
Philippe De Swert (philippe.deswert@jollamobile.com) sent a patch that
was additionally mangling also the last two chars of the key
("vermagic="). Instead of creating an invalid entry in .modinfo section
like this, this patch removes the complete entry, key + value, by
zeroing the entire string.
Much thanks to Philippe who found the issue and pointed to the fix.
Lucas De Marchi [Fri, 16 Nov 2012 14:05:42 +0000 (12:05 -0200)]
depmod: fix asserting mod->kmod == NULL
If we are replacing a lower priority module (due to its location), we
already created a kmod_module, but didn't open the file for reading its
symbols. This means mod->kmod won't be NULL, and this is just ok. Since
all the functions freeing stuff below the previous assert already takes
NULL into consideration, it's safe to just unref mod->kmod and let the
right thing happens.
Lucas De Marchi [Fri, 16 Nov 2012 13:35:30 +0000 (11:35 -0200)]
depmod: fix hash lookup by relpath instead of uncrelpath
We index modules in depmod by it's uncompressed relative path, not
relative path. We didn't notice this bug before since this function is
only triggered if we release a module to be replaced by one of higher
priority.
Also fix a leftover log message referring to relpath instead of
uncrelpath.
Lucas De Marchi [Thu, 8 Nov 2012 04:30:21 +0000 (02:30 -0200)]
kmod 11
Lucas De Marchi [Thu, 8 Nov 2012 04:01:59 +0000 (02:01 -0200)]
TODO: remove completed action
Lucas De Marchi [Tue, 6 Nov 2012 21:20:09 +0000 (19:20 -0200)]
tools: use program_invocation_short_name provided by libc
Thanks to Dave Reisner for pointing this out.
Lucas De Marchi [Tue, 6 Nov 2012 21:06:11 +0000 (19:06 -0200)]
tools: staticize functions that are now only used in log.c
Lucas De Marchi [Tue, 6 Nov 2012 21:01:59 +0000 (19:01 -0200)]
tools: share function for logging
Lucas De Marchi [Tue, 6 Nov 2012 20:26:34 +0000 (18:26 -0200)]
tools: share setting up libkmod log
This also fixes a bug in "e6996c5 rmmod: route all messages to syslog if
told to" in which "+ verbose" was removed. Instead of letting verbose
add to kmod_get_log_priority(), let it be similar to the other programs
instead.
Lucas De Marchi [Tue, 6 Nov 2012 20:04:09 +0000 (18:04 -0200)]
tools: use a single function for logging libkmod output
Lucas De Marchi [Tue, 6 Nov 2012 19:32:41 +0000 (17:32 -0200)]
tools: make usage() messages go to stdout rather than stderr
When user supplied --help/-h, program should output to stdout the usage,
not to stderr. It's the expected behavior, what the user asked for,
not something to log or an error.
Lucas De Marchi [Tue, 6 Nov 2012 19:08:43 +0000 (17:08 -0200)]
tools: share function to convert prio to string
No change is expected in the final binary since right now only an inline
function is shared. Later we expect to share more code.
Lucas De Marchi [Tue, 6 Nov 2012 18:54:17 +0000 (16:54 -0200)]
tools: share getting program name from argv for all tools
Lucas De Marchi [Mon, 5 Nov 2012 20:32:05 +0000 (18:32 -0200)]
rmmod: route all messages to syslog if told to
Lucas De Marchi [Mon, 5 Nov 2012 19:51:32 +0000 (17:51 -0200)]
rmmod: prefer ERR over plain fprintf
Lucas De Marchi [Mon, 5 Nov 2012 19:58:57 +0000 (17:58 -0200)]
modinfo: prefer ERR over plain fprintf
Lucas De Marchi [Mon, 5 Nov 2012 17:08:54 +0000 (15:08 -0200)]
insmod: prefer ERR over plain fprintf
Lucas De Marchi [Mon, 5 Nov 2012 04:07:09 +0000 (02:07 -0200)]
depmod: add depmod prefix to log messages
Lucas De Marchi [Mon, 5 Nov 2012 04:06:38 +0000 (02:06 -0200)]
depmod: remove inline from _log
Lucas De Marchi [Mon, 5 Nov 2012 04:04:44 +0000 (02:04 -0200)]
TODO: update file with tasks
Lucas De Marchi [Mon, 5 Nov 2012 04:01:06 +0000 (02:01 -0200)]
depmod: prefer ERR and WRN over plain fprintf
Lucas De Marchi [Thu, 1 Nov 2012 15:02:10 +0000 (13:02 -0200)]
modprobe: use ERR() instead of fprintf(stderr, ...)
Lucas De Marchi [Thu, 1 Nov 2012 14:45:23 +0000 (12:45 -0200)]
modprobe: prefix log messages to stderr with modprobe
Lucas De Marchi [Thu, 1 Nov 2012 14:39:18 +0000 (12:39 -0200)]
modprobe: move log function
Lucas De Marchi [Thu, 1 Nov 2012 14:24:58 +0000 (12:24 -0200)]
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.
Lucas De Marchi [Thu, 1 Nov 2012 00:00:40 +0000 (22:00 -0200)]
modprobe: use prio_to_str() helper
Lucas De Marchi [Wed, 31 Oct 2012 23:29:54 +0000 (21:29 -0200)]
modprobe: exit in one place
Lucas De Marchi [Tue, 30 Oct 2012 05:46:12 +0000 (03:46 -0200)]
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.
Lucas De Marchi [Tue, 30 Oct 2012 06:08:54 +0000 (04:08 -0200)]
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.
Lucas De Marchi [Tue, 30 Oct 2012 05:16:10 +0000 (03:16 -0200)]
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.
Lucas De Marchi [Tue, 30 Oct 2012 05:16:10 +0000 (03:16 -0200)]
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).
Lucas De Marchi [Tue, 30 Oct 2012 04:32:48 +0000 (02:32 -0200)]
depmod: do not create a hole in struct depmod
Lucas De Marchi [Tue, 23 Oct 2012 12:45:10 +0000 (10:45 -0200)]
build-sys: use AS_IF autoconf macro
Just for consistency with the rest.
Sami Kerola [Mon, 22 Oct 2012 17:40:02 +0000 (18:40 +0100)]
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
Lucas De Marchi [Thu, 18 Oct 2012 04:36:33 +0000 (01:36 -0300)]
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.
Lucas De Marchi [Wed, 17 Oct 2012 21:32:56 +0000 (18:32 -0300)]
rmmod: Deprecate --wait option
Remove --wait from usage() and give a message + sleep(10) if user is in
fact using it.