Skip to content

Commit 243d5ab

Browse files
Zhen LeiFrederic Weisbecker
authored andcommitted
rcu: Eliminate check_cpu_stall() duplicate code
The code and comments of self-detected and other-detected RCU CPU stall warnings are identical except the output function. This commit therefore refactors so as to consolidate the duplicate code. Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
1 parent f3efe02 commit 243d5ab

File tree

1 file changed

+15
-27
lines changed

1 file changed

+15
-27
lines changed

kernel/rcu/tree_stall.h

Lines changed: 15 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ static void print_cpu_stall(unsigned long gps)
711711

712712
static void check_cpu_stall(struct rcu_data *rdp)
713713
{
714-
bool didstall = false;
714+
bool self_detected;
715715
unsigned long gs1;
716716
unsigned long gs2;
717717
unsigned long gps;
@@ -758,10 +758,10 @@ static void check_cpu_stall(struct rcu_data *rdp)
758758
return; /* No stall or GP completed since entering function. */
759759
rnp = rdp->mynode;
760760
jn = jiffies + ULONG_MAX / 2;
761+
self_detected = READ_ONCE(rnp->qsmask) & rdp->grpmask;
761762
if (rcu_gp_in_progress() &&
762-
(READ_ONCE(rnp->qsmask) & rdp->grpmask) &&
763+
(self_detected || ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY)) &&
763764
cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
764-
765765
/*
766766
* If a virtual machine is stopped by the host it can look to
767767
* the watchdog like an RCU stall. Check to see if the host
@@ -770,33 +770,21 @@ static void check_cpu_stall(struct rcu_data *rdp)
770770
if (kvm_check_and_clear_guest_paused())
771771
return;
772772

773-
/* We haven't checked in, so go dump stack. */
774-
print_cpu_stall(gps);
775-
if (READ_ONCE(rcu_cpu_stall_ftrace_dump))
776-
rcu_ftrace_dump(DUMP_ALL);
777-
didstall = true;
778-
779-
} else if (rcu_gp_in_progress() &&
780-
ULONG_CMP_GE(j, js + RCU_STALL_RAT_DELAY) &&
781-
cmpxchg(&rcu_state.jiffies_stall, js, jn) == js) {
782-
783-
/*
784-
* If a virtual machine is stopped by the host it can look to
785-
* the watchdog like an RCU stall. Check to see if the host
786-
* stopped the vm.
787-
*/
788-
if (kvm_check_and_clear_guest_paused())
789-
return;
773+
if (self_detected) {
774+
/* We haven't checked in, so go dump stack. */
775+
print_cpu_stall(gps);
776+
} else {
777+
/* They had a few time units to dump stack, so complain. */
778+
print_other_cpu_stall(gs2, gps);
779+
}
790780

791-
/* They had a few time units to dump stack, so complain. */
792-
print_other_cpu_stall(gs2, gps);
793781
if (READ_ONCE(rcu_cpu_stall_ftrace_dump))
794782
rcu_ftrace_dump(DUMP_ALL);
795-
didstall = true;
796-
}
797-
if (didstall && READ_ONCE(rcu_state.jiffies_stall) == jn) {
798-
jn = jiffies + 3 * rcu_jiffies_till_stall_check() + 3;
799-
WRITE_ONCE(rcu_state.jiffies_stall, jn);
783+
784+
if (READ_ONCE(rcu_state.jiffies_stall) == jn) {
785+
jn = jiffies + 3 * rcu_jiffies_till_stall_check() + 3;
786+
WRITE_ONCE(rcu_state.jiffies_stall, jn);
787+
}
800788
}
801789
}
802790

0 commit comments

Comments
 (0)