rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Conor Dooley <conor@kernel.org>
To: Dirk Behme <dirk.behme@de.bosch.com>
Cc: rust-for-linux@vger.kernel.org, Gary Guo <gary@garyguo.net>,
	Miguel Ojeda <ojeda@kernel.org>
Subject: Re: [PATCH] rust: mutex: fix __mutex_init() usage in case of PREEMPT_RT
Date: Mon, 16 Sep 2024 18:57:44 +0100	[thread overview]
Message-ID: <20240916-geometry-busboy-69d298979a8c@spud> (raw)
In-Reply-To: <20240916073752.3123484-1-dirk.behme@de.bosch.com>

[-- Attachment #1: Type: text/plain, Size: 2003 bytes --]

On Mon, Sep 16, 2024 at 09:37:52AM +0200, Dirk Behme wrote:
> In case CONFIG_PREEMPT_RT is enabled __mutex_init() becomes a macro
> instead of an extern function (simplified from
> include/linux/mutex.h):
> 
> extern void __mutex_init(struct mutex *lock, const char *name,
> 			 struct lock_class_key *key);
> do {							\
> 	rt_mutex_base_init(&(mutex)->rtmutex);		\
> 	__mutex_rt_init((mutex), name, key);		\
> } while (0)
> 
> 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@kernel.org>

Welp, once I turned off the 7 or so lock debugging config options again,
it does seem that this patch has solved the PREEMPT_RT related build
breakage - thanks.
Tested-by: Conor Dooley <conor.dooley@microchip.com>

Cheers,
Conor.

> Link: https://lore.kernel.org/rust-for-linux/20240913-shack-estate-b376a65921b1@spud/
> Link: https://lore.kernel.org/rust-for-linux/20240915123626.1a170103.gary@garyguo.net/ [1]
> Fixes: 6d20d629c6d8 ("rust: lock: introduce `Mutex`")
> Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2024-09-16 17:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-16  7:37 [PATCH] rust: mutex: fix __mutex_init() usage in case of PREEMPT_RT Dirk Behme
2024-09-16 17:57 ` Conor Dooley [this message]
2024-09-16 19:28 ` Gary Guo
2024-09-17  4:54   ` Dirk Behme
2024-09-26 21:18 ` Miguel Ojeda

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=20240916-geometry-busboy-69d298979a8c@spud \
    --to=conor@kernel.org \
    --cc=dirk.behme@de.bosch.com \
    --cc=gary@garyguo.net \
    --cc=ojeda@kernel.org \
    --cc=rust-for-linux@vger.kernel.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;
as well as URLs for NNTP newsgroup(s).