All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RFC tip/core/rcu 0/2] srcu: All SRCU readers from both process and irq
@ 2017-06-05 22:09 Paul E. McKenney
  2017-06-05 22:09 ` [PATCH RFC tip/core/rcu 1/2] srcu: Allow use of Tiny/Tree SRCU from both process and interrupt context Paul E. McKenney
                   ` (2 more replies)
  0 siblings, 3 replies; 25+ messages in thread
From: Paul E. McKenney @ 2017-06-05 22:09 UTC (permalink / raw)
  To: linux-kernel
  Cc: mingo, jiangshanlai, dipankar, akpm, mathieu.desnoyers, josh,
	tglx, peterz, rostedt, dhowells, edumazet, fweisbec, oleg,
	torvalds, paolo.bonzini, linuc.decode

This is a repost of a pair of patches from Paolo Bonzini to a wider
audience.

Linu Cherian reported a WARN in cleanup_srcu_struct when shutting
down a guest that has iperf running on a VFIO assigned device.

This happens because irqfd_wakeup calls srcu_read_lock(&kvm->irq_srcu)
in interrupt context, while a worker thread does the same inside
kvm_set_irq.  If the interrupt happens while the worker thread is
executing __srcu_read_lock, lock_count can fall behind.  (KVM is using
SRCU here not really for the "sleepable" part, but rather due to its
faster detection of grace periods).  One way or another, this needs to
be fixed in v4.12.

We discussed three ways of fixing this:

1.	Have KVM protect process-level ->irq_srcu readers with
	local_irq_disable() or similar.  This works, and is the most
	confined change, but is a bit of an ugly usage restriction.

2.	Make KVM convert ->irq_srcu uses to RCU-sched.	This works, but
	KVM needs fast grace periods, and synchronize_sched_expedited()
	interrupts CPUs, and is thus not particularly friendly to
	real-time workloads.

3.	Make SRCU tolerate use of srcu_read_lock() and srcu_read_unlock()
	from both process context and irq handlers for the same
	srcu_struct.  It turns out that only a small change to SRCU is
	required, namely, changing __srcu_read_lock()'s __this_cpu_inc()
	to this_cpu_inc(), matching the existing __srcu_read_unlock()
	usage.	In addition, this change simplifies the use of SRCU.
	Of course, any RCU change after -rc1 is a bit scary.
	Nevertheless, the following two patches illustrate this approach.

Coward that I am, my personal preferred approach would be #1 during 4.12,
possibly moving to #3 over time.  However, the KVM guys make a good case
for just making a single small change right now and being done with it.
Plus the overall effect of the one-step approach #3 is to make RCU
smaller, even if only by five lines of code.

The reason for splitting this into two patches is to ease backporting.
This means that the two commit logs are quite similar.

Thoughts?  In particular, are there better ways to fix this?

							Thanx, Paul

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

 include/linux/srcu.h     |    2 --
 include/linux/srcutiny.h |    2 +-
 kernel/rcu/rcutorture.c  |    4 ++--
 kernel/rcu/srcu.c        |    5 ++---
 kernel/rcu/srcutiny.c    |   21 ++++++++++-----------
 kernel/rcu/srcutree.c    |    5 ++---
 6 files changed, 17 insertions(+), 22 deletions(-)

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

end of thread, other threads:[~2017-06-06 18:22 UTC | newest]

Thread overview: 25+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-05 22:09 [PATCH RFC tip/core/rcu 0/2] srcu: All SRCU readers from both process and irq Paul E. McKenney
2017-06-05 22:09 ` [PATCH RFC tip/core/rcu 1/2] srcu: Allow use of Tiny/Tree SRCU from both process and interrupt context Paul E. McKenney
2017-06-06 10:53   ` Peter Zijlstra
2017-06-06 12:56     ` Paul E. McKenney
2017-06-06 13:08     ` Paolo Bonzini
2017-06-06 14:45       ` Christian Borntraeger
2017-06-06 15:27         ` Heiko Carstens
2017-06-06 15:37           ` Christian Borntraeger
2017-06-06 15:58             ` Paul E. McKenney
2017-06-06 16:15           ` Peter Zijlstra
2017-06-06 17:00             ` Paul E. McKenney
2017-06-06 17:20             ` Heiko Carstens
2017-06-06 16:12         ` Peter Zijlstra
2017-06-06 16:02       ` Peter Zijlstra
2017-06-06 11:09   ` Peter Zijlstra
2017-06-06 12:01     ` Paolo Bonzini
2017-06-06 12:53       ` Paul E. McKenney
2017-06-06 15:54         ` Peter Zijlstra
2017-06-06 15:59           ` Paul E. McKenney
2017-06-06 17:23   ` Peter Zijlstra
2017-06-06 17:50     ` Paul E. McKenney
2017-06-06 18:00       ` Peter Zijlstra
2017-06-06 18:22         ` Paul E. McKenney
2017-06-05 22:09 ` [PATCH RFC tip/core/rcu 2/2] srcu: Allow use of Classic " Paul E. McKenney
2017-06-06 17:05 ` [PATCH RFC tip/core/rcu 0/2] srcu: All SRCU readers from both process and irq Paul E. McKenney

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.