Skip to content

Commit 579a05d

Browse files
paulmckrcuurezki
authored andcommitted
rcutorture: Decorate failing reader segments with CPU ID
This commit adds CPU number to the "Failure/close-call rcutorture reader segments" list printed at the end of an rcutorture run that had too-short grace periods. This information can help debugging interactions with migration and CPU hotplug. However, experience indicates that sampling the CPU number in rcutorture's read-side code can reduce the probability of too-short bugs by a small integer factor. And small integer factors are crucial to RCU bug hunting, so this commit also introduces a default-off RCU_TORTURE_TEST_LOG_CPU Kconfig option to enable this CPU-number-logging functionality at build time. Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Signed-off-by: Uladzislau Rezki (Sony) <urezki@gmail.com>
1 parent 5ec0900 commit 579a05d

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

kernel/rcu/Kconfig.debug

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ config RCU_TORTURE_TEST
5353
Say M if you want the RCU torture tests to build as a module.
5454
Say N if you are unsure.
5555

56+
config RCU_TORTURE_TEST_LOG_CPU
57+
tristate "Log CPU for rcutorture failures"
58+
depends on RCU_TORTURE_TEST
59+
default n
60+
help
61+
This option causes rcutorture to decorate each entry of its
62+
log of failure/close-call rcutorture reader segments with the
63+
number of the CPU that the reader was running on at the time.
64+
This information can be useful, but it does incur additional
65+
overhead, overhead that can make both failures and close calls
66+
less probable.
67+
68+
Say Y here if you want CPU IDs logged.
69+
Say N if you are unsure.
70+
5671
config RCU_REF_SCALE_TEST
5772
tristate "Scalability tests for read-side synchronization (RCU and others)"
5873
depends on DEBUG_KERNEL

kernel/rcu/rcutorture.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ struct rt_read_seg {
262262
unsigned long rt_delay_ms;
263263
unsigned long rt_delay_us;
264264
bool rt_preempted;
265+
int rt_cpu;
265266
};
266267
static int err_segs_recorded;
267268
static struct rt_read_seg err_segs[RCUTORTURE_RDR_MAX_SEGS];
@@ -1862,6 +1863,8 @@ static void rcutorture_one_extend(int *readstate, int newstate,
18621863
WARN_ON_ONCE(idxold2 < 0);
18631864
WARN_ON_ONCE(idxold2 & ~RCUTORTURE_RDR_ALLBITS);
18641865
rtrsp->rt_readstate = newstate;
1866+
if (IS_ENABLED(CONFIG_RCU_TORTURE_TEST_LOG_CPU))
1867+
rtrsp->rt_cpu = raw_smp_processor_id();
18651868

18661869
/* First, put new protection in place to avoid critical-section gap. */
18671870
if (statesnew & RCUTORTURE_RDR_BH)
@@ -3559,8 +3562,10 @@ rcu_torture_cleanup(void)
35593562
err_segs[i].rt_delay_us);
35603563
firsttime = 0;
35613564
}
3562-
pr_cont("%s\n",
3563-
err_segs[i].rt_preempted ? "preempted" : "");
3565+
pr_cont("%s", err_segs[i].rt_preempted ? "preempted" : "");
3566+
if (IS_ENABLED(CONFIG_RCU_TORTURE_TEST_LOG_CPU))
3567+
pr_cont(" CPU %d", err_segs[i].rt_cpu);
3568+
pr_cont("\n");
35643569

35653570
}
35663571
}

0 commit comments

Comments
 (0)