[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20131123041656.0bb78a4c@gandalf.local.home>
Date: Sat, 23 Nov 2013 04:16:56 -0500
From: Steven Rostedt <rostedt@...dmis.org>
To: Namhyung Kim <namhyung@...nel.org>
Cc: Jiri Olsa <jolsa@...hat.com>, linux-kernel@...r.kernel.org,
Corey Ashford <cjashfor@...ux.vnet.ibm.com>,
Frederic Weisbecker <fweisbec@...il.com>,
Ingo Molnar <mingo@...e.hu>, Paul Mackerras <paulus@...ba.org>,
Peter Zijlstra <a.p.zijlstra@...llo.nl>,
Arnaldo Carvalho de Melo <acme@...hat.com>,
David Ahern <dsahern@...il.com>
Subject: Re: [PATCH 09/22] tools lib traceevent: Add sched_switch plugin
On Fri, 22 Nov 2013 23:53:54 +0900
Namhyung Kim <namhyung@...nel.org> wrote:
> 2013-11-21 (목), 12:01 +0100, Jiri Olsa:
>
> > Backporting sched_switch plugin.
> >
> > Backported from Steven Rostedt's trace-cmd repo (HEAD 0f2c2fb):
> > git://git.kernel.org/pub/scm/linux/kernel/git/rostedt/trace-cmd.git
> >
> > This plugin adds fields resolving for
> > sched:sched_switch tracepoint event.
> >
> > The diff of 'perf script' output generated by old and new code:
> > (data was generated by 'perf record -e sched:sched_switch -a')
> >
> > --- script.sched_switch.old
> > +++ script.sched_switch.new
> > - perf 577 [002] 30965.311852: sched:sched_switch: prev_comm=perf prev_pid=577 prev_prio=120 prev_state=S ==> next_comm=swapper/2 next_pid=0 next_prio=120
> > + perf 577 [002] 30965.311852: sched:sched_switch: perf:577 [120] S ==> swapper/2:0 [120]
>
>
> [SNIP]
>
> > +
> > +static int sched_switch_handler(struct trace_seq *s,
> > + struct pevent_record *record,
> > + struct event_format *event, void *context)
> > +{
> > + struct format_field *field;
> > + unsigned long long val;
> > +
> > + if (pevent_get_field_val(s, event, "prev_pid", record, &val, 1))
> > + return trace_seq_putc(s, '!');
> > +
> > + field = pevent_find_any_field(event, "prev_comm");
> > + if (field) {
> > + write_and_save_comm(field, record, s, val);
> > + trace_seq_putc(s, ':');
> > + }
> > + trace_seq_printf(s, "%lld ", val);
> > +
> > + if (pevent_get_field_val(s, event, "prev_prio", record, &val, 0) == 0)
> > + trace_seq_printf(s, "[%lld] ", val);
> > +
> > + if (pevent_get_field_val(s, event, "prev_state", record, &val, 0) == 0)
> > + write_state(s, val);
> > +
> > + trace_seq_puts(s, " ==> ");
> > +
> > + if (pevent_get_field_val(s, event, "next_pid", record, &val, 1))
> > + return trace_seq_putc(s, '!');
>
>
> Like I said in the previous reply, it'd better to avoid returning from
> the middle of function IMHO. If it's really critical info, check it at
> the beginning of the function and bail out before print anything.
>
Well, it shouldn't lose any data, as I said in a previous reply, it
will print (reprint) the data as if the plugin didn't exist.
-- Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists