Received: by 10.192.165.148 with SMTP id m20csp540991imm; Wed, 25 Apr 2018 03:59:21 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq10hDFAjYVYSMySdAm6nGCuL+MUoXFeciyXWE3bSvbHoudwQk9fwgYg7U4XLQZ0o7z5Hay X-Received: by 2002:a17:902:5952:: with SMTP id e18-v6mr7200228plj.351.1524653961090; Wed, 25 Apr 2018 03:59:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524653961; cv=none; d=google.com; s=arc-20160816; b=y1KgdXCdcOSDPi/nVnMYZxxc2vKAqhxJ180VuULqk9cCm0jzYOArKHzX++HFhTBMIx 1rU6xAYJ6BqMz6s4M9wUxIC3Fa69LsceHxG1aphAFNqRbv2VPPsAYuvyqhOehqZffE7h +qwlLKY9GEiTsaonOSxMvK6FvVI3Pzye6WvKttzbQMeSyh+mn3pw2ZNCpIl4lOzDdVaW xA+MYxjDaHS0o9uoUtIfSUkT0DoosLXjA3bwxbhWsO6rklLEoYnvrmEf6/Y5MyF7Ymfa gcvN3Q2D8P982UQY6PkFRCMLNsOks9sboCEsQEm33IZXhx5/+YBftTTGeUaxNnI+/TAw e3zQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=E020mQXrGTJxeVCx1GtdyUHacVAWaMvQszNKWYtEq0k=; b=K6VDsapSpVKrcBlotzRZatIWgpu7HBaMXXlRGVJl1uBBbsjQ/srTKZKf4mdW4pV0Nx 8Pgk7l3LcJz/8CG+NlBjdsdgVeqYfA8M2utK9veM9famf920BmbEBlGYRtnB249uYGy2 biIPjjFhr9pZeSR9DUukpu0yByv6NoQFOvZaVtMk5XjIkyOlijFp67aG2PaCLyZmU5kd UMv+at2+WLO1SpcusJmbRcFZ9rKoQcYnUe1lv/B7IIoIAlEwJa66Chr1qL6b31PBihCJ 50ngynn/T/o+S+jfQPMJjMczRCFwDIm0FcYD/AHs/szkhLW/95ohTn93TOHFS6EC1NIw A3uQ== 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 f5si12744362pgv.668.2018.04.25.03.59.06; Wed, 25 Apr 2018 03:59:21 -0700 (PDT) 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 S1754169AbeDYKnC (ORCPT + 99 others); Wed, 25 Apr 2018 06:43:02 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:52786 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754139AbeDYKmw (ORCPT ); Wed, 25 Apr 2018 06:42:52 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 7BF9B4A3; Wed, 25 Apr 2018 10:42:51 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephane Eranian , Jiri Olsa , Arnaldo Carvalho de Melo , Alexander Shishkin , Andi Kleen , David Ahern , Namhyung Kim , Peter Zijlstra , Sasha Levin Subject: [PATCH 4.14 136/183] perf record: Fix period option handling Date: Wed, 25 Apr 2018 12:35:56 +0200 Message-Id: <20180425103247.883389928@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180425103242.532713678@linuxfoundation.org> References: <20180425103242.532713678@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jiri Olsa [ Upstream commit f290aa1ffa45ed7e37599840878b4dae68269ee1 ] 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 Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- tools/perf/builtin-record.c | 3 ++- tools/perf/perf.h | 1 + tools/perf/util/evsel.c | 11 ++++++++--- 3 files changed, 11 insertions(+), 4 deletions(-) --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -1611,7 +1611,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, --- 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; --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -943,9 +943,6 @@ void perf_evsel__config(struct perf_evse 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. */ @@ -1047,6 +1044,14 @@ void perf_evsel__config(struct perf_evse apply_config_terms(evsel, opts); 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)