Patch "rust: mutex: fix __mutex_init() usage in case of PREEMPT_RT" has been added to the 6.11-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    rust: mutex: fix __mutex_init() usage in case of PREEMPT_RT

to the 6.11-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     rust-mutex-fix-__mutex_init-usage-in-case-of-preempt.patch
and it can be found in the queue-6.11 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit b02ff80e55d1439c24dd1b86b5797f02ebac190d
Author: Dirk Behme <dirk.behme@xxxxxxxxxxxx>
Date:   Mon Sep 16 09:37:52 2024 +0200

    rust: mutex: fix __mutex_init() usage in case of PREEMPT_RT
    
    [ Upstream commit d065cc76054d21e48a839a2a19ba99dbc51a4d11 ]
    
    In case CONFIG_PREEMPT_RT is enabled __mutex_init() becomes a macro
    instead of an extern function (simplified from
    include/linux/mutex.h):
    
        #ifndef CONFIG_PREEMPT_RT
        extern void __mutex_init(struct mutex *lock, const char *name,
                             struct lock_class_key *key);
        #else
        #define __mutex_init(mutex, name, key)              \
        do {                                                \
            rt_mutex_base_init(&(mutex)->rtmutex);          \
            __mutex_rt_init((mutex), name, key);            \
        } while (0)
        #endif
    
    The macro isn't resolved by bindgen, then. What results in a build
    error:
    
    error[E0425]: cannot find function `__mutex_init` in crate `bindings`
         --> rust/kernel/sync/lock/mutex.rs:104:28
          |
    104   |           unsafe { bindings::__mutex_init(ptr, name, key) }
          |                              ^^^^^^^^^^^^ help: a function with a similar name exists: `__mutex_rt_init`
          |
         ::: rust/bindings/bindings_generated.rs:23722:5
          |
    23722 | /     pub fn __mutex_rt_init(
    23723 | |         lock: *mut mutex,
    23724 | |         name: *const core::ffi::c_char,
    23725 | |         key: *mut lock_class_key,
    23726 | |     );
          | |_____- similarly named function `__mutex_rt_init` defined here
    
    Fix this by adding a helper.
    
    As explained by Gary Guo in [1] no #ifdef CONFIG_PREEMPT_RT
    is needed here as rust/bindings/lib.rs prefers externed function to
    helpers if an externed function exists.
    
    Reported-by: Conor Dooley <conor@xxxxxxxxxx>
    Link: https://lore.kernel.org/rust-for-linux/20240913-shack-estate-b376a65921b1@spud/
    Link: https://lore.kernel.org/rust-for-linux/20240915123626.1a170103.gary@xxxxxxxxxxx/ [1]
    Fixes: 6d20d629c6d8 ("rust: lock: introduce `Mutex`")
    Signed-off-by: Dirk Behme <dirk.behme@xxxxxxxxxxxx>
    Tested-by: Conor Dooley <conor.dooley@xxxxxxxxxxxxx>
    Reviewed-by: Gary Guo <gary@xxxxxxxxxxx>
    Link: https://lore.kernel.org/r/20240916073752.3123484-1-dirk.behme@xxxxxxxxxxxx
    [ Reworded to include the proper example by Dirk. - Miguel ]
    Signed-off-by: Miguel Ojeda <ojeda@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/rust/helpers/mutex.c b/rust/helpers/mutex.c
index 200db7e6279f0..a17ca8cdb50ca 100644
--- a/rust/helpers/mutex.c
+++ b/rust/helpers/mutex.c
@@ -7,3 +7,9 @@ void rust_helper_mutex_lock(struct mutex *lock)
 {
 	mutex_lock(lock);
 }
+
+void rust_helper___mutex_init(struct mutex *mutex, const char *name,
+			      struct lock_class_key *key)
+{
+	__mutex_init(mutex, name, key);
+}




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux