Skip to content

Commit

Permalink
Merge branch 'perf-fixes-for-linus' of git://git.kernel.org/pub/scm/l…
Browse files Browse the repository at this point in the history
…inux/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: (30 commits)
  perf: Add back list_head data types
  perf ui hist browser: Fixup key bindings
  perf ui browser: Add ui_browser__show counterpart: __hide
  perf annotate: Cycle thru sorted lines with samples
  perf ui: Make SPACE work as PGDN in all browsers
  perf annotate: Sort by hottest lines in the TUI
  perf ui: Complete the breakdown of util/newt.c
  perf ui: Move hists browser to util/ui/browsers/
  perf symbols: Ignore mapping symbols on ARM
  perf ui: Move map browser to util/ui/browsers/
  perf ui: Move annotate browser to util/ui/browsers/
  perf ui: Move ui_progress routines to separate file in util/ui/
  perf ui: Move ui_helpline routines to separate file in util/ui/
  perf ui: Shorten ui_browser member names
  perf, x86: P4 PMU -- update nmi irq statistics and unmask lvt entry properly
  perf ui: Start breaking down newt.c into multiple files
  perf tui: Introduce list_head based generic ui_browser refresh routine
  perf probe: Fix memory leaks in add_perf_probe_events
  perf probe: Fix to copy the type for raw parameters
  perf report: Speed up exit path
  ...
  • Loading branch information
Linus Torvalds committed Aug 13, 2010
2 parents 36450e9 + 88d89da commit 4b17caf
Show file tree
Hide file tree
Showing 33 changed files with 1,736 additions and 1,122 deletions.
9 changes: 6 additions & 3 deletions arch/x86/kernel/cpu/perf_event_p4.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,7 @@ static int p4_pmu_handle_irq(struct pt_regs *regs)
cpuc = &__get_cpu_var(cpu_hw_events);

for (idx = 0; idx < x86_pmu.num_counters; idx++) {
int overflow;

if (!test_bit(idx, cpuc->active_mask))
continue;
Expand All @@ -666,12 +667,14 @@ static int p4_pmu_handle_irq(struct pt_regs *regs)
WARN_ON_ONCE(hwc->idx != idx);

/* it might be unflagged overflow */
handled = p4_pmu_clear_cccr_ovf(hwc);
overflow = p4_pmu_clear_cccr_ovf(hwc);

val = x86_perf_event_update(event);
if (!handled && (val & (1ULL << (x86_pmu.cntval_bits - 1))))
if (!overflow && (val & (1ULL << (x86_pmu.cntval_bits - 1))))
continue;

handled += overflow;

/* event overflow for sure */
data.period = event->hw.last_period;

Expand All @@ -687,7 +690,7 @@ static int p4_pmu_handle_irq(struct pt_regs *regs)
inc_irq_stat(apic_perf_irqs);
}

return handled;
return handled > 0;
}

/*
Expand Down
1 change: 1 addition & 0 deletions arch/x86/oprofile/nmi_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ static int __init ppro_init(char **cpu_type)
*cpu_type = "i386/core_2";
break;
case 0x1a:
case 0x1e:
case 0x2e:
spec = &op_arch_perfmon_spec;
*cpu_type = "i386/core_i7";
Expand Down
31 changes: 26 additions & 5 deletions tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ all::
#
# Define NO_DWARF if you do not want debug-info analysis feature at all.

$(shell sh -c 'mkdir -p $(OUTPUT)scripts/python/Perf-Trace-Util/' 2> /dev/null)
$(shell sh -c 'mkdir -p $(OUTPUT)scripts/perl/Perf-Trace-Util/' 2> /dev/null)
$(shell sh -c 'mkdir -p $(OUTPUT)util/scripting-engines/' 2> /dev/null)
$(shell sh -c 'mkdir -p $(OUTPUT)scripts/{perl,python}/Perf-Trace-Util/' 2> /dev/null)
$(shell sh -c 'mkdir -p $(OUTPUT)util/{ui/browsers,scripting-engines}/' 2> /dev/null)
$(shell sh -c 'mkdir $(OUTPUT)bench' 2> /dev/null)

$(OUTPUT)PERF-VERSION-FILE: .FORCE-PERF-VERSION-FILE
Expand Down Expand Up @@ -568,7 +567,20 @@ else
# Fedora has /usr/include/slang/slang.h, but ubuntu /usr/include/slang.h
BASIC_CFLAGS += -I/usr/include/slang
EXTLIBS += -lnewt -lslang
LIB_OBJS += $(OUTPUT)util/newt.o
LIB_OBJS += $(OUTPUT)util/ui/setup.o
LIB_OBJS += $(OUTPUT)util/ui/browser.o
LIB_OBJS += $(OUTPUT)util/ui/browsers/annotate.o
LIB_OBJS += $(OUTPUT)util/ui/browsers/hists.o
LIB_OBJS += $(OUTPUT)util/ui/browsers/map.o
LIB_OBJS += $(OUTPUT)util/ui/helpline.o
LIB_OBJS += $(OUTPUT)util/ui/progress.o
LIB_OBJS += $(OUTPUT)util/ui/util.o
LIB_H += util/ui/browser.h
LIB_H += util/ui/browsers/map.h
LIB_H += util/ui/helpline.h
LIB_H += util/ui/libslang.h
LIB_H += util/ui/progress.h
LIB_H += util/ui/util.h
endif
endif

Expand Down Expand Up @@ -966,7 +978,16 @@ $(OUTPUT)builtin-init-db.o: builtin-init-db.c $(OUTPUT)PERF-CFLAGS
$(OUTPUT)util/config.o: util/config.c $(OUTPUT)PERF-CFLAGS
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DETC_PERFCONFIG='"$(ETC_PERFCONFIG_SQ)"' $<

$(OUTPUT)util/newt.o: util/newt.c $(OUTPUT)PERF-CFLAGS
$(OUTPUT)util/ui/browser.o: util/ui/browser.c $(OUTPUT)PERF-CFLAGS
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<

$(OUTPUT)util/ui/browsers/annotate.o: util/ui/browsers/annotate.c $(OUTPUT)PERF-CFLAGS
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<

$(OUTPUT)util/ui/browsers/hists.o: util/ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<

$(OUTPUT)util/ui/browsers/map.o: util/ui/browsers/map.c $(OUTPUT)PERF-CFLAGS
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<

$(OUTPUT)util/rbtree.o: ../../lib/rbtree.c $(OUTPUT)PERF-CFLAGS
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ static int hist_entry__tty_annotate(struct hist_entry *he)
LIST_HEAD(head);
struct objdump_line *pos, *n;

if (hist_entry__annotate(he, &head) < 0)
if (hist_entry__annotate(he, &head, 0) < 0)
return -1;

if (full_paths)
Expand Down
31 changes: 29 additions & 2 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,18 @@ static int __cmd_report(void)
hists__tty_browse_tree(&session->hists_tree, help);

out_delete:
perf_session__delete(session);
/*
* Speed up the exit process, for large files this can
* take quite a while.
*
* XXX Enable this when using valgrind or if we ever
* librarize this command.
*
* Also experiment with obstacks to see how much speed
* up we'll get here.
*
* perf_session__delete(session);
*/
return ret;
}

Expand Down Expand Up @@ -478,8 +489,24 @@ int cmd_report(int argc, const char **argv, const char *prefix __used)
* so don't allocate extra space that won't be used in the stdio
* implementation.
*/
if (use_browser > 0)
if (use_browser > 0) {
symbol_conf.priv_size = sizeof(struct sym_priv);
/*
* For searching by name on the "Browse map details".
* providing it only in verbose mode not to bloat too
* much struct symbol.
*/
if (verbose) {
/*
* XXX: Need to provide a less kludgy way to ask for
* more space per symbol, the u32 is for the index on
* the ui browser.
* See symbol__browser_index.
*/
symbol_conf.priv_size += sizeof(u32);
symbol_conf.sort_by_name = true;
}
}

if (symbol__init() < 0)
return -1;
Expand Down
4 changes: 2 additions & 2 deletions tools/perf/builtin-timechart.c
Original file line number Diff line number Diff line change
Expand Up @@ -455,8 +455,8 @@ static void sched_switch(int cpu, u64 timestamp, struct trace_entry *te)
if (p->current->state != TYPE_NONE)
pid_put_sample(sw->next_pid, p->current->state, cpu, p->current->state_since, timestamp);

p->current->state_since = timestamp;
p->current->state = TYPE_RUNNING;
p->current->state_since = timestamp;
p->current->state = TYPE_RUNNING;
}

if (prev_p->current) {
Expand Down
19 changes: 7 additions & 12 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
#include "builtin.h"

#include "util/util.h"
#include "perf.h"
#include "util/cache.h"
#include "util/debug.h"
#include "util/exec_cmd.h"
#include "util/header.h"
#include "util/parse-options.h"
#include "util/session.h"
#include "util/symbol.h"
#include "util/thread.h"
#include "util/header.h"
#include "util/exec_cmd.h"
#include "util/trace-event.h"
#include "util/session.h"
#include "util/util.h"

static char const *script_name;
static char const *generate_script_lang;
Expand Down Expand Up @@ -59,14 +62,6 @@ static int cleanup_scripting(void)
return scripting_ops->stop_script();
}

#include "util/parse-options.h"

#include "perf.h"
#include "util/debug.h"

#include "util/trace-event.h"
#include "util/exec_cmd.h"

static char const *input_name = "perf.data";

static int process_sample_event(event_t *event, struct perf_session *session)
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/util/debug.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int eprintf(int level, const char *fmt, ...)
if (verbose >= level) {
va_start(args, fmt);
if (use_browser > 0)
ret = browser__show_help(fmt, args);
ret = ui_helpline__show_help(fmt, args);
else
ret = vfprintf(stderr, fmt, args);
va_end(args);
Expand Down
9 changes: 4 additions & 5 deletions tools/perf/util/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ 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)
static inline int ui_helpline__show_help(const char *format __used, va_list ap __used)
{
return 0;
}
Expand All @@ -30,10 +30,9 @@ static inline void ui_progress__update(struct ui_progress *self __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);
extern char ui_helpline__last_msg[];
int ui_helpline__show_help(const char *format, va_list ap);
#include "ui/progress.h"
#endif

#endif /* __PERF_DEBUG_H */
16 changes: 10 additions & 6 deletions tools/perf/util/hist.c
Original file line number Diff line number Diff line change
Expand Up @@ -876,6 +876,9 @@ unsigned int hists__sort_list_width(struct hists *self)
if (!se->elide)
ret += 2 + hists__col_len(self, se->se_width_idx);

if (verbose) /* Addr + origin */
ret += 3 + BITS_PER_LONG / 4;

return ret;
}

Expand Down Expand Up @@ -980,9 +983,9 @@ int hist_entry__inc_addr_samples(struct hist_entry *self, u64 ip)
return 0;
}

static struct objdump_line *objdump_line__new(s64 offset, char *line)
static struct objdump_line *objdump_line__new(s64 offset, char *line, size_t privsize)
{
struct objdump_line *self = malloc(sizeof(*self));
struct objdump_line *self = malloc(sizeof(*self) + privsize);

if (self != NULL) {
self->offset = offset;
Expand Down Expand Up @@ -1014,7 +1017,7 @@ struct objdump_line *objdump__get_next_ip_line(struct list_head *head,
}

static int hist_entry__parse_objdump_line(struct hist_entry *self, FILE *file,
struct list_head *head)
struct list_head *head, size_t privsize)
{
struct symbol *sym = self->ms.sym;
struct objdump_line *objdump_line;
Expand Down Expand Up @@ -1065,7 +1068,7 @@ static int hist_entry__parse_objdump_line(struct hist_entry *self, FILE *file,
offset = -1;
}

objdump_line = objdump_line__new(offset, line);
objdump_line = objdump_line__new(offset, line, privsize);
if (objdump_line == NULL) {
free(line);
return -1;
Expand All @@ -1075,7 +1078,8 @@ static int hist_entry__parse_objdump_line(struct hist_entry *self, FILE *file,
return 0;
}

int hist_entry__annotate(struct hist_entry *self, struct list_head *head)
int hist_entry__annotate(struct hist_entry *self, struct list_head *head,
size_t privsize)
{
struct symbol *sym = self->ms.sym;
struct map *map = self->ms.map;
Expand Down Expand Up @@ -1140,7 +1144,7 @@ int hist_entry__annotate(struct hist_entry *self, struct list_head *head)
goto out_free_filename;

while (!feof(file))
if (hist_entry__parse_objdump_line(self, file, head) < 0)
if (hist_entry__parse_objdump_line(self, file, head, privsize) < 0)
break;

pclose(file);
Expand Down
3 changes: 2 additions & 1 deletion tools/perf/util/hist.h
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@ size_t hists__fprintf(struct hists *self, struct hists *pair,
bool show_displacement, FILE *fp);

int hist_entry__inc_addr_samples(struct hist_entry *self, u64 ip);
int hist_entry__annotate(struct hist_entry *self, struct list_head *head);
int hist_entry__annotate(struct hist_entry *self, struct list_head *head,
size_t privsize);

void hists__filter_by_dso(struct hists *self, const struct dso *dso);
void hists__filter_by_thread(struct hists *self, const struct thread *thread);
Expand Down
8 changes: 8 additions & 0 deletions tools/perf/util/include/linux/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,12 @@ static inline void list_del_range(struct list_head *begin,
begin->prev->next = end->next;
end->next->prev = begin->prev;
}

/**
* list_for_each_from - iterate over a list from one of its nodes
* @pos: the &struct list_head to use as a loop cursor, from where to start
* @head: the head for your list.
*/
#define list_for_each_from(pos, head) \
for (; prefetch(pos->next), pos != (head); pos = pos->next)
#endif
12 changes: 12 additions & 0 deletions tools/perf/util/include/linux/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,16 @@
#define DECLARE_BITMAP(name,bits) \
unsigned long name[BITS_TO_LONGS(bits)]

struct list_head {
struct list_head *next, *prev;
};

struct hlist_head {
struct hlist_node *first;
};

struct hlist_node {
struct hlist_node *next, **pprev;
};

#endif
11 changes: 8 additions & 3 deletions tools/perf/util/probe-event.c
Original file line number Diff line number Diff line change
Expand Up @@ -1606,8 +1606,10 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,

/* Init vmlinux path */
ret = init_vmlinux();
if (ret < 0)
if (ret < 0) {
free(pkgs);
return ret;
}

/* Loop 1: convert all events */
for (i = 0; i < npevs; i++) {
Expand All @@ -1625,10 +1627,13 @@ int add_perf_probe_events(struct perf_probe_event *pevs, int npevs,
ret = __add_probe_trace_events(pkgs[i].pev, pkgs[i].tevs,
pkgs[i].ntevs, force_add);
end:
/* Loop 3: cleanup trace events */
for (i = 0; i < npevs; i++)
/* Loop 3: cleanup and free trace events */
for (i = 0; i < npevs; i++) {
for (j = 0; j < pkgs[i].ntevs; j++)
clear_probe_trace_event(&pkgs[i].tevs[j]);
free(pkgs[i].tevs);
}
free(pkgs);

return ret;
}
Expand Down
9 changes: 6 additions & 3 deletions tools/perf/util/probe-finder.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <ctype.h>
#include <dwarf-regs.h>

#include "string.h"
#include "event.h"
#include "debug.h"
#include "util.h"
Expand Down Expand Up @@ -706,8 +705,12 @@ static int find_variable(Dwarf_Die *sp_die, struct probe_finder *pf)
pf->tvar->value = strdup(pf->pvar->var);
if (pf->tvar->value == NULL)
return -ENOMEM;
else
return 0;
if (pf->pvar->type) {
pf->tvar->type = strdup(pf->pvar->type);
if (pf->tvar->type == NULL)
return -ENOMEM;
}
return 0;
}

pr_debug("Searching '%s' variable in context.\n",
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/util/pstack.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef _PERF_PSTACK_
#define _PERF_PSTACK_

#include <stdbool.h>

struct pstack;
struct pstack *pstack__new(unsigned short max_nr_entries);
void pstack__delete(struct pstack *self);
Expand Down
Loading

0 comments on commit 4b17caf

Please sign in to comment.