Commit 6fa41366 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'perf-fixes-for-linus' of...

Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  powerpc/perf_events: Fix call-graph recording, add perf_arch_fetch_caller_regs
  perf top: Add missing initialization to zero
  perf probe: Use original address instead of CU-based address
  perf probe: Fix offset to allow signed value
  perf top: Improve the autosizing of column lenghts
  perf probe: Fix need_dwarf flag if lazy matching is used
  perf probe: Fix probe_point buffer overrun
parents 309d1dcb 9eff26ea
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#define PPC_LLARX(t, a, b, eh) PPC_LDARX(t, a, b, eh) #define PPC_LLARX(t, a, b, eh) PPC_LDARX(t, a, b, eh)
#define PPC_STLCX stringify_in_c(stdcx.) #define PPC_STLCX stringify_in_c(stdcx.)
#define PPC_CNTLZL stringify_in_c(cntlzd) #define PPC_CNTLZL stringify_in_c(cntlzd)
#define PPC_LR_STKOFF 16
/* Move to CR, single-entry optimized version. Only available /* Move to CR, single-entry optimized version. Only available
* on POWER4 and later. * on POWER4 and later.
...@@ -51,6 +52,7 @@ ...@@ -51,6 +52,7 @@
#define PPC_STLCX stringify_in_c(stwcx.) #define PPC_STLCX stringify_in_c(stwcx.)
#define PPC_CNTLZL stringify_in_c(cntlzw) #define PPC_CNTLZL stringify_in_c(cntlzw)
#define PPC_MTOCRF stringify_in_c(mtcrf) #define PPC_MTOCRF stringify_in_c(mtcrf)
#define PPC_LR_STKOFF 4
#endif #endif
......
...@@ -127,3 +127,31 @@ _GLOBAL(__setup_cpu_power7) ...@@ -127,3 +127,31 @@ _GLOBAL(__setup_cpu_power7)
_GLOBAL(__restore_cpu_power7) _GLOBAL(__restore_cpu_power7)
/* place holder */ /* place holder */
blr blr
#ifdef CONFIG_EVENT_TRACING
/*
* Get a minimal set of registers for our caller's nth caller.
* r3 = regs pointer, r5 = n.
*
* We only get R1 (stack pointer), NIP (next instruction pointer)
* and LR (link register). These are all we can get in the
* general case without doing complicated stack unwinding, but
* fortunately they are enough to do a stack backtrace, which
* is all we need them for.
*/
_GLOBAL(perf_arch_fetch_caller_regs)
mr r6,r1
cmpwi r5,0
mflr r4
ble 2f
mtctr r5
1: PPC_LL r6,0(r6)
bdnz 1b
PPC_LL r4,PPC_LR_STKOFF(r6)
2: PPC_LL r7,0(r6)
PPC_LL r7,PPC_LR_STKOFF(r7)
PPC_STL r6,GPR1-STACK_FRAME_OVERHEAD(r3)
PPC_STL r4,_NIP-STACK_FRAME_OVERHEAD(r3)
PPC_STL r7,_LINK-STACK_FRAME_OVERHEAD(r3)
blr
#endif /* CONFIG_EVENT_TRACING */
...@@ -47,7 +47,6 @@ ...@@ -47,7 +47,6 @@
#include "util/probe-event.h" #include "util/probe-event.h"
#define MAX_PATH_LEN 256 #define MAX_PATH_LEN 256
#define MAX_PROBES 128
/* Session management structure */ /* Session management structure */
static struct { static struct {
......
...@@ -455,7 +455,7 @@ static void print_sym_table(void) ...@@ -455,7 +455,7 @@ static void print_sym_table(void)
struct sym_entry *syme, *n; struct sym_entry *syme, *n;
struct rb_root tmp = RB_ROOT; struct rb_root tmp = RB_ROOT;
struct rb_node *nd; struct rb_node *nd;
int sym_width = 0, dso_width = 0, max_dso_width; int sym_width = 0, dso_width = 0, dso_short_width = 0;
const int win_width = winsize.ws_col - 1; const int win_width = winsize.ws_col - 1;
samples = userspace_samples = 0; samples = userspace_samples = 0;
...@@ -545,15 +545,20 @@ static void print_sym_table(void) ...@@ -545,15 +545,20 @@ static void print_sym_table(void)
if (syme->map->dso->long_name_len > dso_width) if (syme->map->dso->long_name_len > dso_width)
dso_width = syme->map->dso->long_name_len; dso_width = syme->map->dso->long_name_len;
if (syme->map->dso->short_name_len > dso_short_width)
dso_short_width = syme->map->dso->short_name_len;
if (syme->name_len > sym_width) if (syme->name_len > sym_width)
sym_width = syme->name_len; sym_width = syme->name_len;
} }
printed = 0; printed = 0;
max_dso_width = winsize.ws_col - sym_width - 29; if (sym_width + dso_width > winsize.ws_col - 29) {
if (dso_width > max_dso_width) dso_width = dso_short_width;
dso_width = max_dso_width; if (sym_width + dso_width > winsize.ws_col - 29)
sym_width = winsize.ws_col - dso_width - 29;
}
putchar('\n'); putchar('\n');
if (nr_counters == 1) if (nr_counters == 1)
printf(" samples pcnt"); printf(" samples pcnt");
......
...@@ -242,7 +242,7 @@ void parse_perf_probe_event(const char *str, struct probe_point *pp, ...@@ -242,7 +242,7 @@ void parse_perf_probe_event(const char *str, struct probe_point *pp,
/* Parse probe point */ /* Parse probe point */
parse_perf_probe_probepoint(argv[0], pp); parse_perf_probe_probepoint(argv[0], pp);
if (pp->file || pp->line) if (pp->file || pp->line || pp->lazy_line)
*need_dwarf = true; *need_dwarf = true;
/* Copy arguments and ensure return probe has no C argument */ /* Copy arguments and ensure return probe has no C argument */
......
...@@ -333,8 +333,8 @@ static void show_location(Dwarf_Op *op, struct probe_finder *pf) ...@@ -333,8 +333,8 @@ static void show_location(Dwarf_Op *op, struct probe_finder *pf)
die("%u exceeds max register number.", regn); die("%u exceeds max register number.", regn);
if (deref) if (deref)
ret = snprintf(pf->buf, pf->len, " %s=+%ju(%s)", ret = snprintf(pf->buf, pf->len, " %s=%+jd(%s)",
pf->var, (uintmax_t)offs, regs); pf->var, (intmax_t)offs, regs);
else else
ret = snprintf(pf->buf, pf->len, " %s=%s", pf->var, regs); ret = snprintf(pf->buf, pf->len, " %s=%s", pf->var, regs);
DIE_IF(ret < 0); DIE_IF(ret < 0);
...@@ -352,8 +352,7 @@ static void show_variable(Dwarf_Die *vr_die, struct probe_finder *pf) ...@@ -352,8 +352,7 @@ static void show_variable(Dwarf_Die *vr_die, struct probe_finder *pf)
if (dwarf_attr(vr_die, DW_AT_location, &attr) == NULL) if (dwarf_attr(vr_die, DW_AT_location, &attr) == NULL)
goto error; goto error;
/* TODO: handle more than 1 exprs */ /* TODO: handle more than 1 exprs */
ret = dwarf_getlocation_addr(&attr, (pf->addr - pf->cu_base), ret = dwarf_getlocation_addr(&attr, pf->addr, &expr, &nexpr, 1);
&expr, &nexpr, 1);
if (ret <= 0 || nexpr == 0) if (ret <= 0 || nexpr == 0)
goto error; goto error;
...@@ -437,8 +436,7 @@ static void show_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf) ...@@ -437,8 +436,7 @@ static void show_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf)
/* Get the frame base attribute/ops */ /* Get the frame base attribute/ops */
dwarf_attr(sp_die, DW_AT_frame_base, &fb_attr); dwarf_attr(sp_die, DW_AT_frame_base, &fb_attr);
ret = dwarf_getlocation_addr(&fb_attr, (pf->addr - pf->cu_base), ret = dwarf_getlocation_addr(&fb_attr, pf->addr, &pf->fb_ops, &nops, 1);
&pf->fb_ops, &nops, 1);
if (ret <= 0 || nops == 0) if (ret <= 0 || nops == 0)
pf->fb_ops = NULL; pf->fb_ops = NULL;
...@@ -455,6 +453,9 @@ static void show_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf) ...@@ -455,6 +453,9 @@ static void show_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf)
/* *pf->fb_ops will be cached in libdw. Don't free it. */ /* *pf->fb_ops will be cached in libdw. Don't free it. */
pf->fb_ops = NULL; pf->fb_ops = NULL;
if (pp->found == MAX_PROBES)
die("Too many( > %d) probe point found.\n", MAX_PROBES);
pp->probes[pp->found] = strdup(tmp); pp->probes[pp->found] = strdup(tmp);
pp->found++; pp->found++;
} }
...@@ -641,7 +642,6 @@ static void find_probe_point_by_func(struct probe_finder *pf) ...@@ -641,7 +642,6 @@ static void find_probe_point_by_func(struct probe_finder *pf)
int find_probe_point(int fd, struct probe_point *pp) int find_probe_point(int fd, struct probe_point *pp)
{ {
struct probe_finder pf = {.pp = pp}; struct probe_finder pf = {.pp = pp};
int ret;
Dwarf_Off off, noff; Dwarf_Off off, noff;
size_t cuhl; size_t cuhl;
Dwarf_Die *diep; Dwarf_Die *diep;
...@@ -668,10 +668,6 @@ int find_probe_point(int fd, struct probe_point *pp) ...@@ -668,10 +668,6 @@ int find_probe_point(int fd, struct probe_point *pp)
pf.fname = NULL; pf.fname = NULL;
if (!pp->file || pf.fname) { if (!pp->file || pf.fname) {
/* Save CU base address (for frame_base) */
ret = dwarf_lowpc(&pf.cu_die, &pf.cu_base);
if (ret != 0)
pf.cu_base = 0;
if (pp->function) if (pp->function)
find_probe_point_by_func(&pf); find_probe_point_by_func(&pf);
else if (pp->lazy_line) else if (pp->lazy_line)
......
...@@ -71,7 +71,6 @@ struct probe_finder { ...@@ -71,7 +71,6 @@ struct probe_finder {
/* For variable searching */ /* For variable searching */
Dwarf_Op *fb_ops; /* Frame base attribute */ Dwarf_Op *fb_ops; /* Frame base attribute */
Dwarf_Addr cu_base; /* Current CU base address */
const char *var; /* Current variable name */ const char *var; /* Current variable name */
char *buf; /* Current output buffer */ char *buf; /* Current output buffer */
int len; /* Length of output buffer */ int len; /* Length of output buffer */
......
...@@ -163,9 +163,17 @@ void dso__set_long_name(struct dso *self, char *name) ...@@ -163,9 +163,17 @@ void dso__set_long_name(struct dso *self, char *name)
self->long_name_len = strlen(name); self->long_name_len = strlen(name);
} }
static void dso__set_short_name(struct dso *self, const char *name)
{
if (name == NULL)
return;
self->short_name = name;
self->short_name_len = strlen(name);
}
static void dso__set_basename(struct dso *self) static void dso__set_basename(struct dso *self)
{ {
self->short_name = basename(self->long_name); dso__set_short_name(self, basename(self->long_name));
} }
struct dso *dso__new(const char *name) struct dso *dso__new(const char *name)
...@@ -176,7 +184,7 @@ struct dso *dso__new(const char *name) ...@@ -176,7 +184,7 @@ struct dso *dso__new(const char *name)
int i; int i;
strcpy(self->name, name); strcpy(self->name, name);
dso__set_long_name(self, self->name); dso__set_long_name(self, self->name);
self->short_name = self->name; dso__set_short_name(self, self->name);
for (i = 0; i < MAP__NR_TYPES; ++i) for (i = 0; i < MAP__NR_TYPES; ++i)
self->symbols[i] = self->symbol_names[i] = RB_ROOT; self->symbols[i] = self->symbol_names[i] = RB_ROOT;
self->slen_calculated = 0; self->slen_calculated = 0;
...@@ -897,7 +905,6 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, ...@@ -897,7 +905,6 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
struct kmap *kmap = self->kernel ? map__kmap(map) : NULL; struct kmap *kmap = self->kernel ? map__kmap(map) : NULL;
struct map *curr_map = map; struct map *curr_map = map;
struct dso *curr_dso = self; struct dso *curr_dso = self;
size_t dso_name_len = strlen(self->short_name);
Elf_Data *symstrs, *secstrs; Elf_Data *symstrs, *secstrs;
uint32_t nr_syms; uint32_t nr_syms;
int err = -1; int err = -1;
...@@ -987,7 +994,8 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name, ...@@ -987,7 +994,8 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
char dso_name[PATH_MAX]; char dso_name[PATH_MAX];
if (strcmp(section_name, if (strcmp(section_name,
curr_dso->short_name + dso_name_len) == 0) (curr_dso->short_name +
self->short_name_len)) == 0)
goto new_symbol; goto new_symbol;
if (strcmp(section_name, ".text") == 0) { if (strcmp(section_name, ".text") == 0) {
...@@ -1782,7 +1790,7 @@ struct dso *dso__new_kernel(const char *name) ...@@ -1782,7 +1790,7 @@ struct dso *dso__new_kernel(const char *name)
struct dso *self = dso__new(name ?: "[kernel.kallsyms]"); struct dso *self = dso__new(name ?: "[kernel.kallsyms]");
if (self != NULL) { if (self != NULL) {
self->short_name = "[kernel]"; dso__set_short_name(self, "[kernel]");
self->kernel = 1; self->kernel = 1;
} }
......
...@@ -110,9 +110,10 @@ struct dso { ...@@ -110,9 +110,10 @@ struct dso {
u8 sorted_by_name; u8 sorted_by_name;
u8 loaded; u8 loaded;
u8 build_id[BUILD_ID_SIZE]; u8 build_id[BUILD_ID_SIZE];
u16 long_name_len;
const char *short_name; const char *short_name;
char *long_name; char *long_name;
u16 long_name_len;
u16 short_name_len;
char name[0]; char name[0];
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment