Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1168015ybk; Sun, 10 May 2020 08:11:57 -0700 (PDT) X-Google-Smtp-Source: APiQypLoIaUbfa31qe/9XTrS73nm0Ng94c5VEe2xYbWSoePcXG4Zug6Zpg6u21YigtGdpH51+6AV X-Received: by 2002:a05:6402:1d93:: with SMTP id dk19mr9586339edb.170.1589123517746; Sun, 10 May 2020 08:11:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589123517; cv=none; d=google.com; s=arc-20160816; b=YA1/YqNqq78wxxrSx7FjHEpPfwzwNucfUsjkI4UvXedeVm8lYsy0o5R/lnSkp9zea7 hqIR4GIAPhZEiTCneRfO+Q1qyjrADoIABoRjtkV76S7C1YXpLHvYz3PgJz9R1gznG6rQ OZZj1vbVKqooA+EnUREwUiJMhQFcS/NKX+YA8PIrjM2q7xoVaHJCKapte+dE2I7/+Iwx OzapKjW7dVJ5nhfpXD+jlCgTuTtLqBbSR54sGxhLfBzN0DhfDcdEyywS1aMG4HIoKL2P DyYuMSMDBv5BQVg3IkDlTk3f0Cb9y1nPkjWNneAyOnJa4kjv2xo5E9rV10YPH/yQoL62 c1HA== 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=0gJ/iBhKrq0r7C4wRhaQHeL8thxSYrIDdDv0I9G+lD4=; b=AgFbfHrCFvxVoFw3ik6yjEnduTAfvUUGSd3w0PtqpG3gdXgiiOwjr5aFf/M9O0rSde bFNqyeYcj/FWExWdRNeeyJfqd9pKHiz4N2vycOQDr/y/gZol3glvMUYWAd6WJzKrZ7/F kcQMWry4Qd1045D32pBHFbHJsjE21anjuDFoziEs5PNJzrFKaKUm4FqQyUFmkNDAw5N0 e2u87EzBd+zsgRpaZxNwdghl+BMPpZGup20QFZIDdR581aDsoUA3+gb8W9FQSzxbEIkb fI3BxhPMPiO2OyUkAtVZ5PiZg/fDdE/oWzm4pgoBrfk5/GD3GN2jptoUHgqN2cbbNWP/ jbsQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=erS9ZikC; 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 f14si2636112edw.364.2020.05.10.08.11.34; Sun, 10 May 2020 08:11:57 -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=erS9ZikC; 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 S1729248AbgEJPJd (ORCPT + 99 others); Sun, 10 May 2020 11:09:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48554 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726104AbgEJPJc (ORCPT ); Sun, 10 May 2020 11:09:32 -0400 Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A563EC061A0C for ; Sun, 10 May 2020 08:09:32 -0700 (PDT) Received: by mail-pl1-x642.google.com with SMTP id u10so2814117pls.8 for ; Sun, 10 May 2020 08:09:32 -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=0gJ/iBhKrq0r7C4wRhaQHeL8thxSYrIDdDv0I9G+lD4=; b=erS9ZikCUnuS/43aa4v4XEvdJNNRLLgyUP3Djk55Hem/a8cwR2RtvsdYnwHUNPy9GL hCCXatDEs3gWTNmDeFYjO0qX05EU+cvSfP6c4rsic8LtK4HDs70GUCGIqzj48LJACCGg gDZUrhPqSpUP4ljqhTzHGkJDFKiRoJGDl8TfENz28Vmp/9IAN+hwETZO6ZQnb9L6zMxf IA2sF6xK6KDfAxIHUm1srmWIVxJgZr4XAdRpQ7g2VbP/YhLH0fFCzIP/RLDThva2OUGf uX/yEjrU3sMMNVF9GMspY2YOibCzKUYIbkL9DxEzrbOYhXAqEetvxm4zs2fOOyJfhBuC zkXQ== 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=0gJ/iBhKrq0r7C4wRhaQHeL8thxSYrIDdDv0I9G+lD4=; b=qw3bwfuHoQ72tVCQIigW+vVLP/LySTBRxQw7NG9S2iIdMTNMHwfNb1TkctePdYAJJz lZFI12gtrHvngkVwzS8J161AGbPBxHHytQQ8smadLVBmNVD6He+WQONfF61WZSGieEgs 9w/v2DY8ov7dsikIeCG16mYMDnnVvwyMBEVIz16s3Twl60PjK5oA6jwm2+uD4xoCWD2i nYrx4Jl/g4NkBhlO3ekT8+MYK7GamvSHZTBuS3w6MEWmytYjxAqP3Qyhr07vWxcXpdQ1 +0hIZQY3n4IAPC2LDXqLEG/0uPFBd3FobSLm315UjXHYshSSveVr9bSS9/4t9Hgnuwcu jjeg== X-Gm-Message-State: AGi0PuZ/fWr18eStZPa/5hJ9fQYN7FYw0zMydWFEKp4KqEEePY1I27PL JAYoW+Oenun1jU5yjsXMXyI= X-Received: by 2002:a17:90b:b07:: with SMTP id bf7mr17456825pjb.231.1589123372279; Sun, 10 May 2020 08:09:32 -0700 (PDT) Received: from vultr.guest ([149.248.10.52]) by smtp.gmail.com with ESMTPSA id v7sm6870909pfm.146.2020.05.10.08.09.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2020 08:09:31 -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 12/19] perf ftrace: add support for tracing children processes Date: Sun, 10 May 2020 23:06:21 +0800 Message-Id: <20200510150628.16610-13-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-Type: text/plain; charset=UTF-8 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 '--trace-children' to allow us trace children processes spawned by our target. Signed-off-by: Changbin Du --- tools/perf/builtin-ftrace.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index ab76ba66bd9e..8fd95c109fe8 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -46,6 +46,7 @@ struct perf_ftrace { bool funcgraph_tail; bool long_info; unsigned tracing_thresh; + bool trace_children; }; struct filter_entry { @@ -200,6 +201,7 @@ static void reset_tracing_options(struct perf_ftrace *ftrace __maybe_unused) write_tracing_option_file("irq-info", "0"); write_tracing_option_file("userstacktrace", "0"); write_tracing_option_file("sym-userobj", "0"); + write_tracing_option_file("function-fork", "0"); } static int reset_tracing_files(struct perf_ftrace *ftrace __maybe_unused) @@ -441,6 +443,17 @@ static int set_tracing_funcgraph_tail(struct perf_ftrace *ftrace) return 0; } +static int set_tracing_trace_children(struct perf_ftrace *ftrace) +{ + if (!ftrace->trace_children) + return 0; + + if (write_tracing_option_file("function-fork", "1") < 0) + return -1; + + return 0; +} + static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) { char *trace_file; @@ -539,6 +552,11 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) goto out_reset; } + if (set_tracing_trace_children(ftrace) < 0) { + pr_err("failed to set tracing option function-fork\n"); + goto out_reset; + } + if (write_tracing_file("current_tracer", ftrace->tracer) < 0) { pr_err("failed to set current_tracer to %s\n", ftrace->tracer); goto out_reset; @@ -686,6 +704,8 @@ int cmd_ftrace(int argc, const char **argv) "Show process names, PIDs, timestamps, irq-info if available"), OPT_UINTEGER(0, "tracing-thresh", &ftrace.tracing_thresh, "Only show functions of which the duration is greater than µs"), + OPT_BOOLEAN(0, "trace-children", &ftrace.trace_children, + "Trace children processes"), OPT_END() }; -- 2.25.1