Skip to content

Commit 77f81fe

Browse files
pmladekpaulmck
authored andcommitted
rcu: Finish folding ->fqs_state into ->gp_state
Commit commit 4cdfc17 ("rcu: Move quiescent-state forcing into kthread") started the process of folding the old ->fqs_state into ->gp_state, but did not complete it. This situation does not cause any malfunction, but can result in extremely confusing trace output. This commit completes this task of eliminating ->fqs_state in favor of ->gp_state. The old ->fqs_state was also used to decide when to collect dyntick-idle snapshots. For this purpose, we add a boolean variable into the kthread, which is set on the first call to rcu_gp_fqs() for a given grace period and clear otherwise. Signed-off-by: Petr Mladek <pmladek@suse.com> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
1 parent 49f5903 commit 77f81fe

File tree

3 files changed

+12
-22
lines changed

3 files changed

+12
-22
lines changed

kernel/rcu/tree.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ struct rcu_state sname##_state = { \
9898
.level = { &sname##_state.node[0] }, \
9999
.rda = &sname##_data, \
100100
.call = cr, \
101-
.fqs_state = RCU_GP_IDLE, \
101+
.gp_state = RCU_GP_IDLE, \
102102
.gpnum = 0UL - 300UL, \
103103
.completed = 0UL - 300UL, \
104104
.orphan_lock = __RAW_SPIN_LOCK_UNLOCKED(&sname##_state.orphan_lock), \
@@ -1936,16 +1936,15 @@ static bool rcu_gp_fqs_check_wake(struct rcu_state *rsp, int *gfp)
19361936
/*
19371937
* Do one round of quiescent-state forcing.
19381938
*/
1939-
static int rcu_gp_fqs(struct rcu_state *rsp, int fqs_state_in)
1939+
static void rcu_gp_fqs(struct rcu_state *rsp, bool first_time)
19401940
{
1941-
int fqs_state = fqs_state_in;
19421941
bool isidle = false;
19431942
unsigned long maxj;
19441943
struct rcu_node *rnp = rcu_get_root(rsp);
19451944

19461945
WRITE_ONCE(rsp->gp_activity, jiffies);
19471946
rsp->n_force_qs++;
1948-
if (fqs_state == RCU_SAVE_DYNTICK) {
1947+
if (first_time) {
19491948
/* Collect dyntick-idle snapshots. */
19501949
if (is_sysidle_rcu_state(rsp)) {
19511950
isidle = true;
@@ -1954,7 +1953,6 @@ static int rcu_gp_fqs(struct rcu_state *rsp, int fqs_state_in)
19541953
force_qs_rnp(rsp, dyntick_save_progress_counter,
19551954
&isidle, &maxj);
19561955
rcu_sysidle_report_gp(rsp, isidle, maxj);
1957-
fqs_state = RCU_FORCE_QS;
19581956
} else {
19591957
/* Handle dyntick-idle and offline CPUs. */
19601958
isidle = true;
@@ -1968,7 +1966,6 @@ static int rcu_gp_fqs(struct rcu_state *rsp, int fqs_state_in)
19681966
READ_ONCE(rsp->gp_flags) & ~RCU_GP_FLAG_FQS);
19691967
raw_spin_unlock_irq(&rnp->lock);
19701968
}
1971-
return fqs_state;
19721969
}
19731970

19741971
/*
@@ -2032,7 +2029,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
20322029
/* Declare grace period done. */
20332030
WRITE_ONCE(rsp->completed, rsp->gpnum);
20342031
trace_rcu_grace_period(rsp->name, rsp->completed, TPS("end"));
2035-
rsp->fqs_state = RCU_GP_IDLE;
2032+
rsp->gp_state = RCU_GP_IDLE;
20362033
rdp = this_cpu_ptr(rsp->rda);
20372034
/* Advance CBs to reduce false positives below. */
20382035
needgp = rcu_advance_cbs(rsp, rnp, rdp) || needgp;
@@ -2050,7 +2047,7 @@ static void rcu_gp_cleanup(struct rcu_state *rsp)
20502047
*/
20512048
static int __noreturn rcu_gp_kthread(void *arg)
20522049
{
2053-
int fqs_state;
2050+
bool first_gp_fqs;
20542051
int gf;
20552052
unsigned long j;
20562053
int ret;
@@ -2082,7 +2079,7 @@ static int __noreturn rcu_gp_kthread(void *arg)
20822079
}
20832080

20842081
/* Handle quiescent-state forcing. */
2085-
fqs_state = RCU_SAVE_DYNTICK;
2082+
first_gp_fqs = true;
20862083
j = jiffies_till_first_fqs;
20872084
if (j > HZ) {
20882085
j = HZ;
@@ -2110,7 +2107,8 @@ static int __noreturn rcu_gp_kthread(void *arg)
21102107
trace_rcu_grace_period(rsp->name,
21112108
READ_ONCE(rsp->gpnum),
21122109
TPS("fqsstart"));
2113-
fqs_state = rcu_gp_fqs(rsp, fqs_state);
2110+
rcu_gp_fqs(rsp, first_gp_fqs);
2111+
first_gp_fqs = false;
21142112
trace_rcu_grace_period(rsp->name,
21152113
READ_ONCE(rsp->gpnum),
21162114
TPS("fqsend"));

kernel/rcu/tree.h

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,6 @@ struct rcu_data {
412412
struct rcu_state *rsp;
413413
};
414414

415-
/* Values for fqs_state field in struct rcu_state. */
416-
#define RCU_GP_IDLE 0 /* No grace period in progress. */
417-
#define RCU_GP_INIT 1 /* Grace period being initialized. */
418-
#define RCU_SAVE_DYNTICK 2 /* Need to scan dyntick state. */
419-
#define RCU_FORCE_QS 3 /* Need to force quiescent state. */
420-
#define RCU_SIGNAL_INIT RCU_SAVE_DYNTICK
421-
422415
/* Values for nocb_defer_wakeup field in struct rcu_data. */
423416
#define RCU_NOGP_WAKE_NOT 0
424417
#define RCU_NOGP_WAKE 1
@@ -468,9 +461,8 @@ struct rcu_state {
468461

469462
/* The following fields are guarded by the root rcu_node's lock. */
470463

471-
u8 fqs_state ____cacheline_internodealigned_in_smp;
472-
/* Force QS state. */
473-
u8 boost; /* Subject to priority boost. */
464+
u8 boost ____cacheline_internodealigned_in_smp;
465+
/* Subject to priority boost. */
474466
unsigned long gpnum; /* Current gp number. */
475467
unsigned long completed; /* # of last completed gp. */
476468
struct task_struct *gp_kthread; /* Task for grace periods. */
@@ -538,7 +530,7 @@ struct rcu_state {
538530
#define RCU_GP_FLAG_FQS 0x2 /* Need grace-period quiescent-state forcing. */
539531

540532
/* Values for rcu_state structure's gp_flags field. */
541-
#define RCU_GP_WAIT_INIT 0 /* Initial state. */
533+
#define RCU_GP_IDLE 0 /* Initial state and no GP in progress. */
542534
#define RCU_GP_WAIT_GPS 1 /* Wait for grace-period start. */
543535
#define RCU_GP_DONE_GPS 2 /* Wait done for grace-period start. */
544536
#define RCU_GP_WAIT_FQS 3 /* Wait for force-quiescent-state time. */

kernel/rcu/tree_trace.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ static void print_one_rcu_state(struct seq_file *m, struct rcu_state *rsp)
268268
gpnum = rsp->gpnum;
269269
seq_printf(m, "c=%ld g=%ld s=%d jfq=%ld j=%x ",
270270
ulong2long(rsp->completed), ulong2long(gpnum),
271-
rsp->fqs_state,
271+
rsp->gp_state,
272272
(long)(rsp->jiffies_force_qs - jiffies),
273273
(int)(jiffies & 0xffff));
274274
seq_printf(m, "nfqs=%lu/nfqsng=%lu(%lu) fqlh=%lu oqlen=%ld/%ld\n",

0 commit comments

Comments
 (0)