Skip to contentSkip to conversation

Format of funcgraph_{entry, exit} ftrace event

DISCUSSION Matteo Bertolino 2 participants 2 messages Aug 9, 2022

lore
Share & tools
lore
#0 lore raw

Dear community,
I wish to ask you some clarifications about the format of two ftrace events: funcgraph_entry and funcgraph_exit, basically those in $ANY_DEBUG_FS/tracing/events/ftrace. Let me copy and paste them here:

# cat funcgraph_entry/format
name: funcgraph_entry
ID: 11
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 long func;	offset:8;	size:8;	signed:0;
	field:int depth;	offset:16;	size:4;	signed:1;

print fmt: "--> %ps (%d)", (void *)REC->func, REC->depth

AND

# cat funcgraph_exit/format
name: funcgraph_exit
ID: 10
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 long func;	offset:8;	size:8;	signed:0;
	field:int depth;	offset:16;	size:4;	signed:1;
	field:unsigned int overrun;	offset:20;	size:4;	signed:0;
	field:unsigned long long calltime;	offset:24;	size:8;	signed:0;
	field:unsigned long long rettime;	offset:32;	size:8;	signed:0;

print fmt: "<-- %ps (%d) (start: %llx end: %llx) over: %d", (void *)REC->func, REC->depth, REC->calltime, REC->rettime, REC->depth

While writing a trace.dat, I know that all the entries have an header, described by the Linux ringbuffer format (file header_event):

# compressed entry header
	type_len    :    5 bits
	time_delta  :   27 bits
	array       :   32 bits
	padding     : type == 29
	time_extend : type == 30
	time_stamp : type == 31
	data max type_len  == 28

Such header includes a timestamp (that can be a delta of the timestamp present in the header_page).

I have one question for the ftrace's community:
Why are the following fields of a funcgraph_exit entry useful? calltime and rettime. They look like redundant for me, because the timing information is already present on the header_event.

Please can you clarify me whether I am wrong?
Best Regards && have lovely holidays,
Matteo

#1 lore raw
Quoted 13 lines · On Tue, 9 Aug 2022 13:32:04 +0000 Matteo Bertolino…

While writing a trace.dat, I know that all the entries have an header, described by the Linux ringbuffer format (file header_event):

# compressed entry header
	type_len    :    5 bits
	time_delta  :   27 bits
	array       :   32 bits
	padding     : type == 29
	time_extend : type == 30
	time_stamp : type == 31
	data max type_len  == 28
Quoted 5 lines

Such header includes a timestamp (that can be a delta of the timestamp present in the header_page).

I have one question for the ftrace's community:
Why are the following fields of a funcgraph_exit entry useful? calltime and rettime. They look like redundant for me, because the timing information is already present on the header_event.

The function graph infrastructure records the calltime and rettime and that can be used by other users than the tracer. That is, the users are not guaranteed to have timestamps of their own. Yes it is redundant for the tracing, but it is also a way to test to make sure the timings being recorded are accurate for the other use cases.

-- Steve