RCU Archive on lore.kernel.org
 help / color / Atom feed
* RCU use of swait
@ 2020-03-05  0:35 Paul E. McKenney
  2020-03-05  8:11 ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 4+ messages in thread
From: Paul E. McKenney @ 2020-03-05  0:35 UTC (permalink / raw)
  To: josh, rostedt, mathieu.desnoyers, jiangshanlai, joel, bigeasy,
	tglx, swood, williams, juri.lelli, linux-rt-users
  Cc: rcu, linux-kernel, mingo

Hello!

RCU makes considerable use of swait and friends.  The motivation I recall
was around offloaded callbacks, where in the old days the grace-period
kthread might do a wakeup for up to N tasks, where N is the number of
CPUs, all with interrupts disabled.  This has since been reduced to
roughly sqrt(N) tasks, which might well still be too many wakeups to do
with interrupts disabled throughout.

However, the other use cases have at most one waiter to be awakened.

So I am guessing that I could usefully convert all but the rcu_node
structure's ->nocb_gp_wq field from swait to wait.  Particularly the
use cases in SRCU and Tiny RCU.

Or is there some other reason why {S,}RCU needs to use swait that I
am forgetting?

							Thanx, Paul

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RCU use of swait
  2020-03-05  0:35 RCU use of swait Paul E. McKenney
@ 2020-03-05  8:11 ` Sebastian Andrzej Siewior
  2020-03-19  0:47   ` Joel Fernandes
  0 siblings, 1 reply; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2020-03-05  8:11 UTC (permalink / raw)
  To: Paul E. McKenney
  Cc: josh, rostedt, mathieu.desnoyers, jiangshanlai, joel, tglx,
	swood, williams, juri.lelli, linux-rt-users, rcu, linux-kernel,
	mingo

On 2020-03-04 16:35:26 [-0800], Paul E. McKenney wrote:
> Hello!
Hi Paul,

> Or is there some other reason why {S,}RCU needs to use swait that I
> am forgetting?

swait can be used in hardirq-context (on RT) that is in a section within
local_irq_save() / raw_spin_lock() and so.
wait on the hand uses spinlock_t which can not be used in this context.
So if you have no users which fall into that category then you could
move back to wait.h.

> 							Thanx, Paul
Sebastian

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RCU use of swait
  2020-03-05  8:11 ` Sebastian Andrzej Siewior
@ 2020-03-19  0:47   ` Joel Fernandes
  2020-03-19  9:25     ` Sebastian Andrzej Siewior
  0 siblings, 1 reply; 4+ messages in thread
From: Joel Fernandes @ 2020-03-19  0:47 UTC (permalink / raw)
  To: Sebastian Andrzej Siewior
  Cc: Paul E. McKenney, Josh Triplett, Steven Rostedt,
	Mathieu Desnoyers, Lai Jiangshan, Thomas Glexiner, Scott Wood,
	Clark Williams, Juri Lelli, linux-rt-users, rcu, LKML,
	Ingo Molnar

On Thu, Mar 5, 2020 at 3:11 AM Sebastian Andrzej Siewior
<bigeasy@linutronix.de> wrote:
>
> On 2020-03-04 16:35:26 [-0800], Paul E. McKenney wrote:
> > Hello!
> Hi Paul,
>
> > Or is there some other reason why {S,}RCU needs to use swait that I
> > am forgetting?
>
> swait can be used in hardirq-context (on RT) that is in a section within
> local_irq_save() / raw_spin_lock() and so.
> wait on the hand uses spinlock_t which can not be used in this context.
> So if you have no users which fall into that category then you could
> move back to wait.h.

In RCU, there are some truly-atomic code sections containing an
swake_upXX() call, which would be considered atomic also on
PREEMPT_RT, one example is:

rcu_core() contains an local_irq_{save,restore}() section.

        /* No grace period and unregistered callbacks? */
        if (!rcu_gp_in_progress() &&
            rcu_segcblist_is_enabled(&rdp->cblist) && !offloaded) {
                local_irq_save(flags);
                if (!rcu_segcblist_restempty(&rdp->cblist, RCU_NEXT_READY_TAIL))
                        rcu_accelerate_cbs_unlocked(rnp, rdp);
                local_irq_restore(flags);
        }

And rcu_accelerate_cbs_unlocked(rnp, rdp) calls rcu_gp_kthread_wake()
which does an swake_up_one(), so I think we will have to leave it as
swake_up() the way it is.

thanks,

 - Joel

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RCU use of swait
  2020-03-19  0:47   ` Joel Fernandes
@ 2020-03-19  9:25     ` Sebastian Andrzej Siewior
  0 siblings, 0 replies; 4+ messages in thread
From: Sebastian Andrzej Siewior @ 2020-03-19  9:25 UTC (permalink / raw)
  To: Joel Fernandes
  Cc: Paul E. McKenney, Josh Triplett, Steven Rostedt,
	Mathieu Desnoyers, Lai Jiangshan, Thomas Glexiner, Scott Wood,
	Clark Williams, Juri Lelli, linux-rt-users, rcu, LKML,
	Ingo Molnar

On 2020-03-18 20:47:18 [-0400], Joel Fernandes wrote:
> In RCU, there are some truly-atomic code sections containing an
> swake_upXX() call, which would be considered atomic also on
> PREEMPT_RT, one example is:
> 
> rcu_core() contains an local_irq_{save,restore}() section.
> 
>         /* No grace period and unregistered callbacks? */
>         if (!rcu_gp_in_progress() &&
>             rcu_segcblist_is_enabled(&rdp->cblist) && !offloaded) {
>                 local_irq_save(flags);
>                 if (!rcu_segcblist_restempty(&rdp->cblist, RCU_NEXT_READY_TAIL))
>                         rcu_accelerate_cbs_unlocked(rnp, rdp);
>                 local_irq_restore(flags);
>         }
> 
> And rcu_accelerate_cbs_unlocked(rnp, rdp) calls rcu_gp_kthread_wake()
> which does an swake_up_one(), so I think we will have to leave it as
> swake_up() the way it is.

There is also this:
irq_exit()
 rcu_irq_exit()
  rcu_nmi_exit_common(true);
   rcu_prepare_for_idle()
    if (rcu_segcblist_pend_cbs(&rdp->cblist))
      rcu_gp_kthread_wake()
       swake_up_one(&rcu_state.gp_wq);

So I *think* this is another one.

> thanks,
> 
>  - Joel

Sebastian

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, back to index

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-05  0:35 RCU use of swait Paul E. McKenney
2020-03-05  8:11 ` Sebastian Andrzej Siewior
2020-03-19  0:47   ` Joel Fernandes
2020-03-19  9:25     ` Sebastian Andrzej Siewior

RCU Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/rcu/0 rcu/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 rcu rcu/ https://lore.kernel.org/rcu \
		rcu@vger.kernel.org
	public-inbox-index rcu

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.rcu


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git