Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp867700ybk; Wed, 20 May 2020 14:11:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGPhQt7KGUmSFG1ciW23I0M8S70NVYAb5dsRjJSD5/XCcerHxydOuwa0VIB6pFWvHZ0xdd X-Received: by 2002:a17:906:4dc3:: with SMTP id f3mr866651ejw.323.1590009102934; Wed, 20 May 2020 14:11:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590009102; cv=none; d=google.com; s=arc-20160816; b=jFHX7vhQk4iRLzGSn/XS4yJxHE6HBioF450d9ZUnhkX5tAB9sCItTZdpjOL/ZdAD8e Ni0VCowXKqTqt8HQqDT6ORHo8AxerkbdRWB+guoGeBRbDWQfUeI12jjhCrFp+qVrB19D Gyc3W5yG2h49RmUnQ8VOkeZ+67iNz+Ksegr5jsk5vJ8iorPd9G64yq8GsQRqg+4tIYld YEty9qxG83F2GJRszUaxzoSFORzr3FNTFut1YsniM1LV6WXb/IRbhV0+pQxlHwa83RLv MCcOn/9UIRBMn32lwAFZcyOGJoBzlgdjRGUDLEO6Ky6KwTQ9PY/p+VdFKSb5Q6UlGjoz BDqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=ClQZHh55oAJYyTkgUu/sNKzx5eEt6WTtJJ8zOFQPYkE=; b=H/f8SINR+Pn3djgaQVG9hED5mHNooT20SPN9QA7qdW63ywPvoMwGRQh2NHxQdIP+NG FFZzo2mni8sKSIeu7HOlyHnciPGGoRIjJVv3trGE2Xz8i4m5PiztfNU9iTTKUKwtVdqW m+rC1kt2WS7LijAZCGU1eaJSAKwG1FEjAq2hqys9z+v906WfbREXYvM3ZxHHMsVSSWfg s802EfH1goNCdcGDwYSS6ia9WA9yisjFakQ0aF8jYtrqW3yJNDNt0AtlkMy2moXSAGHT rajhI2TNTgdIW/+4jiC+n8dAZHIxRENRLoD4gi6z3/yNhOvrqoALC9AMsYOJUp+9WKHb zaOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="F87wIk/d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o11si2259536ejg.582.2020.05.20.14.11.20; Wed, 20 May 2020 14:11:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="F87wIk/d"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727942AbgETVHp (ORCPT + 99 others); Wed, 20 May 2020 17:07:45 -0400 Received: from mail.kernel.org ([198.145.29.99]:33598 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727018AbgETVHo (ORCPT ); Wed, 20 May 2020 17:07:44 -0400 Received: from quaco.ghostprotocols.net (unknown [179.97.37.151]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id E330C207E8; Wed, 20 May 2020 21:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590008864; bh=CtGRHuKKEnDSvWHoHfzqUcrsu2KIrLcF0btXPapMeP8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=F87wIk/dB6+dhyT1DY3Gb7YCK7vp62MVuNJo34F3+iDjA/v9CYJh9FbFUKUKBCsUM MhGCElWMn5/KroWVA3UkePMpfdfS5+O/wS1WqvgQwjFMOVNPTj323uL0gd2RuAzC/Y bAjceJjT+51WfpT/7rSgpgIpJge7t0WshohGWfE0= Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id CFEEF40AFD; Wed, 20 May 2020 18:07:41 -0300 (-03) Date: Wed, 20 May 2020 18:07:41 -0300 From: Arnaldo Carvalho de Melo To: Changbin Du Cc: Jiri Olsa , Peter Zijlstra , Ingo Molnar , Namhyung Kim , Steven Rostedt , linux-kernel@vger.kernel.org Subject: Re: [PATCH 11/19] perf ftrace: add option '-u/--userstacktrace' to show userspace stacktrace Message-ID: <20200520210741.GZ32678@kernel.org> References: <20200510150628.16610-1-changbin.du@gmail.com> <20200510150628.16610-12-changbin.du@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200510150628.16610-12-changbin.du@gmail.com> X-Url: http://acmel.wordpress.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Sun, May 10, 2020 at 11:06:20PM +0800, Changbin Du escreveu: > This adds an option ''-u/--userstacktrace' for function tracer to display > userspace back trace. Probably we should have this as a term, an option to --call-graph? For --call-graph the way to suppress this is to ask for the event to be in the kernel only, i.e. something like: perf record -e cycles:k --call-graph So perhaps we should have something like: perf ftrace --call-graph With some default, possibly a bit different than the other perf tools, just including the kernel, and accepting: perf ftrace --call-graph perf ftrace --call-graph k perf ftrace --call-graph u perf ftrace --call-graph uk - Arnaldo > Signed-off-by: Changbin Du > --- > tools/perf/builtin-ftrace.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) > > diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c > index 2ef5d1c4b23c..ab76ba66bd9e 100644 > --- a/tools/perf/builtin-ftrace.c > +++ b/tools/perf/builtin-ftrace.c > @@ -40,6 +40,7 @@ struct perf_ftrace { > struct list_head nograph_funcs; > int graph_depth; > bool func_stack_trace; > + bool userstacktrace; > bool nosleep_time; > bool nofuncgraph_irqs; > bool funcgraph_tail; > @@ -197,6 +198,8 @@ static void reset_tracing_options(struct perf_ftrace *ftrace __maybe_unused) > write_tracing_option_file("funcgraph-proc", "0"); > write_tracing_option_file("funcgraph-abstime", "0"); > write_tracing_option_file("irq-info", "0"); > + write_tracing_option_file("userstacktrace", "0"); > + write_tracing_option_file("sym-userobj", "0"); > } > > static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused) > @@ -287,6 +290,20 @@ static int set_tracing_func_stack_trace(struct perf_ftrace *ftrace) > return 0; > } > > +static int set_tracing_userstacktrace(struct perf_ftrace *ftrace) > +{ > + if (!ftrace->userstacktrace) > + return 0; > + > + if (write_tracing_option_file("userstacktrace", "1") < 0) > + return -1; > + > + if (write_tracing_option_file("sym-userobj", "1") < 0) > + return -1; > + > + return 0; > +} > + > static int reset_tracing_cpu(void) > { > struct perf_cpu_map *cpumap = perf_cpu_map__new(NULL); > @@ -482,6 +499,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) > goto out_reset; > } > > + if (set_tracing_userstacktrace(ftrace) < 0) { > + pr_err("failed to set tracing option userstacktrace\n"); > + goto out_reset; > + } > + > if (set_tracing_filters(ftrace) < 0) { > pr_err("failed to set tracing filters\n"); > goto out_reset; > @@ -644,6 +666,8 @@ int cmd_ftrace(int argc, const char **argv) > "do not trace given functions", parse_filter_func), > OPT_BOOLEAN('s', "func-stack-trace", &ftrace.func_stack_trace, > "Show kernel stack trace for function tracer"), > + OPT_BOOLEAN('u', "userstacktrace", &ftrace.userstacktrace, > + "Show stacktrace of the current user space thread"), > OPT_CALLBACK_DEFAULT('G', "graph-funcs", &ftrace.graph_funcs, "func", > "Set graph filter on given functions (imply to use function_graph tracer)", > parse_filter_func, "*"), > -- > 2.25.1 > -- - Arnaldo