lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1274233792.3036.90.camel@localhost>
Date:	Wed, 19 May 2010 01:49:52 +0000
From:	Lin Ming <ming.m.lin@...el.com>
To:	Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...e.hu>,
	Corey Ashford <cjashfor@...ux.vnet.ibm.com>
Cc:	Frederic Weisbecker <fweisbec@...il.com>,
	Paul Mundt <lethal@...ux-sh.org>,
	"eranian@...il.com" <eranian@...il.com>,
	"Gary.Mohr@...l.com" <Gary.Mohr@...l.com>,
	"arjan@...ux.intel.com" <arjan@...ux.intel.com>,
	"Zhang, Yanmin" <yanmin_zhang@...ux.intel.com>,
	Paul Mackerras <paulus@...ba.org>,
	"David S. Miller" <davem@...emloft.net>,
	Russell King <rmk+kernel@....linux.org.uk>,
	Arnaldo Carvalho de Melo <acme@...hat.com>,
	Will Deacon <will.deacon@....com>,
	Maynard Johnson <mpjohn@...ibm.com>,
	Carl Love <carll@...ibm.com>,
	"greg@...ah.com" <greg@...ah.com>,
	Kay Sievers <kay.sievers@...y.org>,
	lkml <linux-kernel@...r.kernel.org>
Subject: [RFC][PATCH v2 11/11] perf top: demo of how to use the sysfs
 interface

Just a temporary patch to show how to use the pmu sysfs interface...

Signed-off-by: Lin Ming <ming.m.lin@...el.com>
---
 tools/perf/builtin-top.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index adc179d..eaa9405 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1206,6 +1206,7 @@ static void start_counter(int i, int counter)
 	struct perf_event_attr *attr;
 	int cpu;
 	int thread_index;
+	int sys_fd;
 
 	cpu = profile_cpu;
 	if (target_tid == -1 && profile_cpu == -1)
@@ -1226,9 +1227,21 @@ static void start_counter(int i, int counter)
 
 	for (thread_index = 0; thread_index < thread_num; thread_index++) {
 try_again:
+		/*
+		 * This is just an ugly demo of how to use the sysfs interface.
+		 * You can also parse the <event-name> and open sys file as,
+		 * sys_fd = open("/sys/devices/system/cpu/events/<event-name>/event_source/id", O_RDONLY);
+		 */
+		sys_fd = open("/sys/devices/system/cpu/event_source/id", O_RDONLY);
+		if (sys_fd != -1)
+			attr->type |= (sys_fd << PERF_EVENT_ATTR_TYPE_BITS) | PERF_EVENT_FD;
+
 		fd[i][counter][thread_index] = sys_perf_event_open(attr,
 				all_tids[thread_index], cpu, group_fd, 0);
 
+		if (sys_fd != -1)
+			close(sys_fd);
+
 		if (fd[i][counter][thread_index] < 0) {
 			int err = errno;
 




--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ