Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1167819ybk; Sun, 10 May 2020 08:11:39 -0700 (PDT) X-Google-Smtp-Source: APiQypKowGGlNYzjKXs2LTOEkossW4gdu3mkY/yAkj3grDMiSLPH7G7MwHgPJS0s7XwcuxdJYA01 X-Received: by 2002:a17:906:5004:: with SMTP id s4mr10109175ejj.13.1589123499746; Sun, 10 May 2020 08:11:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589123499; cv=none; d=google.com; s=arc-20160816; b=XWOEvfUOFtwzCX75C3SLDCFEeMMSnt7gZwhXVZrORu27JxSvUcRAYzwViZr2oMaD72 /oHvj7E4HpM8jcbx5tveHDDxqMW6fzTeo7nQhamDhHyjkJqQ/Wv1dvECO/GWM2wsEoO9 g2aJZVaRybkJgsy6NxXhQT0DaJCaEM2zHUcXD9vUNA3kHSjDs6Fby4LRQzUC4ZUqpWua i8jKhp6g0GgyckNdJBWxJhVL5RVnJQdPXbOZseQZ0zvoVHc/z2zQa1Nhj5SAv4BpHBxb VfnC9Y6uVsAS2KLoja/mI+wLLo15a+OxCgIXuRZhOHF56bLULD7DYqm92Z3SoVu/0Q0n 4Jew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rm3gEwzwMkQ4JSt/QwcnW8+A21U/dER9sl6TdLfBoeQ=; b=CRHbEJdZM/5savz0RwyZYeIjgISu7lD3Qlp/J9CXJSOf1AkKSGVdGINvBjtOo2Vz89 j+rUUoDVfP1rWscNHJyx1DmOHIcHPmRpaEd23UvNfMqpTotvu1ilnIXfYma28W1Ia583 HrFh7Rko0XGPvJiRWsNhoFJylVmO8qVjeJFahi/z5KPjf8aby9Up8A3xDlvhOrQAE+PJ A5CwTyJWu1K3ppkB3NaK6hlDoaRY6XH+/9Mi4bzLekGLd1Cico/mtB9wZhD+C0xgyC6T aIoDRGrGT7mB3oVi3HISN4umdzlHyxB9dZNClL2TPtoNZ4OVBZcofbOe7tkIsBx4JCFq MsPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WvybVZSK; 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 y27si444918ejj.412.2020.05.10.08.11.16; Sun, 10 May 2020 08:11:39 -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=WvybVZSK; 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 S1729242AbgEJPJF (ORCPT + 99 others); Sun, 10 May 2020 11:09:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726104AbgEJPJE (ORCPT ); Sun, 10 May 2020 11:09:04 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9FD93C061A0C for ; Sun, 10 May 2020 08:09:04 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id a5so6519342pjh.2 for ; Sun, 10 May 2020 08:09:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rm3gEwzwMkQ4JSt/QwcnW8+A21U/dER9sl6TdLfBoeQ=; b=WvybVZSKhY1Bu135cTAjVJYYgIRzEMxsKx7uFLR8wlXhitmtZnSb5f0/Tlnjtyx3z/ +E1tqiLqbGYJWBpVgRLGmOUFuSUlokyVqNV1cgibSM+57hqBwW4uzSHf1kgu6zoJR3n4 ZW39lmEeWhV7aKMbbgY+T7bTsZAjOVkrFpjrHT0LLxklr0NxB43BBu59ek+EqM1zKwzm 2E87jNaFtyhX0Ar2Fhz5ZWxgxfPKeiSCjm8x8ttlGqiUJUadGRYHJUMTmygYbSl7nZsY Xq4ZJ/0Bvh/5V1ljm7ukBQpYsTuvLsFIK3OdNBY2yFx8PCZLHMoYQ5HLjgWbCqyUqwib 4/IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rm3gEwzwMkQ4JSt/QwcnW8+A21U/dER9sl6TdLfBoeQ=; b=AHRSLSazP/YVXp+0G0V8iREsshO8FwT35nkxT9VvnrVbd7Pkk7Td1/ZQImvYIuIm6E lpCRdOJw3/qL6kO98Ba84N3ZenB1S8VknMdNZMvRXFI+XPej8Xer48yngXPUYePohKUX EY3HLXExrqSo57dgbWOLf/siwdScDm5Xyf16Rp0ASu44KvxNi9TrAo6J7RxdyP9VtHVn /Xd7o60yrXm2n8LXAjeGxw5mylkdJof17Wsn1mELBeBvC0LpX2aM72Tlo037RdpXELBa ORHM+OROQx/s1j3jZQ4F+d+1cjQx30DOrJlyjQQ+9p1pzV/3RisCRt3I8EDZMdxSYZFO 9jpg== X-Gm-Message-State: AGi0PuZC83NHHiAkQYwqJ+8gDReAo+7d7OjjcGp0d9XGi9xPvnbOOp+D tw4YqehZnzoawOJlidHwvcA= X-Received: by 2002:a17:90a:7349:: with SMTP id j9mr17690858pjs.196.1589123344173; Sun, 10 May 2020 08:09:04 -0700 (PDT) Received: from vultr.guest ([149.248.10.52]) by smtp.gmail.com with ESMTPSA id v7sm6870909pfm.146.2020.05.10.08.08.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2020 08:09:03 -0700 (PDT) From: Changbin Du To: Jiri Olsa , Arnaldo Carvalho de Melo Cc: Peter Zijlstra , Ingo Molnar , Namhyung Kim , Steven Rostedt , linux-kernel@vger.kernel.org, Changbin Du Subject: [PATCH 11/19] perf ftrace: add option '-u/--userstacktrace' to show userspace stacktrace Date: Sun, 10 May 2020 23:06:20 +0800 Message-Id: <20200510150628.16610-12-changbin.du@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200510150628.16610-1-changbin.du@gmail.com> References: <20200510150628.16610-1-changbin.du@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This adds an option ''-u/--userstacktrace' for function tracer to display userspace back trace. 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