[systemd-devel] Improving module loading

Lennart Poettering lennart at poettering.net
Mon Dec 22 07:04:55 PST 2014

On Sat, 20.12.14 10:45, Hoyer, Marko (ADITG/SW2) (mhoyer at de.adit-jv.com) wrote:

> I had such a discussion earlier with some of the systemd guys. My
> intention was to introduce an additional unit for module loading for
> exactly the reason you mentioned. The following (reasonable) outcome
> was:
> - It is dangerous to load kernel modules from PID 1 since module
>   loading can get stuck

> - Since modules are actually loaded with the thread that calls the
>   syscall, systemd would need additional threads

> - Multi Threading is not really aimed in systemd for stability reasons
> The probably safest way to do what you intended is to use an
> additional process to load your modules, which could be easily done
> by using ExecStartPre= in a service file. We are doing it exactly
> this way not with kmod but with a tool that loads modules in
> parallel.

I'd be willing to merge a good patch that beefs up
systemd-modules-load to load the specified modules in parallel, with
one thread for each.

We already have a very limited number of threaded bits in systemd, and
I figure out would be OK to do that for this too.

Please keep the threading minimal though, i.e. one kmod context per
thread, so that we need no synchronization and no locking. One thread
per module, i.e. no worker thread logic with thread reusing. also,
please set a thred name, so that hanging module loading only hang one
specific thread and the backtrace shows which module is at fault.


Lennart Poettering, Red Hat

More information about the systemd-devel mailing list