Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752078AbcJJFp2 (ORCPT ); Mon, 10 Oct 2016 01:45:28 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:33034 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751934AbcJJFpY (ORCPT ); Mon, 10 Oct 2016 01:45:24 -0400 From: Alexis Berlemont To: linux-kernel@vger.kernel.org Cc: Alexis Berlemont , peterz@infradead.org, mingo@redhat.com, acme@kernel.org, alexander.shishkin@linux.intel.com Subject: [PATCH] perf: implement --delay on perf trace Date: Mon, 10 Oct 2016 07:43:28 +0200 Message-Id: <20161010054328.4028-2-alexis.berlemont@gmail.com> X-Mailer: git-send-email 2.10.0 In-Reply-To: <20161010054328.4028-1-alexis.berlemont@gmail.com> References: <20161010054328.4028-1-alexis.berlemont@gmail.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1461 Lines: 40 Signed-off-by: Alexis Berlemont --- tools/perf/builtin-trace.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index c298bd3..0bae454 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -2310,12 +2310,17 @@ static int trace__run(struct trace *trace, int argc, const char **argv) if (err < 0) goto out_error_mmap; - if (!target__none(&trace->opts.target)) + if (!target__none(&trace->opts.target) && !trace->opts.initial_delay) perf_evlist__enable(evlist); if (forks) perf_evlist__start_workload(evlist); + if (trace->opts.initial_delay) { + usleep(trace->opts.initial_delay * 1000); + perf_evlist__enable(evlist); + } + trace->multiple_threads = thread_map__pid(evlist->threads, 0) == -1 || evlist->threads->nr > 1 || perf_evlist__first(evlist)->attr.inherit; @@ -2816,6 +2821,9 @@ int cmd_trace(int argc, const char **argv, const char *prefix __maybe_unused) "Default: kernel.perf_event_max_stack or " __stringify(PERF_MAX_STACK_DEPTH)), OPT_UINTEGER(0, "proc-map-timeout", &trace.opts.proc_map_timeout, "per thread proc mmap processing timeout in ms"), + OPT_UINTEGER('D', "delay", &trace.opts.initial_delay, + "ms to wait before starting measurement after program " + "start"), OPT_END() }; bool __maybe_unused max_stack_user_set = true; -- 2.10.0