Patches contributed by Eötvös Lorand University
commit 8dc8e5e8bc0ce00b0f656bf972f67cd8a72759e5
Author: Ingo Molnar <mingo@elte.hu>
Date: Thu Jun 11 16:13:24 2009 +0200
perf_counter: Turn off by default
Perfcounters were enabled by default to help testing - but now that we
are submitting it upstream, make it default-disabled.
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/init/Kconfig b/init/Kconfig
index 8158f1f44694..aef16f9b3d23 100644
--- a/init/Kconfig
+++ b/init/Kconfig
@@ -941,7 +941,6 @@ menu "Performance Counters"
config PERF_COUNTERS
bool "Kernel Performance Counters"
depends on HAVE_PERF_COUNTERS
- default y
select ANON_INODES
help
Enable kernel support for performance counter hardware.
commit a308444ceb576d3089f9ca0dfd097eba6f1e623f
Author: Ingo Molnar <mingo@elte.hu>
Date: Thu Jun 11 14:44:26 2009 +0200
perf_counter: Better align code
Whitespace and comment bits. Also update copyrights.
[ Impact: cleanup ]
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
diff --git a/include/linux/perf_counter.h b/include/linux/perf_counter.h
index 20cf5af27ade..1fa1a26cb1b3 100644
--- a/include/linux/perf_counter.h
+++ b/include/linux/perf_counter.h
@@ -1,12 +1,13 @@
/*
* Performance counters:
*
- * Copyright(C) 2008, Thomas Gleixner <tglx@linutronix.de>
- * Copyright(C) 2008, Red Hat, Inc., Ingo Molnar
+ * Copyright (C) 2008-2009, Thomas Gleixner <tglx@linutronix.de>
+ * Copyright (C) 2008-2009, Red Hat, Inc., Ingo Molnar
+ * Copyright (C) 2008-2009, Red Hat, Inc., Peter Zijlstra
*
* Data type definitions, declarations, prototypes.
*
- * Started by: Thomas Gleixner and Ingo Molnar
+ * Started by: Thomas Gleixner and Ingo Molnar
*
* For licencing details see kernel-base/COPYING
*/
@@ -25,18 +26,19 @@
* attr.type
*/
enum perf_type_id {
- PERF_TYPE_HARDWARE = 0,
- PERF_TYPE_SOFTWARE = 1,
- PERF_TYPE_TRACEPOINT = 2,
- PERF_TYPE_HW_CACHE = 3,
- PERF_TYPE_RAW = 4,
+ PERF_TYPE_HARDWARE = 0,
+ PERF_TYPE_SOFTWARE = 1,
+ PERF_TYPE_TRACEPOINT = 2,
+ PERF_TYPE_HW_CACHE = 3,
+ PERF_TYPE_RAW = 4,
- PERF_TYPE_MAX, /* non ABI */
+ PERF_TYPE_MAX, /* non-ABI */
};
/*
- * Generalized performance counter event types, used by the attr.event_id
- * parameter of the sys_perf_counter_open() syscall:
+ * Generalized performance counter event types, used by the
+ * attr.event_id parameter of the sys_perf_counter_open()
+ * syscall:
*/
enum perf_hw_id {
/*
@@ -50,7 +52,7 @@ enum perf_hw_id {
PERF_COUNT_HW_BRANCH_MISSES = 5,
PERF_COUNT_HW_BUS_CYCLES = 6,
- PERF_COUNT_HW_MAX, /* non ABI */
+ PERF_COUNT_HW_MAX, /* non-ABI */
};
/*
@@ -61,29 +63,29 @@ enum perf_hw_id {
* { accesses, misses }
*/
enum perf_hw_cache_id {
- PERF_COUNT_HW_CACHE_L1D = 0,
- PERF_COUNT_HW_CACHE_L1I = 1,
- PERF_COUNT_HW_CACHE_LL = 2,
- PERF_COUNT_HW_CACHE_DTLB = 3,
- PERF_COUNT_HW_CACHE_ITLB = 4,
- PERF_COUNT_HW_CACHE_BPU = 5,
-
- PERF_COUNT_HW_CACHE_MAX, /* non ABI */
+ PERF_COUNT_HW_CACHE_L1D = 0,
+ PERF_COUNT_HW_CACHE_L1I = 1,
+ PERF_COUNT_HW_CACHE_LL = 2,
+ PERF_COUNT_HW_CACHE_DTLB = 3,
+ PERF_COUNT_HW_CACHE_ITLB = 4,
+ PERF_COUNT_HW_CACHE_BPU = 5,
+
+ PERF_COUNT_HW_CACHE_MAX, /* non-ABI */
};
enum perf_hw_cache_op_id {
- PERF_COUNT_HW_CACHE_OP_READ = 0,
- PERF_COUNT_HW_CACHE_OP_WRITE = 1,
- PERF_COUNT_HW_CACHE_OP_PREFETCH = 2,
+ PERF_COUNT_HW_CACHE_OP_READ = 0,
+ PERF_COUNT_HW_CACHE_OP_WRITE = 1,
+ PERF_COUNT_HW_CACHE_OP_PREFETCH = 2,
- PERF_COUNT_HW_CACHE_OP_MAX, /* non ABI */
+ PERF_COUNT_HW_CACHE_OP_MAX, /* non-ABI */
};
enum perf_hw_cache_op_result_id {
PERF_COUNT_HW_CACHE_RESULT_ACCESS = 0,
PERF_COUNT_HW_CACHE_RESULT_MISS = 1,
- PERF_COUNT_HW_CACHE_RESULT_MAX, /* non ABI */
+ PERF_COUNT_HW_CACHE_RESULT_MAX, /* non-ABI */
};
/*
@@ -93,15 +95,15 @@ enum perf_hw_cache_op_result_id {
* well):
*/
enum perf_sw_ids {
- PERF_COUNT_SW_CPU_CLOCK = 0,
- PERF_COUNT_SW_TASK_CLOCK = 1,
- PERF_COUNT_SW_PAGE_FAULTS = 2,
- PERF_COUNT_SW_CONTEXT_SWITCHES = 3,
- PERF_COUNT_SW_CPU_MIGRATIONS = 4,
- PERF_COUNT_SW_PAGE_FAULTS_MIN = 5,
- PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6,
-
- PERF_COUNT_SW_MAX, /* non ABI */
+ PERF_COUNT_SW_CPU_CLOCK = 0,
+ PERF_COUNT_SW_TASK_CLOCK = 1,
+ PERF_COUNT_SW_PAGE_FAULTS = 2,
+ PERF_COUNT_SW_CONTEXT_SWITCHES = 3,
+ PERF_COUNT_SW_CPU_MIGRATIONS = 4,
+ PERF_COUNT_SW_PAGE_FAULTS_MIN = 5,
+ PERF_COUNT_SW_PAGE_FAULTS_MAJ = 6,
+
+ PERF_COUNT_SW_MAX, /* non-ABI */
};
/*
@@ -109,15 +111,15 @@ enum perf_sw_ids {
* in the overflow packets.
*/
enum perf_counter_sample_format {
- PERF_SAMPLE_IP = 1U << 0,
- PERF_SAMPLE_TID = 1U << 1,
- PERF_SAMPLE_TIME = 1U << 2,
- PERF_SAMPLE_ADDR = 1U << 3,
- PERF_SAMPLE_GROUP = 1U << 4,
- PERF_SAMPLE_CALLCHAIN = 1U << 5,
- PERF_SAMPLE_ID = 1U << 6,
- PERF_SAMPLE_CPU = 1U << 7,
- PERF_SAMPLE_PERIOD = 1U << 8,
+ PERF_SAMPLE_IP = 1U << 0,
+ PERF_SAMPLE_TID = 1U << 1,
+ PERF_SAMPLE_TIME = 1U << 2,
+ PERF_SAMPLE_ADDR = 1U << 3,
+ PERF_SAMPLE_GROUP = 1U << 4,
+ PERF_SAMPLE_CALLCHAIN = 1U << 5,
+ PERF_SAMPLE_ID = 1U << 6,
+ PERF_SAMPLE_CPU = 1U << 7,
+ PERF_SAMPLE_PERIOD = 1U << 8,
};
/*
@@ -126,9 +128,9 @@ enum perf_counter_sample_format {
* in increasing order of bit value, after the counter value.
*/
enum perf_counter_read_format {
- PERF_FORMAT_TOTAL_TIME_ENABLED = 1U << 0,
- PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1,
- PERF_FORMAT_ID = 1U << 2,
+ PERF_FORMAT_TOTAL_TIME_ENABLED = 1U << 0,
+ PERF_FORMAT_TOTAL_TIME_RUNNING = 1U << 1,
+ PERF_FORMAT_ID = 1U << 2,
};
/*
@@ -229,12 +231,12 @@ struct perf_counter_mmap_page {
__u64 data_head; /* head in the data section */
};
-#define PERF_EVENT_MISC_CPUMODE_MASK (3 << 0)
-#define PERF_EVENT_MISC_CPUMODE_UNKNOWN (0 << 0)
-#define PERF_EVENT_MISC_KERNEL (1 << 0)
-#define PERF_EVENT_MISC_USER (2 << 0)
-#define PERF_EVENT_MISC_HYPERVISOR (3 << 0)
-#define PERF_EVENT_MISC_OVERFLOW (1 << 2)
+#define PERF_EVENT_MISC_CPUMODE_MASK (3 << 0)
+#define PERF_EVENT_MISC_CPUMODE_UNKNOWN (0 << 0)
+#define PERF_EVENT_MISC_KERNEL (1 << 0)
+#define PERF_EVENT_MISC_USER (2 << 0)
+#define PERF_EVENT_MISC_HYPERVISOR (3 << 0)
+#define PERF_EVENT_MISC_OVERFLOW (1 << 2)
struct perf_event_header {
__u32 type;
@@ -351,14 +353,14 @@ struct hw_perf_counter {
#ifdef CONFIG_PERF_COUNTERS
union {
struct { /* hardware */
- u64 config;
- unsigned long config_base;
- unsigned long counter_base;
- int idx;
+ u64 config;
+ unsigned long config_base;
+ unsigned long counter_base;
+ int idx;
};
union { /* software */
- atomic64_t count;
- struct hrtimer hrtimer;
+ atomic64_t count;
+ struct hrtimer hrtimer;
};
};
atomic64_t prev_count;
@@ -523,37 +525,37 @@ struct perf_counter_context {
* Protect the states of the counters in the list,
* nr_active, and the list:
*/
- spinlock_t lock;
+ spinlock_t lock;
/*
* Protect the list of counters. Locking either mutex or lock
* is sufficient to ensure the list doesn't change; to change
* the list you need to lock both the mutex and the spinlock.
*/
- struct mutex mutex;
+ struct mutex mutex;
- struct list_head counter_list;
- struct list_head event_list;
- int nr_counters;
- int nr_active;
- int is_active;
- atomic_t refcount;
- struct task_struct *task;
+ struct list_head counter_list;
+ struct list_head event_list;
+ int nr_counters;
+ int nr_active;
+ int is_active;
+ atomic_t refcount;
+ struct task_struct *task;
/*
* Context clock, runs when context enabled.
*/
- u64 time;
- u64 timestamp;
+ u64 time;
+ u64 timestamp;
/*
* These fields let us detect when two contexts have both
* been cloned (inherited) from a common ancestor.
*/
- struct perf_counter_context *parent_ctx;
- u64 parent_gen;
- u64 generation;
- int pin_count;
- struct rcu_head rcu_head;
+ struct perf_counter_context *parent_ctx;
+ u64 parent_gen;
+ u64 generation;
+ int pin_count;
+ struct rcu_head rcu_head;
};
/**
@@ -604,9 +606,9 @@ extern int hw_perf_group_sched_in(struct perf_counter *group_leader,
extern void perf_counter_update_userpage(struct perf_counter *counter);
struct perf_sample_data {
- struct pt_regs *regs;
- u64 addr;
- u64 period;
+ struct pt_regs *regs;
+ u64 addr;
+ u64 period;
};
extern int perf_counter_overflow(struct perf_counter *counter, int nmi,
@@ -636,11 +638,14 @@ extern void perf_counter_fork(struct task_struct *tsk);
extern void perf_counter_task_migration(struct task_struct *task, int cpu);
-#define MAX_STACK_DEPTH 255
+#define MAX_STACK_DEPTH 255
struct perf_callchain_entry {
- u16 nr, hv, kernel, user;
- u64 ip[MAX_STACK_DEPTH];
+ u16 nr;
+ u16 hv;
+ u16 kernel;
+ u16 user;
+ u64 ip[MAX_STACK_DEPTH];
};
extern struct perf_callchain_entry *perf_callchain(struct pt_regs *regs);
commit 729ff5e2aaf181f5d3ab849337fce406cd19b1d9
Author: Ingo Molnar <mingo@elte.hu>
Date: Thu Jun 11 14:16:15 2009 +0200
perf_counter tools: Clean up u64 usage
A build error slipped in:
builtin-report.c: In function ‘hist_entry__fprintf’:
builtin-report.c:711: error: format ‘%12d’ expects type ‘int’, but argument 3 has type ‘uint64_t’
Because we got a bit sloppy with those types. uint64_t really sucks,
because there's no printf format for it. So standardize on __u64
instead - for all types that go to or come from the ABI (which is __u64),
or for values that need to be large enough even on 32-bit.
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 3334a8bb1d51..b1ed5f766cb3 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -145,7 +145,7 @@ static void dsos__fprintf(FILE *fp)
dso__fprintf(pos, fp);
}
-static struct symbol *vdso__find_symbol(struct dso *dso, uint64_t ip)
+static struct symbol *vdso__find_symbol(struct dso *dso, __u64 ip)
{
return dso__find_symbol(kernel_dso, ip);
}
@@ -178,19 +178,19 @@ static int load_kernel(void)
struct map {
struct list_head node;
- uint64_t start;
- uint64_t end;
- uint64_t pgoff;
- uint64_t (*map_ip)(struct map *, uint64_t);
+ __u64 start;
+ __u64 end;
+ __u64 pgoff;
+ __u64 (*map_ip)(struct map *, __u64);
struct dso *dso;
};
-static uint64_t map__map_ip(struct map *map, uint64_t ip)
+static __u64 map__map_ip(struct map *map, __u64 ip)
{
return ip - map->start + map->pgoff;
}
-static uint64_t vdso__map_ip(struct map *map, uint64_t ip)
+static __u64 vdso__map_ip(struct map *map, __u64 ip)
{
return ip;
}
@@ -249,7 +249,7 @@ static int map__overlap(struct map *l, struct map *r)
static size_t map__fprintf(struct map *self, FILE *fp)
{
- return fprintf(fp, " %"PRIx64"-%"PRIx64" %"PRIx64" %s\n",
+ return fprintf(fp, " %Lx-%Lx %Lx %s\n",
self->start, self->end, self->pgoff, self->dso->name);
}
@@ -373,7 +373,7 @@ static int thread__fork(struct thread *self, struct thread *parent)
return 0;
}
-static struct map *thread__find_map(struct thread *self, uint64_t ip)
+static struct map *thread__find_map(struct thread *self, __u64 ip)
{
struct map *pos;
@@ -414,7 +414,7 @@ struct hist_entry {
struct map *map;
struct dso *dso;
struct symbol *sym;
- uint64_t ip;
+ __u64 ip;
char level;
uint32_t count;
@@ -533,7 +533,7 @@ static struct sort_entry sort_dso = {
static int64_t
sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
{
- uint64_t ip_l, ip_r;
+ __u64 ip_l, ip_r;
if (left->sym == right->sym)
return 0;
@@ -647,7 +647,7 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
/*
* collect histogram counts
*/
-static void hist_hit(struct hist_entry *he, uint64_t ip)
+static void hist_hit(struct hist_entry *he, __u64 ip)
{
unsigned int sym_size, offset;
struct symbol *sym = he->sym;
@@ -676,7 +676,7 @@ static void hist_hit(struct hist_entry *he, uint64_t ip)
static int
hist_entry__add(struct thread *thread, struct map *map, struct dso *dso,
- struct symbol *sym, uint64_t ip, char level)
+ struct symbol *sym, __u64 ip, char level)
{
struct rb_node **p = &hist.rb_node;
struct rb_node *parent = NULL;
@@ -848,7 +848,7 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head)
int show = 0;
struct dso *dso = NULL;
struct thread *thread = threads__findnew(event->ip.pid);
- uint64_t ip = event->ip.ip;
+ __u64 ip = event->ip.ip;
struct map *map = NULL;
dprintf("%p [%p]: PERF_EVENT (IP, %d): %d: %p\n",
@@ -1031,7 +1031,7 @@ process_event(event_t *event, unsigned long offset, unsigned long head)
}
static int
-parse_line(FILE *file, struct symbol *sym, uint64_t start, uint64_t len)
+parse_line(FILE *file, struct symbol *sym, __u64 start, __u64 len)
{
char *line = NULL, *tmp, *tmp2;
unsigned int offset;
@@ -1112,7 +1112,7 @@ parse_line(FILE *file, struct symbol *sym, uint64_t start, uint64_t len)
static void annotate_sym(struct dso *dso, struct symbol *sym)
{
char *filename = dso->name;
- uint64_t start, end, len;
+ __u64 start, end, len;
char command[PATH_MAX*2];
FILE *file;
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 919f23ca4199..84cd336ae79b 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -223,7 +223,7 @@ static void pid_synthesize_comm_event(pid_t pid, int full)
comm_ev.pid = pid;
comm_ev.header.type = PERF_EVENT_COMM;
- size = ALIGN(size, sizeof(uint64_t));
+ size = ALIGN(size, sizeof(__u64));
comm_ev.header.size = sizeof(comm_ev) - (sizeof(comm_ev.comm) - size);
if (!full) {
@@ -304,7 +304,7 @@ static void pid_synthesize_mmap_samples(pid_t pid)
size = strlen(execname);
execname[size - 1] = '\0'; /* Remove \n */
memcpy(mmap_ev.filename, execname, size);
- size = ALIGN(size, sizeof(uint64_t));
+ size = ALIGN(size, sizeof(__u64));
mmap_ev.len -= mmap_ev.start;
mmap_ev.header.size = (sizeof(mmap_ev) -
(sizeof(mmap_ev.filename) - size));
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index f57fd5c5531a..82fa93b4db99 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -146,7 +146,7 @@ static void dsos__fprintf(FILE *fp)
dso__fprintf(pos, fp);
}
-static struct symbol *vdso__find_symbol(struct dso *dso, uint64_t ip)
+static struct symbol *vdso__find_symbol(struct dso *dso, __u64 ip)
{
return dso__find_symbol(kernel_dso, ip);
}
@@ -193,19 +193,19 @@ static int strcommon(const char *pathname)
struct map {
struct list_head node;
- uint64_t start;
- uint64_t end;
- uint64_t pgoff;
- uint64_t (*map_ip)(struct map *, uint64_t);
+ __u64 start;
+ __u64 end;
+ __u64 pgoff;
+ __u64 (*map_ip)(struct map *, __u64);
struct dso *dso;
};
-static uint64_t map__map_ip(struct map *map, uint64_t ip)
+static __u64 map__map_ip(struct map *map, __u64 ip)
{
return ip - map->start + map->pgoff;
}
-static uint64_t vdso__map_ip(struct map *map, uint64_t ip)
+static __u64 vdso__map_ip(struct map *map, __u64 ip)
{
return ip;
}
@@ -288,7 +288,7 @@ static int map__overlap(struct map *l, struct map *r)
static size_t map__fprintf(struct map *self, FILE *fp)
{
- return fprintf(fp, " %"PRIx64"-%"PRIx64" %"PRIx64" %s\n",
+ return fprintf(fp, " %Lx-%Lx %Lx %s\n",
self->start, self->end, self->pgoff, self->dso->name);
}
@@ -412,7 +412,7 @@ static int thread__fork(struct thread *self, struct thread *parent)
return 0;
}
-static struct map *thread__find_map(struct thread *self, uint64_t ip)
+static struct map *thread__find_map(struct thread *self, __u64 ip)
{
struct map *pos;
@@ -453,10 +453,10 @@ struct hist_entry {
struct map *map;
struct dso *dso;
struct symbol *sym;
- uint64_t ip;
+ __u64 ip;
char level;
- uint64_t count;
+ __u64 count;
};
/*
@@ -572,7 +572,7 @@ static struct sort_entry sort_dso = {
static int64_t
sort__sym_cmp(struct hist_entry *left, struct hist_entry *right)
{
- uint64_t ip_l, ip_r;
+ __u64 ip_l, ip_r;
if (left->sym == right->sym)
return 0;
@@ -684,7 +684,7 @@ hist_entry__collapse(struct hist_entry *left, struct hist_entry *right)
}
static size_t
-hist_entry__fprintf(FILE *fp, struct hist_entry *self, uint64_t total_samples)
+hist_entry__fprintf(FILE *fp, struct hist_entry *self, __u64 total_samples)
{
struct sort_entry *se;
size_t ret;
@@ -708,7 +708,7 @@ hist_entry__fprintf(FILE *fp, struct hist_entry *self, uint64_t total_samples)
ret = color_fprintf(fp, color, " %6.2f%%",
(self->count * 100.0) / total_samples);
} else
- ret = fprintf(fp, "%12d ", self->count);
+ ret = fprintf(fp, "%12Ld ", self->count);
list_for_each_entry(se, &hist_entry__sort_list, list) {
fprintf(fp, " ");
@@ -726,7 +726,7 @@ hist_entry__fprintf(FILE *fp, struct hist_entry *self, uint64_t total_samples)
static int
hist_entry__add(struct thread *thread, struct map *map, struct dso *dso,
- struct symbol *sym, uint64_t ip, char level, uint64_t count)
+ struct symbol *sym, __u64 ip, char level, __u64 count)
{
struct rb_node **p = &hist.rb_node;
struct rb_node *parent = NULL;
@@ -873,7 +873,7 @@ static void output__resort(void)
}
}
-static size_t output__fprintf(FILE *fp, uint64_t total_samples)
+static size_t output__fprintf(FILE *fp, __u64 total_samples)
{
struct hist_entry *pos;
struct sort_entry *se;
@@ -941,8 +941,8 @@ process_overflow_event(event_t *event, unsigned long offset, unsigned long head)
int show = 0;
struct dso *dso = NULL;
struct thread *thread = threads__findnew(event->ip.pid);
- uint64_t ip = event->ip.ip;
- uint64_t period = 1;
+ __u64 ip = event->ip.ip;
+ __u64 period = 1;
struct map *map = NULL;
if (event->header.type & PERF_SAMPLE_PERIOD)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 8ba24808a392..309dbc76ec88 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -79,8 +79,8 @@ static int dump_symtab;
* Symbols
*/
-static uint64_t min_ip;
-static uint64_t max_ip = -1ll;
+static __u64 min_ip;
+static __u64 max_ip = -1ll;
struct sym_entry {
struct rb_node rb_node;
@@ -372,7 +372,7 @@ static int parse_symbols(void)
/*
* Binary search in the histogram table and record the hit:
*/
-static void record_ip(uint64_t ip, int counter)
+static void record_ip(__u64 ip, int counter)
{
struct symbol *sym = dso__find_symbol(kernel_dso, ip);
@@ -392,7 +392,7 @@ static void record_ip(uint64_t ip, int counter)
samples--;
}
-static void process_event(uint64_t ip, int counter)
+static void process_event(__u64 ip, int counter)
{
samples++;
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 32dd47d60d9c..49a55f813712 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -9,9 +9,9 @@
const char *sym_hist_filter;
-static struct symbol *symbol__new(uint64_t start, uint64_t len,
+static struct symbol *symbol__new(__u64 start, __u64 len,
const char *name, unsigned int priv_size,
- uint64_t obj_start, int verbose)
+ __u64 obj_start, int verbose)
{
size_t namelen = strlen(name) + 1;
struct symbol *self = calloc(1, priv_size + sizeof(*self) + namelen);
@@ -89,7 +89,7 @@ static void dso__insert_symbol(struct dso *self, struct symbol *sym)
{
struct rb_node **p = &self->syms.rb_node;
struct rb_node *parent = NULL;
- const uint64_t ip = sym->start;
+ const __u64 ip = sym->start;
struct symbol *s;
while (*p != NULL) {
@@ -104,7 +104,7 @@ static void dso__insert_symbol(struct dso *self, struct symbol *sym)
rb_insert_color(&sym->rb_node, &self->syms);
}
-struct symbol *dso__find_symbol(struct dso *self, uint64_t ip)
+struct symbol *dso__find_symbol(struct dso *self, __u64 ip)
{
struct rb_node *n;
@@ -523,7 +523,7 @@ static int dso__load_sym(struct dso *self, int fd, const char *name,
elf_symtab__for_each_symbol(syms, nr_syms, index, sym) {
struct symbol *f;
- uint64_t obj_start;
+ __u64 obj_start;
if (!elf_sym__is_function(&sym))
continue;
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 4839d68f14f0..0d1292bd8270 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -19,7 +19,7 @@ struct dso {
struct list_head node;
struct rb_root syms;
unsigned int sym_priv_size;
- struct symbol *(*find_symbol)(struct dso *, uint64_t ip);
+ struct symbol *(*find_symbol)(struct dso *, __u64 ip);
char name[0];
};
@@ -35,7 +35,7 @@ static inline void *dso__sym_priv(struct dso *self, struct symbol *sym)
return ((void *)sym) - self->sym_priv_size;
}
-struct symbol *dso__find_symbol(struct dso *self, uint64_t ip);
+struct symbol *dso__find_symbol(struct dso *self, __u64 ip);
int dso__load_kernel(struct dso *self, const char *vmlinux,
symbol_filter_t filter, int verbose);
commit 511b01bdf64ad8a38414096eab283c7784aebfc4
Author: Ingo Molnar <mingo@elte.hu>
Date: Thu Jun 11 00:32:00 2009 +0200
Revert "x86, bts: reenable ptrace branch trace support"
This reverts commit 7e0bfad24d85de7cf2202a7b0ce51de11a077b21.
A late objection to the ABI has arrived:
http://lkml.org/lkml/2009/6/10/253
Keep the ABI disabled out of caution, to not create premature
user-space expectations.
While the hw-branch-tracing variant uses and tests the BTS code.
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Markus Metzger <markus.t.metzger@intel.com>
Cc: Oleg Nesterov <oleg@redhat.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/arch/x86/Kconfig.cpu b/arch/x86/Kconfig.cpu
index 924e156a85ab..8130334329c0 100644
--- a/arch/x86/Kconfig.cpu
+++ b/arch/x86/Kconfig.cpu
@@ -506,6 +506,7 @@ config X86_PTRACE_BTS
bool "Branch Trace Store"
default y
depends on X86_DEBUGCTLMSR
+ depends on BROKEN
---help---
This adds a ptrace interface to the hardware's branch trace store.
commit 92db1e6af747faa129e236d68386af26a0efc12b
Merge: 0bf841281e58 e9a22a13c719
Author: Ingo Molnar <mingo@elte.hu>
Date: Tue Jun 9 16:18:11 2009 +0200
Merge branch 'amd-iommu/fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/joro/linux-2.6-iommu into core/iommu
commit aefcf37b82886260d8540c9fb815e613c8977e06
Author: Ingo Molnar <mingo@elte.hu>
Date: Mon Jun 8 23:15:28 2009 +0200
perf_counter tools: Standardize color printing
The rule is:
- high overhead: red
- mid overhead: green
- low overhead: normal (white/black)
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 0e23fe98ec4e..3334a8bb1d51 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -1085,8 +1085,9 @@ parse_line(FILE *file, struct symbol *sym, uint64_t start, uint64_t len)
percent = 100.0 * hits / sym->hist_sum;
/*
- * We color high-overhead entries in red, low-overhead
- * entries in green - and keep the middle ground normal:
+ * We color high-overhead entries in red, mid-overhead
+ * entries in green - and keep the low overhead places
+ * normal:
*/
if (percent >= 5.0)
color = PERF_COLOR_RED;
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 61d871849b44..0b18cb99a858 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -693,13 +693,16 @@ hist_entry__fprintf(FILE *fp, struct hist_entry *self, uint64_t total_samples)
char *color = PERF_COLOR_NORMAL;
/*
- * We color high-overhead entries in red, low-overhead
- * entries in green - and keep the middle ground normal:
+ * We color high-overhead entries in red, mid-overhead
+ * entries in green - and keep the low overhead places
+ * normal:
*/
- if (percent >= 5.0)
+ if (percent >= 5.0) {
color = PERF_COLOR_RED;
- if (percent < 0.5)
- color = PERF_COLOR_GREEN;
+ } else {
+ if (percent >= 0.5)
+ color = PERF_COLOR_GREEN;
+ }
ret = color_fprintf(fp, color, " %6.2f%%",
(self->count * 100.0) / total_samples);
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index be1698f1189b..8ba24808a392 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -248,13 +248,16 @@ static void print_sym_table(void)
sum_ksamples));
/*
- * We color high-overhead entries in red, low-overhead
- * entries in green - and keep the middle ground normal:
+ * We color high-overhead entries in red, mid-overhead
+ * entries in green - and keep the low overhead places
+ * normal:
*/
- if (pcnt >= 5.0)
+ if (pcnt >= 5.0) {
color = PERF_COLOR_RED;
- if (pcnt < 0.5)
- color = PERF_COLOR_GREEN;
+ } else {
+ if (pcnt >= 0.5)
+ color = PERF_COLOR_GREEN;
+ }
if (nr_counters == 1)
printf("%20.2f - ", syme->weight);
commit 1123e3ad73697d64ad99f0104bbe49f8b52d7d65
Author: Ingo Molnar <mingo@elte.hu>
Date: Fri May 29 11:25:09 2009 +0200
perf_counter: Clean up x86 boot messages
Standardize and tidy up all the messages we print during
perfcounter initialization.
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/arch/x86/kernel/cpu/perf_counter.c b/arch/x86/kernel/cpu/perf_counter.c
index 71590e09d16e..0339d195a3f0 100644
--- a/arch/x86/kernel/cpu/perf_counter.c
+++ b/arch/x86/kernel/cpu/perf_counter.c
@@ -1298,23 +1298,22 @@ static int intel_pmu_init(void)
if (version < 2)
return -ENODEV;
- x86_pmu = intel_pmu;
- x86_pmu.version = version;
- x86_pmu.num_counters = eax.split.num_counters;
+ x86_pmu = intel_pmu;
+ x86_pmu.version = version;
+ x86_pmu.num_counters = eax.split.num_counters;
+ x86_pmu.counter_bits = eax.split.bit_width;
+ x86_pmu.counter_mask = (1ULL << eax.split.bit_width) - 1;
/*
* Quirk: v2 perfmon does not report fixed-purpose counters, so
* assume at least 3 counters:
*/
- x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
-
- x86_pmu.counter_bits = eax.split.bit_width;
- x86_pmu.counter_mask = (1ULL << eax.split.bit_width) - 1;
+ x86_pmu.num_counters_fixed = max((int)edx.split.num_counters_fixed, 3);
rdmsrl(MSR_CORE_PERF_GLOBAL_CTRL, x86_pmu.intel_ctrl);
/*
- * Nehalem:
+ * Install the hw-cache-events table:
*/
switch (boot_cpu_data.x86_model) {
case 17:
@@ -1322,7 +1321,7 @@ static int intel_pmu_init(void)
sizeof(u64)*PERF_COUNT_HW_CACHE_MAX*
PERF_COUNT_HW_CACHE_OP_MAX*PERF_COUNT_HW_CACHE_RESULT_MAX);
- pr_info("... installed Core2 event tables\n");
+ pr_cont("Core2 events, ");
break;
default:
case 26:
@@ -1330,14 +1329,14 @@ static int intel_pmu_init(void)
sizeof(u64)*PERF_COUNT_HW_CACHE_MAX*
PERF_COUNT_HW_CACHE_OP_MAX*PERF_COUNT_HW_CACHE_RESULT_MAX);
- pr_info("... installed Nehalem/Corei7 event tables\n");
+ pr_cont("Nehalem/Corei7 events, ");
break;
case 28:
memcpy(hw_cache_event_ids, atom_hw_cache_event_ids,
sizeof(u64)*PERF_COUNT_HW_CACHE_MAX*
PERF_COUNT_HW_CACHE_OP_MAX*PERF_COUNT_HW_CACHE_RESULT_MAX);
- pr_info("... installed Atom event tables\n");
+ pr_cont("Atom events, ");
break;
}
return 0;
@@ -1353,6 +1352,8 @@ void __init init_hw_perf_counters(void)
{
int err;
+ pr_info("Performance Counters: ");
+
switch (boot_cpu_data.x86_vendor) {
case X86_VENDOR_INTEL:
err = intel_pmu_init();
@@ -1363,14 +1364,13 @@ void __init init_hw_perf_counters(void)
default:
return;
}
- if (err != 0)
+ if (err != 0) {
+ pr_cont("no PMU driver, software counters only.\n");
return;
+ }
- pr_info("%s Performance Monitoring support detected.\n", x86_pmu.name);
- pr_info("... version: %d\n", x86_pmu.version);
- pr_info("... bit width: %d\n", x86_pmu.counter_bits);
+ pr_cont("%s PMU driver.\n", x86_pmu.name);
- pr_info("... num counters: %d\n", x86_pmu.num_counters);
if (x86_pmu.num_counters > X86_PMC_MAX_GENERIC) {
x86_pmu.num_counters = X86_PMC_MAX_GENERIC;
WARN(1, KERN_ERR "hw perf counters %d > max(%d), clipping!",
@@ -1379,23 +1379,25 @@ void __init init_hw_perf_counters(void)
perf_counter_mask = (1 << x86_pmu.num_counters) - 1;
perf_max_counters = x86_pmu.num_counters;
- pr_info("... value mask: %016Lx\n", x86_pmu.counter_mask);
- pr_info("... max period: %016Lx\n", x86_pmu.max_period);
-
if (x86_pmu.num_counters_fixed > X86_PMC_MAX_FIXED) {
x86_pmu.num_counters_fixed = X86_PMC_MAX_FIXED;
WARN(1, KERN_ERR "hw perf counters fixed %d > max(%d), clipping!",
x86_pmu.num_counters_fixed, X86_PMC_MAX_FIXED);
}
- pr_info("... fixed counters: %d\n", x86_pmu.num_counters_fixed);
perf_counter_mask |=
((1LL << x86_pmu.num_counters_fixed)-1) << X86_PMC_IDX_FIXED;
- pr_info("... counter mask: %016Lx\n", perf_counter_mask);
-
perf_counters_lapic_init();
register_die_notifier(&perf_counter_nmi_notifier);
+
+ pr_info("... version: %d\n", x86_pmu.version);
+ pr_info("... bit width: %d\n", x86_pmu.counter_bits);
+ pr_info("... generic counters: %d\n", x86_pmu.num_counters);
+ pr_info("... value mask: %016Lx\n", x86_pmu.counter_mask);
+ pr_info("... max period: %016Lx\n", x86_pmu.max_period);
+ pr_info("... fixed-purpose counters: %d\n", x86_pmu.num_counters_fixed);
+ pr_info("... counter mask: %016Lx\n", perf_counter_mask);
}
static inline void x86_pmu_read(struct perf_counter *counter)
commit e779898aa74cd2e97216368b3f3689ceffe8aeed
Author: Ingo Molnar <mingo@elte.hu>
Date: Sun Jun 7 18:14:46 2009 +0200
perf stat: Print out instructins/cycle metric
Before:
7549326754 cycles # 3201.811 M/sec
10007594937 instructions # 4244.408 M/sec
After:
7542051194 cycles # 3201.996 M/sec
10007743852 instructions # 4248.811 M/sec # 1.327 per cycle
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 184ff95ef4f5..80855090fd9f 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -83,6 +83,7 @@ static __u64 event_scaled[MAX_COUNTERS];
static __u64 runtime_nsecs;
static __u64 walltime_nsecs;
+static __u64 runtime_cycles;
static void create_perf_stat_counter(int counter)
{
@@ -177,6 +178,9 @@ static void read_counter(int counter)
if (attrs[counter].type == PERF_TYPE_SOFTWARE &&
attrs[counter].config == PERF_COUNT_TASK_CLOCK)
runtime_nsecs = count[0];
+ if (attrs[counter].type == PERF_TYPE_HARDWARE &&
+ attrs[counter].config == PERF_COUNT_CPU_CYCLES)
+ runtime_cycles = count[0];
}
/*
@@ -214,6 +218,13 @@ static void print_counter(int counter)
if (runtime_nsecs)
fprintf(stderr, " # %11.3f M/sec",
(double)count[0]/runtime_nsecs*1000.0);
+ if (runtime_cycles &&
+ attrs[counter].type == PERF_TYPE_HARDWARE &&
+ attrs[counter].config == PERF_COUNT_INSTRUCTIONS) {
+
+ fprintf(stderr, " # %1.3f per cycle",
+ (double)count[0] / (double)runtime_cycles);
+ }
}
if (scaled)
fprintf(stderr, " (scaled from %.2f%%)",
commit a14832ff977e78d1982cdf78cdabb1f2320d9ac8
Author: Ingo Molnar <mingo@elte.hu>
Date: Sun Jun 7 17:58:23 2009 +0200
perf report: Print more expressive message in case of file open error
Before:
$ perf report
failed to open file: No such file or directory
After:
$ perf report
failed to open file: perf.data (try 'perf record' first)
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index 242e09ff3658..f053a7463dcf 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -1120,7 +1120,10 @@ static int __cmd_report(void)
input = open(input_name, O_RDONLY);
if (input < 0) {
- perror("failed to open file");
+ fprintf(stderr, " failed to open file: %s", input_name);
+ if (!strcmp(input_name, "perf.data"))
+ fprintf(stderr, " (try 'perf record' first)");
+ fprintf(stderr, "\n");
exit(-1);
}
commit 30c806a094493beb7691bc7957dfa02dee96230a
Author: Ingo Molnar <mingo@elte.hu>
Date: Sun Jun 7 17:46:24 2009 +0200
perf_counter tools: Handle kernels with !CONFIG_PERF_COUNTER
If perf is run on a !CONFIG_PERF_COUNTER kernel right now it
bails out with no messages or with confusing messages.
Standardize this case some more and explain the situation.
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 87866294a0e6..deaee42d5eb0 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -356,9 +356,6 @@ static void create_counter(int counter, int cpu, pid_t pid)
if (fd[nr_cpu][counter] < 0) {
int err = errno;
- if (verbose)
- error("sys_perf_counter_open() syscall returned with %d (%s)\n",
- fd[nr_cpu][counter], strerror(err));
if (err == EPERM)
die("Permission error - are you root?\n");
@@ -376,6 +373,10 @@ static void create_counter(int counter, int cpu, pid_t pid)
attr->config = PERF_COUNT_CPU_CLOCK;
goto try_again;
}
+ printf("\n");
+ error("perfcounter syscall returned with %d (%s)\n",
+ fd[nr_cpu][counter], strerror(err));
+ die("No CONFIG_PERF_COUNTERS=y kernel support configured?\n");
exit(-1);
}
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 1f8c97d5c32e..be1698f1189b 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -551,10 +551,6 @@ static void start_counter(int i, int counter)
if (fd[i][counter] < 0) {
int err = errno;
- if (verbose)
- error("sys_perf_counter_open() syscall returned with %d (%s)\n",
- fd[i][counter], strerror(err));
-
if (err == EPERM)
die("No permission - are you root?\n");
/*
@@ -572,6 +568,10 @@ static void start_counter(int i, int counter)
attr->config = PERF_COUNT_CPU_CLOCK;
goto try_again;
}
+ printf("\n");
+ error("perfcounter syscall returned with %d (%s)\n",
+ fd[i][counter], strerror(err));
+ die("No CONFIG_PERF_COUNTERS=y kernel support configured?\n");
exit(-1);
}
assert(fd[i][counter] >= 0);