Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1168672ybk; Sun, 10 May 2020 08:13:05 -0700 (PDT) X-Google-Smtp-Source: APiQypKF5I49/64qfwvY8W9GNZYA9d+cGFVo1xNWXXLq4lb7kY9Vd118s+6qOw+fvLjWxCNJP1Tb X-Received: by 2002:a05:6402:1b0b:: with SMTP id by11mr9847788edb.269.1589123585566; Sun, 10 May 2020 08:13:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589123585; cv=none; d=google.com; s=arc-20160816; b=oGXZbg69rmruL85Q498kC+XlI0c4zkou4x3DX5C2yothzfjQfg9PGZV9JWnrJLbvP0 wgWASRFrdD/vWCI+viv76LDuBt9vXenH8egMzb5Ae3CYQjNMHgczZ3zL5vcPImXtZKuo 3CiiA3O/dJmf1bHiO+js8fYVZEYT3wo7CV0ABLjjg3o7CXow5+oYixhxbNTPQvVz5Ug0 n2PCbyJiBedKtyWvikynTakOYL4psWPnJPwgkr1jR2S9IxzeL+AWmnb1Tya9flo+Rh/k ipf3JjlA8bXllcWPwEsuEek3sPUW4Ehw5OzTLls+UyAg9hz3sJaUP+bC/2RAusocp7Hr Ez3g== 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=el9+HL0NG4w6riBCeyPr28XbBHtaw2gamEGL+qRM05k=; b=EwqniRGFAyZ0p7+OALLFcWzoQ5Hzt6JHg9fLQkPuROmimPHleLC9akbE7hRByQu2Xx swVDFrWpN9ElCWBmG/V6mKDcqS6fQIQ3SfRw/LHw0JFhcPluyInjMX+2mNt6fUxSMTFJ 6yttmbWzYRxOjfB65pKdidO/QQ9nVA2+uuB7PgBQGSbETceQYFjI5r6klgJLRQhsrNQL Qr23ue0rieraHq5aQzuT9FaTFkMTM304QbIir8O+8rTV1kE7xFeWPw/URjhYPjdZKw4g grmuY1eqmPdXfW1Jk1e2AGKoXM7l85D/mkCPn068P8URxn2U1XczhRpJ8AkwM8bZrMUh Zf3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=WSpyO5pH; 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 l17si2818598eja.69.2020.05.10.08.12.42; Sun, 10 May 2020 08:13:05 -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=WSpyO5pH; 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 S1729168AbgEJPK1 (ORCPT + 99 others); Sun, 10 May 2020 11:10:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48700 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728849AbgEJPK1 (ORCPT ); Sun, 10 May 2020 11:10:27 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 074E8C061A0C for ; Sun, 10 May 2020 08:10:27 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id 145so3488654pfw.13 for ; Sun, 10 May 2020 08:10:27 -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=el9+HL0NG4w6riBCeyPr28XbBHtaw2gamEGL+qRM05k=; b=WSpyO5pHDsRNNmX5tzrIydLzDkxvqQX+GB9PKXyL1gQYIFiCedFjSogxont5VmD+HF MDjyNMNJ7yDThIGteQMMpNXT0BYeStXp6k3yeHDHUK8VlzvAmOhObqr3+i8vcE2/BjSG U+RXqln6wdUM8Y1EJ2QLTjRxVnaLuip0g+mk5MSDA43r/Iw5/IHLiDF4hl0s0tABAV0A DeHmjRGqkLNQdvE9nD+5VkLGygzD1KNuCvIZh4NlA4N2WVjwKR7h1oB1DvIl1CfPtzR1 bzOk+yF8zvv86PpmT9uZV/ZSRDbnsFvd4om/VJYAmJmll637Abzj2qGLUS34qKYvw6d6 a3+w== 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=el9+HL0NG4w6riBCeyPr28XbBHtaw2gamEGL+qRM05k=; b=i+T66fUQvk0SWP/Z39qnAXb/706VMvV1VDd94YBRloT0K3+4gjKjrcG5orQz0/oOTG lzCRe0sUWK7EGj3NDqRPl3jBvLgzQwSf6ZWq9jSi3eGVDx5qqvwTl+Cq9hHbwjvkAIJL cFOnqwB6u2GOZEiecOvaZjnzJM2FPtqjINriDFLX36BzBs6ou8i36y+lkOdXGUy5t7p6 /fFWLqc7dSHsGrHiP3HfCCJApUutMvkVa+quimf2iy1olNNBtmCIrBKYb/+fyAaIM8ib RSutCyGWUGV/+ULqb8Tz9jeiY66CoFyzC/eMhw3V5xMoVOi8E82hutHmKatqZC9RcyEp UoIA== X-Gm-Message-State: AOAM530AKYdckZ6RbVuOGscQA5SLSiZ2TiskEnulg3uGZ4fuqjqK0OTu KM8ScaEwp229CkQ2uaxZ/4g= X-Received: by 2002:a63:712:: with SMTP id 18mr513609pgh.96.1589123426630; Sun, 10 May 2020 08:10:26 -0700 (PDT) Received: from vultr.guest ([149.248.10.52]) by smtp.gmail.com with ESMTPSA id v7sm6870909pfm.146.2020.05.10.08.10.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 10 May 2020 08:10:25 -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 17/19] perf ftrace: add option -d/--delay to delay tracing Date: Sun, 10 May 2020 23:06:26 +0800 Message-Id: <20200510150628.16610-18-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 '-d/--delay' to allow us to start tracing some times later after workload is launched. Signed-off-by: Changbin Du --- tools/perf/builtin-ftrace.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 8d04e5afe2d3..d376b37c53fc 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -49,6 +49,7 @@ struct perf_ftrace { bool trace_children; unsigned buffer_size_kb; bool no_pager; + unsigned initial_delay; }; struct filter_entry { @@ -617,13 +618,23 @@ static int __cmd_ftrace(struct perf_ftrace *ftrace, int argc, const char **argv) /* display column headers */ read_tracing_file_to_stdout("trace"); - if (write_tracing_file("tracing_on", "1") < 0) { - pr_err("can't enable tracing\n"); - goto out_close_fd; + if (!ftrace->initial_delay) { + if (write_tracing_file("tracing_on", "1") < 0) { + pr_err("can't enable tracing\n"); + goto out_close_fd; + } } perf_evlist__start_workload(ftrace->evlist); + if (ftrace->initial_delay) { + usleep(ftrace->initial_delay * 1000); + if (write_tracing_file("tracing_on", "1") < 0) { + pr_err("can't enable tracing\n"); + goto out_close_fd; + } + } + while (!done) { if (poll(&pollfd, 1, -1) < 0) break; @@ -747,6 +758,8 @@ int cmd_ftrace(int argc, const char **argv) "size of per cpu buffer in kb"), OPT_BOOLEAN('P', "no-pager", &ftrace.no_pager, "Do not use pager"), + OPT_UINTEGER('d', "delay", &ftrace.initial_delay, + "Wait ms before tracing"), OPT_END() }; -- 2.25.1