mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Ballance <andrewjballance@gmail.com>
To: jbaron@akamai.com, jim.cromie@gmail.com,
	daniel.almeida@collabora.com, acourbot@nvidia.com,
	ojeda@kernel.org, alex.gaynor@gmail.com, boqun.feng@gmail.com,
	gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org,
	a.hindborg@kernel.org, aliceryhl@google.com, tmgross@umich.edu,
	dakr@kernel.org, gregkh@linuxfoundation.org, rafael@kernel.org,
	rostedt@goodmis.org, andrewjballance@gmail.com
Cc: viresh.kumar@linaro.org, lina+kernel@asahilina.net,
	tamird@gmail.com, jubalh@iodoru.org,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [RFC PATCH v2 0/4] rust: add support for dynamic debug
Date: Fri, 20 Jun 2025 16:05:29 -0500	[thread overview]
Message-ID: <20250620210533.400889-1-andrewjballance@gmail.com> (raw)

This patch series adds support for dynamic debug to the rust
pr_debug! and dev_dbg! macros.

I have tested it and it and it does work but, there are a few
differences between this and the c version (hence why this is a rfc).

rust does not have an equivalent to the C __func__ macro. so, for the
time being this hard codes the function name to be the name of the
macro e.g. "pr_debug!" and "dev_dbg!".

This uses the module_path! macro to get the module name, which will not
be exactly the same as the c version if a kernel module defines a rust mod.
e.g. it might be "kernel_module_name::rust_module_name".
this does give a more accurate description of where the print statement
is located but it is not identical to what the c version does.

This patch series also had to make a small change to the jump_label module.
to add a STATIC_KEY_INIT_FALSE and updates the static_branch_unlikely
macro so that it allows keys that are nested multiple structs deep
within a static variable.

Closes: https://github.com/Rust-for-Linux/linux/issues/453
Link: https://rust-for-linux.zulipchat.com/#narrow/channel/291565-Help/topic/Dynamic.20Debug.3F/with/519289668

changes in v2:
 - fix typos
 - define and use STATIC_KEY_INIT_FALSE.
 - use raw pointers to avoid undefined behavior
 - use cleaner version of macro definition for nested arguments (thanks Alice)
link to v1: https://lore.kernel.org/rust-for-linux/20250611202952.1670168-1-andrewjballance@gmail.com/

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

 rust/bindings/bindings_helper.h |   1 +
 rust/kernel/device.rs           | 105 +++++++++++++++++++-
 rust/kernel/jump_label.rs       |  15 ++-
 rust/kernel/print.rs            | 171 +++++++++++++++++++++++++++++++-
 4 files changed, 281 insertions(+), 11 deletions(-)

-- 
2.49.0


             reply	other threads:[~2025-06-20 21:05 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-20 21:05 Andrew Ballance [this message]
2025-06-20 21:05 ` [RFC PATCH v2 1/4] rust: jump label: add support for nested arguments Andrew Ballance
2025-06-20 21:05 ` [RFC PATCH v2 2/4] rust: jump label: add STATIC_KEY_INIT_FALSE Andrew Ballance
2025-06-20 21:05 ` [RFC PATCH v2 3/4] rust: print: add support for dynamic debug to pr_debug! Andrew Ballance
2025-06-20 21:05 ` [RFC PATCH v2 4/4] rust: device: add support for dynamic debug to dev_dbg! Andrew Ballance

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=20250620210533.400889-1-andrewjballance@gmail.com \
    --to=andrewjballance@gmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jbaron@akamai.com \
    --cc=jim.cromie@gmail.com \
    --cc=jubalh@iodoru.org \
    --cc=lina+kernel@asahilina.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@gmail.com \
    --cc=tmgross@umich.edu \
    --cc=viresh.kumar@linaro.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®