Hi Steve,
On Friday 09 December 2016 09:11 AM, Steven Rostedt wrote:
On Fri, 9 Dec 2016 10:08:35 +0800 Dave Young dyoung@redhat.com wrote:
Ccing Steven, see if he has some comments about the design.
Thanks!
[snip]
+int main(int argc, char *argv[]) +{
- char trace_dir[64];
- struct sigaction sterm, sprint;
- pthread_t tid;
- int i;
- if (argc >= 2 && strlen(argv[1]) < 64)
strcpy(trace_dir, argv[1]);
- else
strcpy(trace_dir, "/sys/kernel/debug/tracing/");
- if (argc >= 3 && strlen(argv[2]) < 64)
strcpy(trace_info.log_path, argv[2]);
- else
strcpy(trace_info.log_path, DEFAULT_LOG_PATH);
- strcpy(trace_info.trace_path, trace_dir);
- strcat(trace_info.trace_path, "trace_pipe");
Please don't parse the text files. Can you open up the per_cpu trace_pipe_raw instead.
I stated playing with trace_pipe_raw. But, I am a bit confused with lack of documentation around the format of ring buffer raw data (I tried to look through kenrel/trace-cmd code, and may be I am not looking at the right section of code, probably you can help here with some pointers).
This is what I understood:
Every page of data will have:
- 8 bytes of timestamp - 4/8 bytes (long) of flags+size - size bytes of data - 4/8 bytes of lost_events
Now coming to data, it will have: - 4 bytes of type_len + time_delta - If type is padding, then next 4 bytes pad length - if type is time_extend, then next 4 bytes about extend info - if it is time_stamp, next 12 byes is time_stamp info - if it is 0, next 4 bytes is length of data - else data length is type_len * 4. and data should be as per format specified in events/system/subsystem/format.
For sure there is something wrong with above understanding, because it does not map to the data I am getting.
I got first few bytes of a page data like following (event id which was enabled: mm_page_free = 0x1be)
15 df e7 60 b ba 0 0 e4 f 0 c0 ff ff ff ff 6 0 0 0 be 1 0 0 6a 6b 0 0 36 a3 22 0 0 0 0 0 0 0 0 0 ca 80 42 2 e6 18 0 0 be 1 0 0 6a 6b 0 0 82 1c 20
So here: time stamp -> 15 df e7 60 b ba 0 0 flags+size -> e4 f 0 c0 ff ff ff ff (so size if 0xfe4, which seems correct) type_len_ts -> 6 0 0 0 type_len = 0x6 there fore data length should be 24 data -> be 1 0 0 6a 6b 0 0 36 a3 22 0 0 0 0 0 0 0 0 0 ca 80 42 2 So, it seems to be of mm_page_free, but they are not matching completely with the format specified in events/kmem/mm_page_free/format. So, whats missing?
Next type_len_ts -> e6 18 0 0 This also not seems correct type_len_ts, so I missed something and I am at wrong offset.
Can you please help me with some pointer so that I can parse them correctly.
Thanks
~Pratyush
PS: # cat /sys/kernel/debug/tracing/events/kmem/mm_page_free/format name: mm_page_free ID: 446 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 pfn; offset:8; size:8; signed:0; field:unsigned int order; offset:16; size:4; signed:0;
print fmt: "page=%p pfn=%lu order=%d", (((struct page *)vmemmap_base) + (REC->pfn)), REC->pfn, REC->order