Page MenuHomeFreeBSD

LinuxKPI: avoid userret: Returning with with pinned thread

Authored by bz on Jun 9 2021, 7:13 PM.



Some code manually calls local_bh_disable() and spin_lock() but
then calls spin_unlock_bh() (or vice versa).
Our code then calls local_bh_disable() again from spin_lock()
which means we have the thread pin count increased twice and that
means we get out of synch and are still pinned when returning to
user space.

Avoid this by adding the explicit local_bh_{enable,disable}() to
the spin_[un]lock_bh() versions.

Sponsored by: The FreeBSD Foundation
MFC after: 2 weeks

Diff Detail

rG FreeBSD src repository
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

bz requested review of this revision.Jun 9 2021, 7:13 PM
bz removed a subscriber: linuxkpi.

I am assuming the reason the sched_[un]pin() are in the spin_[un]lock() and not just in the _bh versions has its reason in Linux and not just in simplification as otherwise we could avoid the "double-pinning"?

I'd really love to get this one sorted quickly as well.

This revision is now accepted and ready to land.Jun 11 2021, 9:56 AM