Skip to contentSkip to conversation

rust: devres: use compile-time type_name for debug info

PATCH In review Aary Milind Kinge 5 participants 8 messages May 26 – May 27

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust: devres: use compile-time type_name for debug info

From: Not-Buddy <[email protected]>

The devres_set_node_dbginfo function previously used a hardcoded c"Devres<T>" string for all device resource nodes because core::any::type_name was not stabilized as a const fn. This made debugging device resources difficult as all nodes shared the same name.

Enable the const_type_name unstable feature in the kernel crate and replace the hardcoded placeholder with the actual generic type name at compile time.

To satisfy the C-API's requirement for a null-terminated string, the bytes are copied into a locally evaluated const array buffer, appended with a null byte, and promoted to static read-only memory by reference before being passed to devres_set_node_dbginfo.

---
 rust/kernel/devres.rs | 41 ++++++++++++++++++++++++++++++++++++++---
 rust/kernel/lib.rs    |  1 +
 2 files changed, 39 insertions(+), 3 deletions(-)
rust/kernel/devres.rs +38 -3
index 9e5f93aed20c..989e9d9a78c4 100644
@@ -185,6 +185,42 @@ pub(super) unsafe fn devres_node_remove(
 }
 
 impl<T: Send> Devres<T> {
+    // 1. Get the standard Rust string at compile time
+    const TYPE_NAME: &'static str = core::any::type_name::<T>();
+
+    // 2. Store the actual bytes in a const array (a VALUE, not a reference)
+    const TYPE_NAME_BUF: [u8; 128] = {
+        let bytes = Self::TYPE_NAME.as_bytes();
+        let mut buf = [0u8; 128];
+        let mut i = 0;
+
+        while i < bytes.len() && i < 127 {
+            buf[i] = bytes[i];
+            i += 1;
+        }
+        buf[i] = 0; // The null terminator
+        buf
+    };
+
+    // 3. Take a reference to the array (which promotes it to static memory)
+    const TYPE_NAME_CSTR: &'static crate::str::CStr = {
+        let static_buf: &'static [u8; 128] = &Self::TYPE_NAME_BUF;
+
+        // Find the length up to the null byte
+        let mut len = 0;
+        while len < 128 && static_buf[len] != 0 {
+            len += 1;
+        }
+
+        // SAFETY: `static_buf` is promoted to static memory, and we verified the null byte.
+        unsafe {
+            crate::str::CStr::from_bytes_with_nul_unchecked(core::slice::from_raw_parts(
+                static_buf.as_ptr(),
+                len + 1,
+            ))
+        }
+    };
+
     /// Creates a new [`Devres`] instance of the given `data`.
     ///
     /// The `data` encapsulated within the returned `Devres` instance' `data` will be
@@ -209,9 +245,8 @@ pub fn new<E>(dev: &Device<Bound>, data: impl PinInit<T, E>) -> Result<Self>
                     unsafe {
                         base::devres_set_node_dbginfo(
                             node,
-                            // TODO: Use `core::any::type_name::<T>()` once it is a `const fn`,
-                            // such that we can convert the `&str` to a `&CStr` at compile-time.
-                            c"Devres<T>".as_char_ptr(),
+                            // Injects the statically promoted C-string pointer
+                            Self::TYPE_NAME_CSTR.as_char_ptr(),
                             core::mem::size_of::<Revocable<T>>(),
                         )
                     };
rust/kernel/lib.rs +1 -0
index b72b2fbe046d..d49fd6edd85f 100644
@@ -21,6 +21,7 @@
 //
 // Expected to become stable.
 #![feature(arbitrary_self_types)]
+#![feature(const_type_name)]
 #![feature(derive_coerce_pointee)]
 //
 // To be determined.
Signature · 1 line
2.51.0
#1 lore raw

PATCH v2 1/1 rust: devres: optimize type name allocation and fix truncation

The unconditional 128-byte const array allocation for every unique Devres<T> caused unnecessary .rodata bloat in production builds, and type names exceeding 127 bytes were silently truncated without any indication in debug logs.

Gate the TYPE_NAME, TYPE_NAME_BUF, and TYPE_NAME_CSTR constants behind #[cfg(CONFIG_DEBUG_DEVRES)] so the 128-byte buffer is only allocated when device resource debugging is enabled. For production builds, use crate::c_str!("") as a zero-cost empty C-string fallback.

When the type name is too long to fit in the 127-byte buffer (plus null terminator), the copy routine now appends "..." at the end — copying only the first 124 bytes — to clearly indicate truncation rather than silently dropping trailing characters.

---
 rust/kernel/devres.rs | 55 ++++++++++++++++++++++++++++++++++++++++---
 rust/kernel/lib.rs    |  1 +
 2 files changed, 53 insertions(+), 3 deletions(-)
rust/kernel/devres.rs +52 -3
index 9e5f93aed20c..79cfe7d9a415 100644
@@ -185,6 +185,57 @@ pub(super) unsafe fn devres_node_remove(
 }
 
 impl<T: Send> Devres<T> {
+    #[cfg(CONFIG_DEBUG_DEVRES)]
+    const TYPE_NAME: &'static str = core::any::type_name::<T>();
+
+    #[cfg(CONFIG_DEBUG_DEVRES)]
+    const TYPE_NAME_BUF: [u8; 128] = {
+        let bytes = Self::TYPE_NAME.as_bytes();
+        let mut buf = [0u8; 128];
+        let mut i = 0;
+
+        if bytes.len() > 127 {
+            // Copy exactly 124 bytes, then append '...' to clearly indicate truncation
+            while i < 124 {
+                buf[i] = bytes[i];
+                i += 1;
+            }
+            buf[124] = b'.';
+            buf[125] = b'.';
+            buf[126] = b'.';
+            buf[127] = 0; // Null terminator
+        } else {
+            // Copy normally
+            while i < bytes.len() {
+                buf[i] = bytes[i];
+                i += 1;
+            }
+            buf[i] = 0; // Null terminator
+        }
+        buf
+    };
+
+    #[cfg(CONFIG_DEBUG_DEVRES)]
+    const TYPE_NAME_CSTR: &'static crate::str::CStr = {
+        let static_buf: &'static [u8; 128] = &Self::TYPE_NAME_BUF;
+
+        let mut len = 0;
+        while len < 128 && static_buf[len] != 0 {
+            len += 1;
+        }
+
+        // SAFETY: `static_buf` is promoted to static memory, and we verified the null byte.
+        unsafe {
+            crate::str::CStr::from_bytes_with_nul_unchecked(core::slice::from_raw_parts(
+                static_buf.as_ptr(),
+                len + 1,
+            ))
+        }
+    };
+
+    #[cfg(not(CONFIG_DEBUG_DEVRES))]
+    const TYPE_NAME_CSTR: &'static crate::str::CStr = crate::c_str!("");
+
     /// Creates a new [`Devres`] instance of the given `data`.
     ///
     /// The `data` encapsulated within the returned `Devres` instance' `data` will be
@@ -209,9 +260,7 @@ pub fn new<E>(dev: &Device<Bound>, data: impl PinInit<T, E>) -> Result<Self>
                     unsafe {
                         base::devres_set_node_dbginfo(
                             node,
-                            // TODO: Use `core::any::type_name::<T>()` once it is a `const fn`,
-                            // such that we can convert the `&str` to a `&CStr` at compile-time.
-                            c"Devres<T>".as_char_ptr(),
+                            Self::TYPE_NAME_CSTR.as_char_ptr(),
                             core::mem::size_of::<Revocable<T>>(),
                         )
                     };
rust/kernel/lib.rs +1 -0
index b72b2fbe046d..48df181788f6 100644
@@ -22,6 +22,7 @@
 // Expected to become stable.
 #![feature(arbitrary_self_types)]
 #![feature(derive_coerce_pointee)]
+#![feature(const_type_name)]
 //
 // To be determined.
 #![feature(used_with_arg)]
Signature · 1 line
2.51.0
#2 lore raw

Re: [PATCH v2] rust: devres: optimize type name allocation and fix truncation

Quoted 3 lines · Aary Milind Kinge

The unconditional 128-byte const array allocation for every unique Devres<T> caused unnecessary .rodata bloat in production builds,

Wasn't the string deduplicated?

Quoted 1 line

terminator), the copy routine now appends "..." at the end — copying

Did an LLM assist this patch? If so, please add a tag:

https://docs.kernel.org/process/generated-content.html
https://docs.kernel.org/process/coding-assistants.html

Moreover, this should be sent to the right maintainers and reviewers, e.g. at least to "DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS". Cc'ing them here, but also please Cc all the "RUST" entry.

Quoted 1 line

+ let mut buf = [0u8; 128];

Why is there a hardcoded literal? Please use constants where possible, deriving the rest of the literals from that.

rust/kernel/devres.rs pub(super) unsafe fn devres_node_remove( · line 227

Quoted 6 lines
rust/kernel/devres.rs +6 -0
+        let mut len = 0;
+        while len < 128 && static_buf[len] != 0 {
+            len += 1;
+        }
+
+        // SAFETY: `static_buf` is promoted to static memory, and we verified the null byte.

This should explain why this is all OK, e.g. why it doesn't go out of bounds (a local-only reading of the loop above would appear to make it so).

Or avoid unsafe altogether if possible.

rust/kernel/devres.rs pub(super) unsafe fn devres_node_remove( · line 237

Quoted 2 lines
rust/kernel/devres.rs +2 -0
+    #[cfg(not(CONFIG_DEBUG_DEVRES))]
+    const TYPE_NAME_CSTR: &'static crate::str::CStr = crate::c_str!("");

Is the name not used at all under !CONFIG_DEBUG_DEVRES?

Either way, could we move the other consts inside this one, and remove the cfg here? i.e. reducing the number of conditional items and avoiding to repeat the "signature" of this const.

Quoted 4 lines

// Expected to become stable.
#![feature(arbitrary_self_types)]
#![feature(derive_coerce_pointee)]
+#![feature(const_type_name)]

New features need to be justified in the commit message, with a link to the tracking issue:

https://github.com/rust-lang/rust/issues/63084

In particular, please justify why you think it will become stable. Usually, we need to double-check with upstream that is the case.

Thanks!

Cheers,
Miguel

#3 lore raw

Re: [PATCH v2] rust: devres: optimize type name allocation and fix truncation

Quoted 30 lines · On Tue, 26 May 2026 14:37:44 +0200 Miguel Ojeda…
Quoted 3 lines · Aary Milind Kinge

The unconditional 128-byte const array allocation for every unique Devres<T> caused unnecessary .rodata bloat in production builds,

Wasn't the string deduplicated?

Quoted 1 line

terminator), the copy routine now appends "..." at the end — copying

Did an LLM assist this patch? If so, please add a tag:

https://docs.kernel.org/process/generated-content.html
https://docs.kernel.org/process/coding-assistants.html

Moreover, this should be sent to the right maintainers and reviewers, e.g. at least to "DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS". Cc'ing them here, but also please Cc all the "RUST" entry.

Quoted 1 line

+ let mut buf = [0u8; 128];

Why is there a hardcoded literal? Please use constants where possible, deriving the rest of the literals from that.

rust/kernel/devres.rs pub(super) unsafe fn devres_node_remove( · line 227

Quoted 6 lines
rust/kernel/devres.rs +6 -0
+        let mut len = 0;
+        while len < 128 && static_buf[len] != 0 {
+            len += 1;
+        }
+
+        // SAFETY: `static_buf` is promoted to static memory, and we verified the null byte.  
Quoted 3 lines

This should explain why this is all OK, e.g. why it doesn't go out of bounds (a local-only reading of the loop above would appear to make it so).

I'm no rust expert (or novice) but that code all looks like run-time initialisers rather that the static data you really want.

Can you generate the '\0' terminated C 'string' by including an explicit zero byte in the rust one?

-- David

maintainer
#4 lore raw

Re: [PATCH v2] rust: devres: optimize type name allocation and fix truncation

In reply to Aary Milind Kinge
Quoted 110 lines · Aary Milind Kinge

The unconditional 128-byte const array allocation for every unique Devres<T> caused unnecessary .rodata bloat in production builds, and type names exceeding 127 bytes were silently truncated without any indication in debug logs.

Gate the TYPE_NAME, TYPE_NAME_BUF, and TYPE_NAME_CSTR constants behind #[cfg(CONFIG_DEBUG_DEVRES)] so the 128-byte buffer is only allocated when device resource debugging is enabled. For production builds, use crate::c_str!("") as a zero-cost empty C-string fallback.

When the type name is too long to fit in the 127-byte buffer (plus null terminator), the copy routine now appends "..." at the end — copying only the first 124 bytes — to clearly indicate truncation rather than silently dropping trailing characters.

---
 rust/kernel/devres.rs | 55 ++++++++++++++++++++++++++++++++++++++++---
 rust/kernel/lib.rs    |  1 +
 2 files changed, 53 insertions(+), 3 deletions(-)
rust/kernel/devres.rs +52 -3
index 9e5f93aed20c..79cfe7d9a415 100644
@@ -185,6 +185,57 @@ pub(super) unsafe fn devres_node_remove(
 }
 
 impl<T: Send> Devres<T> {
+    #[cfg(CONFIG_DEBUG_DEVRES)]
+    const TYPE_NAME: &'static str = core::any::type_name::<T>();
+
+    #[cfg(CONFIG_DEBUG_DEVRES)]
+    const TYPE_NAME_BUF: [u8; 128] = {
+        let bytes = Self::TYPE_NAME.as_bytes();
+        let mut buf = [0u8; 128];
+        let mut i = 0;
+
+        if bytes.len() > 127 {
+            // Copy exactly 124 bytes, then append '...' to clearly indicate truncation
+            while i < 124 {
+                buf[i] = bytes[i];
+                i += 1;
+            }
+            buf[124] = b'.';
+            buf[125] = b'.';
+            buf[126] = b'.';
+            buf[127] = 0; // Null terminator
+        } else {
+            // Copy normally
+            while i < bytes.len() {
+                buf[i] = bytes[i];
+                i += 1;
+            }
+            buf[i] = 0; // Null terminator
+        }
+        buf
+    };
+
+    #[cfg(CONFIG_DEBUG_DEVRES)]
+    const TYPE_NAME_CSTR: &'static crate::str::CStr = {
+        let static_buf: &'static [u8; 128] = &Self::TYPE_NAME_BUF;
+
+        let mut len = 0;
+        while len < 128 && static_buf[len] != 0 {
+            len += 1;
+        }
+
+        // SAFETY: `static_buf` is promoted to static memory, and we verified the null byte.
+        unsafe {
+            crate::str::CStr::from_bytes_with_nul_unchecked(core::slice::from_raw_parts(
+                static_buf.as_ptr(),
+                len + 1,
+            ))
+        }
+    };
+
+    #[cfg(not(CONFIG_DEBUG_DEVRES))]
+    const TYPE_NAME_CSTR: &'static crate::str::CStr = crate::c_str!("");
+
     /// Creates a new [`Devres`] instance of the given `data`.
     ///
     /// The `data` encapsulated within the returned `Devres` instance' `data` will be
@@ -209,9 +260,7 @@ pub fn new<E>(dev: &Device<Bound>, data: impl PinInit<T, E>) -> Result<Self>
                     unsafe {
                         base::devres_set_node_dbginfo(
                             node,
-                            // TODO: Use `core::any::type_name::<T>()` once it is a `const fn`,
-                            // such that we can convert the `&str` to a `&CStr` at compile-time.
-                            c"Devres<T>".as_char_ptr(),
+                            Self::TYPE_NAME_CSTR.as_char_ptr(),
                             core::mem::size_of::<Revocable<T>>(),
                         )
                     };
rust/kernel/lib.rs +1 -0
index b72b2fbe046d..48df181788f6 100644
@@ -22,6 +22,7 @@
 // Expected to become stable.
 #![feature(arbitrary_self_types)]
 #![feature(derive_coerce_pointee)]
+#![feature(const_type_name)]
 //
 // To be determined.
 #![feature(used_with_arg)]
Signature · 1 line
2.51.0

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.

You are receiving this message because of the following common error(s) as indicated below:

- This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this.

If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.

thanks,

greg k-h's patch email bot

author
#5 lore raw

Re: [PATCH v2] rust: devres: optimize type name allocation and fix truncation

Quoted 114 lines · Aary Kinge

Hi Miguel,

Quoted 8 lines · Miguel Ojeda
Quoted 3 lines · Aary Milind Kinge

The unconditional 128-byte const array allocation for every unique Devres<T> caused unnecessary .rodata bloat in production builds,

Wasn't the string deduplicated?

You are right. The original string was identical for all T and would be deduplicated by the linker.
I will reword the commit message to focus on the actual improvement: replacing the generic placeholder with the real type name

Quoted 4 lines
Quoted 2 lines

terminator), the copy routine now appends "..." at the end — copying

Did an LLM assist this patch? If so, please add a tag:

Yes. I will add the appropriate tag in v3.

Quoted 8 lines

https://docs.kernel.org/process/generated-content.html
https://docs.kernel.org/process/coding-assistants.html

Moreover, this should be sent to the right maintainers and reviewers, e.g. at least to "DRIVER CORE, KOBJECTS, DEBUGFS AND SYSFS". Cc'ing them here, but also please Cc all the "RUST" entry.

Yes, I will CC the right maintainers.

Quoted 6 lines
Quoted 3 lines

+ let mut buf = [0u8; 128];

Why is there a hardcoded literal? Please use constants where possible, deriving the rest of the literals from that.

I will replace the hardcoded values with derived constants in v3.

Quoted 9 lines

rust/kernel/devres.rs pub(super) unsafe fn devres_node_remove( · line 227

Quoted 8 lines
rust/kernel/devres.rs +6 -0
+        let mut len = 0;
+        while len < 128 && static_buf[len] != 0 {
+            len += 1;
+        }
+
+        // SAFETY: `static_buf` is promoted to static memory, and we verified the null byte.
Quoted 3 lines

This should explain why this is all OK, e.g. why it doesn't go out of bounds (a local-only reading of the loop above would appear to make it so).

Understood. I will improve the SAFETY comment and see if the unsafe can be avoided entirely.

Quoted 4 lines

Or avoid unsafe altogether if possible.

Quoted 8 lines

rust/kernel/devres.rs pub(super) unsafe fn devres_node_remove( · line 237

Quoted 2 lines
rust/kernel/devres.rs +2 -0
+    #[cfg(not(CONFIG_DEBUG_DEVRES))]
+    const TYPE_NAME_CSTR: &'static crate::str::CStr = crate::c_str!("");

Is the name not used at all under !CONFIG_DEBUG_DEVRES?

Either way, could we move the other consts inside this one, and remove the cfg here? i.e. reducing the number of conditional items and avoiding to repeat the "signature" of this const.

Yes, I will restructure this in v3.

I dug into this and it turns out it is used. The naming is misleading — devres_set_node_dbginfo() stores node->name unconditionally, and the trace_devres_log() tracepoint in drivers/base/trace.h records it unconditionally too. The only thing gated behind CONFIG_DEBUG_DEVRES is the devres_dbg() printk, not the tracepoint.

So if I gate the real type name behind CONFIG_DEBUG_DEVRES, the devres tracepoints show an empty string in production traces for every Rust Devres<T> — which is worse than the generic "Devres<T>" placeholder we had before. The correct approach is to just always provide the real type name. The overhead is negligible (a single const array per monomorphization of Devres<T>).

That means I should drop the #[cfg] gating entirely on TYPE_NAME_CSTR and remove the #[cfg(not(CONFIG_DEBUG_DEVRES))] empty-string branch. Thoughts?

Quoted 7 lines
Quoted 6 lines

// Expected to become stable.
#![feature(arbitrary_self_types)]
#![feature(derive_coerce_pointee)]
+#![feature(const_type_name)]

Quoted 7 lines

New features need to be justified in the commit message, with a link to the tracking issue:

https://github.com/rust-lang/rust/issues/63084

In particular, please justify why you think it will become stable. Usually, we need to double-check with upstream that is the case.

I will update the commit message to justify the feature usage and add the tracking issue link, without making claims about stabilization.

Quoted 6 lines

Thanks!

Cheers,
Miguel

Aary

Quoted 140 lines · Greg KH
Quoted 107 lines · Aary Milind Kinge

The unconditional 128-byte const array allocation for every unique Devres<T> caused unnecessary .rodata bloat in production builds, and type names exceeding 127 bytes were silently truncated without any indication in debug logs.

Gate the TYPE_NAME, TYPE_NAME_BUF, and TYPE_NAME_CSTR constants behind #[cfg(CONFIG_DEBUG_DEVRES)] so the 128-byte buffer is only allocated when device resource debugging is enabled. For production builds, use crate::c_str!("") as a zero-cost empty C-string fallback.

When the type name is too long to fit in the 127-byte buffer (plus null terminator), the copy routine now appends "..." at the end — copying only the first 124 bytes — to clearly indicate truncation rather than silently dropping trailing characters.

---
 rust/kernel/devres.rs | 55 ++++++++++++++++++++++++++++++++++++++++---
 rust/kernel/lib.rs    |  1 +
 2 files changed, 53 insertions(+), 3 deletions(-)
rust/kernel/devres.rs +52 -3
index 9e5f93aed20c..79cfe7d9a415 100644
@@ -185,6 +185,57 @@ pub(super) unsafe fn devres_node_remove(
 }
 
 impl<T: Send> Devres<T> {
+    #[cfg(CONFIG_DEBUG_DEVRES)]
+    const TYPE_NAME: &'static str = core::any::type_name::<T>();
+
+    #[cfg(CONFIG_DEBUG_DEVRES)]
+    const TYPE_NAME_BUF: [u8; 128] = {
+        let bytes = Self::TYPE_NAME.as_bytes();
+        let mut buf = [0u8; 128];
+        let mut i = 0;
+
+        if bytes.len() > 127 {
+            // Copy exactly 124 bytes, then append '...' to clearly indicate truncation
+            while i < 124 {
+                buf[i] = bytes[i];
+                i += 1;
+            }
+            buf[124] = b'.';
+            buf[125] = b'.';
+            buf[126] = b'.';
+            buf[127] = 0; // Null terminator
+        } else {
+            // Copy normally
+            while i < bytes.len() {
+                buf[i] = bytes[i];
+                i += 1;
+            }
+            buf[i] = 0; // Null terminator
+        }
+        buf
+    };
+
+    #[cfg(CONFIG_DEBUG_DEVRES)]
+    const TYPE_NAME_CSTR: &'static crate::str::CStr = {
+        let static_buf: &'static [u8; 128] = &Self::TYPE_NAME_BUF;
+
+        let mut len = 0;
+        while len < 128 && static_buf[len] != 0 {
+            len += 1;
+        }
+
+        // SAFETY: `static_buf` is promoted to static memory, and we verified the null byte.
+        unsafe {
+            crate::str::CStr::from_bytes_with_nul_unchecked(core::slice::from_raw_parts(
+                static_buf.as_ptr(),
+                len + 1,
+            ))
+        }
+    };
+
+    #[cfg(not(CONFIG_DEBUG_DEVRES))]
+    const TYPE_NAME_CSTR: &'static crate::str::CStr = crate::c_str!("");
+
     /// Creates a new [`Devres`] instance of the given `data`.
     ///
     /// The `data` encapsulated within the returned `Devres` instance' `data` will be
@@ -209,9 +260,7 @@ pub fn new<E>(dev: &Device<Bound>, data: impl PinInit<T, E>) -> Result<Self>
                     unsafe {
                         base::devres_set_node_dbginfo(
                             node,
-                            // TODO: Use `core::any::type_name::<T>()` once it is a `const fn`,
-                            // such that we can convert the `&str` to a `&CStr` at compile-time.
-                            c"Devres<T>".as_char_ptr(),
+                            Self::TYPE_NAME_CSTR.as_char_ptr(),
                             core::mem::size_of::<Revocable<T>>(),
                         )
                     };
rust/kernel/lib.rs +1 -1
index b72b2fbe046d..48df181788f6 100644
@@ -22,6 +22,7 @@
 // Expected to become stable.
 #![feature(arbitrary_self_types)]
 #![feature(derive_coerce_pointee)]
+#![feature(const_type_name)]
 //
 // To be determined.
 #![feature(used_with_arg)]
--
Quoted 3 lines

2.51.0

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.

You are receiving this message because of the following common error(s) as indicated below:

- This looks like a new version of a previously submitted patch, but you did not list below the --- line any changes from the previous version. Please read the section entitled "The canonical patch format" in the kernel file, Documentation/process/submitting-patches.rst for what needs to be done here to properly describe this.

If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.

thanks,

greg k-h's patch email bot

reviewer
#6 lore raw
In reply to Aary Milind Kinge
Quoted 10 lines · Aary Milind Kinge

From: Not-Buddy <[email protected]>

The devres_set_node_dbginfo function previously used a hardcoded c"Devres<T>" string for all device resource nodes because core::any::type_name was not stabilized as a const fn. This made debugging device resources difficult as all nodes shared the same name.

Enable the const_type_name unstable feature in the kernel crate and replace the hardcoded placeholder with the actual generic type name at compile time.

NACK. The feature is not stable on latest rustc and is unclear that it is planned to be stabilised, so we cannot just enable and use it.

If you want to enable this feature for kernel, you should first try to help moving the stabilization forward on the Rust side.

Thanks,
Gary

Quoted 11 lines

To satisfy the C-API's requirement for a null-terminated string, the bytes are copied into a locally evaluated const array buffer, appended with a null byte, and promoted to static read-only memory by reference before being passed to devres_set_node_dbginfo.

---
 rust/kernel/devres.rs | 41 ++++++++++++++++++++++++++++++++++++++---
 rust/kernel/lib.rs    |  1 +
 2 files changed, 39 insertions(+), 3 deletions(-)
#7 lore raw
Quoted 6 lines · Gary Guo

NACK. The feature is not stable on latest rustc and is unclear that it is planned to be stabilised, so we cannot just enable and use it.

If you want to enable this feature for kernel, you should first try to help moving the stabilization forward on the Rust side.

Yeah, I requested the justification -- there was a v2 here where I left other feedback too in case you are interested:

https://lore.kernel.org/rust-for-linux/[email protected]/

Cheers,
Miguel