From: tip-bot for Mathieu Poirier <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: jolsa@kernel.org, alexander.shishkin@linux.intel.com,
hpa@zytor.com, peterz@infradead.org, mathieu.poirier@linaro.org,
tglx@linutronix.de, acme@redhat.com,
linux-kernel@vger.kernel.org, mingo@kernel.org
Subject: [tip:perf/core] perf pmu: Push configuration down to PMU driver
Date: Thu, 22 Sep 2016 22:27:18 -0700 [thread overview]
Message-ID: <tip-859442bd3fcbe326a9c0174c6105c938eb101438@git.kernel.org> (raw)
In-Reply-To: <1474041004-13956-6-git-send-email-mathieu.poirier@linaro.org>
Commit-ID: 859442bd3fcbe326a9c0174c6105c938eb101438
Gitweb: http://git.kernel.org/tip/859442bd3fcbe326a9c0174c6105c938eb101438
Author: Mathieu Poirier <mathieu.poirier@linaro.org>
AuthorDate: Fri, 16 Sep 2016 09:50:02 -0600
Committer: Arnaldo Carvalho de Melo <acme@redhat.com>
CommitDate: Thu, 22 Sep 2016 12:19:41 -0300
perf pmu: Push configuration down to PMU driver
This patch adds a PMU callback and the required mechanic so that drivers
can process the command line configuration elements found in
evsel::config_terms.
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Acked-by: Jiri Olsa <jolsa@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: http://lkml.kernel.org/r/1474041004-13956-6-git-send-email-mathieu.poirier@linaro.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
tools/perf/util/Build | 1 +
tools/perf/util/drv_configs.c | 77 ++++++++++++++++++++++
.../plat/smp.h => tools/perf/util/drv_configs.h | 20 +++---
tools/perf/util/pmu.h | 2 +
4 files changed, 90 insertions(+), 10 deletions(-)
diff --git a/tools/perf/util/Build b/tools/perf/util/Build
index 96f99d6..eb60e61 100644
--- a/tools/perf/util/Build
+++ b/tools/perf/util/Build
@@ -86,6 +86,7 @@ libperf-y += term.o
libperf-y += help-unknown-cmd.o
libperf-y += mem-events.o
libperf-y += vsprintf.o
+libperf-y += drv_configs.o
libperf-$(CONFIG_LIBBPF) += bpf-loader.o
libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
diff --git a/tools/perf/util/drv_configs.c b/tools/perf/util/drv_configs.c
new file mode 100644
index 0000000..1647f28
--- /dev/null
+++ b/tools/perf/util/drv_configs.c
@@ -0,0 +1,77 @@
+/*
+ * drv_configs.h: Interface to apply PMU specific configuration
+ * Copyright (c) 2016-2018, Linaro Ltd.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms and conditions of the GNU General Public License,
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
+ * more details.
+ *
+ */
+
+#include "drv_configs.h"
+#include "evlist.h"
+#include "evsel.h"
+#include "pmu.h"
+
+static int
+perf_evsel__apply_drv_configs(struct perf_evsel *evsel,
+ struct perf_evsel_config_term **err_term)
+{
+ bool found = false;
+ int err = 0;
+ struct perf_evsel_config_term *term;
+ struct perf_pmu *pmu = NULL;
+
+ while ((pmu = perf_pmu__scan(pmu)) != NULL)
+ if (pmu->type == evsel->attr.type) {
+ found = true;
+ break;
+ }
+
+ list_for_each_entry(term, &evsel->config_terms, list) {
+ if (term->type != PERF_EVSEL__CONFIG_TERM_DRV_CFG)
+ continue;
+
+ /*
+ * We have a configuration term, report an error if we
+ * can't find the PMU or if the PMU driver doesn't support
+ * cmd line driver configuration.
+ */
+ if (!found || !pmu->set_drv_config) {
+ err = -EINVAL;
+ *err_term = term;
+ break;
+ }
+
+ err = pmu->set_drv_config(term);
+ if (err) {
+ *err_term = term;
+ break;
+ }
+ }
+
+ return err;
+}
+
+int perf_evlist__apply_drv_configs(struct perf_evlist *evlist,
+ struct perf_evsel **err_evsel,
+ struct perf_evsel_config_term **err_term)
+{
+ struct perf_evsel *evsel;
+ int err = 0;
+
+ evlist__for_each_entry(evlist, evsel) {
+ err = perf_evsel__apply_drv_configs(evsel, err_term);
+ if (err) {
+ *err_evsel = evsel;
+ break;
+ }
+ }
+
+ return err;
+}
diff --git a/arch/arc/plat-eznps/include/plat/smp.h b/tools/perf/util/drv_configs.h
similarity index 55%
copy from arch/arc/plat-eznps/include/plat/smp.h
copy to tools/perf/util/drv_configs.h
index 06b59bd..32bc9ba 100644
--- a/arch/arc/plat-eznps/include/plat/smp.h
+++ b/tools/perf/util/drv_configs.h
@@ -1,5 +1,6 @@
/*
- * Copyright(c) 2015 EZchip Technologies.
+ * drv_configs.h: Interface to apply PMU specific configuration
+ * Copyright (c) 2016-2018, Linaro Ltd.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -10,17 +11,16 @@
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
- * The full GNU General Public License is included in this distribution in
- * the file called "COPYING".
*/
-#ifndef __PLAT_EZNPS_SMP_H
-#define __PLAT_EZNPS_SMP_H
+#ifndef __PERF_DRV_CONFIGS_H
+#define __PERF_DRV_CONFIGS_H
-#ifdef CONFIG_SMP
-
-extern void res_service(void);
-
-#endif /* CONFIG_SMP */
+#include "drv_configs.h"
+#include "evlist.h"
+#include "evsel.h"
+int perf_evlist__apply_drv_configs(struct perf_evlist *evlist,
+ struct perf_evsel **err_evsel,
+ struct perf_evsel_config_term **term);
#endif
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index 5d7e844..743422a 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -4,6 +4,7 @@
#include <linux/bitmap.h>
#include <linux/perf_event.h>
#include <stdbool.h>
+#include "evsel.h"
#include "parse-events.h"
enum {
@@ -25,6 +26,7 @@ struct perf_pmu {
struct list_head format; /* HEAD struct perf_pmu_format -> list */
struct list_head aliases; /* HEAD struct perf_pmu_alias -> list */
struct list_head list; /* ELEM */
+ int (*set_drv_config) (struct perf_evsel_config_term *term);
};
struct perf_pmu_info {
next prev parent reply other threads:[~2016-09-23 5:27 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-16 15:49 [PATCH V8 0/7] perf: Driver specific configuration for PMU Mathieu Poirier
2016-09-16 15:49 ` [PATCH V8 1/7] perf tools: confining __get_cpuid() to x86 architecture Mathieu Poirier
2016-09-23 5:25 ` [tip:perf/core] perf tools: Confine " tip-bot for Mathieu Poirier
2016-09-16 15:49 ` [PATCH V8 2/7] perf tools: making coresight PMU listable Mathieu Poirier
2016-09-23 5:26 ` [tip:perf/core] perf tools: Make " tip-bot for Mathieu Poirier
2016-09-16 15:50 ` [PATCH V8 3/7] perf tools: adding coresight etm PMU record capabilities Mathieu Poirier
2016-09-23 5:26 ` [tip:perf/core] perf tools: Add " tip-bot for Mathieu Poirier
2016-09-16 15:50 ` [PATCH V8 4/7] perf tools: add infrastructure for PMU specific configuration Mathieu Poirier
2016-09-16 15:50 ` [PATCH V8 5/7] perf tools: pushing configuration down to PMU driver Mathieu Poirier
2016-09-23 5:27 ` tip-bot for Mathieu Poirier [this message]
2016-09-16 15:50 ` [PATCH V8 6/7] perf tools: adding PMU configuration to tools Mathieu Poirier
2016-09-23 5:27 ` [tip:perf/core] perf tools: Add " tip-bot for Mathieu Poirier
2016-09-16 15:50 ` [PATCH V8 7/7] perf tools: adding sink configuration for cs_etm PMU Mathieu Poirier
2016-09-23 5:28 ` [tip:perf/core] perf tools: Add " tip-bot for Mathieu Poirier
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=tip-859442bd3fcbe326a9c0174c6105c938eb101438@git.kernel.org \
--to=tipbot@zytor.com \
--cc=acme@redhat.com \
--cc=alexander.shishkin@linux.intel.com \
--cc=hpa@zytor.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=mathieu.poirier@linaro.org \
--cc=mingo@kernel.org \
--cc=peterz@infradead.org \
--cc=tglx@linutronix.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox