Skip to content

Commit 3c4a063

Browse files
committed
Merge tag 'trace-v6.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace
Pull more tracing updates from Steven Rostedt: - Remove unneeded goto out statements Over time, the logic was restructured but left a "goto out" where the out label simply did a "return ret;". Instead of jumping to this out label, simply return immediately and remove the out label. - Add guard(ring_buffer_nest) Some calls to the tracing ring buffer can happen when the ring buffer is already being written to at the same context (for example, a trace_printk() in between a ring_buffer_lock_reserve() and a ring_buffer_unlock_commit()). In order to not trigger the recursion detection, these functions use ring_buffer_nest_start() and ring_buffer_nest_end(). Create a guard() for these functions so that their use cases can be simplified and not need to use goto for the release. - Clean up the tracing code with guard() and __free() logic There were several locations that were prime candidates for using guard() and __free() helpers. Switch them over to use them. - Fix output of function argument traces for unsigned int values The function tracer with "func-args" option set will record up to 6 argument registers and then use BTF to format them for human consumption when the trace file is read. There are several arguments that are "unsigned long" and even "unsigned int" that are either and address or a mask. It is easier to understand if they were printed using hexadecimal instead of decimal. The old method just printed all non-pointer values as signed integers, which made it even worse for unsigned integers. For instance, instead of: __local_bh_disable_ip(ip=-2127311112, cnt=256) <-handle_softirqs show: __local_bh_disable_ip(ip=0xffffffff8133cef8, cnt=0x100) <-handle_softirqs" * tag 'trace-v6.17-2' of git://git.kernel.org/pub/scm/linux/kernel/git/trace/linux-trace: tracing: Have unsigned int function args displayed as hexadecimal ring-buffer: Convert ring_buffer_write() to use guard(preempt_notrace) tracing: Use __free(kfree) in trace.c to remove gotos tracing: Add guard() around locks and mutexes in trace.c tracing: Add guard(ring_buffer_nest) tracing: Remove unneeded goto out logic
2 parents 8877fcb + 3ca8243 commit 3c4a063

File tree

5 files changed

+120
-200
lines changed

5 files changed

+120
-200
lines changed

include/linux/ring_buffer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,9 @@ int ring_buffer_write(struct trace_buffer *buffer,
144144
void ring_buffer_nest_start(struct trace_buffer *buffer);
145145
void ring_buffer_nest_end(struct trace_buffer *buffer);
146146

147+
DEFINE_GUARD(ring_buffer_nest, struct trace_buffer *,
148+
ring_buffer_nest_start(_T), ring_buffer_nest_end(_T))
149+
147150
struct ring_buffer_event *
148151
ring_buffer_peek(struct trace_buffer *buffer, int cpu, u64 *ts,
149152
unsigned long *lost_events);

kernel/trace/ring_buffer.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4812,26 +4812,26 @@ int ring_buffer_write(struct trace_buffer *buffer,
48124812
int ret = -EBUSY;
48134813
int cpu;
48144814

4815-
preempt_disable_notrace();
4815+
guard(preempt_notrace)();
48164816

48174817
if (atomic_read(&buffer->record_disabled))
4818-
goto out;
4818+
return -EBUSY;
48194819

48204820
cpu = raw_smp_processor_id();
48214821

48224822
if (!cpumask_test_cpu(cpu, buffer->cpumask))
4823-
goto out;
4823+
return -EBUSY;
48244824

48254825
cpu_buffer = buffer->buffers[cpu];
48264826

48274827
if (atomic_read(&cpu_buffer->record_disabled))
4828-
goto out;
4828+
return -EBUSY;
48294829

48304830
if (length > buffer->max_data_size)
4831-
goto out;
4831+
return -EBUSY;
48324832

48334833
if (unlikely(trace_recursive_lock(cpu_buffer)))
4834-
goto out;
4834+
return -EBUSY;
48354835

48364836
event = rb_reserve_next_event(buffer, cpu_buffer, length);
48374837
if (!event)
@@ -4849,10 +4849,6 @@ int ring_buffer_write(struct trace_buffer *buffer,
48494849

48504850
out_unlock:
48514851
trace_recursive_unlock(cpu_buffer);
4852-
4853-
out:
4854-
preempt_enable_notrace();
4855-
48564852
return ret;
48574853
}
48584854
EXPORT_SYMBOL_GPL(ring_buffer_write);

0 commit comments

Comments
 (0)