Page MenuHomeFreeBSD

Avoid grabbing locks when grabbing the vt(4) console for DDB.
AcceptedPublic

Authored by jhb on Feb 21 2018, 11:53 PM.
Tags
None
Referenced Files
Unknown Object (File)
Jan 2 2024, 2:55 AM
Unknown Object (File)
Jan 1 2024, 7:22 AM
Unknown Object (File)
Jan 1 2024, 5:18 AM
Unknown Object (File)
Dec 21 2023, 4:18 PM
Unknown Object (File)
Oct 30 2023, 12:59 PM
Unknown Object (File)
Oct 13 2023, 4:24 PM
Unknown Object (File)
Sep 6 2023, 4:51 AM
Unknown Object (File)
Jul 28 2023, 3:43 PM

Details

Reviewers
emaste
Summary

Trying to grab locks during cngrab() when entering the debugger is
deadlock prone as all other CPUs are already halted (and thus unable
to release locks) when cngrab() is invoked. One could instead use
try-locks. However, the case that the try-lock fails still has to
be handled. In addition, if the try-lock works it doesn't provide
any greater ordering guarantees than is already provided by entering
and exiting DDB. It is simpler to define a simpler path for the
case that the try-lock would fail and always use that when entering
DDB. Messing with timers, etc. when entering DDB is dubious even if
the try-lock succeeds.

This patch attempts to use the smallest possible set of operations to
grab the vt(4) console when entering DDB without using any locks.

Test Plan
  • tested by Matt Macy on a panic that always hung in VT_LOCK in cngrab() previously

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 15196
Build 15271: arc lint + arc unit

Event Timeline

Just a "works for me." I haven't had time to dig in to what's holding the lock, but the inability to enter ddb consistently when not entering by way of a proper panic has been a serious issue for me for at least the past 6 months. I don't know what others are doing to never see this.

LGTM

sys/dev/vt/vt_core.c
544–547

This existing path seems somewhat dubious

This revision is now accepted and ready to land.Feb 22 2018, 12:30 AM
sys/dev/vt/vt_core.c
544–547

I think a cngrab() when the console is already ttyv0 isn't that rare. :) That said, I think the only place this would now get used is during a clean shutdown and I think the existing path with locking is fine for that?

sys/dev/vt/vt_core.c
544–547

I don't think the existing lock will cause a problem, but am unsure exactly what it's accomplishing.

Update: Although it works fine with SOL through ipmitool, iKVM/HTML5 does _not_ work once it drops you to the db> prompt
Please pull in the keyboard bits as well.