Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp915585ybt; Sun, 14 Jun 2020 04:18:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwVrXgGkZ8ubNrY8ISizwvXlyz2zQycnnvAVtDVhequUv2kUXs53KQEnaStjQFE1quaLqMp X-Received: by 2002:aa7:c2c4:: with SMTP id m4mr18989764edp.299.1592133488100; Sun, 14 Jun 2020 04:18:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592133488; cv=none; d=google.com; s=arc-20160816; b=MRWdrClh1Onl+ZwMoPNux0ArCvpFiwGsFh6tM7pOc8YQV0FDkgfsP6uXVZk2SbZeRC CD/jKZNcsm9EiVa/q6s8tDUZakOeMFVJuE+fH4pwyDTLOgNk17ovzltg2Glqr7EtHBCZ HfJVPawIGmZka2ypw/6z8R0DTuAjBzA63tGcgPmatDz6JpoAOsk7UzFF8j5gGzJ7PZMm PtIeLk2PbeIr1QJ9pnSS1oiSY8+uQKJrz2k2hgVeJvzAMJ3G5BPEgB5T6TpnwG40RYgZ qrweqIz4yOZ+UcQolsy763j4SAe2+98iit9pRXZHxHfDA5GMMJa3bseFxCHkYSQquFdB vOOA== 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=eBlVedxbnk0zmCSE3D/dt+HsodVO7NisY+35aq1wEbc=; b=cteq3vSfwnra9mbyemBsv4mjxp4D4R4QV8uZs/lRAtzlSRYyY1OtxMH955uFOFf51g ULq39LF/qP9ib+OKHCfZefSjotuGFfVtPwmfwb74zMfwQmAvJCRn581dlWhmbzGIS0ER UOqNvnSM1yemWa7GCfYaa7zZ9f0NoWA59u3srRaJtYGQTm4U+GGURueQfXcLDgm/jPF/ ZrBCfeyjB4rRTvCoR9UrmnETGhdym8hQpt4qLJ1krPvSO2gAotk0KzwftJPuzivaKuYR /hxQ2GR2iBrdJQJwORzOphGfNy/skHGq2MoIKnEwg+I2yo070ElPUEhRFfZhqMRCM7NJ ofPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=RDzm80tk; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r22si7336446eji.209.2020.06.14.04.17.45; Sun, 14 Jun 2020 04:18:08 -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=@gmail.com header.s=20161025 header.b=RDzm80tk; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727064AbgFNLP7 (ORCPT + 99 others); Sun, 14 Jun 2020 07:15:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727060AbgFNLP5 (ORCPT ); Sun, 14 Jun 2020 07:15:57 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 117F0C05BD43 for ; Sun, 14 Jun 2020 04:15:57 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id v14so1327663pgl.1 for ; Sun, 14 Jun 2020 04:15:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=eBlVedxbnk0zmCSE3D/dt+HsodVO7NisY+35aq1wEbc=; b=RDzm80tkjqd34Q70BUzo6XAV/GZKBxISFxQmgs+sQD7GdJDFtrsO0xgPTgCyD8Qnz6 Yc9mWptsiVMhwEL8rvcf2v5uBkY9i28bWsXS33kIH5QRWiSKzd8FOveWNJ6nV/hP9EvS y+JJBojebhau6lN11/YnGTSFdTYkQ7SVGsHcJkWNsS1BQT7g46NEt5Q3uqEvW+kucYO/ v9yZjFkQacSEF4KbQoMvqZEzMd6CrROEI5RVHjy+eZYIKNtKphBcLcLfQDdF3Fchx6ZN I1uJb3iNvROsF2A5h/Ydn82sxlu4BDCdXk4gY9/+7OAyQmAKGNNnpb5MX0BtTDWisBNU qfQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=eBlVedxbnk0zmCSE3D/dt+HsodVO7NisY+35aq1wEbc=; b=bk619bTltQ7nsuQbxcclIs20lUukkLKf0Up57R+4grUOGXxr0YZxmGB77uIbw1ww+/ QLop2wS1d94Y79GtwADyrYDaOiyHIao2Q0atST93LhegnUryb3ldZ1LH1NQuZWkOSQhB Fc8qv3PEK1NzVmLv89YsvQxVT4NA73qSHZDOiO1uwitmWghujlJUuWrq1VPc/if14jy8 /EScfR4k1fFy6cEe0/eSpcu88hJ5iY+HuzaFN1Fw8jiW3E1Y88c0qoclzY+d41uYIhc5 6QoZ1SSQ1QmfWGfbE2RYj3+V9GrTf/CdGCegyhpyqfDipz1fSMv89vj5w/Z5hxwZ06fj QcAA== X-Gm-Message-State: AOAM533+zckc6fB66aNBbye8PF5NPZ7bmwUHO5lYsu256J/HajalJ5Vw RpoA02NkNXqEyySnJNUty50= X-Received: by 2002:a62:2cd7:: with SMTP id s206mr18692176pfs.305.1592133356502; Sun, 14 Jun 2020 04:15:56 -0700 (PDT) Received: from mail.google.com ([149.248.10.52]) by smtp.gmail.com with ESMTPSA id l14sm10061825pjh.50.2020.06.14.04.15.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Jun 2020 04:15:55 -0700 (PDT) Date: Sun, 14 Jun 2020 19:15:49 +0800 From: Changbin Du To: Arnaldo Carvalho de Melo Cc: Changbin Du , 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: <20200614111549.57lqs5tulu4frmgr@mail.google.com> References: <20200510150628.16610-1-changbin.du@gmail.com> <20200510150628.16610-12-changbin.du@gmail.com> <20200520210741.GZ32678@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200520210741.GZ32678@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, May 20, 2020 at 06:07:41PM -0300, Arnaldo Carvalho de Melo wrote: > 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 > I just found userstacktrace is not supported by ftrace yet. It is not hard to add this feature in kernel and I have done it locally. So I will drop this option before it is upstreamed. > > 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 -- Cheers, Changbin Du