Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp177182ybh; Fri, 17 Jul 2020 23:54:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyhjODawqjB60dXmSg4uqrMJNKdFKDTYX23Xt8IjNSwqIJW43Vtes7ZbJNJcExApppunRpE X-Received: by 2002:a17:906:3c10:: with SMTP id h16mr11724210ejg.87.1595055242714; Fri, 17 Jul 2020 23:54:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595055242; cv=none; d=google.com; s=arc-20160816; b=0DEvSX7MR3QOyVWOIkUmgDH3o84KmYuRQjULKXq2edqwGYHP88mLUxhSzl1BP1LMpZ iEKHwendduy77XH0j/Ie31C6cv4yXFKPF0Y+zFx2s1dLVImn17yl8CFqsB21AgIowH1j ENwf0ReBjgmktGpBhZUUOrktTHEtlP5jZs0TqVO5wI1b8hG44m/q3sdH/R4mrqUKyokC iUO0neBT8Dkzz8lEMtPLpqXGs0yn2RYPM1jyutDj0tjQzLq6mxKF1Y1KzFgNIMRoDYpL wmAyqmPSHBC1q3bDmkEymaXv+bWEOmcxl4DoWXqCsbjrRaATtBAUPAtISua9zUOc3lHR 6VDg== 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=PGmY2yM7IBrhvEVueqg0kykP3l1lO9dWCgs8ldRYKD4=; b=B9OqXNz685lgeHaC1Pl8DC7CU0tUBiU+89AeGhfzjkC3XCDHBJxlqtb55rxQ4iv9kC 3CG0AxllLcmnhuw+rAyM2CKvy0VWExmvis1RF6BE6MxK5kXO8XKGs2yKSqQDclK8AHxl E3UvCh18A5uwLDAg3kzBAIKNR39+Sg9upOCcrBc/1GfmLQDq+YqQ7vuSTDbzgHuPtt1y SyTMqEj6pJbndR4JsHy8sMsE/hCEBMQCRJR+gJOzawKB8+6aOcyUugV0sdFXGQxEvPAe 9WOP+ShAwfgqlqH9bU/Q5ETF9uhqnnXnKzY5L9gtg5rjuxF5ZEhzNA03lzJYZslEFYbk Vntw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=CCB9DrBT; 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 a3si6960521ejd.741.2020.07.17.23.53.39; Fri, 17 Jul 2020 23:54:02 -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=CCB9DrBT; 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 S1729161AbgGRGuw (ORCPT + 99 others); Sat, 18 Jul 2020 02:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726641AbgGRGuv (ORCPT ); Sat, 18 Jul 2020 02:50:51 -0400 Received: from mail-pj1-x1043.google.com (mail-pj1-x1043.google.com [IPv6:2607:f8b0:4864:20::1043]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B864C0619D2 for ; Fri, 17 Jul 2020 23:50:51 -0700 (PDT) Received: by mail-pj1-x1043.google.com with SMTP id mn17so7488273pjb.4 for ; Fri, 17 Jul 2020 23:50:51 -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=PGmY2yM7IBrhvEVueqg0kykP3l1lO9dWCgs8ldRYKD4=; b=CCB9DrBTBmpG5KzJuUiSjbgH2HRbHpskA/9SulNN83P//qRqUXEqweWhZtzPuj3o86 rpFhDSogj2BYRZrm2aVjWqAuYluTbT1KzKuf+BTqRjc1fdTeMA9zvZbO+5iAzrJhR+7L nvjUHvUuZchuwKB9UKCMn3yOQWDfrVMV+eP7FB6gsyCAsTJ44I0gQMlCr5Ow5wJ8yRtb 5iarU3BjKeXYZyk6jkq61rSXoRIMyxMVEMJ3gyDHZ2w2p/9QMKRYJz6R7AdH2Zm9Oq7z AD6CYqNw0V4FKoTX6M3C2IPugWfpAgn+/fqIobEz8/VMn77cr/QyLmx0GBktTZ7n8ShJ s9qg== 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=PGmY2yM7IBrhvEVueqg0kykP3l1lO9dWCgs8ldRYKD4=; b=SdT2zT4L94xvyrWnRbBMRwFnwFAuGrvillRe8QaZrnK6VSg5+pk8M9KAkY3G7FGtVv YjsFJa/nr6Q+Xaxap4q57Mz1hh2m5hMn04NFM6vgDrqNPkIwnYutiZDtpYRoRvtOWfFJ zWoN96SwyFeOa3fxjGKGkzygYtu3dxbQRJWsG/rABgTiKOHKVFyD4GaEzFO1A5YaA3Si tNLeX/DkIZIFynd3etNQ/Aj9Zdk81GiL8Ma2Mg1TDwsr4jJ0LO9uChayJ720jqE70VE8 9CUOlpHQJHYZ0glp2X0UHUBRmvSMGstVX6+EUoZajAOiI3KxiZxojispHPejdokM+jgL P1IA== X-Gm-Message-State: AOAM530y+eW4tBdX+BDfl5vCB2+bYFE4eu/5ylqunYRRFs2PInfwS362 6x766RKmXrjmc6IAsDIFiNI= X-Received: by 2002:a17:90a:e7cd:: with SMTP id kb13mr13193956pjb.138.1595055051200; Fri, 17 Jul 2020 23:50:51 -0700 (PDT) Received: from vultr.guest ([149.248.10.52]) by smtp.gmail.com with ESMTPSA id q10sm10422781pfk.86.2020.07.17.23.50.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 17 Jul 2020 23:50:50 -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 v7 15/18] perf ftrace: add option -D/--delay to delay tracing Date: Sat, 18 Jul 2020 14:48:23 +0800 Message-Id: <20200718064826.9865-16-changbin.du@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200718064826.9865-1-changbin.du@gmail.com> References: <20200718064826.9865-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/Documentation/perf-ftrace.txt | 4 ++++ tools/perf/builtin-ftrace.c | 19 ++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tools/perf/Documentation/perf-ftrace.txt b/tools/perf/Documentation/perf-ftrace.txt index 6f17939b8789..077249c979f2 100644 --- a/tools/perf/Documentation/perf-ftrace.txt +++ b/tools/perf/Documentation/perf-ftrace.txt @@ -38,6 +38,10 @@ OPTIONS --pid=:: Trace on existing process id (comma separated list). +-D:: +--delay:: + Time (ms) to wait before starting tracing after program start. + -a:: --all-cpus:: Force system-wide collection. Scripts run without a diff --git a/tools/perf/builtin-ftrace.c b/tools/perf/builtin-ftrace.c index 3ddd7568b456..64b68331048a 100644 --- a/tools/perf/builtin-ftrace.c +++ b/tools/perf/builtin-ftrace.c @@ -47,6 +47,7 @@ struct perf_ftrace { int graph_noirqs; int graph_verbose; int graph_thresh; + unsigned int initial_delay; }; struct filter_entry { @@ -594,13 +595,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; @@ -809,6 +820,8 @@ int cmd_ftrace(int argc, const char **argv) "size of per cpu buffer", parse_buffer_size), OPT_BOOLEAN(0, "inherit", &ftrace.inherit, "trace children processes"), + OPT_UINTEGER('D', "delay", &ftrace.initial_delay, + "ms to wait before starting tracing after program start"), OPT_END() }; -- 2.25.1