2010-01-27 23:06:34

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 1/9] perf top: Exit if specified --vmlinux can't be used

From: Arnaldo Carvalho de Melo <[email protected]>

As we do lazy loading of symtabs we only will know if the specified
vmlinux file is invalid when we actually have a hit in kernel space and
then try to load it. So if we get kernel hits and there are _no_ symbols
in the DSO backing the kernel map, bail out.

Reported-by: Mike Galbraith <[email protected]>
Cc: Frédéric Weisbecker <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-top.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 2227b84..78f9c45 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -951,9 +951,31 @@ static void event__process_sample(const event_t *self,
}

if (event__preprocess_sample(self, session, &al, symbol_filter) < 0 ||
- al.sym == NULL || al.filtered)
+ al.filtered)
return;

+ if (al.sym == NULL) {
+ /*
+ * As we do lazy loading of symtabs we only will know if the
+ * specified vmlinux file is invalid when we actually have a
+ * hit in kernel space and then try to load it. So if we get
+ * here and there are _no_ symbols in the DSO backing the
+ * kernel map, bail out.
+ *
+ * We may never get here, for instance, if we use -K/
+ * --hide-kernel-symbols, even if the user specifies an
+ * invalid --vmlinux ;-)
+ */
+ if (al.map == session->vmlinux_maps[MAP__FUNCTION] &&
+ RB_EMPTY_ROOT(&al.map->dso->symbols[MAP__FUNCTION])) {
+ pr_err("The %s file can't be used\n",
+ symbol_conf.vmlinux_name);
+ exit(1);
+ }
+
+ return;
+ }
+
syme = symbol__priv(al.sym);
if (!syme->skip) {
syme->count[counter]++;
--
1.6.2.5


2010-01-27 23:06:12

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 4/9] perf session: Create kernel maps in the constructor

From: Arnaldo Carvalho de Melo <[email protected]>

Removing one extra step needed in the tools that need this, fixing a bug
in 'perf probe' where this was not being done.

Cc: Masami Hiramatsu <[email protected]>
Cc: Frédéric Weisbecker <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-kmem.c | 5 -----
tools/perf/builtin-record.c | 5 -----
tools/perf/builtin-top.c | 5 -----
tools/perf/util/session.c | 13 +++++++++++--
4 files changed, 11 insertions(+), 17 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index e8d716b..5d5dc6b 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -491,11 +491,6 @@ static int __cmd_kmem(void)
if (!perf_session__has_traces(session, "kmem record"))
goto out_delete;

- if (perf_session__create_kernel_maps(session) < 0) {
- pr_err("Problems creating kernel maps\n");
- return -1;
- }
-
setup_pager();
err = perf_session__process_events(session, &event_ops);
if (err != 0)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 7bb9ca1..9034522 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -477,11 +477,6 @@ static int __cmd_record(int argc, const char **argv)
return -1;
}

- if (perf_session__create_kernel_maps(session) < 0) {
- pr_err("Problems creating kernel maps\n");
- return -1;
- }
-
if (!file_new) {
err = perf_header__read(&session->header, output);
if (err < 0)
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index 78f9c45..1fc018e 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -1191,11 +1191,6 @@ static int __cmd_top(void)
if (session == NULL)
return -ENOMEM;

- if (perf_session__create_kernel_maps(session) < 0) {
- pr_err("Problems creating kernel maps\n");
- return -1;
- }
-
if (target_pid != -1)
event__synthesize_thread(target_pid, event__process, session);
else
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 1951e33..8e7c189 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -70,8 +70,17 @@ struct perf_session *perf_session__new(const char *filename, int mode, bool forc
self->unknown_events = 0;
map_groups__init(&self->kmaps);

- if (mode == O_RDONLY && perf_session__open(self, force) < 0)
- goto out_delete;
+ if (mode == O_RDONLY) {
+ if (perf_session__open(self, force) < 0)
+ goto out_delete;
+ } else if (mode == O_WRONLY) {
+ /*
+ * In O_RDONLY mode this will be performed when reading the
+ * kernel MMAP event, in event__process_mmap().
+ */
+ if (perf_session__create_kernel_maps(self) < 0)
+ goto out_delete;
+ }

self->sample_type = perf_header__sample_type(&self->header);
out:
--
1.6.2.5

2010-01-27 23:06:36

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 7/9] tools/perf/perf.c: Clean up trivial style issues.

From: Thiago Farina <[email protected]>

Checked with:
./../scripts/checkpatch.pl --terse --file perf.c

perf.c:51: ERROR: open brace '{' following function declarations go on the next line
perf.c:73: ERROR: "foo*** bar" should be "foo ***bar"
perf.c:112: ERROR: space prohibited before that close parenthesis ')'
perf.c:127: ERROR: space prohibited before that close parenthesis ')'
perf.c:171: ERROR: "foo** bar" should be "foo **bar"
perf.c:213: ERROR: "(foo*)" should be "(foo *)"
perf.c:216: ERROR: "(foo*)" should be "(foo *)"
perf.c:217: ERROR: space required before that '*' (ctx:OxV)
perf.c:452: ERROR: do not initialise statics to 0 or NULL
perf.c:453: ERROR: do not initialise statics to 0 or NULL

Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Signed-off-by: Thiago Farina <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/perf.c | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 05c861c..109b89b 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -48,7 +48,8 @@ int check_pager_config(const char *cmd)
return c.val;
}

-static void commit_pager_choice(void) {
+static void commit_pager_choice(void)
+{
switch (use_pager) {
case 0:
setenv("PERF_PAGER", "cat", 1);
@@ -70,7 +71,7 @@ static void set_debugfs_path(void)
"tracing/events");
}

-static int handle_options(const char*** argv, int* argc, int* envchanged)
+static int handle_options(const char ***argv, int *argc, int *envchanged)
{
int handled = 0;

@@ -109,7 +110,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--perf-dir")) {
if (*argc < 2) {
- fprintf(stderr, "No directory given for --perf-dir.\n" );
+ fprintf(stderr, "No directory given for --perf-dir.\n");
usage(perf_usage_string);
}
setenv(PERF_DIR_ENVIRONMENT, (*argv)[1], 1);
@@ -124,7 +125,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--work-tree")) {
if (*argc < 2) {
- fprintf(stderr, "No directory given for --work-tree.\n" );
+ fprintf(stderr, "No directory given for --work-tree.\n");
usage(perf_usage_string);
}
setenv(PERF_WORK_TREE_ENVIRONMENT, (*argv)[1], 1);
@@ -168,7 +169,7 @@ static int handle_alias(int *argcp, const char ***argv)
{
int envchanged = 0, ret = 0, saved_errno = errno;
int count, option_count;
- const char** new_argv;
+ const char **new_argv;
const char *alias_command;
char *alias_string;

@@ -210,11 +211,11 @@ static int handle_alias(int *argcp, const char ***argv)
if (!strcmp(alias_command, new_argv[0]))
die("recursive alias: %s", alias_command);

- new_argv = realloc(new_argv, sizeof(char*) *
+ new_argv = realloc(new_argv, sizeof(char *) *
(count + *argcp + 1));
/* insert after command name */
- memcpy(new_argv + count, *argv + 1, sizeof(char*) * *argcp);
- new_argv[count+*argcp] = NULL;
+ memcpy(new_argv + count, *argv + 1, sizeof(char *) * *argcp);
+ new_argv[count + *argcp] = NULL;

*argv = new_argv;
*argcp += count - 1;
@@ -450,8 +451,8 @@ int main(int argc, const char **argv)
setup_path();

while (1) {
- static int done_help = 0;
- static int was_alias = 0;
+ static int done_help;
+ static int was_alias;

was_alias = run_argv(&argc, &argv);
if (errno != ENOENT)
--
1.6.2.5

2010-01-27 23:06:52

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 9/9] perf symbols: Ditch vdso global variable

From: Arnaldo Carvalho de Melo <[email protected]>

We can check using strcmp, most DSOs don't start with '[' so the test is
cheap enough and we had to test it there anyway since when reading
perf.data files we weren't calling the routine that created this global
variable and thus weren't setting it as "loaded", which was causing a
bogus:

Failed to open [vdso], continuing without symbols

Message as the first line of 'perf report'.

Cc: Frédéric Weisbecker <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/map.c | 7 ++++++-
tools/perf/util/symbol.c | 26 ++++----------------------
tools/perf/util/symbol.h | 6 +++++-
3 files changed, 15 insertions(+), 24 deletions(-)

diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index 36ff0bf..f6626cc 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -68,8 +68,13 @@ struct map *map__new(struct mmap_event *event, enum map_type type,
map__init(self, type, event->start, event->start + event->len,
event->pgoff, dso);

- if (self->dso == vdso || anon)
+ if (anon) {
+set_identity:
self->map_ip = self->unmap_ip = identity__map_ip;
+ } else if (strcmp(filename, "[vdso]") == 0) {
+ dso__set_loaded(dso, self->type);
+ goto set_identity;
+ }
}
return self;
out_delete:
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 051d71b..e752837 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -53,11 +53,6 @@ bool dso__sorted_by_name(const struct dso *self, enum map_type type)
return self->sorted_by_name & (1 << type);
}

-static void dso__set_loaded(struct dso *self, enum map_type type)
-{
- self->loaded |= (1 << type);
-}
-
static void dso__set_sorted_by_name(struct dso *self, enum map_type type)
{
self->sorted_by_name |= (1 << type);
@@ -1697,7 +1692,6 @@ out_fixup:

LIST_HEAD(dsos__user);
LIST_HEAD(dsos__kernel);
-struct dso *vdso;

static void dsos__add(struct list_head *head, struct dso *dso)
{
@@ -1790,24 +1784,12 @@ static struct dso *dsos__create_kernel(const char *vmlinux)
{
struct dso *kernel = dso__new_kernel(vmlinux);

- if (kernel == NULL)
- return NULL;
-
- vdso = dso__new("[vdso]");
- if (vdso == NULL)
- goto out_delete_kernel_dso;
- dso__set_loaded(vdso, MAP__FUNCTION);
-
- dso__read_running_kernel_build_id(kernel);
-
- dsos__add(&dsos__kernel, kernel);
- dsos__add(&dsos__user, vdso);
+ if (kernel != NULL) {
+ dso__read_running_kernel_build_id(kernel);
+ dsos__add(&dsos__kernel, kernel);
+ }

return kernel;
-
-out_delete_kernel_dso:
- dso__delete(kernel);
- return NULL;
}

int __map_groups__create_kernel_maps(struct map_groups *self,
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index e6a59e5..e90568a 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -121,6 +121,11 @@ void dso__delete(struct dso *self);
bool dso__loaded(const struct dso *self, enum map_type type);
bool dso__sorted_by_name(const struct dso *self, enum map_type type);

+static inline void dso__set_loaded(struct dso *self, enum map_type type)
+{
+ self->loaded |= (1 << type);
+}
+
void dso__sort_by_name(struct dso *self, enum map_type type);

extern struct list_head dsos__user, dsos__kernel;
@@ -161,5 +166,4 @@ int kallsyms__parse(const char *filename, void *arg,
int symbol__init(void);
bool symbol_type__is_a(char symbol_type, enum map_type map_type);

-extern struct dso *vdso;
#endif /* __PERF_SYMBOL */
--
1.6.2.5

2010-01-27 23:06:18

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 5/9] perf symbols: Remove perf_session usage in symbols layer

From: Arnaldo Carvalho de Melo <[email protected]>

I noticed while writing the first test in 'perf regtest' that to just test the
symbol handling routines one needs to create a perf session, that is a layer
centered on a perf.data file, events, etc, so I untied these layers.

This reduces the complexity for the users as the number of parameters to most
of the symbols and session APIs now gets reduced while not adding more state to
all the map instances by only having data that is needed to split the kernel
(kallsyms and ELF symtab sections) maps and do vmlinux relocation on the main
kernel map.

Cc: Frédéric Weisbecker <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-kmem.c | 2 +-
tools/perf/builtin-probe.c | 5 +-
tools/perf/util/event.c | 6 +--
tools/perf/util/map.c | 20 ++++---
tools/perf/util/map.h | 22 ++++++--
tools/perf/util/session.c | 35 +++++++++----
tools/perf/util/session.h | 22 +++++---
tools/perf/util/symbol.c | 122 ++++++++++++++++++++-----------------------
tools/perf/util/symbol.h | 19 ++++---
tools/perf/util/thread.c | 3 +-
tools/perf/util/thread.h | 14 +++--
11 files changed, 149 insertions(+), 121 deletions(-)

diff --git a/tools/perf/builtin-kmem.c b/tools/perf/builtin-kmem.c
index 5d5dc6b..924a951 100644
--- a/tools/perf/builtin-kmem.c
+++ b/tools/perf/builtin-kmem.c
@@ -369,7 +369,7 @@ static void __print_result(struct rb_root *root, struct perf_session *session,
if (is_caller) {
addr = data->call_site;
if (!raw_ip)
- sym = map_groups__find_function(&session->kmaps, session, addr, NULL);
+ sym = map_groups__find_function(&session->kmaps, addr, NULL);
} else
addr = data->ptr;

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 34f2acb..4fa73ec 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -122,8 +122,7 @@ static int opt_del_probe_event(const struct option *opt __used,
static void evaluate_probe_point(struct probe_point *pp)
{
struct symbol *sym;
- sym = map__find_symbol_by_name(session.kmap, pp->function,
- session.psession, NULL);
+ sym = map__find_symbol_by_name(session.kmap, pp->function, NULL);
if (!sym)
die("Kernel symbol \'%s\' not found - probe not added.",
pp->function);
@@ -132,7 +131,7 @@ static void evaluate_probe_point(struct probe_point *pp)
#ifndef NO_LIBDWARF
static int open_vmlinux(void)
{
- if (map__load(session.kmap, session.psession, NULL) < 0) {
+ if (map__load(session.kmap, NULL) < 0) {
pr_debug("Failed to load kernel map.\n");
return -EINVAL;
}
diff --git a/tools/perf/util/event.c b/tools/perf/util/event.c
index bbaee61..c3831f6 100644
--- a/tools/perf/util/event.c
+++ b/tools/perf/util/event.c
@@ -374,9 +374,7 @@ int event__process_mmap(event_t *self, struct perf_session *session)
goto out_problem;

kernel->kernel = 1;
- if (__map_groups__create_kernel_maps(&session->kmaps,
- session->vmlinux_maps,
- kernel) < 0)
+ if (__perf_session__create_kernel_maps(session, kernel) < 0)
goto out_problem;

session->vmlinux_maps[MAP__FUNCTION]->start = self->mmap.start;
@@ -476,7 +474,7 @@ void thread__find_addr_location(struct thread *self,
{
thread__find_addr_map(self, session, cpumode, type, addr, al);
if (al->map != NULL)
- al->sym = map__find_symbol(al->map, session, al->addr, filter);
+ al->sym = map__find_symbol(al->map, al->addr, filter);
else
al->sym = NULL;
}
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index c4d55a0..36ff0bf 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -104,8 +104,7 @@ void map__fixup_end(struct map *self)

#define DSO__DELETED "(deleted)"

-int map__load(struct map *self, struct perf_session *session,
- symbol_filter_t filter)
+int map__load(struct map *self, symbol_filter_t filter)
{
const char *name = self->dso->long_name;
int nr;
@@ -113,7 +112,7 @@ int map__load(struct map *self, struct perf_session *session,
if (dso__loaded(self->dso, self->type))
return 0;

- nr = dso__load(self->dso, self, session, filter);
+ nr = dso__load(self->dso, self, filter);
if (nr < 0) {
if (self->dso->has_build_id) {
char sbuild_id[BUILD_ID_SIZE * 2 + 1];
@@ -144,24 +143,29 @@ int map__load(struct map *self, struct perf_session *session,

return -1;
}
+ /*
+ * Only applies to the kernel, as its symtabs aren't relative like the
+ * module ones.
+ */
+ if (self->dso->kernel)
+ map__reloc_vmlinux(self);

return 0;
}

-struct symbol *map__find_symbol(struct map *self, struct perf_session *session,
- u64 addr, symbol_filter_t filter)
+struct symbol *map__find_symbol(struct map *self, u64 addr,
+ symbol_filter_t filter)
{
- if (map__load(self, session, filter) < 0)
+ if (map__load(self, filter) < 0)
return NULL;

return dso__find_symbol(self->dso, self->type, addr);
}

struct symbol *map__find_symbol_by_name(struct map *self, const char *name,
- struct perf_session *session,
symbol_filter_t filter)
{
- if (map__load(self, session, filter) < 0)
+ if (map__load(self, filter) < 0)
return NULL;

if (!dso__sorted_by_name(self->dso, self->type))
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index 72f0b6a..de04839 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -14,6 +14,8 @@ enum map_type {
#define MAP__NR_TYPES (MAP__VARIABLE + 1)

struct dso;
+struct ref_reloc_sym;
+struct map_groups;

struct map {
union {
@@ -29,6 +31,16 @@ struct map {
struct dso *dso;
};

+struct kmap {
+ struct ref_reloc_sym *ref_reloc_sym;
+ struct map_groups *kmaps;
+};
+
+static inline struct kmap *map__kmap(struct map *self)
+{
+ return (struct kmap *)(self + 1);
+}
+
static inline u64 map__map_ip(struct map *map, u64 ip)
{
return ip - map->start + map->pgoff;
@@ -58,16 +70,14 @@ struct map *map__clone(struct map *self);
int map__overlap(struct map *l, struct map *r);
size_t map__fprintf(struct map *self, FILE *fp);

-struct perf_session;
-
-int map__load(struct map *self, struct perf_session *session,
- symbol_filter_t filter);
-struct symbol *map__find_symbol(struct map *self, struct perf_session *session,
+int map__load(struct map *self, symbol_filter_t filter);
+struct symbol *map__find_symbol(struct map *self,
u64 addr, symbol_filter_t filter);
struct symbol *map__find_symbol_by_name(struct map *self, const char *name,
- struct perf_session *session,
symbol_filter_t filter);
void map__fixup_start(struct map *self);
void map__fixup_end(struct map *self);

+void map__reloc_vmlinux(struct map *self);
+
#endif /* __PERF_MAP_H */
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 8e7c189..dc182b0 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -50,6 +50,11 @@ out_close:
return -1;
}

+static inline int perf_session__create_kernel_maps(struct perf_session *self)
+{
+ return map_groups__create_kernel_maps(&self->kmaps, self->vmlinux_maps);
+}
+
struct perf_session *perf_session__new(const char *filename, int mode, bool force)
{
size_t len = filename ? strlen(filename) + 1 : 0;
@@ -504,6 +509,7 @@ int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
u64 addr)
{
char *bracket;
+ enum map_type i;

self->ref_reloc_sym.name = strdup(symbol_name);
if (self->ref_reloc_sym.name == NULL)
@@ -514,6 +520,12 @@ int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
*bracket = '\0';

self->ref_reloc_sym.addr = addr;
+
+ for (i = 0; i < MAP__NR_TYPES; ++i) {
+ struct kmap *kmap = map__kmap(self->vmlinux_maps[i]);
+ kmap->ref_reloc_sym = &self->ref_reloc_sym;
+ }
+
return 0;
}

@@ -527,20 +539,21 @@ static u64 map__reloc_unmap_ip(struct map *map, u64 ip)
return ip - (s64)map->pgoff;
}

-void perf_session__reloc_vmlinux_maps(struct perf_session *self,
- u64 unrelocated_addr)
+void map__reloc_vmlinux(struct map *self)
{
- enum map_type type;
- s64 reloc = unrelocated_addr - self->ref_reloc_sym.addr;
+ struct kmap *kmap = map__kmap(self);
+ s64 reloc;

- if (!reloc)
+ if (!kmap->ref_reloc_sym || !kmap->ref_reloc_sym->unrelocated_addr)
return;

- for (type = 0; type < MAP__NR_TYPES; ++type) {
- struct map *map = self->vmlinux_maps[type];
+ reloc = (kmap->ref_reloc_sym->unrelocated_addr -
+ kmap->ref_reloc_sym->addr);

- map->map_ip = map__reloc_map_ip;
- map->unmap_ip = map__reloc_unmap_ip;
- map->pgoff = reloc;
- }
+ if (!reloc)
+ return;
+
+ self->map_ip = map__reloc_map_ip;
+ self->unmap_ip = map__reloc_unmap_ip;
+ self->pgoff = reloc;
}
diff --git a/tools/perf/util/session.h b/tools/perf/util/session.h
index 36d1a80..752d75a 100644
--- a/tools/perf/util/session.h
+++ b/tools/perf/util/session.h
@@ -3,13 +3,13 @@

#include "event.h"
#include "header.h"
+#include "symbol.h"
#include "thread.h"
#include <linux/rbtree.h>
#include "../../../include/linux/perf_event.h"

struct ip_callchain;
struct thread;
-struct symbol;

struct perf_session {
struct perf_header header;
@@ -24,10 +24,7 @@ struct perf_session {
unsigned long unknown_events;
struct rb_root hists;
u64 sample_type;
- struct {
- const char *name;
- u64 addr;
- } ref_reloc_sym;
+ struct ref_reloc_sym ref_reloc_sym;
int fd;
int cwdlen;
char *cwd;
@@ -69,9 +66,20 @@ int perf_header__read_build_ids(struct perf_header *self, int input,
int perf_session__set_kallsyms_ref_reloc_sym(struct perf_session *self,
const char *symbol_name,
u64 addr);
-void perf_session__reloc_vmlinux_maps(struct perf_session *self,
- u64 unrelocated_addr);

void mem_bswap_64(void *src, int byte_size);

+static inline int __perf_session__create_kernel_maps(struct perf_session *self,
+ struct dso *kernel)
+{
+ return __map_groups__create_kernel_maps(&self->kmaps,
+ self->vmlinux_maps, kernel);
+}
+
+static inline struct map *
+ perf_session__new_module_map(struct perf_session *self,
+ u64 start, const char *filename)
+{
+ return map_groups__new_module(&self->kmaps, start, filename);
+}
#endif /* __PERF_SESSION_H */
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index f9049d1..6138742 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1,6 +1,5 @@
#include "util.h"
#include "../perf.h"
-#include "session.h"
#include "sort.h"
#include "string.h"
#include "symbol.h"
@@ -34,7 +33,7 @@ enum dso_origin {
static void dsos__add(struct list_head *head, struct dso *dso);
static struct map *map__new2(u64 start, struct dso *dso, enum map_type type);
static int dso__load_kernel_sym(struct dso *self, struct map *map,
- struct perf_session *session, symbol_filter_t filter);
+ symbol_filter_t filter);
static int vmlinux_path__nr_entries;
static char **vmlinux_path;

@@ -480,8 +479,9 @@ static int dso__load_all_kallsyms(struct dso *self, const char *filename,
* the original ELF section names vmlinux have.
*/
static int dso__split_kallsyms(struct dso *self, struct map *map,
- struct perf_session *session, symbol_filter_t filter)
+ symbol_filter_t filter)
{
+ struct map_groups *kmaps = map__kmap(map)->kmaps;
struct map *curr_map = map;
struct symbol *pos;
int count = 0;
@@ -503,7 +503,7 @@ static int dso__split_kallsyms(struct dso *self, struct map *map,
*module++ = '\0';

if (strcmp(curr_map->dso->short_name, module)) {
- curr_map = map_groups__find_by_name(&session->kmaps, map->type, module);
+ curr_map = map_groups__find_by_name(kmaps, map->type, module);
if (curr_map == NULL) {
pr_debug("/proc/{kallsyms,modules} "
"inconsistency while looking "
@@ -538,7 +538,7 @@ static int dso__split_kallsyms(struct dso *self, struct map *map,
}

curr_map->map_ip = curr_map->unmap_ip = identity__map_ip;
- map_groups__insert(&session->kmaps, curr_map);
+ map_groups__insert(kmaps, curr_map);
++kernel_range;
}

@@ -557,9 +557,8 @@ discard_symbol: rb_erase(&pos->rb_node, root);
return count;
}

-
-static int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map,
- struct perf_session *session, symbol_filter_t filter)
+int dso__load_kallsyms(struct dso *self, const char *filename,
+ struct map *map, symbol_filter_t filter)
{
if (dso__load_all_kallsyms(self, filename, map) < 0)
return -1;
@@ -567,7 +566,7 @@ static int dso__load_kallsyms(struct dso *self, const char *filename, struct map
symbols__fixup_end(&self->symbols[map->type]);
self->origin = DSO__ORIG_KERNEL;

- return dso__split_kallsyms(self, map, session, filter);
+ return dso__split_kallsyms(self, map, filter);
}

static int dso__load_perf_map(struct dso *self, struct map *map,
@@ -893,10 +892,10 @@ static bool elf_sec__is_a(GElf_Shdr *self, Elf_Data *secstrs, enum map_type type
}
}

-static int dso__load_sym(struct dso *self, struct map *map,
- struct perf_session *session, const char *name, int fd,
- symbol_filter_t filter, int kernel, int kmodule)
+static int dso__load_sym(struct dso *self, struct map *map, const char *name,
+ int fd, symbol_filter_t filter, int kmodule)
{
+ struct kmap *kmap = self->kernel ? map__kmap(map) : NULL;
struct map *curr_map = map;
struct dso *curr_dso = self;
size_t dso_name_len = strlen(self->short_name);
@@ -953,7 +952,7 @@ static int dso__load_sym(struct dso *self, struct map *map,
nr_syms = shdr.sh_size / shdr.sh_entsize;

memset(&sym, 0, sizeof(sym));
- if (!kernel) {
+ if (!self->kernel) {
self->adjust_symbols = (ehdr.e_type == ET_EXEC ||
elf_section_by_name(elf, &ehdr, &shdr,
".gnu.prelink_undo",
@@ -967,9 +966,9 @@ static int dso__load_sym(struct dso *self, struct map *map,
int is_label = elf_sym__is_label(&sym);
const char *section_name;

- if (kernel && session->ref_reloc_sym.name != NULL &&
- strcmp(elf_name, session->ref_reloc_sym.name) == 0)
- perf_session__reloc_vmlinux_maps(session, sym.st_value);
+ if (kmap && kmap->ref_reloc_sym && kmap->ref_reloc_sym->name &&
+ strcmp(elf_name, kmap->ref_reloc_sym->name) == 0)
+ kmap->ref_reloc_sym->unrelocated_addr = sym.st_value;

if (!is_label && !elf_sym__is_a(&sym, map->type))
continue;
@@ -985,7 +984,7 @@ static int dso__load_sym(struct dso *self, struct map *map,

section_name = elf_sec__name(&shdr, secstrs);

- if (kernel || kmodule) {
+ if (self->kernel || kmodule) {
char dso_name[PATH_MAX];

if (strcmp(section_name,
@@ -1001,7 +1000,7 @@ static int dso__load_sym(struct dso *self, struct map *map,
snprintf(dso_name, sizeof(dso_name),
"%s%s", self->short_name, section_name);

- curr_map = map_groups__find_by_name(&session->kmaps, map->type, dso_name);
+ curr_map = map_groups__find_by_name(kmap->kmaps, map->type, dso_name);
if (curr_map == NULL) {
u64 start = sym.st_value;

@@ -1020,7 +1019,7 @@ static int dso__load_sym(struct dso *self, struct map *map,
curr_map->map_ip = identity__map_ip;
curr_map->unmap_ip = identity__map_ip;
curr_dso->origin = DSO__ORIG_KERNEL;
- map_groups__insert(&session->kmaps, curr_map);
+ map_groups__insert(kmap->kmaps, curr_map);
dsos__add(&dsos__kernel, curr_dso);
} else
curr_dso = curr_map->dso;
@@ -1236,8 +1235,7 @@ char dso__symtab_origin(const struct dso *self)
return origin[self->origin];
}

-int dso__load(struct dso *self, struct map *map, struct perf_session *session,
- symbol_filter_t filter)
+int dso__load(struct dso *self, struct map *map, symbol_filter_t filter)
{
int size = PATH_MAX;
char *name;
@@ -1249,7 +1247,7 @@ int dso__load(struct dso *self, struct map *map, struct perf_session *session,
dso__set_loaded(self, map->type);

if (self->kernel)
- return dso__load_kernel_sym(self, map, session, filter);
+ return dso__load_kernel_sym(self, map, filter);

name = malloc(size);
if (!name)
@@ -1320,7 +1318,7 @@ open_file:
fd = open(name, O_RDONLY);
} while (fd < 0);

- ret = dso__load_sym(self, map, NULL, name, fd, filter, 0, 0);
+ ret = dso__load_sym(self, map, name, fd, filter, 0);
close(fd);

/*
@@ -1376,7 +1374,7 @@ static int dso__kernel_module_get_build_id(struct dso *self)
return 0;
}

-static int perf_session__set_modules_path_dir(struct perf_session *self, char *dirname)
+static int map_groups__set_modules_path_dir(struct map_groups *self, char *dirname)
{
struct dirent *dent;
DIR *dir = opendir(dirname);
@@ -1396,7 +1394,7 @@ static int perf_session__set_modules_path_dir(struct perf_session *self, char *d

snprintf(path, sizeof(path), "%s/%s",
dirname, dent->d_name);
- if (perf_session__set_modules_path_dir(self, path) < 0)
+ if (map_groups__set_modules_path_dir(self, path) < 0)
goto failure;
} else {
char *dot = strrchr(dent->d_name, '.'),
@@ -1410,7 +1408,7 @@ static int perf_session__set_modules_path_dir(struct perf_session *self, char *d
(int)(dot - dent->d_name), dent->d_name);

strxfrchar(dso_name, '-', '_');
- map = map_groups__find_by_name(&self->kmaps, MAP__FUNCTION, dso_name);
+ map = map_groups__find_by_name(self, MAP__FUNCTION, dso_name);
if (map == NULL)
continue;

@@ -1431,7 +1429,7 @@ failure:
return -1;
}

-static int perf_session__set_modules_path(struct perf_session *self)
+static int map_groups__set_modules_path(struct map_groups *self)
{
struct utsname uts;
char modules_path[PATH_MAX];
@@ -1442,7 +1440,7 @@ static int perf_session__set_modules_path(struct perf_session *self)
snprintf(modules_path, sizeof(modules_path), "/lib/modules/%s/kernel",
uts.release);

- return perf_session__set_modules_path_dir(self, modules_path);
+ return map_groups__set_modules_path_dir(self, modules_path);
}

/*
@@ -1452,8 +1450,8 @@ static int perf_session__set_modules_path(struct perf_session *self)
*/
static struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
{
- struct map *self = malloc(sizeof(*self));
-
+ struct map *self = zalloc(sizeof(*self) +
+ (dso->kernel ? sizeof(struct kmap) : 0));
if (self != NULL) {
/*
* ->end will be filled after we load all the symbols
@@ -1464,8 +1462,8 @@ static struct map *map__new2(u64 start, struct dso *dso, enum map_type type)
return self;
}

-struct map *perf_session__new_module_map(struct perf_session *self, u64 start,
- const char *filename)
+struct map *map_groups__new_module(struct map_groups *self, u64 start,
+ const char *filename)
{
struct map *map;
struct dso *dso = __dsos__findnew(&dsos__kernel, filename);
@@ -1478,11 +1476,11 @@ struct map *perf_session__new_module_map(struct perf_session *self, u64 start,
return NULL;

dso->origin = DSO__ORIG_KMODULE;
- map_groups__insert(&self->kmaps, map);
+ map_groups__insert(self, map);
return map;
}

-static int perf_session__create_module_maps(struct perf_session *self)
+static int map_groups__create_modules(struct map_groups *self)
{
char *line = NULL;
size_t n;
@@ -1520,7 +1518,7 @@ static int perf_session__create_module_maps(struct perf_session *self)
*sep = '\0';

snprintf(name, sizeof(name), "[%s]", line);
- map = perf_session__new_module_map(self, start, name);
+ map = map_groups__new_module(self, start, name);
if (map == NULL)
goto out_delete_line;
dso__kernel_module_get_build_id(map->dso);
@@ -1529,7 +1527,7 @@ static int perf_session__create_module_maps(struct perf_session *self)
free(line);
fclose(file);

- return perf_session__set_modules_path(self);
+ return map_groups__set_modules_path(self);

out_delete_line:
free(line);
@@ -1538,7 +1536,6 @@ out_failure:
}

static int dso__load_vmlinux(struct dso *self, struct map *map,
- struct perf_session *session,
const char *vmlinux, symbol_filter_t filter)
{
int err = -1, fd;
@@ -1572,14 +1569,14 @@ static int dso__load_vmlinux(struct dso *self, struct map *map,
return -1;

dso__set_loaded(self, map->type);
- err = dso__load_sym(self, map, session, vmlinux, fd, filter, 1, 0);
+ err = dso__load_sym(self, map, vmlinux, fd, filter, 0);
close(fd);

return err;
}

int dso__load_vmlinux_path(struct dso *self, struct map *map,
- struct perf_session *session, symbol_filter_t filter)
+ symbol_filter_t filter)
{
int i, err = 0;

@@ -1587,8 +1584,7 @@ int dso__load_vmlinux_path(struct dso *self, struct map *map,
vmlinux_path__nr_entries);

for (i = 0; i < vmlinux_path__nr_entries; ++i) {
- err = dso__load_vmlinux(self, map, session, vmlinux_path[i],
- filter);
+ err = dso__load_vmlinux(self, map, vmlinux_path[i], filter);
if (err > 0) {
pr_debug("Using %s for symbols\n", vmlinux_path[i]);
dso__set_long_name(self, strdup(vmlinux_path[i]));
@@ -1600,7 +1596,7 @@ int dso__load_vmlinux_path(struct dso *self, struct map *map,
}

static int dso__load_kernel_sym(struct dso *self, struct map *map,
- struct perf_session *session, symbol_filter_t filter)
+ symbol_filter_t filter)
{
int err;
const char *kallsyms_filename = NULL;
@@ -1621,13 +1617,13 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
* match.
*/
if (symbol_conf.vmlinux_name != NULL) {
- err = dso__load_vmlinux(self, map, session,
+ err = dso__load_vmlinux(self, map,
symbol_conf.vmlinux_name, filter);
goto out_try_fixup;
}

if (vmlinux_path != NULL) {
- err = dso__load_vmlinux_path(self, map, session, filter);
+ err = dso__load_vmlinux_path(self, map, filter);
if (err > 0)
goto out_fixup;
}
@@ -1675,7 +1671,7 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
}

do_kallsyms:
- err = dso__load_kallsyms(self, kallsyms_filename, map, session, filter);
+ err = dso__load_kallsyms(self, kallsyms_filename, map, filter);
free(kallsyms_allocated_filename);

out_try_fixup:
@@ -1812,30 +1808,23 @@ int __map_groups__create_kernel_maps(struct map_groups *self,
enum map_type type;

for (type = 0; type < MAP__NR_TYPES; ++type) {
+ struct kmap *kmap;
+
vmlinux_maps[type] = map__new2(0, kernel, type);
if (vmlinux_maps[type] == NULL)
return -1;

vmlinux_maps[type]->map_ip =
vmlinux_maps[type]->unmap_ip = identity__map_ip;
+
+ kmap = map__kmap(vmlinux_maps[type]);
+ kmap->kmaps = self;
map_groups__insert(self, vmlinux_maps[type]);
}

return 0;
}

-static int map_groups__create_kernel_maps(struct map_groups *self,
- struct map *vmlinux_maps[MAP__NR_TYPES],
- const char *vmlinux)
-{
- struct dso *kernel = dsos__create_kernel(vmlinux);
-
- if (kernel == NULL)
- return -1;
-
- return __map_groups__create_kernel_maps(self, vmlinux_maps, kernel);
-}
-
static void vmlinux_path__exit(void)
{
while (--vmlinux_path__nr_entries >= 0) {
@@ -1941,19 +1930,22 @@ out_free_comm_list:
return -1;
}

-int perf_session__create_kernel_maps(struct perf_session *self)
+int map_groups__create_kernel_maps(struct map_groups *self,
+ struct map *vmlinux_maps[MAP__NR_TYPES])
{
- if (map_groups__create_kernel_maps(&self->kmaps, self->vmlinux_maps,
- symbol_conf.vmlinux_name) < 0)
+ struct dso *kernel = dsos__create_kernel(symbol_conf.vmlinux_name);
+
+ if (kernel == NULL)
+ return -1;
+
+ if (__map_groups__create_kernel_maps(self, vmlinux_maps, kernel) < 0)
return -1;

- if (symbol_conf.use_modules &&
- perf_session__create_module_maps(self) < 0)
- pr_debug("Failed to load list of modules for session %s, "
- "continuing...\n", self->filename);
+ if (symbol_conf.use_modules && map_groups__create_modules(self) < 0)
+ return -1;
/*
* Now that we have all the maps created, just set the ->end of them:
*/
- map_groups__fixup_end(&self->kmaps);
+ map_groups__fixup_end(self);
return 0;
}
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 1243027..e6a59e5 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -80,6 +80,12 @@ static inline void *symbol__priv(struct symbol *self)
return ((void *)self) - symbol_conf.priv_size;
}

+struct ref_reloc_sym {
+ const char *name;
+ u64 addr;
+ u64 unrelocated_addr;
+};
+
struct addr_location {
struct thread *thread;
struct map *map;
@@ -126,12 +132,11 @@ static inline struct dso *dsos__findnew(const char *name)
return __dsos__findnew(&dsos__user, name);
}

-struct perf_session;
-
-int dso__load(struct dso *self, struct map *map, struct perf_session *session,
- symbol_filter_t filter);
+int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
int dso__load_vmlinux_path(struct dso *self, struct map *map,
- struct perf_session *session, symbol_filter_t filter);
+ symbol_filter_t filter);
+int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map,
+ symbol_filter_t filter);
void dsos__fprintf(FILE *fp);
size_t dsos__fprintf_buildid(FILE *fp, bool with_hits);

@@ -156,9 +161,5 @@ int kallsyms__parse(const char *filename, void *arg,
int symbol__init(void);
bool symbol_type__is_a(char symbol_type, enum map_type map_type);

-int perf_session__create_kernel_maps(struct perf_session *self);
-
-struct map *perf_session__new_module_map(struct perf_session *self, u64 start,
- const char *filename);
extern struct dso *vdso;
#endif /* __PERF_SYMBOL */
diff --git a/tools/perf/util/thread.c b/tools/perf/util/thread.c
index 4a08dcf..634b7f7 100644
--- a/tools/perf/util/thread.c
+++ b/tools/perf/util/thread.c
@@ -282,14 +282,13 @@ size_t perf_session__fprintf(struct perf_session *self, FILE *fp)
}

struct symbol *map_groups__find_symbol(struct map_groups *self,
- struct perf_session *session,
enum map_type type, u64 addr,
symbol_filter_t filter)
{
struct map *map = map_groups__find(self, type, addr);

if (map != NULL)
- return map__find_symbol(map, session, map->map_ip(map, addr), filter);
+ return map__find_symbol(map, map->map_ip(map, addr), filter);

return NULL;
}
diff --git a/tools/perf/util/thread.h b/tools/perf/util/thread.h
index e35653c..56f317b 100644
--- a/tools/perf/util/thread.h
+++ b/tools/perf/util/thread.h
@@ -59,15 +59,14 @@ void thread__find_addr_location(struct thread *self,
struct addr_location *al,
symbol_filter_t filter);
struct symbol *map_groups__find_symbol(struct map_groups *self,
- struct perf_session *session,
enum map_type type, u64 addr,
symbol_filter_t filter);

-static inline struct symbol *
-map_groups__find_function(struct map_groups *self, struct perf_session *session,
- u64 addr, symbol_filter_t filter)
+static inline struct symbol *map_groups__find_function(struct map_groups *self,
+ u64 addr,
+ symbol_filter_t filter)
{
- return map_groups__find_symbol(self, session, MAP__FUNCTION, addr, filter);
+ return map_groups__find_symbol(self, MAP__FUNCTION, addr, filter);
}

struct map *map_groups__find_by_name(struct map_groups *self,
@@ -76,4 +75,9 @@ struct map *map_groups__find_by_name(struct map_groups *self,
int __map_groups__create_kernel_maps(struct map_groups *self,
struct map *vmlinux_maps[MAP__NR_TYPES],
struct dso *kernel);
+int map_groups__create_kernel_maps(struct map_groups *self,
+ struct map *vmlinux_maps[MAP__NR_TYPES]);
+
+struct map *map_groups__new_module(struct map_groups *self, u64 start,
+ const char *filename);
#endif /* __PERF_THREAD_H */
--
1.6.2.5

2010-01-27 23:06:11

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 6/9] perf: Ignore perf-archive temp file

From: John Kacur <[email protected]>

Tell git to ignore perf-archive.

Cc: Ingo Molnar <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Signed-off-by: John Kacur <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/.gitignore | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore
index 124760b..e1d60d7 100644
--- a/tools/perf/.gitignore
+++ b/tools/perf/.gitignore
@@ -14,6 +14,7 @@ perf*.html
common-cmds.h
perf.data
perf.data.old
+perf-archive
tags
TAGS
cscope*
--
1.6.2.5

2010-01-27 23:07:40

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 8/9] perf symbols: Fixup vsyscall maps

From: Arnaldo Carvalho de Melo <[email protected]>

While debugging a problem reported by Pekka Enberg by printing the IP
and all the maps for a thread when we don't find a map for an IP I
noticed that dso__load_sym needs to fixup these extra maps it creates to
hold symbols in different ELF sections than the main kernel one.

Now we're back showing things like:

[root@doppio linux-2.6-tip]# perf report | grep vsyscall
0.02% mutt [kernel.kallsyms].vsyscall_fn [.] vread_hpet
0.01% named [kernel.kallsyms].vsyscall_fn [.] vread_hpet
0.01% NetworkManager [kernel.kallsyms].vsyscall_fn [.] vread_hpet
0.01% gconfd-2 [kernel.kallsyms].vsyscall_0 [.] vgettimeofday
0.01% hald-addon-rfki [kernel.kallsyms].vsyscall_fn [.] vread_hpet
0.00% dbus-daemon [kernel.kallsyms].vsyscall_fn [.] vread_hpet
[root@doppio linux-2.6-tip]#

Cc: Frédéric Weisbecker <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Pekka Enberg <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/symbol.c | 13 +++++++++++--
1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 6138742..051d71b 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1011,7 +1011,7 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
if (curr_dso == NULL)
goto out_elf_end;
curr_map = map__new2(start, curr_dso,
- MAP__FUNCTION);
+ map->type);
if (curr_map == NULL) {
dso__delete(curr_dso);
goto out_elf_end;
@@ -1021,6 +1021,7 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
curr_dso->origin = DSO__ORIG_KERNEL;
map_groups__insert(kmap->kmaps, curr_map);
dsos__add(&dsos__kernel, curr_dso);
+ dso__set_loaded(curr_dso, map->type);
} else
curr_dso = curr_map->dso;

@@ -1058,8 +1059,16 @@ new_symbol:
/*
* For misannotated, zeroed, ASM function sizes.
*/
- if (nr > 0)
+ if (nr > 0) {
symbols__fixup_end(&self->symbols[map->type]);
+ if (kmap) {
+ /*
+ * We need to fixup this here too because we create new
+ * maps here, for things like vsyscall sections.
+ */
+ __map_groups__fixup_end(kmap->kmaps, map->type);
+ }
+ }
err = nr;
out_elf_end:
elf_end(elf);
--
1.6.2.5

2010-01-27 23:07:16

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 2/9] perf symbols: Factor out dso__load_vmlinux_path()

From: Arnaldo Carvalho de Melo <[email protected]>

So that we can call it directly from regression tests, and also to
reduce the size of dso__load_kernel_sym(), making it more clear.

Cc: Frédéric Weisbecker <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/symbol.c | 38 ++++++++++++++++++++++++--------------
tools/perf/util/symbol.h | 2 ++
2 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index f1f609d..26ec603 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1578,6 +1578,27 @@ static int dso__load_vmlinux(struct dso *self, struct map *map,
return err;
}

+int dso__load_vmlinux_path(struct dso *self, struct map *map,
+ struct perf_session *session, symbol_filter_t filter)
+{
+ int i, err = 0;
+
+ pr_debug("Looking at the vmlinux_path (%d entries long)\n",
+ vmlinux_path__nr_entries);
+
+ for (i = 0; i < vmlinux_path__nr_entries; ++i) {
+ err = dso__load_vmlinux(self, map, session, vmlinux_path[i],
+ filter);
+ if (err > 0) {
+ pr_debug("Using %s for symbols\n", vmlinux_path[i]);
+ dso__set_long_name(self, strdup(vmlinux_path[i]));
+ break;
+ }
+ }
+
+ return err;
+}
+
static int dso__load_kernel_sym(struct dso *self, struct map *map,
struct perf_session *session, symbol_filter_t filter)
{
@@ -1606,20 +1627,9 @@ static int dso__load_kernel_sym(struct dso *self, struct map *map,
}

if (vmlinux_path != NULL) {
- int i;
- pr_debug("Looking at the vmlinux_path (%d entries long)\n",
- vmlinux_path__nr_entries);
- for (i = 0; i < vmlinux_path__nr_entries; ++i) {
- err = dso__load_vmlinux(self, map, session,
- vmlinux_path[i], filter);
- if (err > 0) {
- pr_debug("Using %s for symbols\n",
- vmlinux_path[i]);
- dso__set_long_name(self,
- strdup(vmlinux_path[i]));
- goto out_fixup;
- }
- }
+ err = dso__load_vmlinux_path(self, map, session, filter);
+ if (err > 0)
+ goto out_fixup;
}

/*
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index ffe0b0f..a94997a 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -129,6 +129,8 @@ struct perf_session;

int dso__load(struct dso *self, struct map *map, struct perf_session *session,
symbol_filter_t filter);
+int dso__load_vmlinux_path(struct dso *self, struct map *map,
+ struct perf_session *session, symbol_filter_t filter);
void dsos__fprintf(FILE *fp);
size_t dsos__fprintf_buildid(FILE *fp, bool with_hits);

--
1.6.2.5

2010-01-27 23:07:42

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: [PATCH 3/9] perf symbols: Split helpers used when creating kernel dso object

From: Arnaldo Carvalho de Melo <[email protected]>

To make it clear and allow for direct usage by, for instance, regression
test suites.

Cc: Frédéric Weisbecker <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/symbol.c | 28 +++++++++++++++++++++-------
tools/perf/util/symbol.h | 2 ++
2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 26ec603..f9049d1 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -1762,24 +1762,38 @@ size_t dsos__fprintf_buildid(FILE *fp, bool with_hits)
__dsos__fprintf_buildid(&dsos__user, fp, with_hits));
}

+struct dso *dso__new_kernel(const char *name)
+{
+ struct dso *self = dso__new(name ?: "[kernel.kallsyms]");
+
+ if (self != NULL) {
+ self->short_name = "[kernel]";
+ self->kernel = 1;
+ }
+
+ return self;
+}
+
+void dso__read_running_kernel_build_id(struct dso *self)
+{
+ if (sysfs__read_build_id("/sys/kernel/notes", self->build_id,
+ sizeof(self->build_id)) == 0)
+ self->has_build_id = true;
+}
+
static struct dso *dsos__create_kernel(const char *vmlinux)
{
- struct dso *kernel = dso__new(vmlinux ?: "[kernel.kallsyms]");
+ struct dso *kernel = dso__new_kernel(vmlinux);

if (kernel == NULL)
return NULL;

- kernel->short_name = "[kernel]";
- kernel->kernel = 1;
-
vdso = dso__new("[vdso]");
if (vdso == NULL)
goto out_delete_kernel_dso;
dso__set_loaded(vdso, MAP__FUNCTION);

- if (sysfs__read_build_id("/sys/kernel/notes", kernel->build_id,
- sizeof(kernel->build_id)) == 0)
- kernel->has_build_id = true;
+ dso__read_running_kernel_build_id(kernel);

dsos__add(&dsos__kernel, kernel);
dsos__add(&dsos__user, vdso);
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index a94997a..1243027 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -109,6 +109,7 @@ struct dso {
};

struct dso *dso__new(const char *name);
+struct dso *dso__new_kernel(const char *name);
void dso__delete(struct dso *self);

bool dso__loaded(const struct dso *self, enum map_type type);
@@ -139,6 +140,7 @@ size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp);
char dso__symtab_origin(const struct dso *self);
void dso__set_long_name(struct dso *self, char *name);
void dso__set_build_id(struct dso *self, void *build_id);
+void dso__read_running_kernel_build_id(struct dso *self);
struct symbol *dso__find_symbol(struct dso *self, enum map_type type, u64 addr);
struct symbol *dso__find_symbol_by_name(struct dso *self, enum map_type type,
const char *name);
--
1.6.2.5

2010-01-27 23:18:35

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH 4/9] perf session: Create kernel maps in the constructor

Arnaldo Carvalho de Melo wrote:
> From: Arnaldo Carvalho de Melo <[email protected]>
>
> Removing one extra step needed in the tools that need this, fixing a bug
> in 'perf probe' where this was not being done.

Thanks,
BTW, when O_WRONLY should be used? I guess I might misunderstand something
in builtin-probe.c, and it should use O_RDONLY ...



--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]

2010-01-27 23:29:52

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 4/9] perf session: Create kernel maps in the constructor

Em Wed, Jan 27, 2010 at 06:17:58PM -0500, Masami Hiramatsu escreveu:
> Arnaldo Carvalho de Melo wrote:
> > From: Arnaldo Carvalho de Melo <[email protected]>
> >
> > Removing one extra step needed in the tools that need this, fixing a bug
> > in 'perf probe' where this was not being done.
>
> Thanks,
> BTW, when O_WRONLY should be used? I guess I might misunderstand something
> in builtin-probe.c, and it should use O_RDONLY ...

O_RDONLY only when you have a perf.data file, O_WRONLY was thought for
'perf record', then for tools that want only to do symbol lookup it was
reused...

I think we should have a proper enum and more clearly specify these
semantics, as well as adding a MMAP mode so that we can lift the code
now in perf top somehow.

But for now using O_WRONLY provides what 'perf probe' needs, I guess :-)

- Arnaldo

2010-01-28 16:29:13

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH 4/9] perf session: Create kernel maps in the constructor

Arnaldo Carvalho de Melo wrote:
> Em Wed, Jan 27, 2010 at 06:17:58PM -0500, Masami Hiramatsu escreveu:
>> Arnaldo Carvalho de Melo wrote:
>>> From: Arnaldo Carvalho de Melo <[email protected]>
>>>
>>> Removing one extra step needed in the tools that need this, fixing a bug
>>> in 'perf probe' where this was not being done.
>>
>> Thanks,
>> BTW, when O_WRONLY should be used? I guess I might misunderstand something
>> in builtin-probe.c, and it should use O_RDONLY ...
>
> O_RDONLY only when you have a perf.data file, O_WRONLY was thought for
> 'perf record', then for tools that want only to do symbol lookup it was
> reused...

Ah, so that is the mode for perf.data.

> I think we should have a proper enum and more clearly specify these
> semantics, as well as adding a MMAP mode so that we can lift the code
> now in perf top somehow.

Yeah, and if you can separate an interface only for handling symbols
from debug/elf binaries, it will be helpful for me too.

> But for now using O_WRONLY provides what 'perf probe' needs, I guess :-)

I think so ;-)

Acked-by: Masami Hiramatsu <[email protected]>

Thank you,

--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]

2010-01-28 18:30:40

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 4/9] perf session: Create kernel maps in the constructor

Em Thu, Jan 28, 2010 at 11:28:29AM -0500, Masami Hiramatsu escreveu:

> Yeah, and if you can separate an interface only for handling symbols
> from debug/elf binaries, it will be helpful for me too.

It was done on this same series, now you can do as the patch at the end
of this message, that will be on my next series, does.

Testing with this patch:

[root@doppio ~]# perf probe --list
[root@doppio ~]# perf probe schedule
Added new event:
probe:schedule (on schedule+0)

You can now use it on all perf tools, such as:

perf record -e probe:schedule -a sleep 1

[root@doppio ~]# perf record -e probe:schedule -a sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.158 MB perf.data (~6923 samples) ]
[root@doppio ~]# perf report | head -9
# Samples: 4
#
# Overhead Command Shared Object Symbol
# ........ ............... ..................... ......
#
25.00% perf libc-2.10.2.so [.] __GI___libc_read
25.00% kondemand/1 [kernel.kallsyms] [k] kernel_thread_helper
25.00% kondemand/0 [kernel.kallsyms] [k] kernel_thread_helper
[root@doppio ~]#

And what about support for modules? You have everything you need there
as well :-)

If you do:

struct map *mod;
struct symbol *sym;

mod = map_groups__find_by_name(&session.kmap_groups,
MAP__FUNCTION, "[ipv6]");

sym = map__find_symbol_by_name(module, "ip6_xmit");

you'll get ipv6.ko located and loaded, mod->dso->long_name thus will
have the file to use with libdwarf and sym->start will have the
unrelocated address, and mod->start will have where ipv6 is loaded in
kernel space.

Also you should be able to find variables by name or address too, just
use MAP__VARIABLE where above you see MAP__FUNCTION.

- Arnaldo

>From 387ab05301cce32c8b091ba9feb94c906124e8a8 Mon Sep 17 00:00:00 2001
From: Arnaldo Carvalho de Melo <[email protected]>
Date: Thu, 28 Jan 2010 16:12:31 -0200
Subject: [PATCH 1/1] perf probe: Don't use a perf_session instance just to resolve symbols
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

With the recent modifications done to untie the session and symbol
layers, 'perf probe' now can use just the symbols layer.

Cc: Fr?d?ric Weisbecker <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
Cc: Mike Galbraith <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-probe.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index 4fa73ec..cd45e02 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -41,7 +41,6 @@
#include "util/debugfs.h"
#include "util/symbol.h"
#include "util/thread.h"
-#include "util/session.h"
#include "util/parse-options.h"
#include "util/parse-events.h" /* For debugfs_path */
#include "util/probe-finder.h"
@@ -59,7 +58,8 @@ static struct {
int nr_probe;
struct probe_point probes[MAX_PROBES];
struct strlist *dellist;
- struct perf_session *psession;
+ struct map_groups kmap_groups;
+ struct map *kmaps[MAP__NR_TYPES];
struct map *kmap;
struct line_range line_range;
} session;
@@ -212,10 +212,13 @@ static void init_vmlinux(void)
pr_debug("Use vmlinux: %s\n", symbol_conf.vmlinux_name);
if (symbol__init() < 0)
die("Failed to init symbol map.");
- session.psession = perf_session__new(NULL, O_WRONLY, false);
- if (session.psession == NULL)
- die("Failed to init perf_session.");
- session.kmap = session.psession->vmlinux_maps[MAP__FUNCTION];
+
+ map_groups__init(&session.kmap_groups);
+ if (map_groups__create_kernel_maps(&session.kmap_groups,
+ session.kmaps) < 0)
+ die("Failed to create kernel maps.");
+
+ session.kmap = session.kmaps[MAP__FUNCTION];
if (!session.kmap)
die("Could not find kernel map.\n");
}
--
1.6.2.5

2010-01-28 21:01:42

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH 4/9] perf session: Create kernel maps in the constructor

Arnaldo Carvalho de Melo wrote:
> Em Thu, Jan 28, 2010 at 11:28:29AM -0500, Masami Hiramatsu escreveu:
>
>> Yeah, and if you can separate an interface only for handling symbols
>> from debug/elf binaries, it will be helpful for me too.
>
> It was done on this same series, now you can do as the patch at the end
> of this message, that will be on my next series, does.

Great! thank you!

>
> Testing with this patch:
>
> [root@doppio ~]# perf probe --list
> [root@doppio ~]# perf probe schedule
> Added new event:
> probe:schedule (on schedule+0)
>
> You can now use it on all perf tools, such as:
>
> perf record -e probe:schedule -a sleep 1
>
> [root@doppio ~]# perf record -e probe:schedule -a sleep 1
> [ perf record: Woken up 1 times to write data ]
> [ perf record: Captured and wrote 0.158 MB perf.data (~6923 samples) ]
> [root@doppio ~]# perf report | head -9
> # Samples: 4
> #
> # Overhead Command Shared Object Symbol
> # ........ ............... ..................... ......
> #
> 25.00% perf libc-2.10.2.so [.] __GI___libc_read
> 25.00% kondemand/1 [kernel.kallsyms] [k] kernel_thread_helper
> 25.00% kondemand/0 [kernel.kallsyms] [k] kernel_thread_helper
> [root@doppio ~]#
>
> And what about support for modules? You have everything you need there
> as well :-)
>
> If you do:
>
> struct map *mod;
> struct symbol *sym;
>
> mod = map_groups__find_by_name(&session.kmap_groups,
> MAP__FUNCTION, "[ipv6]");
>
> sym = map__find_symbol_by_name(module, "ip6_xmit");
>
> you'll get ipv6.ko located and loaded, mod->dso->long_name thus will
> have the file to use with libdwarf and sym->start will have the
> unrelocated address, and mod->start will have where ipv6 is loaded in
> kernel space

Oh, nice :-) Is that available for the modules which aren't loaded?
And yeah, I'd like to support modules and it will requires some
enhancement in kprobe-tracer too.

.
> Also you should be able to find variables by name or address too, just
> use MAP__VARIABLE where above you see MAP__FUNCTION.
>
> - Arnaldo
>
> From 387ab05301cce32c8b091ba9feb94c906124e8a8 Mon Sep 17 00:00:00 2001
> From: Arnaldo Carvalho de Melo <[email protected]>
> Date: Thu, 28 Jan 2010 16:12:31 -0200
> Subject: [PATCH 1/1] perf probe: Don't use a perf_session instance just to resolve symbols
> MIME-Version: 1.0
> Content-Type: text/plain; charset=utf-8
> Content-Transfer-Encoding: 8bit
>
> With the recent modifications done to untie the session and symbol
> layers, 'perf probe' now can use just the symbols layer.

Could you remove session.kmap too?
other parts look good to me.

Thank you,

>
> Cc: Fr?d?ric Weisbecker <[email protected]>
> Cc: Masami Hiramatsu <[email protected]>
> Cc: Mike Galbraith <[email protected]>
> Cc: Peter Zijlstra <[email protected]>
> Cc: Paul Mackerras <[email protected]>
> Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
> ---
> tools/perf/builtin-probe.c | 15 +++++++++------
> 1 files changed, 9 insertions(+), 6 deletions(-)
>
> diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
> index 4fa73ec..cd45e02 100644
> --- a/tools/perf/builtin-probe.c
> +++ b/tools/perf/builtin-probe.c
> @@ -41,7 +41,6 @@
> #include "util/debugfs.h"
> #include "util/symbol.h"
> #include "util/thread.h"
> -#include "util/session.h"
> #include "util/parse-options.h"
> #include "util/parse-events.h" /* For debugfs_path */
> #include "util/probe-finder.h"
> @@ -59,7 +58,8 @@ static struct {
> int nr_probe;
> struct probe_point probes[MAX_PROBES];
> struct strlist *dellist;
> - struct perf_session *psession;
> + struct map_groups kmap_groups;
> + struct map *kmaps[MAP__NR_TYPES];
> struct map *kmap;


> struct line_range line_range;
> } session;
> @@ -212,10 +212,13 @@ static void init_vmlinux(void)
> pr_debug("Use vmlinux: %s\n", symbol_conf.vmlinux_name);
> if (symbol__init() < 0)
> die("Failed to init symbol map.");
> - session.psession = perf_session__new(NULL, O_WRONLY, false);
> - if (session.psession == NULL)
> - die("Failed to init perf_session.");
> - session.kmap = session.psession->vmlinux_maps[MAP__FUNCTION];
> +
> + map_groups__init(&session.kmap_groups);
> + if (map_groups__create_kernel_maps(&session.kmap_groups,
> + session.kmaps) < 0)
> + die("Failed to create kernel maps.");
> +
> + session.kmap = session.kmaps[MAP__FUNCTION];
> if (!session.kmap)
> die("Could not find kernel map.\n");
> }

--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]

2010-01-29 00:42:55

by Arnaldo Carvalho de Melo

[permalink] [raw]
Subject: Re: [PATCH 4/9] perf session: Create kernel maps in the constructor

Em Thu, Jan 28, 2010 at 03:59:38PM -0500, Masami Hiramatsu escreveu:
> Arnaldo Carvalho de Melo wrote:
> > Em Thu, Jan 28, 2010 at 11:28:29AM -0500, Masami Hiramatsu escreveu:

> >> Yeah, and if you can separate an interface only for handling symbols
> >> from debug/elf binaries, it will be helpful for me too.

> > It was done on this same series, now you can do as the patch at the end
> > of this message, that will be on my next series, does.

> Great! thank you!
<SNIP>
> > you'll get ipv6.ko located and loaded, mod->dso->long_name thus will
> > have the file to use with libdwarf and sym->start will have the
> > unrelocated address, and mod->start will have where ipv6 is loaded in
> > kernel space

> Oh, nice :-) Is that available for the modules which aren't loaded?

No it isn't, what usecase do you see where you would like to look at non
loaded modules? Traversing the /lib/modules passed can be made to just
create DSOs, not maps if we need it. Maps when created using one of these
DSOs would find them on the list.

> And yeah, I'd like to support modules and it will requires some
> enhancement in kprobe-tracer too.

Ok

<SNIP>
> > With the recent modifications done to untie the session and symbol
> > layers, 'perf probe' now can use just the symbols layer.

> Could you remove session.kmap too?
> other parts look good to me.

I'll haven't done that just to keep the patch as small as possible :-)
But will do before submitting.

> Thank you,

You're welcome,

- Arnaldo

2010-01-29 06:59:27

by Masami Hiramatsu

[permalink] [raw]
Subject: Re: [PATCH 4/9] perf session: Create kernel maps in the constructor

Arnaldo Carvalho de Melo wrote:
> Em Thu, Jan 28, 2010 at 03:59:38PM -0500, Masami Hiramatsu escreveu:
>>> you'll get ipv6.ko located and loaded, mod->dso->long_name thus will
>>> have the file to use with libdwarf and sym->start will have the
>>> unrelocated address, and mod->start will have where ipv6 is loaded in
>>> kernel space
>
>> Oh, nice :-) Is that available for the modules which aren't loaded?
>
> No it isn't, what usecase do you see where you would like to look at non
> loaded modules? Traversing the /lib/modules passed can be made to just
> create DSOs, not maps if we need it. Maps when created using one of these
> DSOs would find them on the list.

One usecase I thought is probing module init code for checking/debugging
driver initialization routine. For this purpose, build-id checking also
should be solved. If the module is not loaded, we can't check build-id
in that time. I think we can compare it when loading the module,
in kernel, if we can pass target build-id to kprobe-tracer.


>> And yeah, I'd like to support modules and it will requires some
>> enhancement in kprobe-tracer too.
>
> Ok
>
> <SNIP>
>>> With the recent modifications done to untie the session and symbol
>>> layers, 'perf probe' now can use just the symbols layer.
>
>> Could you remove session.kmap too?
>> other parts look good to me.
>
> I'll haven't done that just to keep the patch as small as possible :-)
> But will do before submitting.

Thanks! :-)

--
Masami Hiramatsu

Software Engineer
Hitachi Computer Products (America), Inc.
Software Solutions Division

e-mail: [email protected]

2010-01-29 09:33:08

by Thiago Farina

[permalink] [raw]
Subject: [tip:perf/core] tools/perf/perf.c: Clean up trivial style issues

Commit-ID: d7eeea995561a11e1a788398beb003a619e98990
Gitweb: http://git.kernel.org/tip/d7eeea995561a11e1a788398beb003a619e98990
Author: Thiago Farina <[email protected]>
AuthorDate: Wed, 27 Jan 2010 21:05:55 -0200
Committer: Ingo Molnar <[email protected]>
CommitDate: Fri, 29 Jan 2010 09:20:59 +0100

tools/perf/perf.c: Clean up trivial style issues

Checked with:
./../scripts/checkpatch.pl --terse --file perf.c

perf.c: 51: ERROR: open brace '{' following function declarations go on the next line
perf.c: 73: ERROR: "foo*** bar" should be "foo ***bar"
perf.c:112: ERROR: space prohibited before that close parenthesis ')'
perf.c:127: ERROR: space prohibited before that close parenthesis ')'
perf.c:171: ERROR: "foo** bar" should be "foo **bar"
perf.c:213: ERROR: "(foo*)" should be "(foo *)"
perf.c:216: ERROR: "(foo*)" should be "(foo *)"
perf.c:217: ERROR: space required before that '*' (ctx:OxV)
perf.c:452: ERROR: do not initialise statics to 0 or NULL
perf.c:453: ERROR: do not initialise statics to 0 or NULL

Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/perf.c | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 05c861c..109b89b 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -48,7 +48,8 @@ int check_pager_config(const char *cmd)
return c.val;
}

-static void commit_pager_choice(void) {
+static void commit_pager_choice(void)
+{
switch (use_pager) {
case 0:
setenv("PERF_PAGER", "cat", 1);
@@ -70,7 +71,7 @@ static void set_debugfs_path(void)
"tracing/events");
}

-static int handle_options(const char*** argv, int* argc, int* envchanged)
+static int handle_options(const char ***argv, int *argc, int *envchanged)
{
int handled = 0;

@@ -109,7 +110,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--perf-dir")) {
if (*argc < 2) {
- fprintf(stderr, "No directory given for --perf-dir.\n" );
+ fprintf(stderr, "No directory given for --perf-dir.\n");
usage(perf_usage_string);
}
setenv(PERF_DIR_ENVIRONMENT, (*argv)[1], 1);
@@ -124,7 +125,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--work-tree")) {
if (*argc < 2) {
- fprintf(stderr, "No directory given for --work-tree.\n" );
+ fprintf(stderr, "No directory given for --work-tree.\n");
usage(perf_usage_string);
}
setenv(PERF_WORK_TREE_ENVIRONMENT, (*argv)[1], 1);
@@ -168,7 +169,7 @@ static int handle_alias(int *argcp, const char ***argv)
{
int envchanged = 0, ret = 0, saved_errno = errno;
int count, option_count;
- const char** new_argv;
+ const char **new_argv;
const char *alias_command;
char *alias_string;

@@ -210,11 +211,11 @@ static int handle_alias(int *argcp, const char ***argv)
if (!strcmp(alias_command, new_argv[0]))
die("recursive alias: %s", alias_command);

- new_argv = realloc(new_argv, sizeof(char*) *
+ new_argv = realloc(new_argv, sizeof(char *) *
(count + *argcp + 1));
/* insert after command name */
- memcpy(new_argv + count, *argv + 1, sizeof(char*) * *argcp);
- new_argv[count+*argcp] = NULL;
+ memcpy(new_argv + count, *argv + 1, sizeof(char *) * *argcp);
+ new_argv[count + *argcp] = NULL;

*argv = new_argv;
*argcp += count - 1;
@@ -450,8 +451,8 @@ int main(int argc, const char **argv)
setup_path();

while (1) {
- static int done_help = 0;
- static int was_alias = 0;
+ static int done_help;
+ static int was_alias;

was_alias = run_argv(&argc, &argv);
if (errno != ENOENT)

2010-01-29 09:34:06

by John Kacur

[permalink] [raw]
Subject: [tip:perf/core] perf: Ignore perf-archive temp file

Commit-ID: fbe346c280823783bd1e5eac1980a57667363c1b
Gitweb: http://git.kernel.org/tip/fbe346c280823783bd1e5eac1980a57667363c1b
Author: John Kacur <[email protected]>
AuthorDate: Wed, 27 Jan 2010 21:05:54 -0200
Committer: Ingo Molnar <[email protected]>
CommitDate: Fri, 29 Jan 2010 09:25:37 +0100

perf: Ignore perf-archive temp file

Tell git to ignore perf-archive.

Signed-off-by: John Kacur <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/.gitignore | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore
index 124760b..e1d60d7 100644
--- a/tools/perf/.gitignore
+++ b/tools/perf/.gitignore
@@ -14,6 +14,7 @@ perf*.html
common-cmds.h
perf.data
perf.data.old
+perf-archive
tags
TAGS
cscope*

2010-01-29 09:40:18

by John Kacur

[permalink] [raw]
Subject: [tip:perf/core] perf: Ignore perf-archive temp file

Commit-ID: 6a1b751fb89b61ef7240f2e3ed65a2e2776e7cfd
Gitweb: http://git.kernel.org/tip/6a1b751fb89b61ef7240f2e3ed65a2e2776e7cfd
Author: John Kacur <[email protected]>
AuthorDate: Wed, 27 Jan 2010 21:05:54 -0200
Committer: Ingo Molnar <[email protected]>
CommitDate: Fri, 29 Jan 2010 10:37:33 +0100

perf: Ignore perf-archive temp file

Tell git to ignore perf-archive.

Signed-off-by: John Kacur <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/.gitignore | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore
index 124760b..e1d60d7 100644
--- a/tools/perf/.gitignore
+++ b/tools/perf/.gitignore
@@ -14,6 +14,7 @@ perf*.html
common-cmds.h
perf.data
perf.data.old
+perf-archive
tags
TAGS
cscope*

2010-01-29 09:40:29

by Thiago Farina

[permalink] [raw]
Subject: [tip:perf/core] tools/perf/perf.c: Clean up trivial style issues

Commit-ID: 4c574159d03f4d8a136a7adff2d0b1d82cadcb18
Gitweb: http://git.kernel.org/tip/4c574159d03f4d8a136a7adff2d0b1d82cadcb18
Author: Thiago Farina <[email protected]>
AuthorDate: Wed, 27 Jan 2010 21:05:55 -0200
Committer: Ingo Molnar <[email protected]>
CommitDate: Fri, 29 Jan 2010 10:36:35 +0100

tools/perf/perf.c: Clean up trivial style issues

Checked with:
./../scripts/checkpatch.pl --terse --file perf.c

perf.c: 51: ERROR: open brace '{' following function declarations go on the next line
perf.c: 73: ERROR: "foo*** bar" should be "foo ***bar"
perf.c:112: ERROR: space prohibited before that close parenthesis ')'
perf.c:127: ERROR: space prohibited before that close parenthesis ')'
perf.c:171: ERROR: "foo** bar" should be "foo **bar"
perf.c:213: ERROR: "(foo*)" should be "(foo *)"
perf.c:216: ERROR: "(foo*)" should be "(foo *)"
perf.c:217: ERROR: space required before that '*' (ctx:OxV)
perf.c:452: ERROR: do not initialise statics to 0 or NULL
perf.c:453: ERROR: do not initialise statics to 0 or NULL

Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Frederic Weisbecker <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
---
tools/perf/perf.c | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/tools/perf/perf.c b/tools/perf/perf.c
index 05c861c..109b89b 100644
--- a/tools/perf/perf.c
+++ b/tools/perf/perf.c
@@ -48,7 +48,8 @@ int check_pager_config(const char *cmd)
return c.val;
}

-static void commit_pager_choice(void) {
+static void commit_pager_choice(void)
+{
switch (use_pager) {
case 0:
setenv("PERF_PAGER", "cat", 1);
@@ -70,7 +71,7 @@ static void set_debugfs_path(void)
"tracing/events");
}

-static int handle_options(const char*** argv, int* argc, int* envchanged)
+static int handle_options(const char ***argv, int *argc, int *envchanged)
{
int handled = 0;

@@ -109,7 +110,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--perf-dir")) {
if (*argc < 2) {
- fprintf(stderr, "No directory given for --perf-dir.\n" );
+ fprintf(stderr, "No directory given for --perf-dir.\n");
usage(perf_usage_string);
}
setenv(PERF_DIR_ENVIRONMENT, (*argv)[1], 1);
@@ -124,7 +125,7 @@ static int handle_options(const char*** argv, int* argc, int* envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--work-tree")) {
if (*argc < 2) {
- fprintf(stderr, "No directory given for --work-tree.\n" );
+ fprintf(stderr, "No directory given for --work-tree.\n");
usage(perf_usage_string);
}
setenv(PERF_WORK_TREE_ENVIRONMENT, (*argv)[1], 1);
@@ -168,7 +169,7 @@ static int handle_alias(int *argcp, const char ***argv)
{
int envchanged = 0, ret = 0, saved_errno = errno;
int count, option_count;
- const char** new_argv;
+ const char **new_argv;
const char *alias_command;
char *alias_string;

@@ -210,11 +211,11 @@ static int handle_alias(int *argcp, const char ***argv)
if (!strcmp(alias_command, new_argv[0]))
die("recursive alias: %s", alias_command);

- new_argv = realloc(new_argv, sizeof(char*) *
+ new_argv = realloc(new_argv, sizeof(char *) *
(count + *argcp + 1));
/* insert after command name */
- memcpy(new_argv + count, *argv + 1, sizeof(char*) * *argcp);
- new_argv[count+*argcp] = NULL;
+ memcpy(new_argv + count, *argv + 1, sizeof(char *) * *argcp);
+ new_argv[count + *argcp] = NULL;

*argv = new_argv;
*argcp += count - 1;
@@ -450,8 +451,8 @@ int main(int argc, const char **argv)
setup_path();

while (1) {
- static int done_help = 0;
- static int was_alias = 0;
+ static int done_help;
+ static int was_alias;

was_alias = run_argv(&argc, &argv);
if (errno != ENOENT)