* [PATCH] tracing: Simplify seqfile code for format file
@ 2010-08-17 5:53 Li Zefan
2010-08-17 12:57 ` Steven Rostedt
2010-08-19 11:21 ` [tip:perf/core] tracing: Clean up " tip-bot for Li Zefan
0 siblings, 2 replies; 3+ messages in thread
From: Li Zefan @ 2010-08-17 5:53 UTC (permalink / raw)
To: Steven Rostedt; +Cc: Frederic Weisbecker, Ingo Molnar, LKML
We don't have to use the trick that marks a pointer's LSB to
distinguish event fields from common fields.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
---
kernel/trace/trace_events.c | 55 ++++++++++++++-----------------------------
1 files changed, 18 insertions(+), 37 deletions(-)
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 4c758f1..398c0e8 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -600,21 +600,29 @@ out:
enum {
FORMAT_HEADER = 1,
- FORMAT_PRINTFMT = 2,
+ FORMAT_FIELD_SEPERATOR = 2,
+ FORMAT_PRINTFMT = 3,
};
static void *f_next(struct seq_file *m, void *v, loff_t *pos)
{
struct ftrace_event_call *call = m->private;
struct ftrace_event_field *field;
- struct list_head *head;
+ struct list_head *common_head = &ftrace_common_fields;
+ struct list_head *head = trace_get_fields(call);
(*pos)++;
switch ((unsigned long)v) {
case FORMAT_HEADER:
- head = &ftrace_common_fields;
+ if (unlikely(list_empty(common_head)))
+ return NULL;
+
+ field = list_entry(common_head->prev,
+ struct ftrace_event_field, link);
+ return field;
+ case FORMAT_FIELD_SEPERATOR:
if (unlikely(list_empty(head)))
return NULL;
@@ -626,31 +634,10 @@ static void *f_next(struct seq_file *m, void *v, loff_t *pos)
return NULL;
}
- head = trace_get_fields(call);
-
- /*
- * To separate common fields from event fields, the
- * LSB is set on the first event field. Clear it in case.
- */
- v = (void *)((unsigned long)v & ~1L);
-
field = v;
- /*
- * If this is a common field, and at the end of the list, then
- * continue with main list.
- */
- if (field->link.prev == &ftrace_common_fields) {
- if (unlikely(list_empty(head)))
- return NULL;
- field = list_entry(head->prev, struct ftrace_event_field, link);
- /* Set the LSB to notify f_show to print an extra newline */
- field = (struct ftrace_event_field *)
- ((unsigned long)field | 1);
- return field;
- }
-
- /* If we are done tell f_show to print the format */
- if (field->link.prev == head)
+ if (field->link.prev == common_head)
+ return (void *)FORMAT_FIELD_SEPERATOR;
+ else if (field->link.prev == head)
return (void *)FORMAT_PRINTFMT;
field = list_entry(field->link.prev, struct ftrace_event_field, link);
@@ -688,22 +675,16 @@ static int f_show(struct seq_file *m, void *v)
seq_printf(m, "format:\n");
return 0;
+ case FORMAT_FIELD_SEPERATOR:
+ seq_putc(m, '\n');
+ return 0;
+
case FORMAT_PRINTFMT:
seq_printf(m, "\nprint fmt: %s\n",
call->print_fmt);
return 0;
}
- /*
- * To separate common fields from event fields, the
- * LSB is set on the first event field. Clear it and
- * print a newline if it is set.
- */
- if ((unsigned long)v & 1) {
- seq_putc(m, '\n');
- v = (void *)((unsigned long)v & ~1L);
- }
-
field = v;
/*
--
1.6.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tracing: Simplify seqfile code for format file
2010-08-17 5:53 [PATCH] tracing: Simplify seqfile code for format file Li Zefan
@ 2010-08-17 12:57 ` Steven Rostedt
2010-08-19 11:21 ` [tip:perf/core] tracing: Clean up " tip-bot for Li Zefan
1 sibling, 0 replies; 3+ messages in thread
From: Steven Rostedt @ 2010-08-17 12:57 UTC (permalink / raw)
To: Li Zefan; +Cc: Frederic Weisbecker, Ingo Molnar, LKML
On Tue, 2010-08-17 at 13:53 +0800, Li Zefan wrote:
> We don't have to use the trick that marks a pointer's LSB to
> distinguish event fields from common fields.
>
Hehe, you don't like tricks. I find it as a certain art to the magic of
programming ;-)
> Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
I'll pull this in and see if we can get this into 2.6.36 too.
Thanks!
-- Steve
> ---
> kernel/trace/trace_events.c | 55 ++++++++++++++-----------------------------
> 1 files changed, 18 insertions(+), 37 deletions(-)
>
> diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
> index 4c758f1..398c0e8 100644
> --- a/kernel/trace/trace_events.c
> +++ b/kernel/trace/trace_events.c
> @@ -600,21 +600,29 @@ out:
>
> enum {
> FORMAT_HEADER = 1,
> - FORMAT_PRINTFMT = 2,
> + FORMAT_FIELD_SEPERATOR = 2,
> + FORMAT_PRINTFMT = 3,
> };
>
> static void *f_next(struct seq_file *m, void *v, loff_t *pos)
> {
> struct ftrace_event_call *call = m->private;
> struct ftrace_event_field *field;
> - struct list_head *head;
> + struct list_head *common_head = &ftrace_common_fields;
> + struct list_head *head = trace_get_fields(call);
>
> (*pos)++;
>
> switch ((unsigned long)v) {
> case FORMAT_HEADER:
> - head = &ftrace_common_fields;
> + if (unlikely(list_empty(common_head)))
> + return NULL;
> +
> + field = list_entry(common_head->prev,
> + struct ftrace_event_field, link);
> + return field;
>
> + case FORMAT_FIELD_SEPERATOR:
> if (unlikely(list_empty(head)))
> return NULL;
>
> @@ -626,31 +634,10 @@ static void *f_next(struct seq_file *m, void *v, loff_t *pos)
> return NULL;
> }
>
> - head = trace_get_fields(call);
> -
> - /*
> - * To separate common fields from event fields, the
> - * LSB is set on the first event field. Clear it in case.
> - */
> - v = (void *)((unsigned long)v & ~1L);
> -
> field = v;
> - /*
> - * If this is a common field, and at the end of the list, then
> - * continue with main list.
> - */
> - if (field->link.prev == &ftrace_common_fields) {
> - if (unlikely(list_empty(head)))
> - return NULL;
> - field = list_entry(head->prev, struct ftrace_event_field, link);
> - /* Set the LSB to notify f_show to print an extra newline */
> - field = (struct ftrace_event_field *)
> - ((unsigned long)field | 1);
> - return field;
> - }
> -
> - /* If we are done tell f_show to print the format */
> - if (field->link.prev == head)
> + if (field->link.prev == common_head)
> + return (void *)FORMAT_FIELD_SEPERATOR;
> + else if (field->link.prev == head)
> return (void *)FORMAT_PRINTFMT;
>
> field = list_entry(field->link.prev, struct ftrace_event_field, link);
> @@ -688,22 +675,16 @@ static int f_show(struct seq_file *m, void *v)
> seq_printf(m, "format:\n");
> return 0;
>
> + case FORMAT_FIELD_SEPERATOR:
> + seq_putc(m, '\n');
> + return 0;
> +
> case FORMAT_PRINTFMT:
> seq_printf(m, "\nprint fmt: %s\n",
> call->print_fmt);
> return 0;
> }
>
> - /*
> - * To separate common fields from event fields, the
> - * LSB is set on the first event field. Clear it and
> - * print a newline if it is set.
> - */
> - if ((unsigned long)v & 1) {
> - seq_putc(m, '\n');
> - v = (void *)((unsigned long)v & ~1L);
> - }
> -
> field = v;
>
> /*
^ permalink raw reply [flat|nested] 3+ messages in thread
* [tip:perf/core] tracing: Clean up seqfile code for format file
2010-08-17 5:53 [PATCH] tracing: Simplify seqfile code for format file Li Zefan
2010-08-17 12:57 ` Steven Rostedt
@ 2010-08-19 11:21 ` tip-bot for Li Zefan
1 sibling, 0 replies; 3+ messages in thread
From: tip-bot for Li Zefan @ 2010-08-19 11:21 UTC (permalink / raw)
To: linux-tip-commits; +Cc: linux-kernel, hpa, mingo, rostedt, lizf, tglx
Commit-ID: 86397dc3ccfc0e17b7550d05eaf15fe91f6498dd
Gitweb: http://git.kernel.org/tip/86397dc3ccfc0e17b7550d05eaf15fe91f6498dd
Author: Li Zefan <lizf@cn.fujitsu.com>
AuthorDate: Tue, 17 Aug 2010 13:53:06 +0800
Committer: Steven Rostedt <rostedt@goodmis.org>
CommitDate: Wed, 18 Aug 2010 11:09:14 -0400
tracing: Clean up seqfile code for format file
Remove the nasty hack that marks a pointer's LSB to distinguish common
fields from event fields. Replace it with a more sane approach.
Signed-off-by: Li Zefan <lizf@cn.fujitsu.com>
LKML-Reference: <4C6A23C2.9020606@cn.fujitsu.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
---
kernel/trace/trace_events.c | 55 ++++++++++++++-----------------------------
1 files changed, 18 insertions(+), 37 deletions(-)
diff --git a/kernel/trace/trace_events.c b/kernel/trace/trace_events.c
index 4c758f1..398c0e8 100644
--- a/kernel/trace/trace_events.c
+++ b/kernel/trace/trace_events.c
@@ -600,21 +600,29 @@ out:
enum {
FORMAT_HEADER = 1,
- FORMAT_PRINTFMT = 2,
+ FORMAT_FIELD_SEPERATOR = 2,
+ FORMAT_PRINTFMT = 3,
};
static void *f_next(struct seq_file *m, void *v, loff_t *pos)
{
struct ftrace_event_call *call = m->private;
struct ftrace_event_field *field;
- struct list_head *head;
+ struct list_head *common_head = &ftrace_common_fields;
+ struct list_head *head = trace_get_fields(call);
(*pos)++;
switch ((unsigned long)v) {
case FORMAT_HEADER:
- head = &ftrace_common_fields;
+ if (unlikely(list_empty(common_head)))
+ return NULL;
+
+ field = list_entry(common_head->prev,
+ struct ftrace_event_field, link);
+ return field;
+ case FORMAT_FIELD_SEPERATOR:
if (unlikely(list_empty(head)))
return NULL;
@@ -626,31 +634,10 @@ static void *f_next(struct seq_file *m, void *v, loff_t *pos)
return NULL;
}
- head = trace_get_fields(call);
-
- /*
- * To separate common fields from event fields, the
- * LSB is set on the first event field. Clear it in case.
- */
- v = (void *)((unsigned long)v & ~1L);
-
field = v;
- /*
- * If this is a common field, and at the end of the list, then
- * continue with main list.
- */
- if (field->link.prev == &ftrace_common_fields) {
- if (unlikely(list_empty(head)))
- return NULL;
- field = list_entry(head->prev, struct ftrace_event_field, link);
- /* Set the LSB to notify f_show to print an extra newline */
- field = (struct ftrace_event_field *)
- ((unsigned long)field | 1);
- return field;
- }
-
- /* If we are done tell f_show to print the format */
- if (field->link.prev == head)
+ if (field->link.prev == common_head)
+ return (void *)FORMAT_FIELD_SEPERATOR;
+ else if (field->link.prev == head)
return (void *)FORMAT_PRINTFMT;
field = list_entry(field->link.prev, struct ftrace_event_field, link);
@@ -688,22 +675,16 @@ static int f_show(struct seq_file *m, void *v)
seq_printf(m, "format:\n");
return 0;
+ case FORMAT_FIELD_SEPERATOR:
+ seq_putc(m, '\n');
+ return 0;
+
case FORMAT_PRINTFMT:
seq_printf(m, "\nprint fmt: %s\n",
call->print_fmt);
return 0;
}
- /*
- * To separate common fields from event fields, the
- * LSB is set on the first event field. Clear it and
- * print a newline if it is set.
- */
- if ((unsigned long)v & 1) {
- seq_putc(m, '\n');
- v = (void *)((unsigned long)v & ~1L);
- }
-
field = v;
/*
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2010-08-19 11:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-17 5:53 [PATCH] tracing: Simplify seqfile code for format file Li Zefan
2010-08-17 12:57 ` Steven Rostedt
2010-08-19 11:21 ` [tip:perf/core] tracing: Clean up " tip-bot for Li Zefan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox