mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomasz Fujak <t.fujak@samsung.com>
To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org
Cc: jamie.iles@picochip.com, will.deacon@arm.com, jpihet@mvista.com,
	mingo@elte.hu, peterz@infradead.org, p.osciak@samsung.com,
	m.szyprowski@samsung.com, kyungmin.park@samsung.com,
	Tomasz Fujak <t.fujak@samsung.com>
Subject: [PATCH v1 1/2] perfevent: Add performance event structure definition and 'extevents' sysfs entry
Date: Wed, 20 Jan 2010 10:11:45 +0100	[thread overview]
Message-ID: <1263978706-15499-2-git-send-email-t.fujak@samsung.com> (raw)
In-Reply-To: <1263978706-15499-1-git-send-email-t.fujak@samsung.com>

This patch adds a structure that contains single hardware performance event
 definition (including name and description fields), and sysfs entry suited
to export machine-dependent list of events.

Signed-off-by: Tomasz Fujak <t.fujak@samsung.com>
Reviewed-by: Marek Szyprowski <m.szyprowski@samsung.com>
Reviewed-by: Kyungmin Park <kyungmin.park@samsung.com>

---
 include/linux/perf_event.h |   19 +++++++++++++++++++
 kernel/perf_event.c        |   32 ++++++++++++++++++++++++++++++++
 2 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/include/linux/perf_event.h b/include/linux/perf_event.h
index 9e70126..4dc4d73 100644
--- a/include/linux/perf_event.h
+++ b/include/linux/perf_event.h
@@ -447,6 +447,12 @@ enum perf_callchain_context {
 
 #define PERF_MAX_STACK_DEPTH		255
 
+#define PERF_EVENT_RAW_BIT			(1ULL << 63)
+#define PERF_EVENT_RAW_TO_CONFIG(_val)	((_val) | PERF_EVENT_RAW_BIT)
+#define PERF_EVENT_CONFIG_TO_RAW(_val)	((_val) & ~PERF_EVENT_RAW_BIT)
+#define PERF_EVENT_IS_RAW(_val)		((_val) & PERF_EVENT_RAW_BIT)
+
+
 struct perf_callchain_entry {
 	__u64				nr;
 	__u64				ip[PERF_MAX_STACK_DEPTH];
@@ -538,6 +544,19 @@ struct perf_mmap_data {
 	void				*data_pages[0];
 };
 
+struct perf_event_description {
+	struct list_head	list;
+
+	/* type : 1, subsystem [0..7], id [56..63]*/
+	__u64				config;
+	__u64				min_value;	/* min. wakeup period */
+	__u64				max_value;	/* max. wakeup period */
+	__u32				flags;		/* ??? */
+	__u32				reserved[3];
+	char				*name;
+	char				*description;
+};
+
 struct perf_pending_entry {
 	struct perf_pending_entry *next;
 	void (*func)(struct perf_pending_entry *);
diff --git a/kernel/perf_event.c b/kernel/perf_event.c
index 7f29643..4223870 100644
--- a/kernel/perf_event.c
+++ b/kernel/perf_event.c
@@ -97,6 +97,13 @@ void __weak hw_perf_enable(void)		{ barrier(); }
 void __weak hw_perf_event_setup(int cpu)	{ barrier(); }
 void __weak hw_perf_event_setup_online(int cpu)	{ barrier(); }
 
+static LIST_HEAD(perf_event_empty);
+
+const struct list_head __weak *hw_perf_event_get_list(void)
+{
+	return &perf_event_empty;
+}
+
 int __weak
 hw_perf_group_sched_in(struct perf_event *group_leader,
 	       struct perf_cpu_context *cpuctx,
@@ -5097,6 +5104,23 @@ perf_set_overcommit(struct sysdev_class *class, const char *buf, size_t count)
 	return count;
 }
 
+static ssize_t perf_show_extevents(struct sysdev_class *class, char *buf)
+{
+	char *str = buf;
+	const struct list_head *head = hw_perf_event_get_list();
+	const struct perf_event_description *entry;
+
+	list_for_each_entry(entry, head, list)
+		if (PERF_EVENT_IS_RAW(entry->config))
+			str +=  sprintf(str, "0x%llx\t%s\t%lld-%lld\t%s\n",
+				PERF_EVENT_CONFIG_TO_RAW(entry->config),
+				entry->name, entry->min_value,
+				entry->max_value, entry->description);
+
+	return str - buf;
+}
+
+
 static SYSDEV_CLASS_ATTR(
 				reserve_percpu,
 				0644,
@@ -5111,9 +5135,17 @@ static SYSDEV_CLASS_ATTR(
 				perf_set_overcommit
 			);
 
+static SYSDEV_CLASS_ATTR(
+				extevents,
+				0444,
+				perf_show_extevents,
+				NULL
+			);
+
 static struct attribute *perfclass_attrs[] = {
 	&attr_reserve_percpu.attr,
 	&attr_overcommit.attr,
+	&attr_extevents.attr,
 	NULL
 };
 
-- 
1.5.4.3


  reply	other threads:[~2010-01-20  9:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-20  9:11 [PATCH/RFC v1 0/2] Human readable performance event description in sysfs Tomasz Fujak
2010-01-20  9:11 ` Tomasz Fujak [this message]
2010-01-20  9:11 ` [PATCH v1 2/2] [ARM] perfevent: Event description list for ARMv6, Cortex-A8 and Cortex-A9 exported Tomasz Fujak
2010-01-20  9:16 ` [PATCH/RFC v1 0/2] Human readable performance event description in sysfs Peter Zijlstra
2010-01-20  9:46   ` Tomasz Fujak
2010-01-20  9:57   ` Michał Nazarewicz
2010-01-20 13:31     ` Jamie Iles
2010-01-20 13:39       ` Peter Zijlstra
2010-01-20 13:55         ` Russell King - ARM Linux
2010-01-20 14:01           ` Peter Zijlstra
2010-01-20 14:09             ` Michał Nazarewicz
2010-01-20 14:16               ` Peter Zijlstra
2010-01-20 14:26                 ` Peter Zijlstra
2010-01-20 14:45                   ` Russell King - ARM Linux
2010-01-20 14:54                 ` Michał Nazarewicz
2010-01-20 14:41             ` Russell King - ARM Linux
2010-01-20 15:03               ` Jamie Iles
2010-01-20 15:42                 ` Russell King - ARM Linux
2010-01-20 16:18                   ` Jamie Iles
2010-01-20 16:26               ` Jamie Lokier
2010-01-20 16:35                 ` Russell King - ARM Linux
2010-01-20  9:57 ` Russell King - ARM Linux
2010-01-20 10:21   ` Tomasz Fujak

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=1263978706-15499-2-git-send-email-t.fujak@samsung.com \
    --to=t.fujak@samsung.com \
    --cc=jamie.iles@picochip.com \
    --cc=jpihet@mvista.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mingo@elte.hu \
    --cc=p.osciak@samsung.com \
    --cc=peterz@infradead.org \
    --cc=will.deacon@arm.com \
    /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

all inboxes | Powered by JetHome®