All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gary Guo <gary@garyguo.net>
To: Boqun Feng <boqun.feng@gmail.com>
Cc: Filipe Xavier <felipe_life@live.com>,
	aliceryhl@google.com, ojeda@kernel.org, benno.lossin@proton.me,
	rust-for-linux@vger.kernel.org
Subject: Re: [PATCH] rust: add trylock method support for lock backend
Date: Sun, 15 Sep 2024 13:16:51 +0100	[thread overview]
Message-ID: <20240915131651.02a5df84.gary@garyguo.net> (raw)
In-Reply-To: <ZuZyIRaGHxGMGUid@boqun-archlinux>

On Sat, 14 Sep 2024 22:35:29 -0700
Boqun Feng <boqun.feng@gmail.com> wrote:

> > diff --git a/rust/helpers/spinlock.c b/rust/helpers/spinlock.c
> > index acc1376b833c..775ed4d549ae 100644
> > --- a/rust/helpers/spinlock.c
> > +++ b/rust/helpers/spinlock.c
> > @@ -22,3 +22,8 @@ void rust_helper_spin_unlock(spinlock_t *lock)
> >  {
> >  	spin_unlock(lock);
> >  }
> > +
> > +int rust_helper_spin_trylock(spinlock_t *lock)  
> 
> I'd just change this to `boolean`, but I don't whether it affects
> LTO-inlining, Gary?
> 

I don't see why it would affect LTO inlining. The additional cast
should be easily optimized away.

However I'd be wary of the signature going out-of-sync compared to rest
of C. If we later use bindgen's automatic helper generation or if the C
side made spin_trylock an externed function, then we would have issue
(compilation issue, but still...)

I think we should stick with `int` unless we change the signature of the
static inline functionn to also return `bool`.

Best,
Gary


> > +{
> > +	return spin_trylock(lock);
> > +}

  parent reply	other threads:[~2024-09-15 12:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-14 14:00 [PATCH] rust: add trylock method support for lock backend Filipe Xavier
2024-09-15  5:35 ` Boqun Feng
2024-09-15  8:08   ` Alice Ryhl
2024-09-15 12:16   ` Gary Guo [this message]
2024-09-15 17:32     ` 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=20240915131651.02a5df84.gary@garyguo.net \
    --to=gary@garyguo.net \
    --cc=aliceryhl@google.com \
    --cc=benno.lossin@proton.me \
    --cc=boqun.feng@gmail.com \
    --cc=felipe_life@live.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.