Bug 26856

Summary: dkms rebuilds drivers for kernels unnecessarily
Product: Mageia Reporter: Frank Griffin <ftg>
Component: RPM PackagesAssignee: Kernel and Drivers maintainers <kernel>
Status: NEW --- QA Contact:
Severity: normal    
Priority: Normal CC: fri, ghibomgx, mageia, ouaurelien, pterjan, zen25000
Version: Cauldron   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Source RPM: dkms CVE:
Status comment:

Description Frank Griffin 2020-06-24 18:18:44 CEST
When a kernel is installed, any dkms drivers are rebuilt as part of the install.  However, when the system is rebooted, the drivers are always rebuilt again during boot.  

Moreover, if you have several historical kernels, whenever you boot one *its* dkms drivers are rebuilt even though they have previously been built.

It appears that whatever criterion dkms uses to determine whether drivers need to be rebuilt is faulty.  This is annoying, because the systemd target for dkms can delay the boot by several minutes.
Comment 1 Barry Jackson 2020-06-24 19:04:18 CEST
I agree it's over 2 minutes at every boot and since new kernels still do not remove older ones the time just gets longer and longer.

I almost started a similar report the other day - but forgot about it while waiting for the boot to finish! ;)

CC: (none) => zen25000

Comment 2 Lewis Smith 2020-06-25 17:30:49 CEST
Thank you both for this report.

Assigning to kernel/drivers/tmb.

Assignee: bugsquad => kernel

Comment 3 Pascal Terjan 2020-06-25 17:55:14 CEST
My guess would be that those drivers fail to build and it keeps trying

verbose=yes /usr/sbin/dkms_autoinstaller start


Trying a random driver (dkms-ena) this is what is happening:

    http://ftp.free.fr/mirrors/mageia.org/distrib/cauldron/x86_64/media/core/release/dkms-ena-1.5.3-3.mga8.noarch.rpm
installing dkms-ena-1.5.3-3.mga8.noarch.rpm from /var/cache/urpmi/rpms                                                                                                                                            
Preparing...                     ################################################################################################################################################################################
      1/1: dkms-ena              ################################################################################################################################################################################

Creating symlink /var/lib/dkms/ena/1.5.3-3.mga8/source ->
                 /usr/src/ena-1.5.3-3.mga8

DKMS: add Completed.

Preparing kernel 5.7.1-server-1.mga8 for module build:
(This is not compiling a kernel, just preparing kernel symbols)
Storing current .config to be restored when complete
Running Generic preparation routine
make mrproper....(bad exit status: 2)
using /proc/config.gz
make oldconfig....                      
make prepare....(bad exit status: 2)

Building module:
cleaning build area....
make -j16 KERNELRELEASE=5.7.1-server-1.mga8 -C ena/ BUILD_KERNEL=5.7.1-server-1.mga8....(bad exit status: 2)

Error! Bad return status for module build on kernel: 5.7.1-server-1.mga8 (x86_64)
Consult the make.log in the build directory
/var/lib/dkms/ena/1.5.3-3.mga8/build/ for more information.

# verbose=yes /usr/sbin/dkms_autoinstaller start

ena (1.5.3-3.mga8): Installing module.
dkms build -m ena -v 1.5.3-3.mga8 -k 5.7.1-server-1.mga8 -a x86_64 -q --no-clean-kernel 
(bad exit status: 10)
  Build failed.  Installation skipped.

Can you post the output of dkms status?

CC: (none) => pterjan

Comment 4 Frank Griffin 2020-06-25 18:26:52 CEST
[root@ftglap tgz]# dkms status
virtualbox, 6.1.8-2.mga8, 5.5.3-desktop-1.mga8, x86_64: built 
virtualbox, 6.1.8-2.mga8, 5.6.15-desktop-1.mga8, x86_64: installed 
virtualbox, 6.1.8-2.mga8, 5.5.15-desktop-3.mga8, x86_64: built 
virtualbox, 6.1.8-2.mga8, 5.7.2-desktop-1.mga8, x86_64: installed 
virtualbox, 6.1.8-2.mga8, 5.5.4-desktop-1.mga8, x86_64: built 
virtualbox, 6.1.8-2.mga8, 5.6.14-desktop-2.mga8, x86_64: installed 
virtualbox, 6.1.8-2.mga8, 5.7.1-desktop-1.mga8, x86_64: installed 
virtualbox, 6.1.8-2.mga8, 5.6.5-desktop-1.mga8, x86_64: installed 
virtualbox, 6.1.8-2.mga8, 5.6.8-desktop-1.mga8, x86_64: built 
virtualbox, 6.1.8-2.mga8, 5.6.14-desktop-1.mga8, x86_64: installed 
virtualbox, 6.1.8-2.mga8, 5.5.5-desktop-3.mga8, x86_64: built 
nvidia-current, 430.64-8.mga8.nonfree, 5.6.15-desktop-1.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.7.2-desktop-1.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.6.11-desktop-1.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.7.3-desktop-2.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.6.6-desktop-1.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.6.3-desktop-2.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.5.14-desktop-1.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.6.4-desktop-1.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.6.7-desktop-3.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.6.14-desktop-2.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.7.1-desktop-1.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.6.5-desktop-1.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.6.10-desktop-2.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.6.8-desktop-1.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.6.14-desktop-1.mga8, x86_64: installed 
nvidia-current, 430.64-8.mga8.nonfree, 5.7.4-desktop-1.mga8, x86_64: installed 
virtualbox, 6.1.2-2.mga8, 5.5.3-desktop-1.mga8, x86_64: installed-binary from 5.5.3-desktop-1.mga8
virtualbox, 6.1.4-1.mga8, 5.5.8-desktop-1.mga8, x86_64: installed-binary from 5.5.8-desktop-1.mga8
virtualbox, 6.1.8-2.mga8, 5.6.15-desktop-1.mga8, x86_64: installed-binary from 5.6.15-desktop-1.mga8
virtualbox, 6.1.4-1.mga8, 5.5.7-desktop-1.mga8, x86_64: installed-binary from 5.5.7-desktop-1.mga8
virtualbox, 6.1.4-1.mga8, 5.5.15-desktop-3.mga8, x86_64: installed-binary from 5.5.15-desktop-3.mga8
virtualbox, 6.1.8-2.mga8, 5.7.2-desktop-1.mga8, x86_64: installed-binary from 5.7.2-desktop-1.mga8
virtualbox, 6.1.6-2.mga8, 5.6.12-desktop-1.mga8, x86_64: installed-binary from 5.6.12-desktop-1.mga8
virtualbox, 6.1.6-1.mga8, 5.6.11-desktop-1.mga8, x86_64: installed-binary from 5.6.11-desktop-1.mga8
virtualbox, 6.1.8-2.mga8, 5.7.3-desktop-2.mga8, x86_64: installed-binary from 5.7.3-desktop-2.mga8
virtualbox, 6.1.6-1.mga8, 5.6.6-desktop-1.mga8, x86_64: installed-binary from 5.6.6-desktop-1.mga8
virtualbox, 6.1.4-2.mga8, 5.6.3-desktop-2.mga8, x86_64: installed-binary from 5.6.3-desktop-2.mga8
virtualbox, 6.1.4-1.mga8, 5.5.14-desktop-1.mga8, x86_64: installed-binary from 5.5.14-desktop-1.mga8
virtualbox, 6.1.6-1.mga8, 5.6.4-desktop-1.mga8, x86_64: installed-binary from 5.6.4-desktop-1.mga8
virtualbox, 6.1.6-1.mga8, 5.6.7-desktop-3.mga8, x86_64: installed-binary from 5.6.7-desktop-3.mga8
virtualbox, 6.1.2-2.mga8, 5.5.4-desktop-1.mga8, x86_64: installed-binary from 5.5.4-desktop-1.mga8
virtualbox, 6.1.4-1.mga8, 5.5.9-desktop-1.mga8, x86_64: installed-binary from 5.5.9-desktop-1.mga8
virtualbox, 6.1.4-1.mga8, 5.5.8-desktop-2.mga8, x86_64: installed-binary from 5.5.8-desktop-2.mga8
virtualbox, 6.1.2-2.mga8, 5.5.5-desktop-1.mga8, x86_64: installed-binary from 5.5.5-desktop-1.mga8
virtualbox, 6.1.8-2.mga8, 5.6.14-desktop-2.mga8, x86_64: installed-binary from 5.6.14-desktop-2.mga8
virtualbox, 6.1.2-3.mga8, 5.5.5-desktop-2.mga8, x86_64: installed-binary from 5.5.5-desktop-2.mga8
virtualbox, 6.1.8-2.mga8, 5.7.1-desktop-1.mga8, x86_64: installed-binary from 5.7.1-desktop-1.mga8
virtualbox, 6.1.6-1.mga8, 5.6.5-desktop-1.mga8, x86_64: installed-binary from 5.6.5-desktop-1.mga8
virtualbox, 6.1.4-1.mga8, 5.5.13-desktop-1.mga8, x86_64: installed-binary from 5.5.13-desktop-1.mga8
virtualbox, 6.1.6-1.mga8, 5.6.10-desktop-2.mga8, x86_64: installed-binary from 5.6.10-desktop-2.mga8
virtualbox, 6.1.8-2.mga8, 5.7.5-desktop-1.mga8, x86_64: installed-binary from 5.7.5-desktop-1.mga8
virtualbox, 6.1.6-1.mga8, 5.6.8-desktop-1.mga8, x86_64: installed-binary from 5.6.8-desktop-1.mga8
virtualbox, 6.1.4-1.mga8, 5.5.10-desktop-1.mga8, x86_64: installed-binary from 5.5.10-desktop-1.mga8
virtualbox, 6.1.4-1.mga8, 5.5.6-desktop-2.mga8, x86_64: installed-binary from 5.5.6-desktop-2.mga8
virtualbox, 6.1.8-2.mga8, 5.6.14-desktop-1.mga8, x86_64: installed-binary from 5.6.14-desktop-1.mga8
virtualbox, 6.1.4-1.mga8, 5.5.5-desktop-3.mga8, x86_64: installed-binary from 5.5.5-desktop-3.mga8
virtualbox, 6.1.4-1.mga8, 5.5.15-desktop-1.mga8, x86_64: installed-binary from 5.5.15-desktop-1.mga8
virtualbox, 6.1.2-2.mga8, 5.4.17-desktop-1.mga8, x86_64: installed-binary from 5.4.17-desktop-1.mga8
virtualbox, 6.1.4-1.mga8, 5.5.11-desktop-1.mga8, x86_64: installed-binary from 5.5.11-desktop-1.mga8
virtualbox, 6.1.8-2.mga8, 5.7.4-desktop-1.mga8, x86_64: installed-binary from 5.7.4-desktop-1.mga8
virtualbox, 6.1.4-1.mga8, 5.5.6-desktop-1.mga8, x86_64: installed-binary from 5.5.6-desktop-1.mga8
[root@ftglap tgz]#
Comment 5 Pascal Terjan 2020-06-25 18:51:29 CEST
They are almost all installed or installed-binary so should not get rebuilt, however there are a few ones built but not installed which is strange:

virtualbox, 6.1.8-2.mga8, 5.5.3-desktop-1.mga8, x86_64: built 
virtualbox, 6.1.8-2.mga8, 5.5.15-desktop-3.mga8, x86_64: built 
virtualbox, 6.1.8-2.mga8, 5.5.4-desktop-1.mga8, x86_64: built 
virtualbox, 6.1.8-2.mga8, 5.6.8-desktop-1.mga8, x86_64: built 
virtualbox, 6.1.8-2.mga8, 5.5.5-desktop-3.mga8, x86_64: built 

Can you run "verbose=yes /usr/sbin/dkms_autoinstaller start" too to see which ones it tries to build?
Comment 6 Frank Griffin 2020-06-25 19:02:42 CEST
[root@ftglap tgz]# verbose=yes /usr/sbin/dkms_autoinstaller start

nvidia-current (430.64-8.mga8.nonfree): Already installed on this kernel.
virtualbox (6.1.8-2.mga8): Already installed on this kernel.
[root@ftglap tgz]# 


However, the nvidia line came out immediately, and it took a good 30 seconds at least for the virtualbox line to show up.  Command completion occurred immediately after that.
Comment 7 Pascal Terjan 2020-06-25 19:14:37 CEST
Interesting, so the problem is not that it is building but it is doing "something"...

Actually something more interesting from your status, unlike other ones virtualbox is not built or installed for 5.7.2/5.7.3/5.7.4/5.7.5...

But dkms_autoinstaller start says it is installed for current kernel, which kernel are you running currently?
Comment 8 Martin Whitaker 2020-06-25 20:02:23 CEST
The time taken by dkms(In reply to Pascal Terjan from comment #5)
> They are almost all installed or installed-binary so should not get rebuilt,
> however there are a few ones built but not installed which is strange:

Most likely those kernels have been removed.

dkms_autoinstaller run time seems to increase exponentially with number of module versions present. A good cleanout will probably fix the problem.

IIUC, you should either have dkms-virtualbox or virtualbox-kernel-desktop-latest installed. Having both is an unnecessary duplication of effort and will contribute to slow boot times.
Comment 9 Martin Whitaker 2020-06-25 20:09:37 CEST
See also bug 15230 and bug 22135.

CC: (none) => mageia

Comment 10 Frank Griffin 2020-06-26 02:13:00 CEST
(In reply to Martin Whitaker from comment #8)
> The time taken by dkms(In reply to Pascal Terjan from comment #5)
> > They are almost all installed or installed-binary so should not get rebuilt,
> > however there are a few ones built but not installed which is strange:
> 
> Most likely those kernels have been removed.

Not the case here.

> 
> dkms_autoinstaller run time seems to increase exponentially with number of
> module versions present. A good cleanout will probably fix the problem.

Yeah, but this should not be necessary.  Why should dkms_autoinstall care about kernel versions other than the one being booted, and why should it take minutes to decide that the dkms versions for the current kernel do or do not need to be rebuilt ?
Comment 11 Frank Griffin 2020-06-26 02:55:34 CEST
I'm attaching an strace -f -t of the "verbose=yes /usr/sbin/dkms_autoinstaller start".

It appears to be reading the files in /var/lib/dkms/virtualbox for every installed version.  Is there any reason for this ?  Upstream bug, or something we did here ?

Well, I tried, but it's just too big, even when compressed.  The previous bug references which say that it's a function of the number of installed kernels ppres to be true, but I can't think of a reason why it should be.
Comment 12 Frank Griffin 2020-06-26 02:58:55 CEST
Oh, and interesting that processing for nvidia completes almost immediately, while processing for virtualbox takes forever.  Is the entire binary driver being read for each version ?  It still shouldn't take this long...
Comment 13 Morgan Leijström 2020-06-26 09:55:20 CEST
Related:
Bug 6030 - Inefficient: New kernel and driver => driver module got rebuilt twice

CC: (none) => fri

Comment 14 Martin Whitaker 2020-06-26 13:19:40 CEST
The issue is with pre-built modules. Support for those in dkms is a Mageia extension (inherited from Mandriva). The problem is that it reuses the function that checks for weak-installed modules, which by its nature ignores the requested version and checks all available versions. The time taken is proportional to the number of installed kernels times the number of pre-built modules.

(/sbin/dkms is just a bash script - take a look for yourself)

You will only encounter this problem if you have both the pre-built binary packages and dkms-virtualbox installed. If you don't have dkms-virtualbox installed, dkms_autoinstaller won't check the pre-built modules.
Comment 15 Frank Griffin 2020-06-26 15:40:13 CEST
So why are we still providing pre-built binaries and how do they get pulled in ?  And how does dkms even know to look for them ?  Pre-builts shouldn't be going anywhere near /var/lib/dkms.
Comment 16 Frank Griffin 2020-06-26 17:50:52 CEST
And from the latest kernel install, we have this:

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Preparing kernel 5.7.4-desktop-1.mga8 for module build:
(This is not compiling a kernel, just preparing kernel symbols)
Storing current .config to be restored when complete
Running Generic preparation routine
make mrproper....(bad exit status: 2)
using /proc/config.gz
make oldconfig......
make prepare....(bad exit status: 2)

Building module:
cleaning build area....(bad exit status: 2)
./vboxbuild /lib/modules/5.7.4-desktop-1.mga8/build.......
cleaning build area....(bad exit status: 2)
cleaning kernel tree (make mrproper)....(bad exit status: 2)

DKMS: build Completed.
+ /usr/sbin/dkms --rpm_safe_upgrade install -m virtualbox -v 6.1.10-2.mga8

vboxdrv.ko.xz:
 - Installation
   - Installing to /lib/modules/5.7.4-desktop-1.mga8/dkms/3rdparty/vbox/

vboxnetflt.ko.xz:
 - Installation
   - Installing to /lib/modules/5.7.4-desktop-1.mga8/dkms/3rdparty/vbox/

vboxnetadp.ko.xz:
 - Installation
   - Installing to /lib/modules/5.7.4-desktop-1.mga8/dkms/3rdparty/vbox/

depmod......

DKMS: install Completed.
+ /sbin/rmmod vboxnetflt
+ /sbin/rmmod vboxnetadp
+ /sbin/rmmod vboxdrv
+ /sbin/modprobe vboxdrv
+ /sbin/modprobe vboxnetflt
+ /sbin/modprobe vboxnetadp
+ :
+ /usr/sbin/dkms --rpm_safe_upgrade remove -m virtualbox -v 6.1.8-2.mga8 --all

-------- Uninstall Beginning --------
Module:  virtualbox
Version: 6.1.8-2.mga8
Kernel:  5.5.3-desktop-1.mga8 (x86_64)
-------------------------------------

Status: This module version was INACTIVE for this kernel.
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
depmod......

DKMS: uninstall Completed.

-------- Uninstall Beginning --------
Module:  virtualbox
Version: 6.1.8-2.mga8
Kernel:  5.6.15-desktop-1.mga8 (x86_64)
-------------------------------------

Status: Before uninstall, this module version was ACTIVE on this kernel.

vboxdrv.ko.xz:
 - Uninstallation
   - Deleting from: /lib/modules/5.6.15-desktop-1.mga8/dkms/3rdparty/vbox/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

vboxnetflt.ko.xz:
 - Uninstallation
   - Deleting from: /lib/modules/5.6.15-desktop-1.mga8/dkms/3rdparty/vbox/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.

vboxnetadp.ko.xz:
 - Uninstallation
   - Deleting from: /lib/modules/5.6.15-desktop-1.mga8/dkms/3rdparty/vbox/
 - Original module
   - No original module was found for this module on this kernel.
   - Use the dkms install command to reinstall any previous module version.
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
depmod......

DKMS: uninstall Completed.

-------- Uninstall Beginning --------
Module:  virtualbox
Version: 6.1.8-2.mga8
Kernel:  5.5.15-desktop-3.mga8 (x86_64)
-------------------------------------

Status: This module version was INACTIVE for this kernel.
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 2006: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
/usr/sbin/dkms: line 1861: echo: write error: Broken pipe
depmod......

DKMS: uninstall Completed.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Why is dkms managing the pre-built binaries ?  And if it is, why doesn't it know enough to ignore them during autostart ?
Comment 17 Pascal Terjan 2020-06-26 17:56:33 CEST
pre built binaries are separate packages (for example virtualbox-kernel-*) which register the prebuilt module with dkms and are useful to not need a compiler etc on your machine. 

dkms needs to know about them else if you also install dkms-virtualbox for example, it would build it even if you already have a prebuilt one.

If the way dkms handles them is very slow, we should fix it...
Comment 18 Frank Griffin 2020-06-26 18:31:37 CEST
OK, so two more questions:

1) Why is dkms_autostart even looking at driver versions other than the one which matches the kernel being used ?

2) Why is dkms repeatedly rebuilding drivers it has built previously, either during urpmi --auto-update or during a previous boot ?
Comment 19 Martin Whitaker 2020-06-26 18:43:50 CEST
I already answered question 1 in comment 14.

I can't answer question 2. I've only seen that happen when the build is failing. What messages appear in the system journal?
Comment 20 Pascal Terjan 2020-06-26 19:08:26 CEST
Something is definitely broken, when dkms-virtualbox-6.1.10-2.mga8 gets installed here the module gets built and installed, but then dkms_autoinstaller tries (and fails) to build it despite it building fine. This may be due to the binary ones having an older version as it seems they haven't been rebuilt when dkms-virtualbox was updated.

# urpmi dkms-virtualbox
    http://ftp.free.fr/mirrors/mageia.org/distrib/cauldron/x86_64/media/core/release/dkms-virtualbox-6.1.10-2.mga8.noarch.rpm
installing dkms-virtualbox-6.1.10-2.mga8.noarch.rpm from /var/cache/urpmi/rpms                                                                                                                                    
Preparing...                     ################################################################################################################################################################################
      1/1: dkms-virtualbox       ################################################################################################################################################################################
+ /usr/sbin/dkms --rpm_safe_upgrade add -m virtualbox -v 6.1.10-2.mga8

Creating symlink /var/lib/dkms/virtualbox/6.1.10-2.mga8/source ->
                 /usr/src/virtualbox-6.1.10-2.mga8

DKMS: add Completed.
+ '[' -z '' ']'
+ /usr/sbin/dkms --rpm_safe_upgrade build -m virtualbox -v 6.1.10-2.mga8

Preparing kernel 5.7.1-server-1.mga8 for module build:
(This is not compiling a kernel, just preparing kernel symbols)
Storing current .config to be restored when complete
Running Generic preparation routine
make mrproper....(bad exit status: 2)
using /proc/config.gz
make oldconfig....
make prepare....(bad exit status: 2)

Building module:
cleaning build area....(bad exit status: 2)
./vboxbuild /lib/modules/5.7.1-server-1.mga8/build......
cleaning build area....(bad exit status: 2)
cleaning kernel tree (make mrproper)....(bad exit status: 2)

DKMS: build Completed.
+ /usr/sbin/dkms --rpm_safe_upgrade install -m virtualbox -v 6.1.10-2.mga8

vboxdrv.ko.xz:
 - Installation
   - Installing to /lib/modules/5.7.1-server-1.mga8/dkms/3rdparty/vbox/

vboxnetflt.ko.xz:
 - Installation
   - Installing to /lib/modules/5.7.1-server-1.mga8/dkms/3rdparty/vbox/

vboxnetadp.ko.xz:
 - Installation
   - Installing to /lib/modules/5.7.1-server-1.mga8/dkms/3rdparty/vbox/

depmod......

DKMS: install Completed.
+ /sbin/rmmod vboxnetflt
+ /sbin/rmmod vboxnetadp
+ /sbin/rmmod vboxdrv
+ /sbin/modprobe vboxdrv
+ /sbin/modprobe vboxnetflt
+ /sbin/modprobe vboxnetadp
+ :

# dkms status
ena, 2.2.9-3.mga8, 5.7.5-server-1.mga8, x86_64: installed 
ena, 2.2.9-3.mga8, 5.7.1-server-1.mga8, x86_64: installed 
virtualbox, 6.1.10-2.mga8, 5.7.1-server-1.mga8, x86_64: installed 
virtualbox, 6.1.8-2.mga8, 5.7.4-server-1.mga8, x86_64: installed-binary from 5.7.4-server-1.mga8
virtualbox, 6.1.8-2.mga8, 5.7.1-server-1.mga8, x86_64: installed-binary from 5.7.1-server-1.mga8

# verbose=yes /usr/sbin/dkms_autoinstaller start

ena (2.2.9-3.mga8): Already installed on this kernel.
virtualbox (6.1.10-2.mga8): Installing module.
dkms build -m virtualbox -v 6.1.10-2.mga8 -k 5.7.1-server-1.mga8 -a x86_64 -q --no-clean-kernel 
(bad exit status: 3)
  Build failed.  Installation skipped.
Comment 21 Pascal Terjan 2020-06-26 19:15:32 CEST
Sorry previous comment is a local bug due to adding some debugging :)
Comment 22 Frank Griffin 2020-06-26 19:21:46 CEST
(In reply to Martin Whitaker from comment #19)
> I already answered question 1 in comment 14.

Well, basically you said that it happens, not why or whether it serves any purpose.
Comment 23 Martin Whitaker 2020-06-26 19:47:03 CEST
(In reply to Frank Griffin from comment #22)

Why it happens:

"The problem is that it reuses the function that checks for weak-installed modules, which by its nature ignores the requested version and checks all available versions."

Is it the desired behaviour:

"The problem is..."
Comment 24 Thomas Backlund 2020-06-26 21:18:48 CEST
(In reply to Pascal Terjan from comment #17)
> pre built binaries are separate packages (for example virtualbox-kernel-*)
> which register the prebuilt module with dkms and are useful to not need a
> compiler etc on your machine. 
> 
> dkms needs to know about them else if you also install dkms-virtualbox for
> example, it would build it even if you already have a prebuilt one.
> 
> If the way dkms handles them is very slow, we should fix it...

dkms should be upgraded to a newer version as many of the stuff we patched in eons ago have years later been added upstream in different ways, and we also have some obsolete stuff there too...

I started ~1 year ago, but did not have time/energy to finish it for mga7+

You can find the work here:
 http://svnweb.mageia.org/packages/cauldron/dkms/branches/WIP/current/

Of course there is now newver version of dkms upstream nowdays...

CC: (none) => tmb

Thomas Backlund 2020-06-26 21:20:25 CEST

CC: tmb => (none)

Comment 25 Frank Griffin 2020-09-21 04:21:26 CEST
Ping ?
Comment 26 Morgan Leijström 2020-09-21 09:14:14 CEST
Related:
Bug 6030 - Inefficient: New kernel and driver => driver module got rebuilt twice
Comment 27 Martin Whitaker 2020-09-21 09:39:05 CEST
So, from previous comments, the problem is not that the dkms modules are being rebuilt, but that the dkms checks are slow.

As said before, to fix the slow boot:

1. Remove unneeded old kernels.
2. Remove dkms-virtualbox.

or if you really must keep lots of old kernels:

1. Remove virtualbox-kernel-*
2. Keep dkms-virtualbox
Comment 28 Giuseppe Ghibò 2020-09-21 11:45:29 CEST
Hi Martin, I've updated the code in SVN in the link pointed by Thomas here:

http://svnweb.mageia.org/packages/cauldron/dkms/branches/WIP/current/

to the release 2.8.3, to the point where I was arrived to port. Still there is some mageia customization stuff to be completed and  to be backported to 2.8.3. I think with some cooperation from who has already knowledge/experience of dkms code, it can be finally upgraded. Also because actually our current dkms is pretty old (2.0.19 as of 2011). The dkms stuff is become a little weak compared to other distro and with some annoying side effects (e.g. as of bug #27080).

Maybe we can open a dedicated bug report for dkms upgrade (as enhancements) with the progress.

CC: (none) => ghibomgx

Comment 29 Giuseppe Ghibò 2020-09-21 11:46:11 CEST
Even better would be to maintain the mageia customizations upstream.
Comment 30 Aurelien Oudelet 2020-09-21 12:15:05 CEST
dkms should be upgraded.

CC: (none) => ouaurelien

Comment 31 Martin Whitaker 2020-09-21 21:34:13 CEST
(In reply to Giuseppe Ghibò from comment #28)
> Maybe we can open a dedicated bug report for dkms upgrade (as enhancements)
> with the progress.

There's already a bug report for that: bug 17198.