Re: [PATCH] ftrace: support binary record

From: Lai Jiangshan
Date: Tue Dec 09 2008 - 23:52:52 EST


Steven Rostedt wrote:
>
>
> On Wed, 10 Dec 2008, Lai Jiangshan wrote:
>
>> Binary record will save memory in trace buffer, and more events
>> can be recorded in buffer.
>>
>> This patch add infrastructure for supporting binary record.
>>
>> This infrastructure records events by binary and shows events
>> by human readable text.
>
> Hmm, interesting. But could you show an example of its use. It is quite a
> lot of code, and looks a little complex.
consider ftrace_struct_printk() as ftrace_printk(), but the
first parameter is "struct ftrace_struct *fmt"

new file: kernel/trace/trace_struct.c : this infrastructure's code

lib/vsprintf.c : formator
other files add ftrace_struct_printk()

>
>> And add a API ftrace_struct_printk() using this infrastructure.
>> (it's like ftrace_printk(), but it record the date by binary)
>>


example:
...
<...>-3246 [000] 1243.166054: sys_read: sys_read by ftrace_printk, 3, asdfuuuuu
<...>-3246 [000] 1243.166057: sys_read: sys_read by ftrace_struct_printk, 3, asdfuuuuu
<...>-3246 [000] 1243.166490: sys_read: sys_read by ftrace_printk, 9, asdfuuuuu
<...>-3246 [000] 1243.166491: sys_read: sys_read by ftrace_struct_printk, 9, asdfuuuuu
...
diff --git a/fs/read_write.c b/fs/read_write.c
index 969a6d9..0d9fbed 100644
--- a/fs/read_write.c
+++ b/fs/read_write.c
@@ -17,7 +17,7 @@
#include <linux/pagemap.h>
#include <linux/splice.h>
#include "read_write.h"
-
+#include <linux/ftrace.h>
#include <asm/uaccess.h>
#include <asm/unistd.h>

@@ -356,12 +356,15 @@ static inline void file_pos_write(struct file *file, loff_t pos)
file->f_pos = pos;
}

+struct ftrace_struct test = {"ixxs", "sys_read by ftrace_struct_printk, %d, %s\n"};
asmlinkage ssize_t sys_read(unsigned int fd, char __user * buf, size_t count)
{
struct file *file;
ssize_t ret = -EBADF;
int fput_needed;

+ ftrace_printk("sys_read by ftrace_printk, %d, %s\n", fd, "asdfuuuuu");
+ ftrace_struct_printk(&test, fd, "asdfuuuuu");
file = fget_light(fd, &fput_needed);
if (file) {
loff_t pos = file_pos_read(file);

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/