History

eprobes: Remove redundant event type information

Currently, the event probes save the type of the event they are attached to when recording the event. For example: # echo 'e:switch sched/sched_switch prev_state=$prev_state prev_prio=$prev_prio next_pid=$next_pid next_prio=$next_prio' > dynamic_events # cat events/eprobes/switch/format name: switch ID: 1717 format: field:unsigned short common_type; offset:0; size:2; signed:0; field:unsigned char common_flags; offset:2; size:1; signed:0; field:unsigned char common_preempt_count; offset:3; size:1; signed:0; field:int common_pid; offset:4; size:4; signed:1; field:unsigned int __probe_type; offset:8; size:4; signed:0; field:u64 prev_state; offset:12; size:8; signed:0; field:u64 prev_prio; offset:20; size:8; signed:0; field:u64 next_pid; offset:28; size:8; signed:0; field:u64 next_prio; offset:36; size:8; signed:0; print fmt: "(%u) prev_state=0x%Lx prev_prio=0x%Lx next_pid=0x%Lx next_prio=0x%Lx", REC->__probe_type, REC->prev_state, REC->prev_prio, REC->next_pid, REC->next_prio The __probe_type adds 4 bytes to every event. One of the reasons for creating eprobes is to limit what is traced in an event to be able to limit what is written into the ring buffer. Having this redundant 4 bytes to every event takes away from this. The event that is recorded can be retrieved from the event probe itself, that is available when the trace is happening. For user space tools, it could simply read the dynamic_event file to find the event they are for. So there is really no reason to write this information into the ring buffer for every event. Link: https://lkml.kernel.org/r/20220218190057.2f5a19a8@gandalf.local.home

Steven Rostedt (Google) committed 4 years ago

Commit b61edd51 parent 302e9ed4 files · +12 −16Browse files

Unified · Split

4 files
  1. kernel/trace/trace.h +0 −1
  2. kernel/trace/trace_eprobe.c +7 −9
  3. kernel/trace/trace_probe.c +5 −5
  4. kernel/trace/trace_probe.h +0 −1
kernel/trace/trace.h+0−1
@@ -136,7 +136,6 @@ struct kprobe_trace_entry_head { · 135 unmodified lines
136136
137137 struct eprobe_trace_entry_head {
138138 struct trace_entry ent;
139− unsigned int type;
140139 };
141140
142141 struct kretprobe_trace_entry_head {
kernel/trace/trace_eprobe.c+7−9
@@ -242,7 +242,6 @@ static int trace_eprobe_tp_arg_update(struct trace_eprobe *ep, int i) · 241 unmodified lines
242242
243243 static int eprobe_event_define_fields(struct trace_event_call *event_call)
244244 {
245− int ret;
246245 struct eprobe_trace_entry_head field;
247246 struct trace_probe *tp;
248247
@@ -250,8 +249,6 @@ static int eprobe_event_define_fields(struct trace_event_call *event_call) · 1 unmodified line
250249 if (WARN_ON_ONCE(!tp))
251250 return -ENOENT;
252251
253− DEFINE_FIELD(unsigned int, type, FIELD_STRING_TYPE, 0);
254−
255252 return traceprobe_define_arg_fields(event_call, sizeof(field), tp);
256253 }
257254
@@ -270,7 +267,9 @@ print_eprobe_event(struct trace_iterator *iter, int flags, · 12 unmodified lines
270267 struct trace_event_call *pevent;
271268 struct trace_event *probed_event;
272269 struct trace_seq *s = &iter->seq;
270+ struct trace_eprobe *ep;
273271 struct trace_probe *tp;
272+ unsigned int type;
274273
275274 field = (struct eprobe_trace_entry_head *)iter->ent;
276275 tp = trace_probe_primary_from_call(
@@ -278,15 +277,18 @@ print_eprobe_event(struct trace_iterator *iter, int flags, · 1 unmodified line
278277 if (WARN_ON_ONCE(!tp))
279278 goto out;
280279
280+ ep = container_of(tp, struct trace_eprobe, tp);
281+ type = ep->event->event.type;
282+
281283 trace_seq_printf(s, "%s: (", trace_probe_name(tp));
282284
283− probed_event = ftrace_find_event(field->type);
285+ probed_event = ftrace_find_event(type);
284286 if (probed_event) {
285287 pevent = container_of(probed_event, struct trace_event_call, event);
286288 trace_seq_printf(s, "%s.%s", pevent->class->system,
287289 trace_event_name(pevent));
288290 } else {
289− trace_seq_printf(s, "%u", field->type);
291+ trace_seq_printf(s, "%u", type);
290292 }
291293
292294 trace_seq_putc(s, ')');
@@ -498,10 +500,6 @@ __eprobe_trace_func(struct eprobe_data *edata, void *rec) · 205 unmodified lines
498500 return;
499501
500502 entry = fbuffer.entry = ring_buffer_event_data(fbuffer.event);
501− if (edata->ep->event)
502− entry->type = edata->ep->event->event.type;
503− else
504− entry->type = 0;
505503 store_trace_args(&entry[1], &edata->ep->tp, rec, sizeof(*entry), dsize);
506504
507505 trace_event_buffer_commit(&fbuffer);
kernel/trace/trace_probe.c+5−5
@@ -871,15 +871,15 @@ static int __set_print_fmt(struct trace_probe *tp, char *buf, int len, · 870 unmodified lines
871871 switch (ptype) {
872872 case PROBE_PRINT_NORMAL:
873873 fmt = "(%lx)";
874− arg = "REC->" FIELD_STRING_IP;
874+ arg = ", REC->" FIELD_STRING_IP;
875875 break;
876876 case PROBE_PRINT_RETURN:
877877 fmt = "(%lx <- %lx)";
878− arg = "REC->" FIELD_STRING_FUNC ", REC->" FIELD_STRING_RETIP;
878+ arg = ", REC->" FIELD_STRING_FUNC ", REC->" FIELD_STRING_RETIP;
879879 break;
880880 case PROBE_PRINT_EVENT:
881− fmt = "(%u)";
882− arg = "REC->" FIELD_STRING_TYPE;
881+ fmt = "";
882+ arg = "";
883883 break;
884884 default:
885885 WARN_ON_ONCE(1);
@@ -903,7 +903,7 @@ static int __set_print_fmt(struct trace_probe *tp, char *buf, int len, · 17 unmodified lines
903903 parg->type->fmt);
904904 }
905905
906− pos += snprintf(buf + pos, LEN_OR_ZERO, "\", %s", arg);
906+ pos += snprintf(buf + pos, LEN_OR_ZERO, "\"%s", arg);
907907
908908 for (i = 0; i < tp->nr_args; i++) {
909909 parg = tp->args + i;
kernel/trace/trace_probe.h+0−1
@@ -38,7 +38,6 @@ · 37 unmodified lines
3838 #define FIELD_STRING_IP "__probe_ip"
3939 #define FIELD_STRING_RETIP "__probe_ret_ip"
4040 #define FIELD_STRING_FUNC "__probe_func"
41−#define FIELD_STRING_TYPE "__probe_type"
4241
4342 #undef DEFINE_FIELD
4443 #define DEFINE_FIELD(type, item, name, is_signed) \

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t