Loading a kernel module at boot time is blocking?

Hello, I followed this guide to load my module at boot time and it worked :slight_smile:

In my module I an using the wait_for_random_bytes() function from linux/random.h, so my module can have some delay in loading.
The modules are loaded sequentially? This module of mine can delay the loading of other modules?

Look into https://github.com/torvalds/linux/blob/master/include/linux/delay.h

  1. ndelay(ns) - wait for given number of nanoseconds,
  2. udelay(us) - wait for given number of microseconds,
  3. mdelay(ms) - wait for given number of milliseconds.

Thank you for your answer!
Maybe I donโ€™t get it, but my purpose is not to use a function to delay some modules.
My question is if, by loading my module at boot time, and calling wait_for_random_bytes(), am I actually delaying the loading of other modules?

I donโ€™t think so (as I am not the Linux kernel dev). But, one can control order of loading from config file using /etc/modprobe.d/ directory. For example, create a new config file called /etc/modprobe.d/demo.conf :

softdep c pre: a b post: d e

So when system boots or root usr run sudo modprobe c command, first system loads a and b module, next it would load c module, and finally d and e modules. It is like as follows but using config file

modprobe a b c d e

This is only way to control sequentially loading modules as per your need. Another option might work as follows:

## many system services uses numbers 0,1,2,3 and so on to load config
## options sequentially. So load foo first and next load bar module config

See the following page

man 5 modprobe.d

Linux sysadmin blog - Linux/Unix Howtos and Tutorials - Linux bash shell scripting wiki