From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754930AbcFPPOQ (ORCPT ); Thu, 16 Jun 2016 11:14:16 -0400 Received: from smtprelay0014.hostedemail.com ([216.40.44.14]:54108 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754593AbcFPPOO (ORCPT ); Thu, 16 Jun 2016 11:14:14 -0400 X-Session-Marker: 726F737465647440676F6F646D69732E6F7267 X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,rostedt@goodmis.org,:::::,RULES_HIT:2:41:355:379:541:599:800:960:966:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1535:1593:1594:1605:1606:1730:1747:1777:1792:1801:2196:2199:2393:2553:2559:2562:2693:3138:3139:3140:3141:3142:3622:3865:3866:3867:3868:3870:3871:3872:3874:4117:4321:4362:4385:4605:5007:6119:6120:6261:6299:7576:7774:7875:8957:9040:10004:10848:10967:11026:11232:11473:11658:11914:12043:12050:12109:12291:12296:12438:12517:12519:12555:12683:12740:13439:14093:14097:14659:21060:21080:30029:30051:30054:30062:30064:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: wall33_7938bb491e02 X-Filterd-Recvd-Size: 6815 Date: Thu, 16 Jun 2016 11:14:10 -0400 From: Steven Rostedt To: Omar Sandoval Cc: linux-kernel@vger.kernel.org, kernel-team@fb.com Subject: Re: [PATCH] trace-cmd record: add --max-graph-depth option Message-ID: <20160616111410.0ac2b4eb@gandalf.local.home> In-Reply-To: <52d19bb3c0daf4d03db68da438c605b318ca41a8.1466021761.git.osandov@fb.com> References: <52d19bb3c0daf4d03db68da438c605b318ca41a8.1466021761.git.osandov@fb.com> X-Mailer: Claws Mail 3.13.2 (GTK+ 2.24.30; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 15 Jun 2016 13:18:21 -0700 Omar Sandoval wrote: > From: Omar Sandoval > > This is exposed in debugfs but there's no quick way to set it with > trace-cmd. While we're adding support for this, fix --profile so it sets > max_graph_depth back to whatever it was before. > > Signed-off-by: Omar Sandoval Hi! Thanks for the patch. I don't mind the long name, but I would also like a short cut version. Maybe use 'L'? (as mMgGdD are already used :-p) I may just pull this patch and add the shortcut myself. Thanks! -- Steve > --- > Documentation/trace-cmd-record.1.txt | 5 ++++ > trace-record.c | 52 +++++++++++++++++++++++++++--------- > trace-usage.c | 1 + > 3 files changed, 45 insertions(+), 13 deletions(-) > > diff --git a/Documentation/trace-cmd-record.1.txt b/Documentation/trace-cmd-record.1.txt > index d88050d87558..b80520e5e815 100644 > --- a/Documentation/trace-cmd-record.1.txt > +++ b/Documentation/trace-cmd-record.1.txt > @@ -263,6 +263,11 @@ OPTIONS > timestamp to gettimeofday which will allow wall time output from the > timestamps reading the created 'trace.dat' file. > > +*--max-graph-depth* 'depth':: > + Set the maximum depth the function_graph tracer will trace into a function. > + A value of one will only show where userspace enters the kernel but not any > + functions called in the kernel. The default is zero, which means no limit. > + > *--profile*:: > With the *--profile* option, "trace-cmd" will enable tracing that can > be used with trace-cmd-report(1) --profile option. If a tracer *-p* is > diff --git a/trace-record.c b/trace-record.c > index 9f220c9c6330..fc124b7f1e98 100644 > --- a/trace-record.c > +++ b/trace-record.c > @@ -2180,6 +2180,20 @@ static void set_clock(struct buffer_instance *instance) > write_instance_file(instance, "trace_clock", instance->clock, "clock"); > } > > +static void set_max_graph_depth(struct buffer_instance *instance, char *max_graph_depth) > +{ > + char *path; > + int ret; > + > + path = get_instance_file(instance, "max_graph_depth"); > + reset_save_file(path, RESET_DEFAULT_PRIO); > + tracecmd_put_tracing_file(path); > + ret = write_instance_file(instance, "max_graph_depth", max_graph_depth, > + NULL); > + if (ret < 0) > + die("could not write to max_graph_depth"); > +} > + > static struct event_list * > create_event(struct buffer_instance *instance, char *path, struct event_list *old_event) > { > @@ -3993,7 +4007,6 @@ profile_add_event(struct buffer_instance *instance, const char *event_str, int s > static void enable_profile(struct buffer_instance *instance) > { > int stacktrace = 0; > - int ret; > int i; > char *trigger_events[] = { > "sched:sched_switch", > @@ -4015,10 +4028,7 @@ static void enable_profile(struct buffer_instance *instance) > if (!instance->plugin) { > if (trace_check_file_exists(instance, "max_graph_depth")) { > instance->plugin = "function_graph"; > - ret = write_instance_file(instance, "max_graph_depth", > - "1", NULL); > - if (ret < 0) > - die("could not write to max_graph_depth"); > + set_max_graph_depth(instance, "1"); > } else > warning("Kernel does not support max_graph_depth\n" > " Skipping user/kernel profiling"); > @@ -4103,14 +4113,16 @@ void update_first_instance(struct buffer_instance *instance, int topt) > } > > enum { > - OPT_debug = 247, > - OPT_tsoffset = 249, > - OPT_bycomm = 250, > - OPT_stderr = 251, > - OPT_profile = 252, > - OPT_nosplice = 253, > - OPT_funcstack = 254, > - OPT_date = 255, > + > + OPT_debug = 247, > + OPT_max_graph_depth = 248, > + OPT_tsoffset = 249, > + OPT_bycomm = 250, > + OPT_stderr = 251, > + OPT_profile = 252, > + OPT_nosplice = 253, > + OPT_funcstack = 254, > + OPT_date = 255, > }; > > void trace_record (int argc, char **argv) > @@ -4140,6 +4152,7 @@ void trace_record (int argc, char **argv) > int neg_event = 0; > int date = 0; > int manual = 0; > + char *max_graph_depth = NULL; > int topt = 0; > int do_child = 0; > int data_flags = 0; > @@ -4311,6 +4324,7 @@ void trace_record (int argc, char **argv) > {"stderr", no_argument, NULL, OPT_stderr}, > {"by-comm", no_argument, NULL, OPT_bycomm}, > {"ts-offset", required_argument, NULL, OPT_tsoffset}, > + {"max-graph-depth", required_argument, NULL, OPT_max_graph_depth}, > {"debug", no_argument, NULL, OPT_debug}, > {"help", no_argument, NULL, '?'}, > {NULL, 0, NULL, 0} > @@ -4574,6 +4588,12 @@ void trace_record (int argc, char **argv) > die("Can not use both --date and --ts-offset"); > data_flags |= DATA_FL_OFFSET; > break; > + case OPT_max_graph_depth: > + free(max_graph_depth); > + max_graph_depth = strdup(optarg); > + if (!max_graph_depth) > + die("Could not allocate option"); > + break; > case OPT_debug: > debug = 1; > break; > @@ -4691,6 +4711,12 @@ void trace_record (int argc, char **argv) > > set_options(); > > + if (max_graph_depth) { > + for_all_instances(instance) > + set_max_graph_depth(instance, max_graph_depth); > + free(max_graph_depth); > + } > + > allocate_seq(); > > if (type & (TRACE_TYPE_RECORD | TRACE_TYPE_STREAM)) { > diff --git a/trace-usage.c b/trace-usage.c > index b5304ef9fda1..5c1a69255581 100644 > --- a/trace-usage.c > +++ b/trace-usage.c > @@ -52,6 +52,7 @@ static struct usage_help usage_help[] = { > " --profile enable tracing options needed for report --profile\n" > " --func-stack perform a stack trace for function tracer\n" > " (use with caution)\n" > + " --max-graph-depth limit function_graph depth\n" > }, > { > "start",