Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 191317
b: refs/heads/master
c: 9840280
h: refs/heads/master
i:
  191315: d1a1f45
v: v3
  • Loading branch information
Frederic Weisbecker committed May 9, 2010
1 parent 2169fcf commit bd548e1
Show file tree
Hide file tree
Showing 16 changed files with 128 additions and 121 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 232a5c948da5e23dff27e48180abf4a4238f7602
refs/heads/master: 984028075794c00cbf4fb1e94bb6233e8be08875
9 changes: 6 additions & 3 deletions trunk/tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ static int annotate__hist_hit(struct hist_entry *he, u64 ip)
struct sym_priv *priv;
struct sym_hist *h;

he->count++;

if (!sym || !he->ms.map)
return 0;

Expand All @@ -97,8 +99,9 @@ static int annotate__hist_hit(struct hist_entry *he, u64 ip)
}

static int perf_session__add_hist_entry(struct perf_session *self,
struct addr_location *al)
struct addr_location *al, u64 count)
{
bool hit;
struct hist_entry *he;

if (sym_hist_filter != NULL &&
Expand All @@ -112,7 +115,7 @@ static int perf_session__add_hist_entry(struct perf_session *self,
return 0;
}

he = __perf_session__add_hist_entry(&self->hists, al, NULL, 1);
he = __perf_session__add_hist_entry(&self->hists, al, NULL, count, &hit);
if (he == NULL)
return -ENOMEM;

Expand All @@ -132,7 +135,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)
return -1;
}

if (!al.filtered && perf_session__add_hist_entry(session, &al)) {
if (!al.filtered && perf_session__add_hist_entry(session, &al, 1)) {
pr_warning("problem incrementing symbol count, "
"skipping event\n");
return -1;
Expand Down
14 changes: 11 additions & 3 deletions trunk/tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,17 @@ static bool show_displacement;
static int perf_session__add_hist_entry(struct perf_session *self,
struct addr_location *al, u64 count)
{
if (__perf_session__add_hist_entry(&self->hists, al, NULL, count) != NULL)
return 0;
return -ENOMEM;
bool hit;
struct hist_entry *he = __perf_session__add_hist_entry(&self->hists,
al, NULL,
count, &hit);
if (he == NULL)
return -ENOMEM;

if (hit)
__perf_session__add_count(he, al, count);

return 0;
}

static int diff__process_sample_event(event_t *event, struct perf_session *session)
Expand Down
34 changes: 24 additions & 10 deletions trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,29 @@ static void event__synthesize_guest_os(struct machine *machine, void *data)
" relocation symbol.\n", machine->pid);
}

static struct perf_event_header finished_round_event = {
.size = sizeof(struct perf_event_header),
.type = PERF_RECORD_FINISHED_ROUND,
};

static void mmap_read_all(void)
{
int i, counter, thread;

for (i = 0; i < nr_cpu; i++) {
for (counter = 0; counter < nr_counters; counter++) {
for (thread = 0; thread < thread_num; thread++) {
if (mmap_array[i][counter][thread].base)
mmap_read(&mmap_array[i][counter][thread]);
}

}
}

if (perf_header__has_feat(&session->header, HEADER_TRACE_INFO))
write_output(&finished_round_event, sizeof(finished_round_event));
}

static int __cmd_record(int argc, const char **argv)
{
int i, counter;
Expand Down Expand Up @@ -726,16 +749,7 @@ static int __cmd_record(int argc, const char **argv)
int hits = samples;
int thread;

for (i = 0; i < nr_cpu; i++) {
for (counter = 0; counter < nr_counters; counter++) {
for (thread = 0;
thread < thread_num; thread++) {
if (mmap_array[i][counter][thread].base)
mmap_read(&mmap_array[i][counter][thread]);
}

}
}
mmap_read_all();

if (hits == samples) {
if (done)
Expand Down
48 changes: 34 additions & 14 deletions trunk/tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ static int perf_session__add_hist_entry(struct perf_session *self,
{
struct map_symbol *syms = NULL;
struct symbol *parent = NULL;
int err = -ENOMEM;
bool hit;
int err;
struct hist_entry *he;
struct event_stat_id *stats;
struct perf_event_attr *attr;
Expand All @@ -100,17 +101,39 @@ static int perf_session__add_hist_entry(struct perf_session *self,
else
stats = get_stats(self, data->id, 0, 0);
if (stats == NULL)
goto out_free_syms;
return -ENOMEM;
he = __perf_session__add_hist_entry(&stats->hists, al, parent,
data->period);
data->period, &hit);
if (he == NULL)
goto out_free_syms;
err = 0;
if (symbol_conf.use_callchain)
return -ENOMEM;

if (hit)
__perf_session__add_count(he, al, data->period);

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

if (err)
return err;
}

return 0;
}

static int validate_chain(struct ip_callchain *chain, event_t *event)
{
unsigned int chain_size;

chain_size = event->header.size;
chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event;

if (chain->nr*sizeof(u64) > chain_size)
return -1;

return 0;
}

static int add_event_total(struct perf_session *session,
Expand Down Expand Up @@ -148,7 +171,7 @@ static int process_sample_event(event_t *event, struct perf_session *session)

dump_printf("... chain: nr:%Lu\n", data.callchain->nr);

if (!ip_callchain__valid(data.callchain, event)) {
if (validate_chain(data.callchain, event) < 0) {
pr_debug("call-chain problem with event, "
"skipping it.\n");
return 0;
Expand Down Expand Up @@ -343,7 +366,7 @@ static int
parse_callchain_opt(const struct option *opt __used, const char *arg,
int unset)
{
char *tok, *tok2;
char *tok;
char *endptr;

/*
Expand Down Expand Up @@ -388,13 +411,10 @@ parse_callchain_opt(const struct option *opt __used, const char *arg,
if (!tok)
goto setup;

tok2 = strtok(NULL, ",");
callchain_param.min_percent = strtod(tok, &endptr);
if (tok == endptr)
return -1;

if (tok2)
callchain_param.print_limit = strtod(tok2, &endptr);
setup:
if (register_callchain_param(&callchain_param) < 0) {
fprintf(stderr, "Can't register callchain params\n");
Expand Down
7 changes: 0 additions & 7 deletions trunk/tools/perf/util/callchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@

#include "callchain.h"

bool ip_callchain__valid(struct ip_callchain *chain, event_t *event)
{
unsigned int chain_size = event->header.size;
chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event;
return chain->nr * sizeof(u64) <= chain_size;
}

#define chain_for_each_child(child, parent) \
list_for_each_entry(child, &parent->children, brothers)

Expand Down
4 changes: 0 additions & 4 deletions trunk/tools/perf/util/callchain.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include "../perf.h"
#include <linux/list.h>
#include <linux/rbtree.h>
#include "event.h"
#include "util.h"
#include "symbol.h"

Expand Down Expand Up @@ -34,7 +33,6 @@ typedef void (*sort_chain_func_t)(struct rb_root *, struct callchain_node *,

struct callchain_param {
enum chain_mode mode;
u32 print_limit;
double min_percent;
sort_chain_func_t sort;
};
Expand All @@ -60,6 +58,4 @@ static inline u64 cumul_hits(struct callchain_node *node)
int register_callchain_param(struct callchain_param *param);
int append_chain(struct callchain_node *root, struct ip_callchain *chain,
struct map_symbol *syms);

bool ip_callchain__valid(struct ip_callchain *chain, event_t *event);
#endif /* __PERF_CALLCHAIN_H */
27 changes: 2 additions & 25 deletions trunk/tools/perf/util/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,8 @@ int event__process_mmap(event_t *self, struct perf_session *session)
return 0;
}

machine = perf_session__find_host_machine(session);
if (machine == NULL)
goto out_problem;
thread = perf_session__findnew(session, self->mmap.pid);
machine = perf_session__find_host_machine(session);
map = map__new(&machine->user_dsos, self->mmap.start,
self->mmap.len, self->mmap.pgoff,
self->mmap.pid, self->mmap.filename,
Expand Down Expand Up @@ -554,18 +552,14 @@ void thread__find_addr_map(struct thread *self,
if (cpumode == PERF_RECORD_MISC_KERNEL && perf_host) {
al->level = 'k';
machine = perf_session__find_host_machine(session);
if (machine == NULL) {
al->map = NULL;
return;
}
mg = &machine->kmaps;
} else if (cpumode == PERF_RECORD_MISC_USER && perf_host) {
al->level = '.';
machine = perf_session__find_host_machine(session);
} else if (cpumode == PERF_RECORD_MISC_GUEST_KERNEL && perf_guest) {
al->level = 'g';
machine = perf_session__find_machine(session, pid);
if (machine == NULL) {
if (!machine) {
al->map = NULL;
return;
}
Expand Down Expand Up @@ -656,16 +650,6 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session,
goto out_filtered;

dump_printf(" ... thread: %s:%d\n", thread->comm, thread->pid);
/*
* Have we already created the kernel maps for the host machine?
*
* This should have happened earlier, when we processed the kernel MMAP
* events, but for older perf.data files there was no such thing, so do
* it now.
*/
if (cpumode == PERF_RECORD_MISC_KERNEL &&
session->host_machine.vmlinux_maps[MAP__FUNCTION] == NULL)
machine__create_kernel_maps(&session->host_machine);

thread__find_addr_map(thread, session, cpumode, MAP__FUNCTION,
self->ip.pid, self->ip.ip, al);
Expand All @@ -692,13 +676,6 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session,
dso__calc_col_width(al->map->dso);

al->sym = map__find_symbol(al->map, al->addr, filter);
} else {
const unsigned int unresolved_col_width = BITS_PER_LONG / 4;

if (dsos__col_width < unresolved_col_width &&
!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
!symbol_conf.dso_list)
dsos__col_width = unresolved_col_width;
}

if (symbol_conf.sym_list && al->sym &&
Expand Down
3 changes: 2 additions & 1 deletion trunk/tools/perf/util/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,12 @@ struct build_id_event {
char filename[];
};

enum perf_header_event_type { /* above any possible kernel type */
enum perf_user_event_type { /* above any possible kernel type */
PERF_RECORD_HEADER_ATTR = 64,
PERF_RECORD_HEADER_EVENT_TYPE = 65,
PERF_RECORD_HEADER_TRACING_DATA = 66,
PERF_RECORD_HEADER_BUILD_ID = 67,
PERF_RECORD_FINISHED_ROUND = 68,
PERF_RECORD_HEADER_MAX
};

Expand Down
Loading

0 comments on commit bd548e1

Please sign in to comment.