From: William Cohen <wcohen@redhat.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [patch] Performance Counters for Linux, v3
Date: Thu, 11 Dec 2008 17:05:05 -0500 [thread overview]
Message-ID: <49418E91.9090904@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 542 bytes --]
I was taking a look at the proposed performance monitoring and kerneltop.c. I
noticed that http://redhat.com/~mingo/perfcounters/kerneltop.c doesn't work
with the v3 version. I didn't see a more recent version available, so I made
some modifications to make allow it to work with the v3 kernel (with the
attached). However, I assume some where there is an updated version of kerneltop.c
The Documentation/perf-counters.txt doesn't describe how the group_fd is used.
Found that -1 used to indicate not connected to any other fd.
-Will
[-- Attachment #2: v3.diff --]
[-- Type: text/x-patch, Size: 2420 bytes --]
--- kerneltop.c.old 2008-12-11 15:34:58.000000000 -0500
+++ kerneltop.c 2008-12-11 16:06:28.000000000 -0500
@@ -62,15 +62,31 @@
# define __NR_perf_counter_open 333
#endif
+/*
+ * Hardware event to monitor via a performance monitoring counter:
+ */
+struct perf_counter_hw_event {
+ int64_t type;
+
+ u_int64_t irq_period;
+ u_int32_t record_type;
+
+ u_int32_t disabled : 1, /* off by default */
+ nmi : 1, /* NMI sampling */
+ raw : 1, /* raw event type */
+ __reserved_1 : 29;
+
+ u_int64_t __reserved_2;
+};
+
int
-perf_counter_open(int hw_event_type,
- unsigned int hw_event_period,
- unsigned int record_type,
+perf_counter_open(struct perf_counter_hw_event *hw_event_uptr,
pid_t pid,
- int cpu)
+ int cpu,
+ int group_fd)
{
- return syscall(__NR_perf_counter_open, hw_event_type, hw_event_period,
- record_type, pid, cpu);
+ return syscall(__NR_perf_counter_open, hw_event_uptr,
+ pid, cpu, group_fd);
}
enum hw_event_types {
@@ -82,10 +98,6 @@
PERF_COUNT_BRANCH_MISSES,
PERF_COUNT_MAX,
- /*
- * If this bit is set in the type, then trigger NMI sampling:
- */
- PERF_COUNT_NMI = (1 << 30),
};
const char *event_types [] = {
@@ -616,14 +628,14 @@
{
struct pollfd event_array[MAX_NR_CPUS][MAX_COUNTERS];
int fd[MAX_NR_CPUS][MAX_COUNTERS];
- unsigned int nmi_flag = 0;
- unsigned int flags, cpu;
+ unsigned int cpu;
int i, counter;
uint64_t ip;
ssize_t res;
#if USE_POLL
int ret;
#endif
+ struct perf_counter_hw_event hw_event;
process_options(argc, argv);
@@ -633,18 +645,18 @@
assert(nr_cpus <= MAX_NR_CPUS);
- if (nmi)
- nmi_flag |= PERF_COUNT_NMI;
-
for (i = 0; i < nr_cpus; i++) {
for (counter = 0; counter < nr_counters; counter++) {
- flags = event_id[counter] | nmi_flag;
-
cpu = profile_cpu;
if (tid == -1 && profile_cpu == -1)
cpu = i;
-
- fd[i][counter] = perf_counter_open(flags, event_count[counter], 1, tid, cpu);
+ hw_event.type = event_id[counter];
+ hw_event.irq_period = event_count[counter];
+ hw_event.record_type = 1;
+ hw_event.nmi = nmi ? 1 : 0;
+
+ fd[i][counter] = perf_counter_open(&hw_event, tid,
+ cpu, -1 );
if (fd[i][counter] < 0) {
printf("kerneltop error: syscall returned with %d (%s)\n",
fd[i][counter], strerror(-fd[i][counter]));
next reply other threads:[~2008-12-11 22:05 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-11 22:05 William Cohen [this message]
-- strict thread matches above, loose matches on Subject: below --
2008-12-11 15:52 [patch] Performance Counters for Linux, v3 Ingo Molnar
2008-12-11 18:02 ` Vince Weaver
2008-12-12 8:25 ` Peter Zijlstra
2008-12-12 8:35 ` stephane eranian
2008-12-12 8:51 ` Peter Zijlstra
2008-12-12 9:00 ` Peter Zijlstra
2008-12-12 9:07 ` Ingo Molnar
2008-12-12 8:59 ` stephane eranian
2008-12-12 9:23 ` Peter Zijlstra
2008-12-12 10:21 ` Robert Richter
2008-12-12 10:59 ` Christoph Hellwig
2008-12-12 11:35 ` Robert Richter
2008-12-12 16:45 ` Chris Friesen
2008-12-12 17:42 ` stephane eranian
2008-12-12 18:01 ` stephane eranian
2008-12-12 19:45 ` Chris Friesen
2008-12-15 14:50 ` stephane eranian
2008-12-15 22:32 ` Chris Friesen
2008-12-17 7:45 ` stephane eranian
2008-12-14 23:13 ` Ingo Molnar
2008-12-15 0:37 ` Paul Mackerras
2008-12-15 12:58 ` stephane eranian
2008-12-15 14:42 ` stephane eranian
2008-12-15 20:58 ` stephane eranian
2008-12-15 22:53 ` Paul Mackerras
2008-12-13 11:17 ` Peter Zijlstra
2008-12-13 13:48 ` Henrique de Moraes Holschuh
2008-12-13 17:44 ` stephane eranian
2008-12-14 1:02 ` Paul Mackerras
2008-12-14 22:37 ` Ingo Molnar
2008-12-15 0:50 ` Paul Mackerras
2008-12-15 13:02 ` stephane eranian
2008-12-12 17:03 ` Samuel Thibault
2008-12-12 17:11 ` Peter Zijlstra
2008-12-12 18:18 ` Vince Weaver
2008-12-11 18:35 ` Andrew Morton
2008-12-12 6:22 ` Ingo Molnar
2008-12-11 19:11 ` Tony Luck
2008-12-11 19:34 ` Ingo Molnar
2008-12-12 8:29 ` Peter Zijlstra
2008-12-12 8:54 ` Ingo Molnar
2008-12-12 13:42 ` Andi Kleen
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=49418E91.9090904@redhat.com \
--to=wcohen@redhat.com \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.