Skip to content

Commit 0e730bc

Browse files
committed
tracing: Move __trace_buffer_{un}lock_*() functions to trace.h
The file trace.c has become a catchall for most things tracing. Start making it smaller by breaking out various aspects into their own files. Move the __always_inline functions __trace_buffer_lock_reserve(), __trace_buffer_unlock_commit() and trace_event_setup() into trace.h. The trace.c file will be split up and these functions will be used in more than one of these files. As they are already __always_inline they can easily be moved into the trace.h header file. Cc: Masami Hiramatsu <mhiramat@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com> Cc: Andrew Morton <akpm@linux-foundation.org> Link: https://patch.msgid.link/20260208032449.813550600@kernel.org Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
1 parent a4f77ff commit 0e730bc

2 files changed

Lines changed: 41 additions & 42 deletions

File tree

kernel/trace/trace.c

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1058,30 +1058,6 @@ static inline void ftrace_trace_stack(struct trace_array *tr,
10581058

10591059
#endif
10601060

1061-
static __always_inline void
1062-
trace_event_setup(struct ring_buffer_event *event,
1063-
int type, unsigned int trace_ctx)
1064-
{
1065-
struct trace_entry *ent = ring_buffer_event_data(event);
1066-
1067-
tracing_generic_entry_update(ent, type, trace_ctx);
1068-
}
1069-
1070-
static __always_inline struct ring_buffer_event *
1071-
__trace_buffer_lock_reserve(struct trace_buffer *buffer,
1072-
int type,
1073-
unsigned long len,
1074-
unsigned int trace_ctx)
1075-
{
1076-
struct ring_buffer_event *event;
1077-
1078-
event = ring_buffer_lock_reserve(buffer, len);
1079-
if (event != NULL)
1080-
trace_event_setup(event, type, trace_ctx);
1081-
1082-
return event;
1083-
}
1084-
10851061
void tracer_tracing_on(struct trace_array *tr)
10861062
{
10871063
if (tr->array_buffer.buffer)
@@ -1109,24 +1085,6 @@ void tracing_on(void)
11091085
}
11101086
EXPORT_SYMBOL_GPL(tracing_on);
11111087

1112-
1113-
static __always_inline void
1114-
__buffer_unlock_commit(struct trace_buffer *buffer, struct ring_buffer_event *event)
1115-
{
1116-
__this_cpu_write(trace_taskinfo_save, true);
1117-
1118-
/* If this is the temp buffer, we need to commit fully */
1119-
if (this_cpu_read(trace_buffered_event) == event) {
1120-
/* Length is in event->array[0] */
1121-
ring_buffer_write(buffer, event->array[0], &event->array[1]);
1122-
/* Release the temp buffer */
1123-
this_cpu_dec(trace_buffered_event_cnt);
1124-
/* ring_buffer_unlock_commit() enables preemption */
1125-
preempt_enable_notrace();
1126-
} else
1127-
ring_buffer_unlock_commit(buffer);
1128-
}
1129-
11301088
int __trace_array_puts(struct trace_array *tr, unsigned long ip,
11311089
const char *str, int size)
11321090
{

kernel/trace/trace.h

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,6 +1568,47 @@ char *trace_user_fault_read(struct trace_user_buf_info *tinfo,
15681568
const char __user *ptr, size_t size,
15691569
trace_user_buf_copy copy_func, void *data);
15701570

1571+
static __always_inline void
1572+
trace_event_setup(struct ring_buffer_event *event,
1573+
int type, unsigned int trace_ctx)
1574+
{
1575+
struct trace_entry *ent = ring_buffer_event_data(event);
1576+
1577+
tracing_generic_entry_update(ent, type, trace_ctx);
1578+
}
1579+
1580+
static __always_inline struct ring_buffer_event *
1581+
__trace_buffer_lock_reserve(struct trace_buffer *buffer,
1582+
int type,
1583+
unsigned long len,
1584+
unsigned int trace_ctx)
1585+
{
1586+
struct ring_buffer_event *event;
1587+
1588+
event = ring_buffer_lock_reserve(buffer, len);
1589+
if (event != NULL)
1590+
trace_event_setup(event, type, trace_ctx);
1591+
1592+
return event;
1593+
}
1594+
1595+
static __always_inline void
1596+
__buffer_unlock_commit(struct trace_buffer *buffer, struct ring_buffer_event *event)
1597+
{
1598+
__this_cpu_write(trace_taskinfo_save, true);
1599+
1600+
/* If this is the temp buffer, we need to commit fully */
1601+
if (this_cpu_read(trace_buffered_event) == event) {
1602+
/* Length is in event->array[0] */
1603+
ring_buffer_write(buffer, event->array[0], &event->array[1]);
1604+
/* Release the temp buffer */
1605+
this_cpu_dec(trace_buffered_event_cnt);
1606+
/* ring_buffer_unlock_commit() enables preemption */
1607+
preempt_enable_notrace();
1608+
} else
1609+
ring_buffer_unlock_commit(buffer);
1610+
}
1611+
15711612
static inline void
15721613
__trace_event_discard_commit(struct trace_buffer *buffer,
15731614
struct ring_buffer_event *event)

0 commit comments

Comments
 (0)