Kernel modules performance impact?

Really basic question, but does having the kernel modules for various packages installed improve performance? For instance, does adding kmod-fs-squashfs improve file system performance?

In general, kernel modules add functionality, not performance. For example, the kmod-fs-squashfs module adds the ability to handle squashfs filesystems; if your system does not have one if those filesystems, then the kernel module is just going to sit there idle.

1 Like

I see, thank you for the clarification. So a followup question: the base file system is squashfs, why does the system not require that kernel module to boot?

Because squashfs is built statically into the kernel (it needs to be on most targets, in order to mount the rootfs which is residing on a squashfs), the kmod-squashfs*.ipk is just a dummy to satisfy the dependency (at least on targets where the rootfs generally is on squashfs).

1 Like

I see, so the module is not required because it's already in the kernel; but the functionality is required one way or another; via a module or by being statically included. Thanks for clarifying :grin:

So, are there any programs in OpenWrt that can benefit from doing some things in a kernel module, vs user space?

There is no generic answer to this.

Just very roughly speaking, kernel modules are often faster - userspace tends to be more flexible and allows quicker/ more vibrant development. But there are very few instances where a 1:1 mapping exists between functionality alternatively provided in userspace XOR in kernelspace[0].

But I think you're mixing up the difference between kernel- and userspace, with building a module statically into the kernel - or keeping it on the rootfs as dynamically loadable *.ko file. For this question, once loaded, there is no performance difference between both options, they're almost 100% equivalent[1],[2],[3].

--
[0] counter examples would include ntfs.ko vs ntfs-3g (and some other fuse based filesystems), samba vs ksmbd - or more remotely similar, wireguard or IPsec vs. OpenVPN.
[1] there are some modules that must be included statically, because they're needed before the rootfs is available (OpenWrt doesn't use an initramfs, which could avoid some of this necessity); squashfs would be the prime example for this.
[2] locating and loading a kernel module from the rootfs takes slightly longer than having it builtin statically into the kernel, but this exclusively affects the time to boot up, not making use of the functionality it provides to the kernel.
[3] having a kernel module builtin can save a tiny amount of RAM, as the unload procedures (and part of the loading facilities, if you don't need any modules at all, can be omitted/ compiled out; this isn't really relevant - not even on 32 MB RAM devices and comes with other disadvantages (namely that the module is always loaded/ wasting RAM, if you need it or not).

1 Like

Yes, doing thinks in kernel space is much faster than in user space. However, this is not a matter of just installing some kernel modules, you need to rethink your entire application from the ground up.

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.