Skip to content

Commit 289e7b0

Browse files
Sebastian Andrzej Siewiorrostedt
authored andcommitted
tracing: Account bottom half disabled sections.
Disabling only bottom halves via local_bh_disable() disables also preemption but this remains invisible to tracing. On a CONFIG_PREEMPT kernel one might wonder why there is no scheduling happening despite the N flag in the trace. The reason might be the a rcu_read_lock_bh() section. Add a 'b' to the tracing output if in task context with disabled bottom halves. Link: https://lkml.kernel.org/r/YbcbtdtC/[email protected] Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Steven Rostedt <[email protected]>
1 parent 86599db commit 289e7b0

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

include/linux/trace_events.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ enum trace_flag_type {
172172
TRACE_FLAG_SOFTIRQ = 0x10,
173173
TRACE_FLAG_PREEMPT_RESCHED = 0x20,
174174
TRACE_FLAG_NMI = 0x40,
175+
TRACE_FLAG_BH_OFF = 0x80,
175176
};
176177

177178
#ifdef CONFIG_TRACE_IRQFLAGS_SUPPORT

kernel/trace/trace.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2603,6 +2603,8 @@ unsigned int tracing_gen_ctx_irq_test(unsigned int irqs_status)
26032603
trace_flags |= TRACE_FLAG_HARDIRQ;
26042604
if (in_serving_softirq())
26052605
trace_flags |= TRACE_FLAG_SOFTIRQ;
2606+
if (softirq_count() >> (SOFTIRQ_SHIFT + 1))
2607+
trace_flags |= TRACE_FLAG_BH_OFF;
26062608

26072609
if (tif_need_resched())
26082610
trace_flags |= TRACE_FLAG_NEED_RESCHED;
@@ -4190,7 +4192,7 @@ unsigned long trace_total_entries(struct trace_array *tr)
41904192
static void print_lat_help_header(struct seq_file *m)
41914193
{
41924194
seq_puts(m, "# _------=> CPU# \n"
4193-
"# / _-----=> irqs-off \n"
4195+
"# / _-----=> irqs-off/BH-disabled\n"
41944196
"# | / _----=> need-resched \n"
41954197
"# || / _---=> hardirq/softirq \n"
41964198
"# ||| / _--=> preempt-depth \n"
@@ -4231,7 +4233,7 @@ static void print_func_help_header_irq(struct array_buffer *buf, struct seq_file
42314233

42324234
print_event_info(buf, m);
42334235

4234-
seq_printf(m, "# %.*s _-----=> irqs-off\n", prec, space);
4236+
seq_printf(m, "# %.*s _-----=> irqs-off/BH-disabled\n", prec, space);
42354237
seq_printf(m, "# %.*s / _----=> need-resched\n", prec, space);
42364238
seq_printf(m, "# %.*s| / _---=> hardirq/softirq\n", prec, space);
42374239
seq_printf(m, "# %.*s|| / _--=> preempt-depth\n", prec, space);

kernel/trace/trace_output.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,14 +445,18 @@ int trace_print_lat_fmt(struct trace_seq *s, struct trace_entry *entry)
445445
char irqs_off;
446446
int hardirq;
447447
int softirq;
448+
int bh_off;
448449
int nmi;
449450

450451
nmi = entry->flags & TRACE_FLAG_NMI;
451452
hardirq = entry->flags & TRACE_FLAG_HARDIRQ;
452453
softirq = entry->flags & TRACE_FLAG_SOFTIRQ;
454+
bh_off = entry->flags & TRACE_FLAG_BH_OFF;
453455

454456
irqs_off =
457+
(entry->flags & TRACE_FLAG_IRQS_OFF && bh_off) ? 'D' :
455458
(entry->flags & TRACE_FLAG_IRQS_OFF) ? 'd' :
459+
bh_off ? 'b' :
456460
(entry->flags & TRACE_FLAG_IRQS_NOSUPPORT) ? 'X' :
457461
'.';
458462

0 commit comments

Comments
 (0)