Skip to content

Commit

Permalink
Merge branch 'perf' of git://git.kernel.org/pub/scm/linux/kernel/git/…
Browse files Browse the repository at this point in the history
…acme/linux-2.6 into perf/core
  • Loading branch information
Ingo Molnar committed Apr 3, 2010
2 parents 40b91cd + 533c46c commit 70a7c12
Show file tree
Hide file tree
Showing 25 changed files with 806 additions and 587 deletions.
325 changes: 168 additions & 157 deletions tools/perf/Makefile

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion tools/perf/bench/mem-memcpy.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "../perf.h"
#include "../util/util.h"
#include "../util/parse-options.h"
#include "../util/string.h"
#include "../util/header.h"
#include "bench.h"

Expand Down
1 change: 0 additions & 1 deletion tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "util/cache.h"
#include <linux/rbtree.h>
#include "util/symbol.h"
#include "util/string.h"

#include "perf.h"
#include "util/debug.h"
Expand Down
9 changes: 7 additions & 2 deletions tools/perf/builtin-kmem.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,19 +363,21 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
struct alloc_stat *data = rb_entry(next, struct alloc_stat,
node);
struct symbol *sym = NULL;
struct map *map;
char buf[BUFSIZ];
u64 addr;

if (is_caller) {
addr = data->call_site;
if (!raw_ip)
sym = map_groups__find_function(&session->kmaps, addr, NULL);
sym = map_groups__find_function(&session->kmaps,
addr, &map, NULL);
} else
addr = data->ptr;

if (sym != NULL)
snprintf(buf, sizeof(buf), "%s+%Lx", sym->name,
addr - sym->start);
addr - map->unmap_ip(map, sym->start));
else
snprintf(buf, sizeof(buf), "%#Lx", addr);
printf(" %-34s |", buf);
Expand Down Expand Up @@ -488,6 +490,9 @@ static int __cmd_kmem(void)
if (session == NULL)
return -ENOMEM;

if (perf_session__create_kernel_maps(session) < 0)
goto out_delete;

if (!perf_session__has_traces(session, "kmem record"))
goto out_delete;

Expand Down
4 changes: 3 additions & 1 deletion tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
#include "util/util.h"
#include "util/parse-options.h"
#include "util/parse-events.h"
#include "util/string.h"

#include "util/header.h"
#include "util/event.h"
Expand Down Expand Up @@ -575,6 +574,9 @@ static int __cmd_record(int argc, const char **argv)

err = event__synthesize_kernel_mmap(process_synthesized_event,
session, "_text");
if (err < 0)
err = event__synthesize_kernel_mmap(process_synthesized_event,
session, "_stext");
if (err < 0) {
pr_err("Couldn't record kernel reference relocation symbol.\n");
return err;
Expand Down
23 changes: 14 additions & 9 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "util/cache.h"
#include <linux/rbtree.h>
#include "util/symbol.h"
#include "util/string.h"
#include "util/callchain.h"
#include "util/strlist.h"
#include "util/values.h"
Expand Down Expand Up @@ -89,9 +88,12 @@ static int perf_session__add_hist_entry(struct perf_session *self,
struct event_stat_id *stats;
struct perf_event_attr *attr;

if ((sort__has_parent || symbol_conf.use_callchain) && data->callchain)
if ((sort__has_parent || symbol_conf.use_callchain) && data->callchain) {
syms = perf_session__resolve_callchain(self, al->thread,
data->callchain, &parent);
if (syms == NULL)
return -ENOMEM;
}

attr = perf_header__find_attr(data->id, &self->header);
if (attr)
Expand All @@ -110,8 +112,8 @@ static int perf_session__add_hist_entry(struct perf_session *self,

if (symbol_conf.use_callchain) {
if (!hit)
callchain_init(&he->callchain);
err = append_chain(&he->callchain, data->callchain, syms);
callchain_init(he->callchain);
err = append_chain(he->callchain, data->callchain, syms);
free(syms);

if (err)
Expand Down Expand Up @@ -303,14 +305,16 @@ static int __cmd_report(void)
next = rb_first(&session->stats_by_id);
while (next) {
struct event_stat_id *stats;
u64 nr_hists;

stats = rb_entry(next, struct event_stat_id, rb_node);
perf_session__collapse_resort(&stats->hists);
perf_session__output_resort(&stats->hists, stats->stats.total);

nr_hists = perf_session__output_resort(&stats->hists,
stats->stats.total);
if (use_browser)
perf_session__browse_hists(&stats->hists,
stats->stats.total, help);
perf_session__browse_hists(&stats->hists, nr_hists,
stats->stats.total, help,
input_name);
else {
if (rb_first(&session->stats_by_id) ==
rb_last(&session->stats_by_id))
Expand Down Expand Up @@ -469,7 +473,8 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
setup_sorting(report_usage, options);

if (parent_pattern != default_parent_pattern) {
sort_dimension__add("parent");
if (sort_dimension__add("parent") < 0)
return -1;
sort_parent.elide = 1;
} else
symbol_conf.exclude_other = false;
Expand Down
1 change: 0 additions & 1 deletion tools/perf/builtin-timechart.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "util/cache.h"
#include <linux/rbtree.h>
#include "util/symbol.h"
#include "util/string.h"
#include "util/callchain.h"
#include "util/strlist.h"

Expand Down
1 change: 0 additions & 1 deletion tools/perf/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include "util/quote.h"
#include "util/run-command.h"
#include "util/parse-events.h"
#include "util/string.h"
#include "util/debugfs.h"

bool use_browser;
Expand Down
6 changes: 5 additions & 1 deletion tools/perf/util/PERF-VERSION-GEN
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
#!/bin/sh

GVF=PERF-VERSION-FILE
if [ $# -eq 1 ] ; then
OUTPUT=$1
fi

GVF=${OUTPUT}PERF-VERSION-FILE
DEF_VER=v0.0.2.PERF

LF='
Expand Down
53 changes: 49 additions & 4 deletions tools/perf/util/color.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,31 @@ int perf_color_default_config(const char *var, const char *value, void *cb)
return perf_default_config(var, value, cb);
}

static int __color_vsnprintf(char *bf, size_t size, const char *color,
const char *fmt, va_list args, const char *trail)
{
int r = 0;

/*
* Auto-detect:
*/
if (perf_use_color_default < 0) {
if (isatty(1) || pager_in_use())
perf_use_color_default = 1;
else
perf_use_color_default = 0;
}

if (perf_use_color_default && *color)
r += snprintf(bf, size, "%s", color);
r += vsnprintf(bf + r, size - r, fmt, args);
if (perf_use_color_default && *color)
r += snprintf(bf + r, size - r, "%s", PERF_COLOR_RESET);
if (trail)
r += snprintf(bf + r, size - r, "%s", trail);
return r;
}

static int __color_vfprintf(FILE *fp, const char *color, const char *fmt,
va_list args, const char *trail)
{
Expand All @@ -191,22 +216,36 @@ static int __color_vfprintf(FILE *fp, const char *color, const char *fmt,
return r;
}

int color_vsnprintf(char *bf, size_t size, const char *color,
const char *fmt, va_list args)
{
return __color_vsnprintf(bf, size, color, fmt, args, NULL);
}

int color_vfprintf(FILE *fp, const char *color, const char *fmt, va_list args)
{
return __color_vfprintf(fp, color, fmt, args, NULL);
}

int color_snprintf(char *bf, size_t size, const char *color,
const char *fmt, ...)
{
va_list args;
int r;

va_start(args, fmt);
r = color_vsnprintf(bf, size, color, fmt, args);
va_end(args);
return r;
}

int color_fprintf(FILE *fp, const char *color, const char *fmt, ...)
{
va_list args;
int r;

va_start(args, fmt);
if (use_browser)
r = vfprintf(fp, fmt, args);
else
r = color_vfprintf(fp, color, fmt, args);
r = color_vfprintf(fp, color, fmt, args);
va_end(args);
return r;
}
Expand Down Expand Up @@ -277,3 +316,9 @@ int percent_color_fprintf(FILE *fp, const char *fmt, double percent)

return r;
}

int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent)
{
const char *color = get_percent_color(percent);
return color_snprintf(bf, size, color, fmt, percent);
}
4 changes: 4 additions & 0 deletions tools/perf/util/color.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,14 @@ int perf_color_default_config(const char *var, const char *value, void *cb);
int perf_config_colorbool(const char *var, const char *value, int stdout_is_tty);
void color_parse(const char *value, const char *var, char *dst);
void color_parse_mem(const char *value, int len, const char *var, char *dst);
int color_vsnprintf(char *bf, size_t size, const char *color,
const char *fmt, va_list args);
int color_vfprintf(FILE *fp, const char *color, const char *fmt, va_list args);
int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
int color_snprintf(char *bf, size_t size, const char *color, const char *fmt, ...);
int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
int color_fwrite_lines(FILE *fp, const char *color, size_t count, const char *buf);
int percent_color_snprintf(char *bf, size_t size, const char *fmt, double percent);
int percent_color_fprintf(FILE *fp, const char *fmt, double percent);
const char *get_percent_color(double percent);

Expand Down
16 changes: 16 additions & 0 deletions tools/perf/util/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,29 @@ extern int dump_trace;
int dump_printf(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
void trace_event(event_t *event);

struct ui_progress;

#ifdef NO_NEWT_SUPPORT
static inline int browser__show_help(const char *format __used, va_list ap __used)
{
return 0;
}

static inline struct ui_progress *ui_progress__new(const char *title __used,
u64 total __used)
{
return (struct ui_progress *)1;
}

static inline void ui_progress__update(struct ui_progress *self __used,
u64 curr __used) {}

static inline void ui_progress__delete(struct ui_progress *self __used) {}
#else
int browser__show_help(const char *format, va_list ap);
struct ui_progress *ui_progress__new(const char *title, u64 total);
void ui_progress__update(struct ui_progress *self, u64 curr);
void ui_progress__delete(struct ui_progress *self);
#endif

#endif /* __PERF_DEBUG_H */
9 changes: 9 additions & 0 deletions tools/perf/util/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
continue;
pbf += n + 3;
if (*pbf == 'x') { /* vm_exec */
u64 vm_pgoff;
char *execname = strchr(bf, '/');

/* Catch VDSO */
Expand All @@ -139,6 +140,14 @@ static int event__synthesize_mmap_events(pid_t pid, pid_t tgid,
if (execname == NULL)
continue;

pbf += 3;
n = hex2u64(pbf, &vm_pgoff);
/* pgoff is in bytes, not pages */
if (n >= 0)
ev.mmap.pgoff = vm_pgoff << getpagesize();
else
ev.mmap.pgoff = 0;

size = strlen(execname);
execname[size - 1] = '\0'; /* Remove \n */
memcpy(ev.mmap.filename, execname, size);
Expand Down
Loading

0 comments on commit 70a7c12

Please sign in to comment.