Subject: Re: linux-next: Signed-off-by missing for commit in the rcu tree

From: "Paul E. McKenney" <[email-masked]>
Date: Wed, 18 Nov 2020 15:40:49 -0800

On Mon, Sep 28, 2020 at 10:33:13AM -0700, Paul E. McKenney wrote:
> On Mon, Sep 28, 2020 at 09:57:29AM +0200, Peter Zijlstra wrote:
> > On Thu, Sep 17, 2020 at 11:00:05AM -0700, Paul E. McKenney wrote:
> > > On Thu, Sep 17, 2020 at 01:26:52PM +1000, Stephen Rothwell wrote:
> > > > Hi all,
> > > > 
> > > > Commit
> > > > 
> > > >   903c5302fa2d ("sched/core: Allow try_invoke_on_locked_down_task() with irqs disabled")
> > > > 
> > > > is missing a Signed-off-by from its author and committer.
> > > > 
> > > > I didn't complain about this when it was first present because I figured
> > > > it was just a debugging commit that would be removed quickly.  However,
> > > > there are now quite a few follow up commits ...
> > > 
> > > Without Peter's Signed-off-by, I clearly won't be submitting it to the
> > > upcoming merge window.
> > > 
> > > Peter, this is now quite close to your original patch.  May I please
> > > add your Signed-off-by?
> > 
> > Sure!
> 
> Much appreciated!!!
> 
> But I already replaced that commit with one that moves the call to
> try_invoke_on_locked_down_task() an interrupts-enabled region of code.
> Which is probably what I should have done to start with...  :-/

Except that Marco Elver is making that fail, so I am resuscitating your
patch with your Signed-off-by, as shown below.

So once again, much appreciated!!!

							Thanx, Paul

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

commit 444ef3bbd0f243b912fdfd51f326704f8ee872bf
Author: Peter Zijlstra <[email-masked]>
Date:   Sat Aug 29 10:22:24 2020 -0700

    sched/core: Allow try_invoke_on_locked_down_task() with irqs disabled
    
    The try_invoke_on_locked_down_task() function currently requires
    that interrupts be enabled, but it is called with interrupts
    disabled from rcu_print_task_stall(), resulting in an "IRQs not
    enabled as expected" diagnostic.  This commit therefore updates
    try_invoke_on_locked_down_task() to use raw_spin_lock_irqsave() instead
    of raw_spin_lock_irq(), thus allowing use from either context.
    
    Link: https://lore.kernel.org/lkml/[email-masked]/
    Link: https://lore.kernel.org/lkml/[email-masked]/
    Reported-by: [email-masked]
    Signed-off-by: Peter Zijlstra <[email-masked]>
    Signed-off-by: Paul E. McKenney <[email-masked]>

diff --git a/kernel/sched/core.c b/kernel/sched/core.c
index e172f2d..09ef5cf 100644
--- a/kernel/sched/core.c
+++ b/kernel/sched/core.c
@@ -2984,7 +2984,7 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
 
 /**
  * try_invoke_on_locked_down_task - Invoke a function on task in fixed state
- * @p: Process for which the function is to be invoked.
+ * @p: Process for which the function is to be invoked, can be @current.
  * @func: Function to invoke.
  * @arg: Argument to function.
  *
@@ -3002,12 +3002,11 @@ try_to_wake_up(struct task_struct *p, unsigned int state, int wake_flags)
  */
 bool try_invoke_on_locked_down_task(struct task_struct *p, bool (*func)(struct task_struct *t, void *arg), void *arg)
 {
-	bool ret = false;
 	struct rq_flags rf;
+	bool ret = false;
 	struct rq *rq;
 
-	lockdep_assert_irqs_enabled();
-	raw_spin_lock_irq(&p->pi_lock);
+	raw_spin_lock_irqsave(&p->pi_lock, rf.flags);
 	if (p->on_rq) {
 		rq = __task_rq_lock(p, &rf);
 		if (task_rq(p) == rq)
@@ -3024,7 +3023,7 @@ bool try_invoke_on_locked_down_task(struct task_struct *p, bool (*func)(struct t
 				ret = func(p, arg);
 		}
 	}
-	raw_spin_unlock_irq(&p->pi_lock);
+	raw_spin_unlock_irqrestore(&p->pi_lock, rf.flags);
 	return ret;
 }