Linux Kernel & OS

Linux kernel developers propose removing KGDB debugging after 18 years

Key Takeaway

Intel kernel maintainer Peter Zijlstra has submitted a patch to completely remove KGDB, arguing QEMU's gdb-server has made the serial/network-based dual-machine debugger obsolete and its NMI-context behavior causes systemic reliability problems.

Summary

A patch posted by longtime Intel Linux developer Peter Zijlstra proposes the complete removal of KGDB, the kernel debugging subsystem merged in Linux 2.6.26 back in 2008. KGDB enables kernel debugging through GDB using a second machine connected via serial or Ethernet, but Zijlstra argues the approach has been superseded by virtualization-based debugging via QEMU's gdb-server, which does not require dedicated hardware or null-modem cables.

The removal rationale centers on KGDB's fundamental architectural problems: it operates in NMI context which corrupts timekeeping, triggers watchdog failures, and interacts poorly with code patching and breakpoints. Multiple prior attempts to repair KGDB's breakpoint handling have proven unsatisfactory. An alternative proposal suggests disabling KGDB through Kconfig initially and deferring full removal to a later kernel release, though no timeline has been established for either approach.

KGDB removal rationale and technical risks

  • NMI context hazards: KGDB execution in non-maskable interrupt context can terminally corrupt kernel timekeeping subsystems and cause watchdog timer expirations, making it unreliable for debugging timing-sensitive code paths.
  • Breakpoint and code patching conflicts: The subsystem has persistent unresolved issues with breakpoint placement and dynamic code patching, with prior fix attempts described as inadequate by the proposing maintainer.
  • Hardware dependency workaround: For debugging scenarios requiring specific physical hardware, Zijlstra recommends device pass-through to QEMU, hardware emulation, or fallback to printk-based debugging rather than retaining KGDB.
  • Kconfig disable alternative: A counter-proposal suggests initially disabling KGDB through kernel configuration options rather than immediate source removal, potentially staging deletion across multiple release cycles.
  • QEMU gdb-server replacement: The recommended migration path leverages QEMU's built-in gdb remote debugging server, which provides equivalent kernel debugging capabilities without dedicated physical infrastructure.

Why it matters

Kernel developers and Linux distribution maintainers who maintain KGDB-enabled debug kernel packages would need to validate QEMU-based debugging workflows for hardware-specific issues. The change reflects broader industry migration toward virtualized development environments, though embedded and bare-metal kernel engineers with legacy serial debugging infrastructure face workflow disruption if the removal proceeds.

Original reference: www.phoronix.com →