On Wed, May 08, 2024 at 08:38:06PM +0300, Dan Carpenter wrote:
> On Wed, May 08, 2024 at 10:32:43AM -0700, Paul E. McKenney wrote:
> > 
> > Agreed, and please see below for the proposed cleanup in this case.
> > 
> >                                                     Thanx, Paul
> 
> Thanks!  Did you see the other warning I mentioned?
> 
>     kernel/rcu/srcutree.c:910 srcu_gp_end()
>     warn: mixing irq and irqsave

I did, but then I promptly forgot about it.  Thank you for the reminder.

> Btw, I'm mostly sending you these because I know you're interested in
> these sorts of cleanups.  I didn't bother sending one to aacraid people,
> for example.  :P

Maintainer's choice!  ;-)

How about the following?

                                                        Thanx, Paul

------------------------------------------------------------------------

commit 75a3b18f319a1f06df94cfeef81d7dd6a38cd59b
Author: Paul E. McKenney <[email protected]>
Date:   Wed May 8 16:47:16 2024 -0700

    srcu: Disable interrupts directly in srcu_gp_end()
    
    Interrupts are enabled in srcu_gp_end(), so this commit switches from
    spin_lock_irqsave_rcu_node() and spin_unlock_irqrestore_rcu_node()
    to spin_lock_irq_rcu_node() and spin_unlock_irq_rcu_node().
    
    Link: 
https://lore.kernel.org/all/[email protected]/
    
    Reported-by: Dan Carpenter <[email protected]>
    Signed-off-by: Paul E. McKenney <[email protected]>

diff --git a/kernel/rcu/srcutree.c b/kernel/rcu/srcutree.c
index 98f79ba01b0af..9a8b7ecd2ff45 100644
--- a/kernel/rcu/srcutree.c
+++ b/kernel/rcu/srcutree.c
@@ -846,7 +846,6 @@ static void srcu_gp_end(struct srcu_struct *ssp)
        bool cbs;
        bool last_lvl;
        int cpu;
-       unsigned long flags;
        unsigned long gpseq;
        int idx;
        unsigned long mask;
@@ -908,12 +907,12 @@ static void srcu_gp_end(struct srcu_struct *ssp)
        if (!(gpseq & counter_wrap_check))
                for_each_possible_cpu(cpu) {
                        sdp = per_cpu_ptr(ssp->sda, cpu);
-                       spin_lock_irqsave_rcu_node(sdp, flags);
+                       spin_lock_irq_rcu_node(sdp);
                        if (ULONG_CMP_GE(gpseq, sdp->srcu_gp_seq_needed + 100))
                                sdp->srcu_gp_seq_needed = gpseq;
                        if (ULONG_CMP_GE(gpseq, sdp->srcu_gp_seq_needed_exp + 
100))
                                sdp->srcu_gp_seq_needed_exp = gpseq;
-                       spin_unlock_irqrestore_rcu_node(sdp, flags);
+                       spin_unlock_irq_rcu_node(sdp);
                }
 
        /* Callback initiation done, allow grace periods after next. */

Reply via email to