Skip to content

Commit 91afaf3

Browse files
Paul E. McKenneypaulmck
authored andcommitted
rcu: Add failure tracing to rcutorture
Trace the rcutorture RCU accesses and dump the trace buffer when the first failure is detected. Signed-off-by: Paul E. McKenney <paul.mckenney@linaro.org> Signed-off-by: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Reviewed-by: Josh Triplett <josh@joshtriplett.org>
1 parent a8eecf2 commit 91afaf3

4 files changed

Lines changed: 62 additions & 0 deletions

File tree

‎include/linux/rcupdate.h‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,13 +51,21 @@ extern int rcutorture_runnable; /* for sysctl */
5151
#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU)
5252
extern void rcutorture_record_test_transition(void);
5353
extern void rcutorture_record_progress(unsigned long vernum);
54+
extern void do_trace_rcu_torture_read(char *rcutorturename,
55+
struct rcu_head *rhp);
5456
#else
5557
static inline void rcutorture_record_test_transition(void)
5658
{
5759
}
5860
static inline void rcutorture_record_progress(unsigned long vernum)
5961
{
6062
}
63+
#ifdef CONFIG_RCU_TRACE
64+
extern void do_trace_rcu_torture_read(char *rcutorturename,
65+
struct rcu_head *rhp);
66+
#else
67+
#define do_trace_rcu_torture_read(rcutorturename, rhp) do { } while (0)
68+
#endif
6169
#endif
6270

6371
#define UINT_CMP_GE(a, b) (UINT_MAX / 2 >= (a) - (b))

‎include/trace/events/rcu.h‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,31 @@ TRACE_EVENT(rcu_batch_end,
437437
__entry->rcuname, __entry->callbacks_invoked)
438438
);
439439

440+
/*
441+
* Tracepoint for rcutorture readers. The first argument is the name
442+
* of the RCU flavor from rcutorture's viewpoint and the second argument
443+
* is the callback address.
444+
*/
445+
TRACE_EVENT(rcu_torture_read,
446+
447+
TP_PROTO(char *rcutorturename, struct rcu_head *rhp),
448+
449+
TP_ARGS(rcutorturename, rhp),
450+
451+
TP_STRUCT__entry(
452+
__field(char *, rcutorturename)
453+
__field(struct rcu_head *, rhp)
454+
),
455+
456+
TP_fast_assign(
457+
__entry->rcutorturename = rcutorturename;
458+
__entry->rhp = rhp;
459+
),
460+
461+
TP_printk("%s torture read %p",
462+
__entry->rcutorturename, __entry->rhp)
463+
);
464+
440465
#else /* #ifdef CONFIG_RCU_TRACE */
441466

442467
#define trace_rcu_grace_period(rcuname, gpnum, gpevent) do { } while (0)
@@ -452,6 +477,7 @@ TRACE_EVENT(rcu_batch_end,
452477
#define trace_rcu_invoke_callback(rcuname, rhp) do { } while (0)
453478
#define trace_rcu_invoke_kfree_callback(rcuname, rhp, offset) do { } while (0)
454479
#define trace_rcu_batch_end(rcuname, callbacks_invoked) do { } while (0)
480+
#define trace_rcu_torture_read(rcutorturename, rhp) do { } while (0)
455481

456482
#endif /* #else #ifdef CONFIG_RCU_TRACE */
457483

‎kernel/rcupdate.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,3 +316,13 @@ struct debug_obj_descr rcuhead_debug_descr = {
316316
};
317317
EXPORT_SYMBOL_GPL(rcuhead_debug_descr);
318318
#endif /* #ifdef CONFIG_DEBUG_OBJECTS_RCU_HEAD */
319+
320+
#if defined(CONFIG_TREE_RCU) || defined(CONFIG_TREE_PREEMPT_RCU) || defined(CONFIG_RCU_TRACE)
321+
void do_trace_rcu_torture_read(char *rcutorturename, struct rcu_head *rhp)
322+
{
323+
trace_rcu_torture_read(rcutorturename, rhp);
324+
}
325+
EXPORT_SYMBOL_GPL(do_trace_rcu_torture_read);
326+
#else
327+
#define do_trace_rcu_torture_read(rcutorturename, rhp) do { } while (0)
328+
#endif

‎kernel/rcutorture.c‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,18 @@ rcu_torture_fakewriter(void *arg)
913913
return 0;
914914
}
915915

916+
void rcutorture_trace_dump(void)
917+
{
918+
static atomic_t beenhere = ATOMIC_INIT(0);
919+
920+
if (atomic_read(&beenhere))
921+
return;
922+
if (atomic_xchg(&beenhere, 1) != 0)
923+
return;
924+
do_trace_rcu_torture_read(cur_ops->name, (struct rcu_head *)~0UL);
925+
ftrace_dump(DUMP_ALL);
926+
}
927+
916928
/*
917929
* RCU torture reader from timer handler. Dereferences rcu_torture_current,
918930
* incrementing the corresponding element of the pipeline array. The
@@ -934,6 +946,7 @@ static void rcu_torture_timer(unsigned long unused)
934946
rcu_read_lock_bh_held() ||
935947
rcu_read_lock_sched_held() ||
936948
srcu_read_lock_held(&srcu_ctl));
949+
do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
937950
if (p == NULL) {
938951
/* Leave because rcu_torture_writer is not yet underway */
939952
cur_ops->readunlock(idx);
@@ -951,6 +964,8 @@ static void rcu_torture_timer(unsigned long unused)
951964
/* Should not happen, but... */
952965
pipe_count = RCU_TORTURE_PIPE_LEN;
953966
}
967+
if (pipe_count > 1)
968+
rcutorture_trace_dump();
954969
__this_cpu_inc(rcu_torture_count[pipe_count]);
955970
completed = cur_ops->completed() - completed;
956971
if (completed > RCU_TORTURE_PIPE_LEN) {
@@ -994,6 +1009,7 @@ rcu_torture_reader(void *arg)
9941009
rcu_read_lock_bh_held() ||
9951010
rcu_read_lock_sched_held() ||
9961011
srcu_read_lock_held(&srcu_ctl));
1012+
do_trace_rcu_torture_read(cur_ops->name, &p->rtort_rcu);
9971013
if (p == NULL) {
9981014
/* Wait for rcu_torture_writer to get underway */
9991015
cur_ops->readunlock(idx);
@@ -1009,6 +1025,8 @@ rcu_torture_reader(void *arg)
10091025
/* Should not happen, but... */
10101026
pipe_count = RCU_TORTURE_PIPE_LEN;
10111027
}
1028+
if (pipe_count > 1)
1029+
rcutorture_trace_dump();
10121030
__this_cpu_inc(rcu_torture_count[pipe_count]);
10131031
completed = cur_ops->completed() - completed;
10141032
if (completed > RCU_TORTURE_PIPE_LEN) {

0 commit comments

Comments
 (0)