Skip to content

RFC rust: add support for dynamic debug

Andrew Ballance lkml rust-for-linux 2 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 RFC Latest4 patches 0 repliesNew
  2. v1 RFC3 patches 5 repliesSuperseded

Changes in v2 from the cover letter

- 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/[email protected]/

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4rust: jump label: add support for nested argumentsrust/kernel/jump_label.rs+5 -50 replies
2/4rust: jump label: add STATIC_KEY_INIT_FALSErust/kernel/jump_label.rs+5 -00 replies
3/4rust: print: add support for dynamic debug to pr_debug!rust/bindings/bindings_helper.h rust/kernel/print.rs+168 -40 replies
4/4rust: device: add support for dynamic debug to dev_dbg!rust/kernel/device.rs+103 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [RFC PATCH v2 0/4] rust: add support for dynamic debug

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.

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/[email protected]/

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(-)
Signature · 1 line
2.49.0