mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zhi Wang <zhiw@nvidia.com>
To: <rust-for-linux@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Cc: <andrewjballance@gmail.com>, <daniel.almeida@collabora.com>,
	<dakr@kernel.org>, <aliceryhl@google.com>, <ojeda@kernel.org>,
	<boqun@kernel.org>, <gary@garyguo.net>,
	<bjorn3_gh@protonmail.com>, <lossin@kernel.org>,
	<a.hindborg@kernel.org>, <tmgross@umich.edu>, <cjia@nvidia.com>,
	<smitra@nvidia.com>, <ankita@nvidia.com>, <aniketa@nvidia.com>,
	<kwankhede@nvidia.com>, <targupta@nvidia.com>, <kjaju@nvidia.com>,
	<alkumar@nvidia.com>, <acourbot@nvidia.com>,
	<jhubbard@nvidia.com>, <zhiwang@kernel.org>,
	Zhi Wang <zhiw@nvidia.com>
Subject: [PATCH v3 0/5] Rust dynamic debug support for pr_debug! and dev_dbg!
Date: Thu, 1 Oct 2026 17:59:35 +0300	[thread overview]
Message-ID: <20261001145940.1077801-1-zhiw@nvidia.com> (raw)

Add runtime dynamic debug control to Rust pr_debug! and dev_dbg!, using
the existing C control file, boot/module parameters, prefixes and jump
labels. Callsite flags and static keys always start disabled. Users enable
messages with dyndbg queries; Rust debug assertions do not affect whether
a debug message is printed.

This continues Andrew Ballance's RFC v2:
https://lore.kernel.org/rust-for-linux/20250620210533.400889-1-andrewjballance@gmail.com/

This revision retains RFC v2's nested-field static-branch macros and
static mut descriptors addressed through raw pointers.

Changes since RFC v2:

- Make debug logging independent of Rust's debug_assertions setting.
  Both pr_debug! and dev_dbg! start disabled and are enabled through
  dyndbg; without dynamic debug support, both remain disabled.
- Keep caller expressions outside unsafe blocks and avoid implicit Rust
  references when reading descriptor flags without jump labels.
- Correct big-endian bitfield layout and keep module descriptors writable
  with #[used(compiler)]. This fixes the kernel write fault when
  static_key_enable_cpuslocked() tries to write the static key.
- Use Kbuild module names and actual format strings for filtering, preserve
  the crate log prefix, and support +d stack output.
- Complete DYNAMIC_DEBUG_CORE-only support with per-crate opt-in.
- Port to driver-core-testing and preserve Nova's firmware validation when
  debug logging is disabled.

Limitations:

- Function metadata deliberately remains <unknown>;

Andrew Ballance (3):
  rust: jump label: add support for nested arguments
  rust: print: add dynamic debug support to pr_debug!
  rust: device: add dynamic debug support to dev_dbg!

Zhi Wang (2):
  gpu: nova-core: validate firmware versions before debug logging
  dynamic_debug: expose printing declarations with the core enabled

 .../admin-guide/dynamic-debug-howto.rst       |  41 ++++
 MAINTAINERS                                   |   2 +
 drivers/gpu/nova-core/firmware/booter.rs      |   8 +-
 drivers/gpu/nova-core/firmware/fsp.rs         |   3 +-
 .../nova-core/firmware/fwsec/bootloader.rs    |   7 +-
 drivers/gpu/nova-core/firmware/gsp.rs         |   3 +-
 drivers/gpu/nova-core/firmware/riscv.rs       |   7 +-
 include/linux/dynamic_debug.h                 |  16 +-
 rust/Makefile                                 |   3 +
 rust/bindings/bindings_helper.h               |   1 +
 rust/helpers/dynamic_debug.c                  |  33 +++
 rust/helpers/helpers.c                        |   1 +
 rust/kernel/device.rs                         |  42 +++-
 rust/kernel/jump_label.rs                     |  17 +-
 rust/kernel/print.rs                          |  53 ++++-
 rust/kernel/print/dynamic_debug.rs            | 192 ++++++++++++++++++
 scripts/Makefile.build                        |   1 +
 scripts/generate_rust_analyzer.py             |   1 +
 18 files changed, 386 insertions(+), 45 deletions(-)
 create mode 100644 rust/helpers/dynamic_debug.c
 create mode 100644 rust/kernel/print/dynamic_debug.rs


base-commit: f1850e443b0e4f2429ddf42a8d5033ea54ae8a90
-- 
2.53.0


             reply	other threads:[~2026-10-01 15:00 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-01 14:59 Zhi Wang [this message]
2026-10-01 14:59 ` [PATCH v3 1/5] gpu: nova-core: validate firmware versions before debug logging Zhi Wang
2026-10-01 14:59 ` [PATCH v3 2/5] rust: jump label: add support for nested arguments Zhi Wang
2026-10-01 14:59 ` [PATCH v3 3/5] dynamic_debug: expose printing declarations with the core enabled Zhi Wang
2026-10-01 14:59 ` [PATCH v3 4/5] rust: print: add dynamic debug support to pr_debug! Zhi Wang
2026-10-01 14:59 ` [PATCH v3 5/5] rust: device: add dynamic debug support to dev_dbg! Zhi Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261001145940.1077801-1-zhiw@nvidia.com \
    --to=zhiw@nvidia.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=aliceryhl@google.com \
    --cc=alkumar@nvidia.com \
    --cc=andrewjballance@gmail.com \
    --cc=aniketa@nvidia.com \
    --cc=ankita@nvidia.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun@kernel.org \
    --cc=cjia@nvidia.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=jhubbard@nvidia.com \
    --cc=kjaju@nvidia.com \
    --cc=kwankhede@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=smitra@nvidia.com \
    --cc=targupta@nvidia.com \
    --cc=tmgross@umich.edu \
    --cc=zhiwang@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®