Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935392AbdGTIxt (ORCPT ); Thu, 20 Jul 2017 04:53:49 -0400 Received: from terminus.zytor.com ([65.50.211.136]:53051 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935044AbdGTIxq (ORCPT ); Thu, 20 Jul 2017 04:53:46 -0400 Date: Thu, 20 Jul 2017 01:51:32 -0700 From: tip-bot for Jiri Olsa Message-ID: Cc: acme@redhat.com, mingo@kernel.org, linux-kernel@vger.kernel.org, tglx@linutronix.de, jolsa@kernel.org, a.p.zijlstra@chello.nl, namhyung@kernel.org, dsahern@gmail.com, hpa@zytor.com, tmricht@linux.vnet.ibm.com Reply-To: dsahern@gmail.com, namhyung@kernel.org, a.p.zijlstra@chello.nl, hpa@zytor.com, tmricht@linux.vnet.ibm.com, acme@redhat.com, mingo@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, jolsa@kernel.org In-Reply-To: <20170703145030.12903-4-jolsa@kernel.org> References: <20170703145030.12903-4-jolsa@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tests attr: Add test_attr__ready function Git-Commit-ID: 10213e2ff2e0453324689eb50e73df3df1ee6163 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 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3020 Lines: 98 Commit-ID: 10213e2ff2e0453324689eb50e73df3df1ee6163 Gitweb: http://git.kernel.org/tip/10213e2ff2e0453324689eb50e73df3df1ee6163 Author: Jiri Olsa AuthorDate: Mon, 3 Jul 2017 16:50:18 +0200 Committer: Arnaldo Carvalho de Melo CommitDate: Tue, 18 Jul 2017 23:14:15 -0300 perf tests attr: Add test_attr__ready function We create many test events before the real ones just to test specific features. But there's no way for attr tests to separate those test events from those it needs to check. Adding 'ready' call from the events open interface to trigger/start events collection for attr test. Signed-off-by: Jiri Olsa Cc: David Ahern Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Thomas Richter Link: http://lkml.kernel.org/r/20170703145030.12903-4-jolsa@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/perf.h | 1 + tools/perf/tests/attr.c | 10 ++++++++++ tools/perf/util/evsel.c | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/tools/perf/perf.h b/tools/perf/perf.h index 806c216..2c010dd 100644 --- a/tools/perf/perf.h +++ b/tools/perf/perf.h @@ -7,6 +7,7 @@ #include extern bool test_attr__enabled; +void test_attr__ready(void); void test_attr__init(void); void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, int fd, int group_fd, unsigned long flags); diff --git a/tools/perf/tests/attr.c b/tools/perf/tests/attr.c index 08b1d5c..84c0eb5 100644 --- a/tools/perf/tests/attr.c +++ b/tools/perf/tests/attr.c @@ -36,6 +36,7 @@ #define ENV "PERF_TEST_ATTR" static char *dir; +static bool ready; void test_attr__init(void) { @@ -67,6 +68,9 @@ static int store_event(struct perf_event_attr *attr, pid_t pid, int cpu, FILE *file; char path[PATH_MAX]; + if (!ready) + return 0; + snprintf(path, PATH_MAX, "%s/event-%d-%llu-%d", dir, attr->type, attr->config, fd); @@ -144,6 +148,12 @@ void test_attr__open(struct perf_event_attr *attr, pid_t pid, int cpu, errno = errno_saved; } +void test_attr__ready(void) +{ + if (unlikely(test_attr__enabled) && !ready) + ready = true; +} + static int run_dir(const char *d, const char *perf) { char v[] = "-vvvvv"; diff --git a/tools/perf/util/evsel.c b/tools/perf/util/evsel.c index df567e4..6dd069a 100644 --- a/tools/perf/util/evsel.c +++ b/tools/perf/util/evsel.c @@ -58,6 +58,8 @@ static int perf_evsel__no_extra_init(struct perf_evsel *evsel __maybe_unused) return 0; } +void __weak test_attr__ready(void) { } + static void perf_evsel__no_extra_fini(struct perf_evsel *evsel __maybe_unused) { } @@ -1572,6 +1574,8 @@ retry_open: pr_debug2("sys_perf_event_open: pid %d cpu %d group_fd %d flags %#lx", pid, cpus->map[cpu], group_fd, flags); + test_attr__ready(); + fd = sys_perf_event_open(&evsel->attr, pid, cpus->map[cpu], group_fd, flags);