Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 205361
b: refs/heads/master
c: 9fc3af4
h: refs/heads/master
i:
  205359: 03aae3d
v: v3
  • Loading branch information
Ingo Molnar committed Aug 2, 2010
1 parent 5a17201 commit f64f7dd
Show file tree
Hide file tree
Showing 25 changed files with 1,254 additions and 655 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: cc05152ab72d7a65e6ea97d286af4f878c8f7371
refs/heads/master: 9fc3af467d0749989518a23f7289a6f44e5cb214
8 changes: 4 additions & 4 deletions trunk/tools/perf/Documentation/perf-buildid-cache.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ SYNOPSIS

DESCRIPTION
-----------
This command manages the build-id cache. It can add and remove files to the
cache. In the future it should as well purge older entries, set upper limits
for the space used by the cache, etc.
This command manages the build-id cache. It can add and remove files to/from
the cache. In the future it should as well purge older entries, set upper
limits for the space used by the cache, etc.

OPTIONS
-------
Expand All @@ -23,7 +23,7 @@ OPTIONS
Add specified file to the cache.
-r::
--remove=::
Remove specified file to the cache.
Remove specified file from the cache.
-v::
--verbose::
Be more verbose.
Expand Down
4 changes: 1 addition & 3 deletions trunk/tools/perf/builtin-buildid-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,8 @@ static int __cmd_buildid_list(void)
if (session == NULL)
return -1;

if (with_hits) {
symbol_conf.full_paths = true;
if (with_hits)
perf_session__process_events(session, &build_id__mark_dso_hit_ops);
}

perf_session__fprintf_dsos_buildid(session, stdout, with_hits);

Expand Down
2 changes: 0 additions & 2 deletions trunk/tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ static const struct option options[] = {
OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
OPT_BOOLEAN('m', "modules", &symbol_conf.use_modules,
"load module symbols - WARNING: use only with -k and LIVE kernel"),
OPT_BOOLEAN('P', "full-paths", &symbol_conf.full_paths,
"Don't shorten the pathnames taking into account the cwd"),
OPT_STRING('d', "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
"only consider symbols in these dsos"),
OPT_STRING('C', "comms", &symbol_conf.comm_list_str, "comm[,comm...]",
Expand Down
1 change: 0 additions & 1 deletion trunk/tools/perf/builtin-probe.c
Original file line number Diff line number Diff line change
Expand Up @@ -267,4 +267,3 @@ int cmd_probe(int argc, const char **argv, const char *prefix __used)
}
return 0;
}

37 changes: 30 additions & 7 deletions trunk/tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,8 @@ static void atexit_header(void)

process_buildids();
perf_header__write(&session->header, output, true);
perf_session__delete(session);
symbol__exit();
}
}

Expand Down Expand Up @@ -558,12 +560,15 @@ static int __cmd_record(int argc, const char **argv)
if (!file_new) {
err = perf_header__read(session, output);
if (err < 0)
return err;
goto out_delete_session;
}

if (have_tracepoints(attrs, nr_counters))
perf_header__set_feat(&session->header, HEADER_TRACE_INFO);

/*
* perf_session__delete(session) will be called at atexit_header()
*/
atexit(atexit_header);

if (forks) {
Expand Down Expand Up @@ -768,6 +773,10 @@ static int __cmd_record(int argc, const char **argv)
bytes_written / 24);

return 0;

out_delete_session:
perf_session__delete(session);
return err;
}

static const char * const record_usage[] = {
Expand Down Expand Up @@ -824,7 +833,7 @@ static const struct option options[] = {

int cmd_record(int argc, const char **argv, const char *prefix __used)
{
int i,j;
int i, j, err = -ENOMEM;

argc = parse_options(argc, argv, options, record_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
Expand Down Expand Up @@ -863,7 +872,7 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
} else {
all_tids=malloc(sizeof(pid_t));
if (!all_tids)
return -ENOMEM;
goto out_symbol_exit;

all_tids[0] = target_tid;
thread_num = 1;
Expand All @@ -873,13 +882,13 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
for (j = 0; j < MAX_COUNTERS; j++) {
fd[i][j] = malloc(sizeof(int)*thread_num);
if (!fd[i][j])
return -ENOMEM;
goto out_free_fd;
}
}
event_array = malloc(
sizeof(struct pollfd)*MAX_NR_CPUS*MAX_COUNTERS*thread_num);
if (!event_array)
return -ENOMEM;
goto out_free_fd;

if (user_interval != ULLONG_MAX)
default_interval = user_interval;
Expand All @@ -895,8 +904,22 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
default_interval = freq;
} else {
fprintf(stderr, "frequency and count are zero, aborting\n");
exit(EXIT_FAILURE);
err = -EINVAL;
goto out_free_event_array;
}

return __cmd_record(argc, argv);
err = __cmd_record(argc, argv);

out_free_event_array:
free(event_array);
out_free_fd:
for (i = 0; i < MAX_NR_CPUS; i++) {
for (j = 0; j < MAX_COUNTERS; j++)
free(fd[i][j]);
}
free(all_tids);
all_tids = NULL;
out_symbol_exit:
symbol__exit();
return err;
}
2 changes: 0 additions & 2 deletions trunk/tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,6 @@ static const struct option options[] = {
"pretty printing style key: normal raw"),
OPT_STRING('s', "sort", &sort_order, "key[,key2...]",
"sort by key(s): pid, comm, dso, symbol, parent"),
OPT_BOOLEAN('P', "full-paths", &symbol_conf.full_paths,
"Don't shorten the pathnames taking into account the cwd"),
OPT_BOOLEAN(0, "showcpuutilization", &symbol_conf.show_cpu_utilization,
"Show sample percentage for different cpu modes"),
OPT_STRING('p', "parent", &parent_pattern, "regex",
Expand Down
18 changes: 18 additions & 0 deletions trunk/tools/perf/util/build-id.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "event.h"
#include "symbol.h"
#include <linux/kernel.h>
#include "debug.h"

static int build_id__mark_dso_hit(event_t *event, struct perf_session *session)
{
Expand All @@ -34,10 +35,27 @@ static int build_id__mark_dso_hit(event_t *event, struct perf_session *session)
return 0;
}

static int event__exit_del_thread(event_t *self, struct perf_session *session)
{
struct thread *thread = perf_session__findnew(session, self->fork.tid);

dump_printf("(%d:%d):(%d:%d)\n", self->fork.pid, self->fork.tid,
self->fork.ppid, self->fork.ptid);

if (thread) {
rb_erase(&thread->rb_node, &session->threads);
session->last_match = NULL;
thread__delete(thread);
}

return 0;
}

struct perf_event_ops build_id__mark_dso_hit_ops = {
.sample = build_id__mark_dso_hit,
.mmap = event__process_mmap,
.fork = event__process_task,
.exit = event__exit_del_thread,
};

char *dso__build_id_filename(struct dso *self, char *bf, size_t size)
Expand Down
42 changes: 21 additions & 21 deletions trunk/tools/perf/util/event.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,30 +340,29 @@ int event__synthesize_kernel_mmap(event__handler_t process,
return process(&ev, session);
}

static void thread__comm_adjust(struct thread *self)
static void thread__comm_adjust(struct thread *self, struct hists *hists)
{
char *comm = self->comm;

if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
(!symbol_conf.comm_list ||
strlist__has_entry(symbol_conf.comm_list, comm))) {
unsigned int slen = strlen(comm);
u16 slen = strlen(comm);

if (slen > comms__col_width) {
comms__col_width = slen;
threads__col_width = slen + 6;
}
if (hists__new_col_len(hists, HISTC_COMM, slen))
hists__set_col_len(hists, HISTC_THREAD, slen + 6);
}
}

static int thread__set_comm_adjust(struct thread *self, const char *comm)
static int thread__set_comm_adjust(struct thread *self, const char *comm,
struct hists *hists)
{
int ret = thread__set_comm(self, comm);

if (ret)
return ret;

thread__comm_adjust(self);
thread__comm_adjust(self, hists);

return 0;
}
Expand All @@ -374,7 +373,8 @@ int event__process_comm(event_t *self, struct perf_session *session)

dump_printf(": %s:%d\n", self->comm.comm, self->comm.tid);

if (thread == NULL || thread__set_comm_adjust(thread, self->comm.comm)) {
if (thread == NULL || thread__set_comm_adjust(thread, self->comm.comm,
&session->hists)) {
dump_printf("problem processing PERF_RECORD_COMM, skipping event.\n");
return -1;
}
Expand Down Expand Up @@ -456,6 +456,7 @@ static int event__process_kernel_mmap(event_t *self,
goto out_problem;

map->dso->short_name = name;
map->dso->sname_alloc = 1;
map->end = map->start + self->mmap.len;
} else if (is_kernel_mmap) {
const char *symbol_name = (self->mmap.filename +
Expand Down Expand Up @@ -514,12 +515,13 @@ int event__process_mmap(event_t *self, struct perf_session *session)
if (machine == NULL)
goto out_problem;
thread = perf_session__findnew(session, self->mmap.pid);
if (thread == NULL)
goto out_problem;
map = map__new(&machine->user_dsos, self->mmap.start,
self->mmap.len, self->mmap.pgoff,
self->mmap.pid, self->mmap.filename,
MAP__FUNCTION, session->cwd, session->cwdlen);

if (thread == NULL || map == NULL)
MAP__FUNCTION);
if (map == NULL)
goto out_problem;

thread__insert_map(thread, map);
Expand Down Expand Up @@ -641,16 +643,13 @@ void thread__find_addr_location(struct thread *self,
al->sym = NULL;
}

static void dso__calc_col_width(struct dso *self)
static void dso__calc_col_width(struct dso *self, struct hists *hists)
{
if (!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
(!symbol_conf.dso_list ||
strlist__has_entry(symbol_conf.dso_list, self->name))) {
u16 slen = self->short_name_len;
if (verbose)
slen = self->long_name_len;
if (dsos__col_width < slen)
dsos__col_width = slen;
u16 slen = dso__name_len(self);
hists__new_col_len(hists, HISTC_DSO, slen);
}

self->slen_calculated = 1;
Expand Down Expand Up @@ -729,16 +728,17 @@ int event__preprocess_sample(const event_t *self, struct perf_session *session,
* sampled.
*/
if (!sort_dso.elide && !al->map->dso->slen_calculated)
dso__calc_col_width(al->map->dso);
dso__calc_col_width(al->map->dso, &session->hists);

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 &&
if (hists__col_len(&session->hists, HISTC_DSO) < unresolved_col_width &&
!symbol_conf.col_width_list_str && !symbol_conf.field_sep &&
!symbol_conf.dso_list)
dsos__col_width = unresolved_col_width;
hists__set_col_len(&session->hists, HISTC_DSO,
unresolved_col_width);
}

if (symbol_conf.sym_list && al->sym &&
Expand Down
Loading

0 comments on commit f64f7dd

Please sign in to comment.