Received: by 10.223.176.5 with SMTP id f5csp2991298wra; Mon, 5 Feb 2018 13:43:35 -0800 (PST) X-Google-Smtp-Source: AH8x226/XDBzyRW5Aj7+0PZEdwoQ28ukcDAi2AYaLiYJpr8Eakk3KRXmdl02WFz6NsHwMxch5kMp X-Received: by 2002:a17:902:b605:: with SMTP id b5-v6mr210316pls.318.1517867015841; Mon, 05 Feb 2018 13:43:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517867015; cv=none; d=google.com; s=arc-20160816; b=HNGJxF+H6bzMXyyIouZBC4s4y9cuVGgV5gTER6G//NI6TC+dTGjLSxqhEAMQyMXcsp c9WXTUVHLl1VvbmmgLnBR2LiYk3i/On4ES3gRcaIqWM/AuPeGIZyEJQBAm8+XGbNEEJA l6R48b58mcFeMkAtuZNPQk04pjvirGBDesnsu9/SyIKf8vAaWep+3sSLTxhVeSCXVy+P LnDcy8tE3GaA042FQGqrU7p/ha0e6yRBPjF7Df7seaOVmI/ULTe1SYkpr/mFTCxQr1+X ir0fkF/1xU6hgeW7ytwEgWD70rsW/PjnwSwQmId+nEK4YKHFe+fNe1MSL6H+8FfKxcVW TLqQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition :content-transfer-encoding:mime-version:robot-unsubscribe:robot-id :git-commit-id:subject:to:references:in-reply-to:reply-to:cc :message-id:from:date:arc-authentication-results; bh=bLSDj0FSQ5IMS9TeIySHCLCIByXXTddxNDmmRhlsN0w=; b=CS9SO1pCN+WkZwT5kD0jH/XAdjdPiQgQOqMOKY9JaXyW/LZLdm5ski4MS10AYWjUWW zx2el0ENFMlR2Mj2ht84LnU0VPQ2OwFg7rkqDnaAossoRkz3ZFoR4nazfD59edYD9+Ep Trv4MKSA98CC7N+5+YpUGUy0ZDgtQug4SVtyT+uj6X+dk53tkfA4vwpQ7QrJKRL/baSP O3LkZz1ztA1OAiCccQWQzPGFBuYaSYySUPE9X4KrxB0q6Zv0oBzQiIqTDuA8PvWBMYxv cJXPD/ecTeCV/CXDHVk4+uqioCM9+ffQHscBFPk8xlaZFwVjtTyga7bMk4yHUpC5kmaX YelQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g11si80530pgf.367.2018.02.05.13.43.21; Mon, 05 Feb 2018 13:43:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752100AbeBEVlC (ORCPT + 99 others); Mon, 5 Feb 2018 16:41:02 -0500 Received: from terminus.zytor.com ([65.50.211.136]:35461 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752555AbeBEVkw (ORCPT ); Mon, 5 Feb 2018 16:40:52 -0500 Received: from terminus.zytor.com (localhost [127.0.0.1]) by terminus.zytor.com (8.15.2/8.15.2) with ESMTP id w15LaQ6p031276; Mon, 5 Feb 2018 13:36:26 -0800 Received: (from tipbot@localhost) by terminus.zytor.com (8.15.2/8.15.2/Submit) id w15LaQ75031273; Mon, 5 Feb 2018 13:36:26 -0800 Date: Mon, 5 Feb 2018 13:36:26 -0800 X-Authentication-Warning: terminus.zytor.com: tipbot set sender to tipbot@zytor.com using -f From: tip-bot for Jiri Olsa Message-ID: Cc: jolsa@kernel.org, namhyung@kernel.org, linux-kernel@vger.kernel.org, hpa@zytor.com, peterz@infradead.org, tglx@linutronix.de, acme@redhat.com, mingo@kernel.org, alexander.shishkin@linux.intel.com, dsahern@gmail.com, eranian@google.com, ak@linux.intel.com Reply-To: tglx@linutronix.de, namhyung@kernel.org, jolsa@kernel.org, peterz@infradead.org, linux-kernel@vger.kernel.org, hpa@zytor.com, eranian@google.com, ak@linux.intel.com, mingo@kernel.org, acme@redhat.com, dsahern@gmail.com, alexander.shishkin@linux.intel.com In-Reply-To: <20180201083812.11359-3-jolsa@kernel.org> References: <20180201083812.11359-3-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/urgent] perf record: Fix period option handling Git-Commit-ID: f290aa1ffa45ed7e37599840878b4dae68269ee1 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline X-Spam-Status: No, score=-2.9 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham autolearn_force=no version=3.4.1 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on terminus.zytor.com Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: f290aa1ffa45ed7e37599840878b4dae68269ee1 Gitweb: https://git.kernel.org/tip/f290aa1ffa45ed7e37599840878b4dae68269ee1 Author: Jiri Olsa AuthorDate: Thu, 1 Feb 2018 09:38:11 +0100 Committer: Arnaldo Carvalho de Melo CommitDate: Mon, 5 Feb 2018 12:18:28 -0300 perf record: Fix period option handling Stephan reported we don't unset PERIOD sample type when --no-period is specified. Adding the unset check and reset PERIOD if --no-period is specified. Committer notes: Check the sample_type, it shouldn't have PERF_SAMPLE_PERIOD there when --no-period is used. Before: # perf record --no-period sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.018 MB perf.data (7 samples) ] # perf evlist -v cycles:ppp: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME|PERIOD, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1 # After: [root@jouet ~]# perf record --no-period sleep 1 [ perf record: Woken up 1 times to write data ] [ perf record: Captured and wrote 0.019 MB perf.data (17 samples) ] [root@jouet ~]# perf evlist -v cycles:ppp: size: 112, { sample_period, sample_freq }: 4000, sample_type: IP|TID|TIME, disabled: 1, inherit: 1, mmap: 1, comm: 1, freq: 1, enable_on_exec: 1, task: 1, precise_ip: 3, sample_id_all: 1, exclude_guest: 1, mmap2: 1, comm_exec: 1 [root@jouet ~]# Reported-by: Stephane Eranian Signed-off-by: Jiri Olsa Tested-by: Arnaldo Carvalho de Melo Tested-by: Stephane Eranian Cc: Alexander Shishkin Cc: Andi Kleen Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Link: http://lkml.kernel.org/r/20180201083812.11359-3-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-record.c | 3 ++- tools/perf/perf.h | 1 + tools/perf/util/evsel.c | 11 ++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 65681a1..bf4ca74 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1566,7 +1566,8 @@ static struct option __record_options[] = { OPT_BOOLEAN_SET('T', "timestamp", &record.opts.sample_time, &record.opts.sample_time_set, "Record the sample timestamps"), - OPT_BOOLEAN('P', "period", &record.opts.period, "Record the sample period"), + OPT_BOOLEAN_SET('P', "period", &record.opts.period, &record.opts.period_set, + "Record the sample period"), OPT_BOOLEAN('n', "no-samples", &record.opts.no_samples, "don't sample"), OPT_BOOLEAN_SET('N', "no-buildid-cache", &record.no_buildid_cache, diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 2357f4cc..cfe4623 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -50,6 +50,7 @@ struct record_opts { bool sample_time_set; bool sample_cpu; bool period; + bool period_set; bool running_time; bool full_auxtrace; bool auxtrace_snapshot_mode; diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index f2f2eaa..ff359c9 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -971,9 +971,6 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts, if (target__has_cpu(&opts->target) || opts->sample_cpu) perf_evsel__set_sample_bit(evsel, CPU); - if (opts->period) - perf_evsel__set_sample_bit(evsel, PERIOD); - /* * When the user explicitly disabled time don't force it here. */ @@ -1075,6 +1072,14 @@ void perf_evsel__config(struct perf_evsel *evsel, struct record_opts *opts, apply_config_terms(evsel, opts, track); evsel->ignore_missing_thread = opts->ignore_missing_thread; + + /* The --period option takes the precedence. */ + if (opts->period_set) { + if (opts->period) + perf_evsel__set_sample_bit(evsel, PERIOD); + else + perf_evsel__reset_sample_bit(evsel, PERIOD); + } } static int perf_evsel__alloc_fd(struct perf_evsel *evsel, int ncpus, int nthreads)