public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Lai Jiangshan <laijs@cn.fujitsu.com>
To: Ingo Molnar <mingo@elte.hu>, Steven Rostedt <rostedt@goodmis.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Masami Hiramatsu <mhiramat@redhat.com>,
	Jason Baron <jbaron@redhat.com>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH V5 0/10] tracing: use defined fields to print formats
Date: Tue, 15 Dec 2009 15:39:10 +0800	[thread overview]
Message-ID: <4B273D1E.6070003@cn.fujitsu.com> (raw)

It seems that ftrace_format_##call() and ftrace_define_fields_##call()
are duplicate more or less.

trace_define_field() defines fields and links them into
strcut ftrace_event_call. We reuse them to print formats
and remove ftrace_format_##call(). It make all things simpler.

Quote(From Steven):
"""
I totally agree that your patch is a nice clean up, and saves space and 
prevents more bugs. On the other hand, we are changing an API to users 
where all tools that parse this must be able to cope.
"""

But now, this new patchset does not change any API to userspace.
PATCH#1 fix a mistake of trace_kprobe's format. You can

1) apply PATCH#1, compile, reboot with new kernel,
   add kprobe_events, save all the format files.

2) apply PATCH#2...10 additionally, compile, reboot with new kernel,
   add kprobe_events, save all the format files.

Take diffs of these two sets of format files, there are nothing changed.

So, this patchset does not change any API.

And this patchset does a nice cleanup and removes hunk of codes:
# size vmlinux.o.old vmlinux.o
   text    data     bss     dec     hex filename
5640127  589938 1299464 7529529  72e439 vmlinux.o.old
5620506  589938 1298888 7509332  729554 vmlinux.o

Patches are partitioned for easy to review:
PATCH#1~5 prepare (PATCH#2 fix a regression)
PATCH#6 add "print_fmt" field to struct ftrace_event_call and and initialization code for it.
PATCH#7 "print_fmt" initialization code for trace_syscalls
PATCH#8 "print_fmt" initialization code for trace_kprobe
PATCH#9 use defined fields and "print_fmt" to print formats
PATCH#10 remove show_format and corresponding codes.

How this patchset works:

# cat events/irq/irq_handler_entry/format
name: irq_handler_entry
ID: 97
format:

A) ======> name, ID, and a string "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:int common_lock_depth;    offset:8;       size:4; signed:1;

        field:int irq;  offset:12;      size:4; signed:1;
        field:__data_loc char[] name;   offset:16;      size:4; signed:1;

B) ========> fields.

print fmt: "irq=%d name=%s", REC->irq, __get_str(name)

C) ========> string "print fmt: " and the print format after it.

For B)
Ensure all fields are add into struct ftrace_event_call->fields. (patch#4)
Ensure all fields are correct. (patch#5)

For C)
add a print_fmt field (patch#6)
init print_fmt carefully (patch#6 and patch#7 patch#8)

So when we generate format file:
print name
print ID
print string "format:"
use struct ftrace_event_call->fields to print fields
use struct ftrace_event_call->print_fmt to print "print fmt: XXXXXXXXXXX"

-- Lai

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
---
 include/linux/ftrace_event.h  |    3
 include/linux/syscalls.h      |    8 --
 include/trace/ftrace.h        |  168 +++++++++---------------------------------
 include/trace/syscall.h       |    4 -
 kernel/trace/trace_events.c   |   78 ++++++++++---------
 kernel/trace/trace_export.c   |   94 ++++-------------------
 kernel/trace/trace_kprobe.c   |  103 +++++++++++--------------
 kernel/trace/trace_syscalls.c |   96 ++++++++++++------------
 8 files changed, 192 insertions(+), 362 deletions(-)


             reply	other threads:[~2009-12-15  7:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-12-15  7:39 Lai Jiangshan [this message]
2009-12-16  4:41 ` [PATCH V5 0/10] tracing: use defined fields to print formats Steven Rostedt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4B273D1E.6070003@cn.fujitsu.com \
    --to=laijs@cn.fujitsu.com \
    --cc=fweisbec@gmail.com \
    --cc=jbaron@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mhiramat@redhat.com \
    --cc=mingo@elte.hu \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox