rust/kernel/debugfs/traits.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Since we are going to make `Mutex<T>` structurally pin the data (i.e.
`T`), therefore `.lock()` function only returns a `Guard` that can
dereference a mutable reference to `T` if only `T` is `Unpin`, therefore
restrict the impl `Reader` block of `Mutex<T>` to that.
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
---
rust/kernel/debugfs/traits.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/debugfs/traits.rs b/rust/kernel/debugfs/traits.rs
index ab009eb254b3..ba7ec5a900b8 100644
--- a/rust/kernel/debugfs/traits.rs
+++ b/rust/kernel/debugfs/traits.rs
@@ -50,7 +50,7 @@ pub trait Reader {
fn read_from_slice(&self, reader: &mut UserSliceReader) -> Result;
}
-impl<T: FromStr> Reader for Mutex<T> {
+impl<T: FromStr + Unpin> Reader for Mutex<T> {
fn read_from_slice(&self, reader: &mut UserSliceReader) -> Result {
let mut buf = [0u8; 128];
if reader.len() > buf.len() {
--
2.51.0
On 10/22/25 5:42 AM, Boqun Feng wrote: > Since we are going to make `Mutex<T>` structurally pin the data (i.e. > `T`), therefore `.lock()` function only returns a `Guard` that can > dereference a mutable reference to `T` if only `T` is `Unpin`, therefore > restrict the impl `Reader` block of `Mutex<T>` to that. > > Signed-off-by: Boqun Feng <boqun.feng@gmail.com> I assume this can go through the driver-core tree, since it's only about a conflict in linux-next?
On 10/22/25 11:07 AM, Danilo Krummrich wrote: > On 10/22/25 5:42 AM, Boqun Feng wrote: >> Since we are going to make `Mutex<T>` structurally pin the data (i.e. >> `T`), therefore `.lock()` function only returns a `Guard` that can >> dereference a mutable reference to `T` if only `T` is `Unpin`, therefore >> restrict the impl `Reader` block of `Mutex<T>` to that. >> >> Signed-off-by: Boqun Feng <boqun.feng@gmail.com> > > I assume this can go through the driver-core tree, since it's only about a > conflict in linux-next? Sorry, I confused this, obviously your tree is broken without this change, please feel free to take it. Acked-by: Danilo Krummrich <dakr@kernel.org>
The following commit has been merged into the locking/core branch of tip:
Commit-ID: 37d0472c8ac441af8bc10fc4959ad9d62dd5fa4c
Gitweb: https://git.kernel.org/tip/37d0472c8ac441af8bc10fc4959ad9d62dd5fa4c
Author: Boqun Feng <boqun.feng@gmail.com>
AuthorDate: Tue, 21 Oct 2025 23:42:37 -04:00
Committer: Peter Zijlstra <peterz@infradead.org>
CommitterDate: Wed, 22 Oct 2025 15:21:51 +02:00
rust: debugfs: Implement Reader for Mutex<T> only when T is Unpin
Since we are going to make `Mutex<T>` structurally pin the data (i.e.
`T`), therefore `.lock()` function only returns a `Guard` that can
dereference a mutable reference to `T` if only `T` is `Unpin`, therefore
restrict the impl `Reader` block of `Mutex<T>` to that.
Signed-off-by: Boqun Feng <boqun.feng@gmail.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/20251022034237.70431-1-boqun.feng@gmail.com
---
rust/kernel/debugfs/traits.rs | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/rust/kernel/debugfs/traits.rs b/rust/kernel/debugfs/traits.rs
index ab009eb..ba7ec5a 100644
--- a/rust/kernel/debugfs/traits.rs
+++ b/rust/kernel/debugfs/traits.rs
@@ -50,7 +50,7 @@ pub trait Reader {
fn read_from_slice(&self, reader: &mut UserSliceReader) -> Result;
}
-impl<T: FromStr> Reader for Mutex<T> {
+impl<T: FromStr + Unpin> Reader for Mutex<T> {
fn read_from_slice(&self, reader: &mut UserSliceReader) -> Result {
let mut buf = [0u8; 128];
if reader.len() > buf.len() {
© 2016 - 2026 Red Hat, Inc.