Skip to content

Commit 8c7c482

Browse files
committed
rcu: Awaken grace-period kthread if too long since FQS
Recent kernels can fail to awaken the grace-period kthread for quiescent-state forcing. This commit is a crude hack that does a wakeup if a scheduling-clock interrupt sees that it has been too long since force-quiescent-state (FQS) processing. Signed-off-by: Paul E. McKenney <[email protected]>
1 parent fcfd0a2 commit 8c7c482

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

kernel/rcu/tree.c

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -385,9 +385,11 @@ module_param(qlowmark, long, 0444);
385385

386386
static ulong jiffies_till_first_fqs = ULONG_MAX;
387387
static ulong jiffies_till_next_fqs = ULONG_MAX;
388+
static bool rcu_kick_kthreads;
388389

389390
module_param(jiffies_till_first_fqs, ulong, 0644);
390391
module_param(jiffies_till_next_fqs, ulong, 0644);
392+
module_param(rcu_kick_kthreads, bool, 0644);
391393

392394
/*
393395
* How long the grace period must be before we start recruiting
@@ -1251,6 +1253,24 @@ static void rcu_dump_cpu_stacks(struct rcu_state *rsp)
12511253
}
12521254
}
12531255

1256+
/*
1257+
* If too much time has passed in the current grace period, and if
1258+
* so configured, go kick the relevant kthreads.
1259+
*/
1260+
static void rcu_stall_kick_kthreads(struct rcu_state *rsp)
1261+
{
1262+
unsigned long j;
1263+
1264+
if (!rcu_kick_kthreads)
1265+
return;
1266+
j = READ_ONCE(rsp->jiffies_kick_kthreads);
1267+
if (time_after(jiffies, j) && rsp->gp_kthread) {
1268+
WARN_ONCE(1, "Kicking %s grace-period kthread\n", rsp->name);
1269+
wake_up_process(rsp->gp_kthread);
1270+
WRITE_ONCE(rsp->jiffies_kick_kthreads, j + HZ);
1271+
}
1272+
}
1273+
12541274
static void print_other_cpu_stall(struct rcu_state *rsp, unsigned long gpnum)
12551275
{
12561276
int cpu;
@@ -1262,6 +1282,11 @@ static void print_other_cpu_stall(struct rcu_state *rsp, unsigned long gpnum)
12621282
struct rcu_node *rnp = rcu_get_root(rsp);
12631283
long totqlen = 0;
12641284

1285+
/* Kick and suppress, if so configured. */
1286+
rcu_stall_kick_kthreads(rsp);
1287+
if (rcu_cpu_stall_suppress)
1288+
return;
1289+
12651290
/* Only let one CPU complain about others per time interval. */
12661291

12671292
raw_spin_lock_irqsave_rcu_node(rnp, flags);
@@ -1335,6 +1360,11 @@ static void print_cpu_stall(struct rcu_state *rsp)
13351360
struct rcu_node *rnp = rcu_get_root(rsp);
13361361
long totqlen = 0;
13371362

1363+
/* Kick and suppress, if so configured. */
1364+
rcu_stall_kick_kthreads(rsp);
1365+
if (rcu_cpu_stall_suppress)
1366+
return;
1367+
13381368
/*
13391369
* OK, time to rat on ourselves...
13401370
* See Documentation/RCU/stallwarn.txt for info on how to debug
@@ -1379,8 +1409,10 @@ static void check_cpu_stall(struct rcu_state *rsp, struct rcu_data *rdp)
13791409
unsigned long js;
13801410
struct rcu_node *rnp;
13811411

1382-
if (rcu_cpu_stall_suppress || !rcu_gp_in_progress(rsp))
1412+
if ((rcu_cpu_stall_suppress && !rcu_kick_kthreads) ||
1413+
!rcu_gp_in_progress(rsp))
13831414
return;
1415+
rcu_stall_kick_kthreads(rsp);
13841416
j = jiffies;
13851417

13861418
/*
@@ -2119,8 +2151,11 @@ static int __noreturn rcu_gp_kthread(void *arg)
21192151
}
21202152
ret = 0;
21212153
for (;;) {
2122-
if (!ret)
2154+
if (!ret) {
21232155
rsp->jiffies_force_qs = jiffies + j;
2156+
WRITE_ONCE(rsp->jiffies_kick_kthreads,
2157+
jiffies + 3 * j);
2158+
}
21242159
trace_rcu_grace_period(rsp->name,
21252160
READ_ONCE(rsp->gpnum),
21262161
TPS("fqswait"));

kernel/rcu/tree.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,8 @@ struct rcu_state {
513513

514514
unsigned long jiffies_force_qs; /* Time at which to invoke */
515515
/* force_quiescent_state(). */
516+
unsigned long jiffies_kick_kthreads; /* Time at which to kick */
517+
/* kthreads, if configured. */
516518
unsigned long n_force_qs; /* Number of calls to */
517519
/* force_quiescent_state(). */
518520
unsigned long n_force_qs_lh; /* ~Number of calls leaving */

0 commit comments

Comments
 (0)