linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC PATCH 0/2] Introduce KGDB_DEBUG_SPINLOCKS
@ 2020-05-22 14:55 Daniel Thompson
  2020-05-22 14:55 ` [RFC PATCH 1/2] debug: Convert dbg_slave_lock to an atomic Daniel Thompson
  2020-05-22 14:55 ` [RFC PATCH 2/2] locking/spinlock/debug: Add checks for kgdb trap safety Daniel Thompson
  0 siblings, 2 replies; 5+ messages in thread
From: Daniel Thompson @ 2020-05-22 14:55 UTC (permalink / raw)
  To: sumit.garg, jason.wessel, dianders
  Cc: Daniel Thompson, kgdb-bugreport, linux-kernel, patches, pmladek,
	sergey.senozhatsky, Peter Zijlstra, Ingo Molnar, Will Deacon

The execution context for kgdb/kdb is pretty much unique. We are running
a debug trap handler with all CPUs parked in a holding loop and with
interrupts disabled. At least one CPU is in an unknowable execution
state (could be NMI, IRQ, irqs disabled, etc) and the others are either
servicing an IRQ or NMI depending on architecture.

Breakpoints (including some implicit breakpoints when serious errors
are detected) can happen on more or less any context, including when we
own important spin locks.

As such spin lock waits should never happen whilst we are executing the
kgdb trap handler used except, occasionally, via an explicit command
from a (forewarned?) local operator.

Currently kdb doesn't meet this criteria (although I think kgdb does)
so I started thinking about what tooling we could employ to reinforce
code review and bring problems to the surface.

The result is a patch that extends DEBUG_SPINLOCKS and checks whether
the execution context is safe. The "except via an explicit command"
aspect (mentioned above) convinced me to make the checks conditional
on KGDB_DEBUG_SPINLOCKS.

Daniel Thompson (2):
  debug: Convert dbg_slave_lock to an atomic
  locking/spinlock/debug: Add checks for kgdb trap safety

 include/linux/kgdb.h            | 16 ++++++++++++++++
 kernel/debug/debug_core.c       |  8 ++++----
 kernel/locking/spinlock_debug.c |  4 ++++
 lib/Kconfig.kgdb                | 11 +++++++++++
 4 files changed, 35 insertions(+), 4 deletions(-)


base-commit: 6a8b55ed4056ea5559ebe4f6a4b247f627870d4c
--
2.25.4


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-05-22 16:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-22 14:55 [RFC PATCH 0/2] Introduce KGDB_DEBUG_SPINLOCKS Daniel Thompson
2020-05-22 14:55 ` [RFC PATCH 1/2] debug: Convert dbg_slave_lock to an atomic Daniel Thompson
2020-05-22 16:26   ` Peter Zijlstra
2020-05-22 14:55 ` [RFC PATCH 2/2] locking/spinlock/debug: Add checks for kgdb trap safety Daniel Thompson
2020-05-22 16:35   ` Peter Zijlstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).