public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: tip-bot for Jiri Olsa <jolsa@redhat.com>
To: linux-tip-commits@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, eranian@google.com,
	paulus@samba.org, hpa@zytor.com, mingo@kernel.org,
	a.p.zijlstra@chello.nl, acme@ghostprotocols.net,
	jolsa@redhat.com, fweisbec@gmail.com, tglx@linutronix.de,
	cjashfor@linux.vnet.ibm.com
Subject: [tip:perf/core] perf/x86: Filter out undefined events from sysfs events attribute
Date: Wed, 24 Oct 2012 03:03:36 -0700	[thread overview]
Message-ID: <tip-8300daa26755c9a194776778bd822acf1fa2dbf6@git.kernel.org> (raw)
In-Reply-To: <1349873598-12583-3-git-send-email-jolsa@redhat.com>

Commit-ID:  8300daa26755c9a194776778bd822acf1fa2dbf6
Gitweb:     http://git.kernel.org/tip/8300daa26755c9a194776778bd822acf1fa2dbf6
Author:     Jiri Olsa <jolsa@redhat.com>
AuthorDate: Wed, 10 Oct 2012 14:53:12 +0200
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Wed, 24 Oct 2012 10:41:24 +0200

perf/x86: Filter out undefined events from sysfs events attribute

The sysfs events group attribute currently shows all hw events,
including also undefined ones.

This patch filters out all undefined events out of the sysfs events
group attribute, so they don't even show up.

Suggested-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Stephane Eranian <eranian@google.com>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1349873598-12583-3-git-send-email-jolsa@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/kernel/cpu/perf_event.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)

diff --git a/arch/x86/kernel/cpu/perf_event.c b/arch/x86/kernel/cpu/perf_event.c
index 9fa4c45..39737a6 100644
--- a/arch/x86/kernel/cpu/perf_event.c
+++ b/arch/x86/kernel/cpu/perf_event.c
@@ -1321,6 +1321,26 @@ struct perf_pmu_events_attr {
 	u64 id;
 };
 
+/*
+ * Remove all undefined events (x86_pmu.event_map(id) == 0)
+ * out of events_attr attributes.
+ */
+static void __init filter_events(struct attribute **attrs)
+{
+	int i, j;
+
+	for (i = 0; attrs[i]; i++) {
+		if (x86_pmu.event_map(i))
+			continue;
+
+		for (j = i; attrs[j]; j++)
+			attrs[j] = attrs[j + 1];
+
+		/* Check the shifted attr. */
+		i--;
+	}
+}
+
 ssize_t events_sysfs_show(struct device *dev, struct device_attribute *attr,
 			  char *page)
 {
@@ -1420,6 +1440,8 @@ static int __init init_hw_perf_events(void)
 
 	if (!x86_pmu.events_sysfs_show)
 		x86_pmu_events_group.attrs = &empty_attrs;
+	else
+		filter_events(x86_pmu_events_group.attrs);
 
 	pr_info("... version:                %d\n",     x86_pmu.version);
 	pr_info("... bit width:              %d\n",     x86_pmu.cntval_bits);

  reply	other threads:[~2012-10-24 10:04 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-10 12:53 [PATCHv4 0/8] perf, tool: Allow to use hw events in PMU syntax Jiri Olsa
2012-10-10 12:53 ` [PATCH 1/8] perf x86: Making hardware events translations available in sysfs Jiri Olsa
2012-10-24 10:02   ` [tip:perf/core] perf/x86: Make hardware event " tip-bot for Jiri Olsa
2012-10-10 12:53 ` [PATCH 2/8] perf x86: Filter out undefined events from sysfs events attribute Jiri Olsa
2012-10-24 10:03   ` tip-bot for Jiri Olsa [this message]
2012-10-10 12:53 ` [PATCH 3/8] perf x86: Adding hardware events translations for intel cpus Jiri Olsa
2012-10-24 10:04   ` [tip:perf/core] perf/x86: Add hardware events translations for Intel cpus tip-bot for Jiri Olsa
2012-10-10 12:53 ` [PATCH 4/8] perf x86: Adding hardware events translations for amd cpus Jiri Olsa
2012-10-10 14:11   ` Peter Zijlstra
2012-10-10 14:25     ` Jiri Olsa
2012-10-10 14:38       ` Peter Zijlstra
2012-10-24 10:05   ` [tip:perf/core] perf/x86: Add hardware events translations for AMD cpus tip-bot for Jiri Olsa
2012-10-10 12:53 ` [PATCH 5/8] perf x86: Adding hardware events translations for p6 cpus Jiri Olsa
2012-10-24 10:06   ` [tip:perf/core] perf/x86: Add hardware events translations for Intel P6 cpus tip-bot for Jiri Olsa
2012-10-10 12:53 ` [PATCH 6/8] perf tools: Fix pmu object alias initialization Jiri Olsa
2012-10-24 10:07   ` [tip:perf/core] perf tools: Fix PMU " tip-bot for Jiri Olsa
2012-10-10 12:53 ` [PATCH 7/8] perf tools: Add support to specify hw event as pmu event term Jiri Olsa
2012-10-24 10:08   ` [tip:perf/core] perf tools: Add support to specify hw event as PMU " tip-bot for Jiri Olsa
2012-10-10 12:53 ` [PATCH 8/8] perf test: Add automated tests for pmu sysfs translated events Jiri Olsa
2012-10-24 10:09   ` [tip:perf/core] " tip-bot for Jiri Olsa
2012-10-10 13:34 ` [PATCHv4 0/8] perf, tool: Allow to use hw events in PMU syntax Stephane Eranian
2012-10-10 13:40   ` Jiri Olsa
2012-10-10 13:44     ` Stephane Eranian
2012-10-23 15:05 ` Peter Zijlstra

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-8300daa26755c9a194776778bd822acf1fa2dbf6@git.kernel.org \
    --to=jolsa@redhat.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@ghostprotocols.net \
    --cc=cjashfor@linux.vnet.ibm.com \
    --cc=eranian@google.com \
    --cc=fweisbec@gmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tip-commits@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=paulus@samba.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