Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp1772097ybh; Fri, 17 Jul 2020 00:07:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyAfboUR8DUvaqZlK9SDlGPPJ7D2DmQHncpjdYnmaqi0tgsg8k0GO4MUWlJg/kQ+eIZZo7v X-Received: by 2002:a05:6402:31ba:: with SMTP id dj26mr7978301edb.181.1594969660187; Fri, 17 Jul 2020 00:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594969660; cv=none; d=google.com; s=arc-20160816; b=LpgRniI5LU4fjwY/7AHT0alJwU9uGKEU1ihrQ2kkdFlLvDiWX/R3Ex3rmKwQbZ7jA6 IqTSsAvTU1gm96TtEx6WZ8Ob7q3x1Nr1YSzYOp8DtxHW2B0vQWMakox3XmhTh9L5ntIU Dx6K8qyXzX+dccCbPFsyLBC0JK5jQ9LS1H8AHLAhnGwobQ6oe9l8JuaNOcBaW+v53MQD 1C2GIb+r4ja7k6s8nUfLtEkk6jCzoayZIwrxhytuqcytOxTrCYIcX/qYVwBylDuNDUyI efx0SHclugBBrd0HmczgQ7d4R6fCx2B3B+V1E9HW6rlU4mCWmZIXx8jgFHJp1sdh/+Q2 F7jg== 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=xxA/Kmeo1mqA+iruDpnDukjoVrMA5+W8X6TJkabeIVo=; b=uwgFj+NqDmc/SYqzNE7ScN2OO4+mqShSrMxoUsEKm5LqYtclKp5YNKh63E3+Zc4105 BEY/MTgO2vFExP7u8XKsfFkVt/AutkwDpSqE055EQxUNQGQt/nCKcYYegIt1fH2il6sS Fn/l2DkQV9Ff9t8UxqxMUosN06YP2GHBObMyekDCdNcZuk4KhZFWtJh9k/e9iIvw0WXL DhdJTS5YCOZ12M3PYiX84LRJHSq1RM7SAPSRfkKaDY8zDQSx831L1Wl72AzvKpEYNdzL bJPLFCAqje4NrWp7B4HCwqCVEu27WSvqnRf2Jrrezhb8PoxBTTgytblPgTNzwv6XrDca XrBw== 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 r3si4783207ejr.664.2020.07.17.00.07.16; Fri, 17 Jul 2020 00:07:40 -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 S1727043AbgGQHHK (ORCPT + 99 others); Fri, 17 Jul 2020 03:07:10 -0400 Received: from mga01.intel.com ([192.55.52.88]:38001 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726141AbgGQHHJ (ORCPT ); Fri, 17 Jul 2020 03:07:09 -0400 IronPort-SDR: gok8GXoPxkVzoqmsmxWN3Hj97f+vTq/akZjoMiZumZ52mD57/e1MeU4rkjN9aKKqCik+duWXdF fIZz62h22Eyg== X-IronPort-AV: E=McAfee;i="6000,8403,9684"; a="167680899" X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="167680899" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jul 2020 00:07:09 -0700 IronPort-SDR: Jv5xMwbLDaGKRG+tL3ywaod2aBqSGvjN/d1Dkqkhytw5NWzpuE9UcPtL4g+/++Wl4+rpaHQ9wb BT5NGFsUlHdg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,362,1589266800"; d="scan'208";a="300481559" Received: from linux.intel.com ([10.54.29.200]) by orsmga002.jf.intel.com with ESMTP; 17 Jul 2020 00:07:08 -0700 Received: from [10.249.224.34] (abudanko-mobl.ccr.corp.intel.com [10.249.224.34]) by linux.intel.com (Postfix) with ESMTP id 9B58B580824; Fri, 17 Jul 2020 00:07:05 -0700 (PDT) Subject: [PATCH v12 13/15] 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: <8d91c3a0-3db4-0a7a-ae13-299adb444bd6@linux.intel.com> Organization: Intel Corp. Message-ID: <3e7d362c-7973-ee5d-e81e-c60ea22432c3@linux.intel.com> Date: Fri, 17 Jul 2020 10:07:03 +0300 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <8d91c3a0-3db4-0a7a-ae13-299adb444bd6@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 Acked-by: Jiri Olsa Acked-by: Namhyung Kim --- 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 fa8a5fcd27ab..a84376605805 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 19b1d5effb7a..cd1892c4844b 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1749,8 +1749,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); @@ -2462,8 +2466,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 a333a9a64f27..bea461b6f937 100644 --- a/tools/perf/builtin-trace.c +++ b/tools/perf/builtin-trace.c @@ -4812,7 +4812,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 39d1de4b2a36..da138dcb4d34 100644 --- a/tools/perf/util/record.h +++ b/tools/perf/util/record.h @@ -61,7 +61,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