From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754799Ab3KWJRD (ORCPT ); Sat, 23 Nov 2013 04:17:03 -0500 Received: from cdptpa-outbound-snat.email.rr.com ([107.14.166.226]:49338 "EHLO cdptpa-oedge-vip.email.rr.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750791Ab3KWJQ6 convert rfc822-to-8bit (ORCPT ); Sat, 23 Nov 2013 04:16:58 -0500 Date: Sat, 23 Nov 2013 04:16:56 -0500 From: Steven Rostedt To: Namhyung Kim Cc: Jiri Olsa , linux-kernel@vger.kernel.org, Corey Ashford , Frederic Weisbecker , Ingo Molnar , Paul Mackerras , Peter Zijlstra , Arnaldo Carvalho de Melo , David Ahern Subject: Re: [PATCH 09/22] tools lib traceevent: Add sched_switch plugin Message-ID: <20131123041656.0bb78a4c@gandalf.local.home> In-Reply-To: <1385132034.1747.58.camel@leonhard> References: <1385031680-9014-1-git-send-email-jolsa@redhat.com> <1385031680-9014-10-git-send-email-jolsa@redhat.com> <1385132034.1747.58.camel@leonhard> X-Mailer: Claws Mail 3.9.2 (GTK+ 2.24.20; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8BIT X-RR-Connecting-IP: 107.14.168.118:25 X-Cloudmark-Score: 0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 22 Nov 2013 23:53:54 +0900 Namhyung Kim 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