rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guangbo Cui <2407018371@qq.com>
To: lyude@redhat.com
Cc: boqun.feng@gmail.com, linux-kernel@vger.kernel.org,
	longman@redhat.com, mingo@redhat.com, peterz@infradead.org,
	rust-for-linux@vger.kernel.org, tglx@linutronix.de,
	will@kernel.org
Subject: Re: [PATCH v9 9/9] locking: Switch to _irq_{disable,enable}() variants in cleanup guards
Date: Sat, 5 Apr 2025 16:55:06 +0800	[thread overview]
Message-ID: <tencent_D533AC8B48B52FF3359EE89ACC69D32FDA09@qq.com> (raw)
In-Reply-To: <tencent_6257D365DB7BACED49A32ED535ACE884CD09@qq.com>

On Sat, Apr 05, 2025 at 04:25:11PM +0800, Guangbo Cui wrote:
> >  include/linux/spinlock.h | 26 ++++++++++++--------------
> >  1 file changed, 12 insertions(+), 14 deletions(-)
> > 
> > diff --git a/include/linux/spinlock.h b/include/linux/spinlock.h
> > index 897114d60cfd4..764c9fd797d0e 100644
> > --- a/include/linux/spinlock.h
> > +++ b/include/linux/spinlock.h
> > @@ -605,18 +605,17 @@ DEFINE_LOCK_GUARD_1(raw_spinlock_nested, raw_spinlock_t,
> >  		      raw_spin_unlock(_T->lock))
> >  
> >  DEFINE_LOCK_GUARD_1(raw_spinlock_irq, raw_spinlock_t,
> > -		      raw_spin_lock_irq(_T->lock),
> > -		      raw_spin_unlock_irq(_T->lock))
> > +		      raw_spin_lock_irq_disable(_T->lock),
> > +		      raw_spin_unlock_irq_enable(_T->lock))
> >  
> > -DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irq, _try, raw_spin_trylock_irq(_T->lock))
> > +DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irq, _try, raw_spin_trylock_irq_disable(_T->lock))
> >  
> >  DEFINE_LOCK_GUARD_1(raw_spinlock_irqsave, raw_spinlock_t,
> > -		      raw_spin_lock_irqsave(_T->lock, _T->flags),
> > -		      raw_spin_unlock_irqrestore(_T->lock, _T->flags),
> > -		      unsigned long flags)
> > +		      raw_spin_lock_irq_disable(_T->lock),
> > +		      raw_spin_unlock_irq_enable(_T->lock))
> >  
> >  DEFINE_LOCK_GUARD_1_COND(raw_spinlock_irqsave, _try,
> > -			   raw_spin_trylock_irqsave(_T->lock, _T->flags))
> > +			   raw_spin_trylock_irq_disable(_T->lock))
> 
> It seems that the `raw_spin_trylock_irq_disable` function is missing from
> spinlock_rt.h, which will lead to a build failure when compiling with 
> PREEMPT_RT enabled.
>

Sorry, my fault, I mean the `spin_trylock_irq_disable` function.

> DEFINE_LOCK_GUARD_1_COND(spinlock_irq, _try,
> 			   spin_trylock_irq_disable(_T->lock))
> 
> DEFINE_LOCK_GUARD_1_COND(spinlock_irqsave, _try,
>			   spin_trylock_irq_disable(_T->lock))

Not sure if I wrote it correctly, but you know what I mean.

diff --git a/include/linux/spinlock_rt.h b/include/linux/spinlock_rt.h
index 6ea08fafa6d7..4a65da35b211 100644
--- a/include/linux/spinlock_rt.h
+++ b/include/linux/spinlock_rt.h
@@ -151,6 +151,11 @@ static __always_inline void spin_unlock_irqrestore(spinlock_t *lock,
 	__locked;					\
 })
 
+static __always_inline int spin_trylock_irq_disable(spinlock_t *lock)
+{
+	return rt_spin_trylock(lock);
+}
+
 #define spin_is_contended(lock)		(((void)(lock), 0))
 
 static inline int spin_is_locked(spinlock_t *lock)
-- 

Best regards,
Guangbo Cui


      reply	other threads:[~2025-04-05  8:55 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-27 22:10 [PATCH v9 0/9] Refcounted interrupts, SpinLockIrq for rust Lyude Paul
2025-02-27 22:10 ` [PATCH v9 1/9] preempt: Introduce HARDIRQ_DISABLE_BITS Lyude Paul
2025-02-27 23:09   ` Steven Rostedt
2025-02-28  1:33     ` Boqun Feng
2025-03-03 21:55       ` Lyude Paul
2025-02-28  7:57   ` Peter Zijlstra
2025-02-27 22:10 ` [PATCH v9 2/9] preempt: Introduce __preempt_count_{sub, add}_return() Lyude Paul
2025-02-28  1:49   ` Boqun Feng
2025-02-28  9:15   ` Heiko Carstens
2025-02-28  9:24     ` Peter Zijlstra
2025-04-30 21:38     ` Lyude Paul
2025-05-05  9:56       ` Heiko Carstens
2025-03-01 18:49   ` kernel test robot
2025-03-01 19:00   ` kernel test robot
2025-02-27 22:10 ` [PATCH v9 3/9] irq & spin_lock: Add counted interrupt disabling/enabling Lyude Paul
2025-03-01 20:19   ` kernel test robot
2025-02-27 22:10 ` [PATCH v9 4/9] rust: Introduce interrupt module Lyude Paul
2025-03-02 16:56   ` Dirk Behme
2025-02-27 22:10 ` [PATCH v9 5/9] rust: helper: Add spin_{un,}lock_irq_{enable,disable}() helpers Lyude Paul
2025-02-27 22:10 ` [PATCH v9 6/9] rust: sync: Add SpinLockIrq Lyude Paul
2025-03-02 11:51   ` Guangbo Cui
2025-03-03 22:15     ` Lyude Paul
2025-03-02 17:07   ` Dirk Behme
2025-04-04 21:56     ` Lyude Paul
2025-02-27 22:10 ` [PATCH v9 7/9] rust: sync: Introduce lock::Backend::Context Lyude Paul
2025-03-03 14:22   ` Dirk Behme
2025-02-27 22:10 ` [PATCH v9 8/9] rust: sync: lock: Add `Backend::BackendInContext` Lyude Paul
2025-03-03 14:23   ` Dirk Behme
2025-02-27 22:10 ` [PATCH v9 9/9] locking: Switch to _irq_{disable,enable}() variants in cleanup guards Lyude Paul
2025-04-05  8:25   ` Guangbo Cui
2025-04-05  8:55     ` Guangbo Cui [this message]

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=tencent_D533AC8B48B52FF3359EE89ACC69D32FDA09@qq.com \
    --to=2407018371@qq.com \
    --cc=boqun.feng@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=lyude@redhat.com \
    --cc=mingo@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rust-for-linux@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=will@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).