Re: how to have the kernel do udev's job and autoload the right modules ?

From: Ken Moffat
Date: Tue May 05 2015 - 18:26:53 EST


On Tue, May 05, 2015 at 06:08:01PM +0000, linux cbon wrote:
> On Mon, May 4, 2015 at 11:24 PM, Richard Weinberger <richard@xxxxxx> wrote:
> > You can build in the needed modules or just use udev...
>
> Sorry , but I don't want a monolithic or a huge kernel with many modules inside.
> I want a minimal and modular kernel which only loads the needed modules.
> If I understand, there are 2 choices left :
> 1/ the kernel without modules has a minimal builtin support for my
> network (RTL8111/8168B)
> and my sound (RS780 and SBx00) ... but it doesn't seem the case.

I don't think you have ever given any context about what you are
trying to do. It looks to me as if there are two alternatives:

1. You are building for a particular machine. Either build
everything into the kernel, or use an initscript to load the modules.
For an x86 machine, the only reason to use modules in this situation
(apart from giving them a compile-test in the kernel) would be to
save memory, e.g. by not loading sound in runlevel 1. Using modules
seems to offer minimal benefits in that situation.

2. You are building a distro. For most distros, the need to support
as many users as possible is important. Limiting the network to
juut 2 modules, and the same with audio, does not seem to make any
sense. So, if this is a distro, the target is a tiny number of
machines, and you got lucky in only having two different network
drivers and two sound drivers.

If this is a "one build will run on all my own machines" system, you
could identify the particular machine in an initscript (check `uname
-n`) and modprobe the required modules. Or, you could perhaps build
both these options into a monolithic kernel. You said you don't
want a huge kernel, but you appear to be saying that only two things
differ. Personally, I think that using a *specific* .config for each
of my machines is the way to go. But then, I happily use eudev
(with some of my own initscripts, e.g. to control cpufreq).

>From your comment, I assume you have already removed all the config
options you do not use - if so, you are doing better than I am. My
point here is that, at least on a machine from the last few years,
you probably have enough RAM that wasting a little of it by building
too much into your kernel is not a significant problem.

...
> I don't add modprobes in my sysinit, because I find it's a dirty
> workaround, it's manual,
> it works only for one kind of hardware and not for another etc.

If you think modprobe is a dirty workaround (really?) but you want
to use a semi-generic kernel without a udev variant, you don't seem
to leave yourself a lot of space to do things on a desktop machine.

What is so dirty about modprobe ? Make a list of your hardware, per
machine (by this stage I'm fairly sure you want to use one kernel for
both, or all, your machines) and write a simple shell script to work
out which machine it is running on, and load the correct modules.

Äen
--
Nanny Ogg usually went to bed early. After all, she was an old lady.
Sometimes she went to bed as early as 6 a.m.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/