Skip to content

Commit

Permalink
Merge branch 'perfcounters-fixes-for-linus' of git://git.kernel.org/p…
Browse files Browse the repository at this point in the history
…ub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'perfcounters-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
  perf_counter, powerpc, sparc: Fix compilation after perf_counter_overflow() change
  perf_counter: x86: Fix PMU resource leak
  perf util: SVG performance improvements
  perf util: Make the timechart SVG width dynamic
  perf timechart: Show the duration of scheduler delays in the SVG
  perf timechart: Show the name of the waker/wakee in timechart
  • Loading branch information
torvalds committed Sep 21, 2009
2 parents 8e4bc3d + cd74c86 commit f4eccb6
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 69 deletions.
3 changes: 1 addition & 2 deletions arch/powerpc/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,15 +1162,14 @@ static void record_and_restart(struct perf_counter *counter, unsigned long val,
*/
if (record) {
struct perf_sample_data data = {
.regs = regs,
.addr = 0,
.period = counter->hw.last_period,
};

if (counter->attr.sample_type & PERF_SAMPLE_ADDR)
perf_get_data_addr(regs, &data.addr);

if (perf_counter_overflow(counter, nmi, &data)) {
if (perf_counter_overflow(counter, nmi, &data, regs)) {
/*
* Interrupts are coming too fast - throttle them
* by setting the counter to 0, so it will be
Expand Down
3 changes: 1 addition & 2 deletions arch/sparc/kernel/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,6 @@ static int __kprobes perf_counter_nmi_handler(struct notifier_block *self,

regs = args->regs;

data.regs = regs;
data.addr = 0;

cpuc = &__get_cpu_var(cpu_hw_counters);
Expand All @@ -513,7 +512,7 @@ static int __kprobes perf_counter_nmi_handler(struct notifier_block *self,
if (!sparc_perf_counter_set_period(counter, hwc, idx))
continue;

if (perf_counter_overflow(counter, 1, &data))
if (perf_counter_overflow(counter, 1, &data, regs))
sparc_pmu_disable_counter(hwc, idx);
}

Expand Down
9 changes: 6 additions & 3 deletions arch/x86/kernel/cpu/perf_counter.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,6 +924,8 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
if (err)
return err;

counter->destroy = hw_perf_counter_destroy;

/*
* Generate PMC IRQs:
* (keep 'enabled' bit clear for now)
Expand Down Expand Up @@ -953,8 +955,6 @@ static int __hw_perf_counter_init(struct perf_counter *counter)
return -EOPNOTSUPP;
}

counter->destroy = hw_perf_counter_destroy;

/*
* Raw event type provide the config in the event structure
*/
Expand Down Expand Up @@ -2107,8 +2107,11 @@ const struct pmu *hw_perf_counter_init(struct perf_counter *counter)
int err;

err = __hw_perf_counter_init(counter);
if (err)
if (err) {
if (counter->destroy)
counter->destroy(counter);
return ERR_PTR(err);
}

return &pmu;
}
Expand Down
17 changes: 0 additions & 17 deletions include/linux/perf_counter.h
Original file line number Diff line number Diff line change
Expand Up @@ -849,23 +849,6 @@ static inline void perf_counter_comm(struct task_struct *tsk) { }
static inline void perf_counter_fork(struct task_struct *tsk) { }
static inline void perf_counter_init(void) { }

static inline int
perf_output_begin(struct perf_output_handle *handle, struct perf_counter *c,
unsigned int size, int nmi, int sample) { }
static inline void perf_output_end(struct perf_output_handle *handle) { }
static inline void
perf_output_copy(struct perf_output_handle *handle,
const void *buf, unsigned int len) { }
static inline void
perf_output_sample(struct perf_output_handle *handle,
struct perf_event_header *header,
struct perf_sample_data *data,
struct perf_counter *counter) { }
static inline void
perf_prepare_sample(struct perf_event_header *header,
struct perf_sample_data *data,
struct perf_counter *counter,
struct pt_regs *regs) { }
#endif

#define perf_output_put(handle, x) \
Expand Down
3 changes: 3 additions & 0 deletions tools/perf/Documentation/perf-timechart.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ OPTIONS
-i::
--input=::
Select the input file (default: perf.data)
-w::
--width=::
Select the width of the SVG file (default: 1000)


SEE ALSO
Expand Down
23 changes: 15 additions & 8 deletions tools/perf/builtin-timechart.c
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,7 @@ static void draw_wakeups(void)
we = wake_events;
while (we) {
int from = 0, to = 0;
char *task_from = NULL, *task_to = NULL;

/* locate the column of the waker and wakee */
p = all_data;
Expand All @@ -760,10 +761,14 @@ static void draw_wakeups(void)
c = p->all;
while (c) {
if (c->Y && c->start_time <= we->time && c->end_time >= we->time) {
if (p->pid == we->waker)
if (p->pid == we->waker) {
from = c->Y;
if (p->pid == we->wakee)
task_from = c->comm;
}
if (p->pid == we->wakee) {
to = c->Y;
task_to = c->comm;
}
}
c = c->next;
}
Expand All @@ -776,7 +781,7 @@ static void draw_wakeups(void)
else if (from && to && abs(from - to) == 1)
svg_wakeline(we->time, from, to);
else
svg_partial_wakeline(we->time, from, to);
svg_partial_wakeline(we->time, from, task_from, to, task_to);
we = we->next;
}
}
Expand Down Expand Up @@ -822,15 +827,15 @@ static void draw_process_bars(void)
continue;
}

svg_box(Y, p->start_time, p->end_time, "process");
svg_box(Y, c->start_time, c->end_time, "process");
sample = c->samples;
while (sample) {
if (sample->type == TYPE_RUNNING)
svg_sample(Y, sample->cpu, sample->start_time, sample->end_time, "sample");
svg_sample(Y, sample->cpu, sample->start_time, sample->end_time);
if (sample->type == TYPE_BLOCKED)
svg_box(Y, sample->start_time, sample->end_time, "blocked");
if (sample->type == TYPE_WAITING)
svg_box(Y, sample->start_time, sample->end_time, "waiting");
svg_waiting(Y, sample->start_time, sample->end_time);
sample = sample->next;
}

Expand Down Expand Up @@ -910,9 +915,9 @@ static void write_svg_file(const char *filename)
if (count < 15)
count = determine_display_tasks(TIME_THRESH / 10);

open_svg(filename, numcpus, count);
open_svg(filename, numcpus, count, first_time, last_time);

svg_time_grid(first_time, last_time);
svg_time_grid();
svg_legenda();

for (i = 0; i < numcpus; i++)
Expand Down Expand Up @@ -1127,6 +1132,8 @@ static const struct option options[] = {
"input file name"),
OPT_STRING('o', "output", &output_name, "file",
"output file name"),
OPT_INTEGER('w', "width", &svg_page_width,
"page width"),
OPT_END()
};

Expand Down
Loading

0 comments on commit f4eccb6

Please sign in to comment.