Page MenuHomeFreeBSD

Create devctl freeze/thaw.
ClosedPublic

Authored by imp on Aug 15 2018, 10:14 PM.
Tags
None
Referenced Files
Unknown Object (File)
Fri, Nov 1, 11:19 PM
Unknown Object (File)
Fri, Nov 1, 11:19 PM
Unknown Object (File)
Fri, Nov 1, 11:19 PM
Unknown Object (File)
Fri, Nov 1, 11:19 PM
Unknown Object (File)
Fri, Nov 1, 11:18 PM
Unknown Object (File)
Fri, Nov 1, 11:18 PM
Unknown Object (File)
Fri, Nov 1, 11:17 PM
Unknown Object (File)
Fri, Nov 1, 11:17 PM

Details

Summary

This adds it to devctl, libdevctl, defines the two IOCTLs and stubs
them out in the kernel. freeze causes any new drivers that are added
via kldload to be queued up until a 'thaw' comes in. These do not
stack: it is an error to freeze while frozen, or thaw while thawed.

It also adds the kernel bits

And the rc.d bits

And the devmatch take out the workaround bits

these will be separate commits.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

  • Improve devmatch driver loading
  • Remove sorting of matches and print all the matches as we find them.
  • First cut: Untested kernel bits
imp retitled this revision from Create the userland side of devctl freeze/thaw. to Create devctl freeze/thaw..Aug 17 2018, 6:35 PM
imp edited the summary of this revision. (Show Details)
brooks added a subscriber: brooks.

Not my area of expertise, but looks valid to me.

This revision is now accepted and ready to land.Aug 17 2018, 7:49 PM

Fix

  • fold devctl prog
  • Stupid debug
  • Allow NULL to be passed into the device name to send the message
This revision now requires review to proceed.Aug 18 2018, 12:44 AM
hselasky added inline comments.
sys/kern/subr_bus.c
5672 ↗(On Diff #46867)

Should these debug prints be removed?

sys/kern/subr_bus.c
5672 ↗(On Diff #46867)

Yes. Of course. I have them as a separate commit I'll strip out before I push this upstream.

blacklist
don't reload unloaded drivers, part 2

  • Improve devmatch driver loading
  • Remove sorting of matches and print all the matches as we find them.
  • Stupid debug
  • fold kernel
  • Add a new device flag: DF_ATTACHED_ONCE
  • When trying to match the nomatch event passed to us, attempt to look
  • Implement blacklisting for devmatch
sys/kern/subr_bus.c
1221 ↗(On Diff #46920)

This is the only part I'm not sure of. Currently I don't think anything does a scan with this patch in place (e.g. if someone hotplugs a device during the window in rc.d/devmatch between freeze and thaw). I'm not sure what the right answer is. One might be to just let the NOMATCH events fire anyway. Another might be to queue them in the kernel and fire them during thaw (rechecking to see if a device is still unattached before firing the actual event though). You could use a similar 'DF_NOMATCHPENDING' flag here (which is always cleared if a device attaches) and then just walk all devices doing the NOMATCH bits for them during a thaw (or use a dedicated linked list instead of the flag if we think the list of devices is too long to walk)

  • Improve devmatch driver loading
  • Remove sorting of matches and print all the matches as we find them.
  • Stupid debug
  • fold kernel
  • Add a new device flag: DF_ATTACHED_ONCE
  • When trying to match the nomatch event passed to us, attempt to look
  • Implement blacklisting for devmatch
  • Mark nomatch devices
imp marked 3 inline comments as done.Aug 21 2018, 3:59 PM
imp added inline comments.
sys/kern/subr_bus.c
1221 ↗(On Diff #46920)

I'd considered this when writing it, but was unsure. I've updated things, and it turns out to be easy and simplifies things a little (though we look at more devices, which isn't a huge burden). Let me know what you think of the NEEDNOMATCH flag.

bcr added a subscriber: bcr.

Add manpages for lib/libdevctl/devctl.3

OK from manpages, but .Dd on lib/libdevctl/devctl.3 should be bumped.

This revision is now accepted and ready to land.Aug 21 2018, 5:19 PM
sys/kern/subr_bus.c
5438 ↗(On Diff #47043)

I don't think this works? A driver link is just an instance of a parent devclass (e.g. "pci") to a set of driver methods (kobj class holding DEVMETHOD array). I think you'd have to have a separate loop after the outermost TAILQ_FOREACH completes that then iterates over all device_t's to handle this.

I think for now it might be simplest to just let NOMATCH events be (and let them fire during a freeze as it can't really hurt if the module is loaded multiple times during a freeze).

imp marked an inline comment as done.Aug 22 2018, 3:03 PM
imp added inline comments.
sys/kern/subr_bus.c
5438 ↗(On Diff #47043)

Doh! You're right. I misread the device definition. I'll update. It's easy enough to do.

This revision now requires review to proceed.Aug 22 2018, 3:10 PM
This revision was not accepted when it landed; it landed in state Needs Review.Aug 23 2018, 5:05 AM
Closed by commit rS338233: Create devctl freeze/thaw. (authored by imp). · Explain Why
This revision was automatically updated to reflect the committed changes.