* [RFC PATCH] rcu: call kvm_check_and_clear_guest_paused unconditionally
@ 2021-07-16 5:41 Sergey Senozhatsky
2021-07-16 6:23 ` Sergey Senozhatsky
0 siblings, 1 reply; 3+ messages in thread
From: Sergey Senozhatsky @ 2021-07-16 5:41 UTC (permalink / raw)
To: Paul E. McKenney, Steven Rostedt, Mathieu Desnoyers,
Lai Jiangshan, Joel Fernandes
Cc: Suleiman Souhlal, rcu, linux-kernel, Sergey Senozhatsky
Do not call kvm_check_and_clear_guest_paused() only from the
stall branch (which requires an active grace period in the
first place), but instead handle PVCLOCK_GUEST_STOPPED as
early as possible.
pvclock_touch_watchdogs() touches various watchdogs, which
have different timeouts, so the earlier we handle stopped
VCPU the better (lockup watchdog does the same).
Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org>
---
diff --git a/kernel/rcu/tree_stall.h b/kernel/rcu/tree_stall.h
index 677ee3d8671b..5dd6ea2ead0c 100644
--- a/kernel/rcu/tree_stall.h
+++ b/kernel/rcu/tree_stall.h
@@ -657,6 +657,13 @@ static void check_cpu_stall(struct rcu_data *rdp)
unsigned long js;
struct rcu_node *rnp;
+ /*
+ * If a virtual machine is stopped by the host it can look to
+ * the watchdog like an RCU stall. Check to see if the host
+ * stopped the vm.
+ */
+ kvm_check_and_clear_guest_paused();
+
lockdep_assert_irqs_disabled();
if ((rcu_stall_is_suppressed() && !READ_ONCE(rcu_kick_kthreads)) ||
!rcu_gp_in_progress())
@@ -699,14 +706,6 @@ static void check_cpu_stall(struct rcu_data *rdp)
(READ_ONCE(rnp->qsmask) & rdp->grpmask) &&
cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
- /*
- * If a virtual machine is stopped by the host it can look to
- * the watchdog like an RCU stall. Check to see if the host
- * stopped the vm.
- */
- if (kvm_check_and_clear_guest_paused())
- return;
-
/* We haven't checked in, so go dump stack. */
print_cpu_stall(gps);
if (READ_ONCE(rcu_cpu_stall_ftrace_dump))
@@ -717,14 +716,6 @@ static void check_cpu_stall(struct rcu_data *rdp)
ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY) &&
cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
- /*
- * If a virtual machine is stopped by the host it can look to
- * the watchdog like an RCU stall. Check to see if the host
- * stopped the vm.
- */
- if (kvm_check_and_clear_guest_paused())
- return;
-
/* They had a few time units to dump stack, so complain. */
print_other_cpu_stall(gs2, gps);
if (READ_ONCE(rcu_cpu_stall_ftrace_dump))
--
2.32.0.402.g57bb445576-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] rcu: call kvm_check_and_clear_guest_paused unconditionally
2021-07-16 5:41 [RFC PATCH] rcu: call kvm_check_and_clear_guest_paused unconditionally Sergey Senozhatsky
@ 2021-07-16 6:23 ` Sergey Senozhatsky
2021-07-19 18:06 ` Paul E. McKenney
0 siblings, 1 reply; 3+ messages in thread
From: Sergey Senozhatsky @ 2021-07-16 6:23 UTC (permalink / raw)
To: Sergey Senozhatsky
Cc: Paul E. McKenney, Steven Rostedt, Mathieu Desnoyers,
Lai Jiangshan, Joel Fernandes, Suleiman Souhlal, rcu,
linux-kernel
On (21/07/16 14:41), Sergey Senozhatsky wrote:
> @@ -657,6 +657,13 @@ static void check_cpu_stall(struct rcu_data *rdp)
> unsigned long js;
> struct rcu_node *rnp;
>
> + /*
> + * If a virtual machine is stopped by the host it can look to
> + * the watchdog like an RCU stall. Check to see if the host
> + * stopped the vm.
> + */
> + kvm_check_and_clear_guest_paused();
> +
> lockdep_assert_irqs_disabled();
> if ((rcu_stall_is_suppressed() && !READ_ONCE(rcu_kick_kthreads)) ||
> !rcu_gp_in_progress())
> @@ -699,14 +706,6 @@ static void check_cpu_stall(struct rcu_data *rdp)
> (READ_ONCE(rnp->qsmask) & rdp->grpmask) &&
> cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
>
> - /*
> - * If a virtual machine is stopped by the host it can look to
> - * the watchdog like an RCU stall. Check to see if the host
> - * stopped the vm.
> - */
> - if (kvm_check_and_clear_guest_paused())
> - return;
> -
> /* We haven't checked in, so go dump stack. */
> print_cpu_stall(gps);
> if (READ_ONCE(rcu_cpu_stall_ftrace_dump))
> @@ -717,14 +716,6 @@ static void check_cpu_stall(struct rcu_data *rdp)
> ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY) &&
> cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
>
> - /*
> - * If a virtual machine is stopped by the host it can look to
> - * the watchdog like an RCU stall. Check to see if the host
> - * stopped the vm.
> - */
> - if (kvm_check_and_clear_guest_paused())
> - return;
> -
> /* They had a few time units to dump stack, so complain. */
> print_other_cpu_stall(gs2, gps);
> if (READ_ONCE(rcu_cpu_stall_ftrace_dump))
This patch depends on
https://lore.kernel.org/lkml/20210716053405.1243239-1-senozhatsky@chromium.org/
If that x86/kvm patch lands, then we need to handle
PVCLOCK_GUEST_STOPPED in watchdogs.
In theory, this patch opens a small race window, if the VCPU gets preempted
after kvm_check_and_clear_guest_paused() (external interrupt, etc.)
But it's hard to tell how likely the problem is.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC PATCH] rcu: call kvm_check_and_clear_guest_paused unconditionally
2021-07-16 6:23 ` Sergey Senozhatsky
@ 2021-07-19 18:06 ` Paul E. McKenney
0 siblings, 0 replies; 3+ messages in thread
From: Paul E. McKenney @ 2021-07-19 18:06 UTC (permalink / raw)
To: Sergey Senozhatsky
Cc: Steven Rostedt, Mathieu Desnoyers, Lai Jiangshan, Joel Fernandes,
Suleiman Souhlal, rcu, linux-kernel
On Fri, Jul 16, 2021 at 03:23:07PM +0900, Sergey Senozhatsky wrote:
> On (21/07/16 14:41), Sergey Senozhatsky wrote:
> > @@ -657,6 +657,13 @@ static void check_cpu_stall(struct rcu_data *rdp)
> > unsigned long js;
> > struct rcu_node *rnp;
> >
> > + /*
> > + * If a virtual machine is stopped by the host it can look to
> > + * the watchdog like an RCU stall. Check to see if the host
> > + * stopped the vm.
> > + */
> > + kvm_check_and_clear_guest_paused();
> > +
> > lockdep_assert_irqs_disabled();
> > if ((rcu_stall_is_suppressed() && !READ_ONCE(rcu_kick_kthreads)) ||
> > !rcu_gp_in_progress())
> > @@ -699,14 +706,6 @@ static void check_cpu_stall(struct rcu_data *rdp)
> > (READ_ONCE(rnp->qsmask) & rdp->grpmask) &&
> > cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
> >
> > - /*
> > - * If a virtual machine is stopped by the host it can look to
> > - * the watchdog like an RCU stall. Check to see if the host
> > - * stopped the vm.
> > - */
> > - if (kvm_check_and_clear_guest_paused())
> > - return;
> > -
> > /* We haven't checked in, so go dump stack. */
> > print_cpu_stall(gps);
> > if (READ_ONCE(rcu_cpu_stall_ftrace_dump))
> > @@ -717,14 +716,6 @@ static void check_cpu_stall(struct rcu_data *rdp)
> > ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY) &&
> > cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
> >
> > - /*
> > - * If a virtual machine is stopped by the host it can look to
> > - * the watchdog like an RCU stall. Check to see if the host
> > - * stopped the vm.
> > - */
> > - if (kvm_check_and_clear_guest_paused())
> > - return;
> > -
> > /* They had a few time units to dump stack, so complain. */
> > print_other_cpu_stall(gs2, gps);
> > if (READ_ONCE(rcu_cpu_stall_ftrace_dump))
>
> This patch depends on
> https://lore.kernel.org/lkml/20210716053405.1243239-1-senozhatsky@chromium.org/
>
> If that x86/kvm patch lands, then we need to handle
> PVCLOCK_GUEST_STOPPED in watchdogs.
OK, please let me know how and when you would like to proceed.
> In theory, this patch opens a small race window, if the VCPU gets preempted
> after kvm_check_and_clear_guest_paused() (external interrupt, etc.)
> But it's hard to tell how likely the problem is.
There is always attempting to provoke it, possibly accompanied by
artificially widening the race window.
Thanx, Paul
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-07-19 18:10 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-16 5:41 [RFC PATCH] rcu: call kvm_check_and_clear_guest_paused unconditionally Sergey Senozhatsky
2021-07-16 6:23 ` Sergey Senozhatsky
2021-07-19 18:06 ` Paul E. McKenney
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).