Page MenuHomeFreeBSD

newbus: Ensure that we hold topo lock for calls to devclass_find_internal
AcceptedPublic

Authored by imp on Wed, Oct 29, 6:08 PM.
Tags
None
Referenced Files
Unknown Object (File)
Mon, Nov 3, 12:08 AM
Unknown Object (File)
Fri, Oct 31, 2:23 PM
Unknown Object (File)
Fri, Oct 31, 2:19 PM
Unknown Object (File)
Fri, Oct 31, 2:18 PM
Unknown Object (File)
Fri, Oct 31, 12:55 AM
Unknown Object (File)
Fri, Oct 31, 12:55 AM
Unknown Object (File)
Thu, Oct 30, 7:57 PM
Unknown Object (File)
Thu, Oct 30, 2:16 PM
Subscribers

Details

Reviewers
markj
jhb
Summary

Since devclass_find_internal looks at and modifies the devclass
structures, it needs to hold the topo lock when called.

Sponsored by: Netflix

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 68239
Build 65122: arc lint + arc unit

Event Timeline

imp requested review of this revision.Wed, Oct 29, 6:08 PM

Since devclass_find_internal looks at and modifies the devclass
structures, it needs to hold the topo lock when called.

But presumably the callers of devclass_create() and devclass_find() are doing so as well, since those functions return a devclass pointer.

It looks like devclasses are never freed, so I think it's ok to lock devclass_find() and devclass_create() this way, but other devclass accessors need to be externally locked. For instance, you can't really apply this approach to devclass_get_devices(), since it returns objects that are protected only by the topo lock.

I'd change the message to note that the devclass list is the main thing being synchronized here.

This revision is now accepted and ready to land.Wed, Oct 29, 7:35 PM