Received: by 2002:a25:2c96:0:0:0:0:0 with SMTP id s144csp1112602ybs; Mon, 25 May 2020 07:27:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwrx1mrWTtZRtvGLxNuCk3iLtkW7XjOomYgBKGXq2xM48xfiJ/EvJ3Yuda6zdFv8xuu4yM7 X-Received: by 2002:a05:6402:1a23:: with SMTP id be3mr15745912edb.202.1590416834098; Mon, 25 May 2020 07:27:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590416834; cv=none; d=google.com; s=arc-20160816; b=wl9pI/v/GMcrual+JWg2MVqvOh7n36XYaBPJ/Cs9YgFgMxZ2svJfIzvZJF7E3P/O60 cBZEb9qdhjNLRssZClt7SsYwq7RP+JDfhI2t4hSNwClyNPInvnMRVp41zZ+VZ+nFlGjV VfPBYBZR+D3AYvDmghjrayTlhaGcQLazK2AHisZnpk8BBoaRUeU1Z0Z5S0Rhpr9WVNRi ue2+9zstvg+5MpE0d9ITlUwbLYnReM8UOZLiSvK1jvhAuxX7hZLQVjUzyq35aATl8eRt /Yi2AxgF5SseNzzJuvMxrq/UPiNxnfn+ewpDDoRluApukni+/RLMyJ2TSs8AR5wbFF8X M6fQ== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:references:cc:to:from:subject:ironport-sdr :ironport-sdr; bh=UMqpU1zLsMNwlu1I3Bad7zOoUQWD8hCkG7KCKU+kGhc=; b=L9v68g8ruUaWFtT722W0mPw6bO/fnukDsrbcy547BSS8ARejWJtFWbhCE5zRZGNSYD kunyqpC8PgtfuuX0id16Kb1shKd3tFYfWwAQJ7xGgVaT/VdGWN/zOFCbF+oRL22YqY1p J/GSvgEDNZU18xBpadz24vgramfjzsYI0KRXVlqpmsEvkcQg2V4BXk0OKB8jNjF02ab9 Ru5ojkM2UR1mXcwpdx2CE5elLSQgkQ+DXlJswUtRtIQcCfeihjwBGUn348UwgPuzp2Gf Kmfon4/4beOgfsgh2nLBXxbacfSUwWE+0vZBRXyD8EUr7Mbwn0QzPz7qrktHlUBGvMZP +ueg== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a17si9312378ejy.272.2020.05.25.07.26.50; Mon, 25 May 2020 07:27:14 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2403940AbgEYOWk (ORCPT + 99 others); Mon, 25 May 2020 10:22:40 -0400 Received: from mga11.intel.com ([192.55.52.93]:52410 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390867AbgEYOWk (ORCPT ); Mon, 25 May 2020 10:22:40 -0400 IronPort-SDR: Kseo0IeU8VA9aSz+pJZ/A6+GFuiKw6pkPG/l721VzBVocROmeNVQ/LMaZjEgdc/iwp/JXBIMG2 jb5q1GBWZJXA== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 May 2020 07:22:39 -0700 IronPort-SDR: Dy4R9+UNOgvdCEFojLundGpO8xkwlKnyqSjhnFmxO+0xvXp3/8crQYLP0vPaMQ6YeQTdDWYWDj 76CXRy6un3Cw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,433,1583222400"; d="scan'208";a="256234261" Received: from linux.intel.com ([10.54.29.200]) by fmsmga008.fm.intel.com with ESMTP; 25 May 2020 07:22:36 -0700 Received: from [10.249.227.191] (abudanko-mobl.ccr.corp.intel.com [10.249.227.191]) by linux.intel.com (Postfix) with ESMTP id 87497580646; Mon, 25 May 2020 07:22:34 -0700 (PDT) Subject: [PATCH v4 08/10] perf record: extend -D,--delay option with -1 value From: Alexey Budankov To: Arnaldo Carvalho de Melo Cc: Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , Andi Kleen , linux-kernel References: <653fe5f3-c986-a841-1ed8-0a7d2fa24c00@linux.intel.com> Organization: Intel Corp. Message-ID: <94a53e84-e75d-30d4-5702-7c7317784407@linux.intel.com> Date: Mon, 25 May 2020 17:22:33 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <653fe5f3-c986-a841-1ed8-0a7d2fa24c00@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extend -D,--delay option with -1 to start collection with events disabled to be enabled later by enable command provided via control file descriptor. Signed-off-by: Alexey Budankov --- tools/perf/Documentation/perf-record.txt | 5 +++-- tools/perf/builtin-record.c | 12 ++++++++---- tools/perf/builtin-trace.c | 2 +- tools/perf/util/record.h | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt index 561ef55743e2..c2c4ce7ccee2 100644 --- a/tools/perf/Documentation/perf-record.txt +++ b/tools/perf/Documentation/perf-record.txt @@ -407,8 +407,9 @@ if combined with -a or -C options. -D:: --delay=:: -After starting the program, wait msecs before measuring. This is useful to -filter out the startup phase of the program, which is often very different. +After starting the program, wait msecs before measuring (-1: start with events +disabled). This is useful to filter out the startup phase of the program, which +is often very different. -I:: --intr-regs:: diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 444cf4d2732a..8c3ec29e7e80 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1761,8 +1761,12 @@ static int __cmd_record(struct record *rec, int argc, const char **argv) } if (opts->initial_delay) { - usleep(opts->initial_delay * USEC_PER_MSEC); - evlist__enable(rec->evlist); + pr_info(EVLIST_DISABLED_MSG); + if (opts->initial_delay > 0) { + usleep(opts->initial_delay * USEC_PER_MSEC); + evlist__enable(rec->evlist); + pr_info(EVLIST_ENABLED_MSG); + } } trigger_ready(&auxtrace_snapshot_trigger); @@ -2474,8 +2478,8 @@ static struct option __record_options[] = { OPT_CALLBACK('G', "cgroup", &record.evlist, "name", "monitor event in cgroup name only", parse_cgroups), - OPT_UINTEGER('D', "delay", &record.opts.initial_delay, - "ms to wait before starting measurement after program start"), + OPT_INTEGER('D', "delay", &record.opts.initial_delay, + "ms to wait before starting measurement after program start (-1: start with events disabled)"), OPT_BOOLEAN(0, "kcore", &record.opts.kcore, "copy /proc/kcore"), OPT_STRING('u', "uid", &record.opts.target.uid_str, "user", "user to profile"), diff --git a/tools/perf/builtin-trace.c b/tools/perf/builtin-trace.c index 61bafca1018a..8b2034eeef19 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -4787,7 +4787,7 @@ int cmd_trace(int argc, const char **argv) "per thread proc mmap processing timeout in ms"), OPT_CALLBACK('G', "cgroup", &trace, "name", "monitor event in cgroup name only", trace__parse_cgroups), - OPT_UINTEGER('D', "delay", &trace.opts.initial_delay, + OPT_INTEGER('D', "delay", &trace.opts.initial_delay, "ms to wait before starting measurement after program " "start"), OPTS_EVSWITCH(&trace.evswitch), diff --git a/tools/perf/util/record.h b/tools/perf/util/record.h index 923565c3b155..96a73bbd8cd4 100644 --- a/tools/perf/util/record.h +++ b/tools/perf/util/record.h @@ -60,7 +60,7 @@ struct record_opts { const char *auxtrace_snapshot_opts; const char *auxtrace_sample_opts; bool sample_transaction; - unsigned initial_delay; + int initial_delay; bool use_clockid; clockid_t clockid; u64 clockid_res_ns; -- 2.24.1