Page MenuHomeFreeBSD

asmc: Convert driver to CTLFLAG_MPSAFE
AcceptedPublic

Authored by guest-seuros on Fri, Jan 9, 12:37 PM.
Tags
None
Referenced Files
F141820476: D54613.id169375.diff
Sat, Jan 10, 9:44 PM
Unknown Object (File)
Sat, Jan 10, 3:56 PM
Unknown Object (File)
Sat, Jan 10, 6:55 AM
Unknown Object (File)
Sat, Jan 10, 5:39 AM
Unknown Object (File)
Fri, Jan 9, 6:48 PM
Subscribers

Details

Reviewers
adrian
ngie
markj
Summary

Replace CTLFLAG_NEEDGIANT with CTLFLAG_MPSAFE for all sysctls.
The driver already uses spin mutexes (sc->sc_mtx) for hardware
access protection and does not require the Giant lock.

This improves scalability by allowing concurrent sysctl access
without Giant serialization.

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 69747
Build 66630: arc lint + arc unit

Event Timeline

Some of these handlers perform read-modify-writes. The spin mutex serializes hardware accesses but not higher-level operations, as in asmc_mb_sysctl_fanmanual() for instance. Is it ok to leave them unserialized?

We could wrap it with a sleep mutex, but concurrent fan control from multiple threads is not a realistic scenario.
The worst case is a lost update, not a crash.

My approach is to upgrade to MPSAFE, stress test on real hardware, then ship.
That's also why I'm not submitting upgrades for every drivers, I only upgrade what I can actually test on hardware I have.

A follow-up sweep can remove unnecessary locking where it makes no sense.

I had a chat with seuros on discord about it. I think its fine as an intermediary step, but I do think it'll be worth revisiting the driver locking later and pushing more stuff into functionality locks rather than per device IO locks.

(I do need to get a couple reference devices though, my macbook air devices don't have fans :-) )

yeah, looking at asmc again with spin mutex use i really don't want to clean that up whilst removing GIANT here.
it should be ok-ish for now.

let's land this and then figure out how to expand the spin mutexes a bit to cover features a bit cleaner.
(And then see i they really NEED to be spin mutexes..)

This revision is now accepted and ready to land.Sun, Jan 11, 12:10 AM