Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756697AbdGCOyS (ORCPT ); Mon, 3 Jul 2017 10:54:18 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6751 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932173AbdGCOuk (ORCPT ); Mon, 3 Jul 2017 10:50:40 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 814087D0C3 Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: ext-mx02.extmail.prod.ext.phx2.redhat.com; spf=none smtp.mailfrom=jolsa@kernel.org DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 814087D0C3 From: Jiri Olsa To: Arnaldo Carvalho de Melo Cc: lkml , Ingo Molnar , Peter Zijlstra , Namhyung Kim , David Ahern , Thomas Richter Subject: [PATCH 03/15] perf tests attr: Add test_attr__ready function Date: Mon, 3 Jul 2017 16:50:18 +0200 Message-Id: <20170703145030.12903-4-jolsa@kernel.org> In-Reply-To: <20170703145030.12903-1-jolsa@kernel.org> References: <20170703145030.12903-1-jolsa@kernel.org> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 03 Jul 2017 14:50:39 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2532 Lines: 87 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. Link: http://lkml.kernel.org/n/tip-mugsnw0j4lb44ytlbwxajh92@git.kernel.org Signed-off-by: Jiri Olsa --- 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 806c216a1078..2c010dd6a79d 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 08b1d5ce9020..84c0eb598a67 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 915fe3cd6544..7f9ed521f42c 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) { } @@ -1568,6 +1570,8 @@ int perf_evsel__open(struct perf_evsel *evsel, struct cpu_map *cpus, 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); -- 2.9.4