mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Ballance <andrewjballance@gmail.com>
To: Alice Ryhl <aliceryhl@google.com>
Cc: jbaron@akamai.com, jim.cromie@gmail.com,
	daniel.almeida@collabora.com, acourbot@nvidia.com,
	ojeda@kernel.org, alex.gaynor@gmail.com, boqun.feng@gmail.com,
	gary@garyguo.net, bjorn3_gh@protonmail.com, lossin@kernel.org,
	a.hindborg@kernel.org, tmgross@umich.edu, dakr@kernel.org,
	gregkh@linuxfoundation.org, rafael@kernel.org,
	rostedt@goodmis.org, viresh.kumar@linaro.org,
	lina+kernel@asahilina.net, tamird@gmail.com, jubalh@iodoru.org,
	rust-for-linux@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [RFC PATCH 2/3] rust: device add support for dynamic debug to pr_debug!
Date: Wed, 11 Jun 2025 23:02:45 -0500	[thread overview]
Message-ID: <2c9504c3-2498-4b59-8e26-0911a8be8e96@gmail.com> (raw)
In-Reply-To: <CAH5fLggTL9Ej8rcakd-gDz+h0dZhA1PRzxf+76EjxotOBJW7fg@mail.gmail.com>

On 6/11/25 4:38 PM, Alice Ryhl wrote:
> Please define a STATIC_KEY_INIT_FALSE constant in
> rust/kernel/jump_label.rs and refer to it. You can use mem::zeroed()
> in the definition of the constant.

Will do for the v2.

> No, we can't use mutable references like this. In Rust, the real
> meaning of &mut is exclusive, not mutable. (And the real meaning of &
> is shared.) We don't have exclusive access to the DEBUG_INFO static
> here - the access is shared, so we must use &_ references instead of
> &mut _ references here.
> 
> Note that by using Opaque, it's possible to mutate the value even if
> it's behind a &_ reference.
> #[repr(transparent)]
> pub struct _Ddebug {
>      pub inner: Opaque<bindings::_ddebug>,
> }
> and then you can do DEBUG_INFO.inner.get() to obtain a mutable raw
> pointer to the contents.
> 

Unfortunately, static_branch_unlikely does not work with keys contained
within a Opaque, because it uses offset_of and sym. I can create a macro
specifically for dealing with Opaque::<type_that_contains_a_static_key>
because I imagine that many uses of static branch will end up wrapped
in an Opaque.

Best regards,
Andrew Ballance

  reply	other threads:[~2025-06-12  4:02 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-11 20:29 [RFC PATCH 0/3] rust: add suppord for dynamic debug Andrew Ballance
2025-06-11 20:29 ` [RFC PATCH 1/3] rust: static jump: add support for nested arguments Andrew Ballance
2025-06-11 21:32   ` Alice Ryhl
2025-06-11 20:29 ` [RFC PATCH 2/3] rust: device add support for dynamic debug to pr_debug! Andrew Ballance
2025-06-11 21:38   ` Alice Ryhl
2025-06-12  4:02     ` Andrew Ballance [this message]
2025-06-12  7:17       ` Alice Ryhl
2025-06-11 20:29 ` [RFC PATCH 3/3] rust: device add support for dynamic debug to dev_dbg! Andrew Ballance
2025-06-11 20:36 ` [RFC PATCH 0/3] rust: add suppord for dynamic debug Andrew Ballance

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=2c9504c3-2498-4b59-8e26-0911a8be8e96@gmail.com \
    --to=andrewjballance@gmail.com \
    --cc=a.hindborg@kernel.org \
    --cc=acourbot@nvidia.com \
    --cc=alex.gaynor@gmail.com \
    --cc=aliceryhl@google.com \
    --cc=bjorn3_gh@protonmail.com \
    --cc=boqun.feng@gmail.com \
    --cc=dakr@kernel.org \
    --cc=daniel.almeida@collabora.com \
    --cc=gary@garyguo.net \
    --cc=gregkh@linuxfoundation.org \
    --cc=jbaron@akamai.com \
    --cc=jim.cromie@gmail.com \
    --cc=jubalh@iodoru.org \
    --cc=lina+kernel@asahilina.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lossin@kernel.org \
    --cc=ojeda@kernel.org \
    --cc=rafael@kernel.org \
    --cc=rostedt@goodmis.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tamird@gmail.com \
    --cc=tmgross@umich.edu \
    --cc=viresh.kumar@linaro.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

all inboxes | Powered by JetHome®