optimize the dkms init script to be less greedy at boot time

Bug #484386 reported by Steve Langasek
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
dkms (Ubuntu)
Fix Released
Medium
Unassigned

Bug Description

Binary package hint: dkms

The dkms_autoinstall script is noticeable in bootcharts of karmic on the Dell Mini 10V reference hardware. In the general case, dkms should have nothing to do at boot time because the modules will already be around from the previous boot; so it would be nice to have this script more efficiently detect that it doesn't need to do anything.

I've identified three changes that I think will make the script more efficient (but haven't tested this yet):

- consolidate our walking of /var/lib/dkms to use a single call to find, avoiding multiple stat() calls for each file
- avoid forking grep for a string match, use case instead
- port to POSIX sh, so that we can spawn /bin/ash instead of /bin/bash.

Patch to follow.

ProblemType: Bug
Architecture: amd64
Date: Tue Nov 17 12:33:56 2009
DistroRelease: Ubuntu 9.10
Package: dkms (not installed)
ProcEnviron:
 PATH=(custom, user)
 LANG=en_US.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.31-15.50-generic
SourcePackage: dkms
Uname: Linux 2.6.31-15-generic x86_64

Related branches

Revision history for this message
Steve Langasek (vorlon) wrote :
Revision history for this message
Steve Langasek (vorlon) wrote :
Changed in dkms (Ubuntu):
assignee: nobody → Scott James Remnant (scott)
Revision history for this message
Giuseppe Iuculano (giuseppe-iuculano) wrote :

This doesn't work. Attached is a proposed diff based on Steve patchset. It needs review and testing.

Revision history for this message
Mario Limonciello (superm1) wrote :

Although some of these changes are good and will work, I don't believe switching to bash is doable. The dkms.conf's that are sourced use arrays, eg PATCH[0], PATCH[1]. Without breaking compatibility for earlier DKMS versions, I don't think that syntax can be changed.

Revision history for this message
Steve Langasek (vorlon) wrote : Re: [Bug 484386] Re: optimize the dkms init script to be less greedy at boot time

On Mon, Dec 07, 2009 at 10:41:59PM -0000, Mario Limonciello wrote:
> Although some of these changes are good and will work, I don't believe
> switching to bash is doable. The dkms.conf's that are sourced use
> arrays, eg PATCH[0], PATCH[1]. Without breaking compatibility for
> earlier DKMS versions, I don't think that syntax can be changed.

Oh, gar. Sorry, of course this isn't obvious when looking at the script
itself since those config files are provided by other packages.

--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer http://www.debian.org/
<email address hidden> <email address hidden>

Revision history for this message
Mario Limonciello (superm1) wrote :

I'm still going to incorporate the breadth of that patch (aside from another logic problem i see), and I'll see about moving that bit of logic that's sourcing all of dkms.conf out of here.

Revision history for this message
Steve Langasek (vorlon) wrote :

On Tue, Nov 24, 2009 at 11:44:16AM -0000, Giuseppe Iuculano wrote:
> This doesn't work.

What didn't work? Comparing the diffs, I see a bug in mine that I used the
'filename' variable twice when the first instance should have been
'module_in_tree'; but your version instead introduces new variables
(PACKAGE_NAME?) that aren't defined anywhere in the script. I guess this
comes from the source/dkms.conf; should this value always be the same as the
directory name, or is there ever a reason to prefer one or the other?

- version_in_tree="$filename"
+ version_in_tree="$(basename $filename)"

This adds an extra fork for each directory. Can be done in shell instead
as:

  version_in_tree=${filename##*/}
  module_in_tree=${filename%/*}
  module_in_tree=${module_in_tree##*/}

Also, the double for loop is needed because we care about counting how many
versions are available for the same module; with your changes, we lose that
information.

Updated patch attached.

Revision history for this message
Mario Limonciello (superm1) wrote :

OK, i've committed this upstream with some modifications.
 * You were using dirname in both for loops
 * I've set it up to just pull AUTOINSTALL from the dkms.conf
 * I've switched the interpreter to /bin/sh (as in the original patch) now that it doesn't need to source a conf file with arrays.

I'll do an updated release with this change into Lucid after catching up on other patches.

http://linux.dell.com/git/?p=dkms.git;a=commit;h=fd2971d3cf23c7c38f90d3c64a75724023553c45

Changed in dkms (Ubuntu):
status: New → Fix Committed
Changed in dkms (Ubuntu):
assignee: Scott James Remnant (scott) → nobody
Revision history for this message
Steve Langasek (vorlon) wrote :

On Tue, Dec 08, 2009 at 12:51:59AM -0000, Mario Limonciello wrote:
> OK, i've committed this upstream with some modifications.
> * You were using dirname in both for loops

Yes, I don't think this was buggy - but using different variable names is
also obviously not buggy :)

Cheers,
--
Steve Langasek Give me a lever long enough and a Free OS
Debian Developer to set it on, and I can move the world.
Ubuntu Developer http://www.debian.org/
<email address hidden> <email address hidden>

Changed in dkms (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Mario Limonciello (superm1) wrote :

This should have been closed from the last upload. If there are any other improvements that can be seen in other places, please reopen it.

Changed in dkms (Ubuntu):
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.