Hi Ingo,
Please pull from:
git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 perf/core
Regards,
- Arnaldo
Andy Isaacson (2):
perf debug: fix hex dump partial final line
perf session: fix error message on failure to open perf.data
Chase Douglas (1):
perf probe: Add kernel source path option
Eric B Munson (1):
perf symbols: Function descriptor symbol lookup
Kirill Smelkov (1):
perf tools: .gitignore += config.make config.make.autogen
Stephane Eranian (2):
perf record: Avoid synthesizing mmap() for all processes in per-thread mode
perf record: Add option to avoid updating buildid cache
tools/perf/.gitignore | 2 +
tools/perf/Documentation/perf-probe.txt | 4 ++
tools/perf/Documentation/perf-record.txt | 6 +++
tools/perf/builtin-probe.c | 2 +
tools/perf/builtin-record.c | 7 +++-
tools/perf/util/debug.c | 10 ++---
tools/perf/util/header.c | 10 +++++-
tools/perf/util/probe-finder.c | 58 ++++++++++++++++++++++++++++--
tools/perf/util/session.c | 6 ++-
tools/perf/util/symbol.c | 37 +++++++++++++++++--
tools/perf/util/symbol.h | 1 +
tools/perf/util/util.h | 1 +
12 files changed, 128 insertions(+), 16 deletions(-)
From: Stephane Eranian <[email protected]>
A bug was introduced by commit c45c6ea2e5c57960dc67e00294c2b78e9540c007.
Perf record was scanning /proc/PID to create synthetic PERF_RECOR_MMAP
entries even though it was running in per-thread mode. There was a bogus
check to select what mmaps to synthesize. We only need all processes in
system-wide mode.
Cc: David S. Miller <[email protected]>
Cc: Frédéric Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Stephane Eranian <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Stephane Eranian <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/builtin-record.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 39c7247..5efc3fc 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -714,7 +714,7 @@ static int __cmd_record(int argc, const char **argv)
if (perf_guest)
perf_session__process_machines(session, event__synthesize_guest_os);
- if (!system_wide && cpu_list)
+ if (!system_wide)
event__synthesize_thread(target_tid, process_synthesized_event,
session);
else
--
1.6.2.5
From: Eric B Munson <[email protected]>
Currently symbol resolution does not work for 64-bit programs on architectures
that use function descriptors such as ppc64.
The problem is that a symbol doesn't point to a text address, it points to a
data area that contains (amongst other things) a pointer to the text address.
We look for a section called ".opd" which is the function descriptor area. To
create the full symbol table, when we see a symbol in the function descriptor
section we load the first pointer and use that as the text address.
Cc: Ingo Molnar <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Anton Blanchard <[email protected]>
Signed-off-by: Eric B Munson <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/symbol.c | 37 ++++++++++++++++++++++++++++++++++---
1 files changed, 34 insertions(+), 3 deletions(-)
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index b63e571..971d0a0 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -933,6 +933,25 @@ static bool elf_sec__is_a(GElf_Shdr *self, Elf_Data *secstrs, enum map_type type
}
}
+static size_t elf_addr_to_index(Elf *elf, GElf_Addr addr)
+{
+ Elf_Scn *sec = NULL;
+ GElf_Shdr shdr;
+ size_t cnt = 1;
+
+ while ((sec = elf_nextscn(elf, sec)) != NULL) {
+ gelf_getshdr(sec, &shdr);
+
+ if ((addr >= shdr.sh_addr) &&
+ (addr < (shdr.sh_addr + shdr.sh_size)))
+ return cnt;
+
+ ++cnt;
+ }
+
+ return -1;
+}
+
static int dso__load_sym(struct dso *self, struct map *map, const char *name,
int fd, symbol_filter_t filter, int kmodule)
{
@@ -944,12 +963,13 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
int err = -1;
uint32_t idx;
GElf_Ehdr ehdr;
- GElf_Shdr shdr;
- Elf_Data *syms;
+ GElf_Shdr shdr, opdshdr;
+ Elf_Data *syms, *opddata = NULL;
GElf_Sym sym;
- Elf_Scn *sec, *sec_strndx;
+ Elf_Scn *sec, *sec_strndx, *opdsec;
Elf *elf;
int nr = 0;
+ size_t opdidx = 0;
elf = elf_begin(fd, PERF_ELF_C_READ_MMAP, NULL);
if (elf == NULL) {
@@ -969,6 +989,10 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
goto out_elf_end;
}
+ opdsec = elf_section_by_name(elf, &ehdr, &opdshdr, ".opd", &opdidx);
+ if (opdsec)
+ opddata = elf_rawdata(opdsec, NULL);
+
syms = elf_getdata(sec, NULL);
if (syms == NULL)
goto out_elf_end;
@@ -1013,6 +1037,13 @@ static int dso__load_sym(struct dso *self, struct map *map, const char *name,
if (!is_label && !elf_sym__is_a(&sym, map->type))
continue;
+ if (opdsec && sym.st_shndx == opdidx) {
+ u32 offset = sym.st_value - opdshdr.sh_addr;
+ u64 *opd = opddata->d_buf + offset;
+ sym.st_value = *opd;
+ sym.st_shndx = elf_addr_to_index(elf, sym.st_value);
+ }
+
sec = elf_getscn(elf, sym.st_shndx);
if (!sec)
goto out_elf_end;
--
1.6.2.5
From: Andy Isaacson <[email protected]>
If we cannot open our data file, print strerror(errno) for a more
comprehensible error message; and only suggest 'perf record' on ENOENT.
In particular, this fixes the nonsensical advice when:
% sudo perf record sleep 1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.009 MB perf.data (~381 samples) ]
% perf trace
failed to open file: perf.data (try 'perf record' first)
%
Cc: Ingo Molnar <[email protected]>
LPU-Reference: <[email protected]>
Signed-off-by: Andy Isaacson <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/session.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/tools/perf/util/session.c b/tools/perf/util/session.c
index 8f83a18..0564a5c 100644
--- a/tools/perf/util/session.c
+++ b/tools/perf/util/session.c
@@ -27,8 +27,10 @@ static int perf_session__open(struct perf_session *self, bool force)
self->fd = open(self->filename, O_RDONLY);
if (self->fd < 0) {
- pr_err("failed to open file: %s", self->filename);
- if (!strcmp(self->filename, "perf.data"))
+ int err = errno;
+
+ pr_err("failed to open %s: %s", self->filename, strerror(err));
+ if (err == ENOENT && !strcmp(self->filename, "perf.data"))
pr_err(" (try 'perf record' first)");
pr_err("\n");
return -errno;
--
1.6.2.5
From: Kirill Smelkov <[email protected]>
These are local-configuration files and should be ignored.
LKML-Reference: <[email protected]>
Signed-off-by: Kirill Smelkov <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/.gitignore | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/tools/perf/.gitignore b/tools/perf/.gitignore
index e1d60d7..cb43289 100644
--- a/tools/perf/.gitignore
+++ b/tools/perf/.gitignore
@@ -18,3 +18,5 @@ perf-archive
tags
TAGS
cscope*
+config.mak
+config.mak.autogen
--
1.6.2.5
From: Andy Isaacson <[email protected]>
The loop counter math in trace_event was much more complicated than
necessary, resulting in incorrectly decoding the human-readable
portion of the partial last line of hexdump in "perf trace -D" output:
. 0020: 00 00 00 00 00 00 00 00 2f 73 62 69 6e 2f 69 6e ......../sbin/i
. 0030: 69 74 00 00 00 00 00 00 /sbin/i
With this fixed (and simpler!) code, we get the correct output:
. 0020: 00 00 00 00 00 00 00 00 2f 73 62 69 6e 2f 69 6e ......../sbin/in
. 0030: 69 74 00 00 00 00 00 00 it......
Cc: Ingo Molnar <[email protected]>
LPU-Reference: <[email protected]>
Signed-off-by: Andy Isaacson <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/util/debug.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/tools/perf/util/debug.c b/tools/perf/util/debug.c
index 6cddff2..318dab1 100644
--- a/tools/perf/util/debug.c
+++ b/tools/perf/util/debug.c
@@ -86,12 +86,10 @@ void trace_event(event_t *event)
dump_printf_color(" ", color);
for (j = 0; j < 15-(i & 15); j++)
dump_printf_color(" ", color);
- for (j = 0; j < (i & 15); j++) {
- if (isprint(raw_event[i-15+j]))
- dump_printf_color("%c", color,
- raw_event[i-15+j]);
- else
- dump_printf_color(".", color);
+ for (j = i & ~15; j <= i; j++) {
+ dump_printf_color("%c", color,
+ isprint(raw_event[j]) ?
+ raw_event[j] : '.');
}
dump_printf_color("\n", color);
}
--
1.6.2.5
From: Chase Douglas <[email protected]>
The probe plugin requires access to the source code for some operations. The
source code must be in the exact same location as specified by the DWARF tags,
but sometimes the location is an absolute path that cannot be replicated by a
normal user. This change adds the -s|--source option to allow the user to
specify the root of the kernel source tree.
Cc: Ingo Molnar <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Masami Hiramatsu <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Chase Douglas <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/Documentation/perf-probe.txt | 4 ++
tools/perf/builtin-probe.c | 2 +
tools/perf/util/probe-finder.c | 58 +++++++++++++++++++++++++++++--
tools/perf/util/symbol.h | 1 +
4 files changed, 62 insertions(+), 3 deletions(-)
diff --git a/tools/perf/Documentation/perf-probe.txt b/tools/perf/Documentation/perf-probe.txt
index 94a258c..ea531d9 100644
--- a/tools/perf/Documentation/perf-probe.txt
+++ b/tools/perf/Documentation/perf-probe.txt
@@ -31,6 +31,10 @@ OPTIONS
--vmlinux=PATH::
Specify vmlinux path which has debuginfo (Dwarf binary).
+-s::
+--source=PATH::
+ Specify path to kernel source.
+
-v::
--verbose::
Be more verbose (show parsed arguments, etc).
diff --git a/tools/perf/builtin-probe.c b/tools/perf/builtin-probe.c
index e4a4da3..5455186 100644
--- a/tools/perf/builtin-probe.c
+++ b/tools/perf/builtin-probe.c
@@ -182,6 +182,8 @@ static const struct option options[] = {
"Show source code lines.", opt_show_lines),
OPT_STRING('k', "vmlinux", &symbol_conf.vmlinux_name,
"file", "vmlinux pathname"),
+ OPT_STRING('s', "source", &symbol_conf.source_prefix,
+ "directory", "path to kernel source"),
#endif
OPT__DRY_RUN(&probe_event_dry_run),
OPT_INTEGER('\0', "max-probes", ¶ms.max_probe_points,
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index d964cb1..baf6653 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -37,6 +37,7 @@
#include "event.h"
#include "debug.h"
#include "util.h"
+#include "symbol.h"
#include "probe-finder.h"
/* Kprobe tracer basic type is up to u64 */
@@ -57,6 +58,55 @@ static int strtailcmp(const char *s1, const char *s2)
return 0;
}
+/*
+ * Find a src file from a DWARF tag path. Prepend optional source path prefix
+ * and chop off leading directories that do not exist. Result is passed back as
+ * a newly allocated path on success.
+ * Return 0 if file was found and readable, -errno otherwise.
+ */
+static int get_real_path(const char *raw_path, char **new_path)
+{
+ if (!symbol_conf.source_prefix) {
+ if (access(raw_path, R_OK) == 0) {
+ *new_path = strdup(raw_path);
+ return 0;
+ } else
+ return -errno;
+ }
+
+ *new_path = malloc((strlen(symbol_conf.source_prefix) +
+ strlen(raw_path) + 2));
+ if (!*new_path)
+ return -ENOMEM;
+
+ for (;;) {
+ sprintf(*new_path, "%s/%s", symbol_conf.source_prefix,
+ raw_path);
+
+ if (access(*new_path, R_OK) == 0)
+ return 0;
+
+ switch (errno) {
+ case ENAMETOOLONG:
+ case ENOENT:
+ case EROFS:
+ case EFAULT:
+ raw_path = strchr(++raw_path, '/');
+ if (!raw_path) {
+ free(*new_path);
+ *new_path = NULL;
+ return -ENOENT;
+ }
+ continue;
+
+ default:
+ free(*new_path);
+ *new_path = NULL;
+ return -errno;
+ }
+ }
+}
+
/* Line number list operations */
/* Add a line to line number list */
@@ -1096,11 +1146,13 @@ end:
static int line_range_add_line(const char *src, unsigned int lineno,
struct line_range *lr)
{
+ int ret;
+
/* Copy real path */
if (!lr->path) {
- lr->path = strdup(src);
- if (lr->path == NULL)
- return -ENOMEM;
+ ret = get_real_path(src, &lr->path);
+ if (ret != 0)
+ return ret;
}
return line_list__add_line(&lr->line_list, lineno);
}
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 10b7ff8..80e569b 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -71,6 +71,7 @@ struct symbol_conf {
full_paths,
show_cpu_utilization;
const char *vmlinux_name,
+ *source_prefix,
*field_sep;
const char *default_guest_vmlinux_name,
*default_guest_kallsyms,
--
1.6.2.5
From: Stephane Eranian <[email protected]>
There are situations where there is enough information in the perf.data
to process the samples. Updating the buildid cache may add unecessary
overhead in terms of disk space and time (copying large elf images).
A persistent option to do this already exists via the perfconfig file,
simply do:
[buildid]
dir = /dev/null
This patch provides a way to suppress builid cache updates on a per-run
basis. It addds a new option, -N, to perf record. Buildids are still
generated in the perf.data file.
Cc: David S. Miller <[email protected]>
Cc: Frédéric Weisbecker <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Peter Zijlstra <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Stephane Eranian <[email protected]>
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
---
tools/perf/Documentation/perf-record.txt | 6 ++++++
tools/perf/builtin-record.c | 5 +++++
tools/perf/util/header.c | 10 +++++++++-
tools/perf/util/util.h | 1 +
4 files changed, 21 insertions(+), 1 deletions(-)
diff --git a/tools/perf/Documentation/perf-record.txt b/tools/perf/Documentation/perf-record.txt
index 25576b4..3ee27dc 100644
--- a/tools/perf/Documentation/perf-record.txt
+++ b/tools/perf/Documentation/perf-record.txt
@@ -110,6 +110,12 @@ comma-sperated list with no space: 0,1. Ranges of CPUs are specified with -: 0-2
In per-thread mode with inheritance mode on (default), samples are captured only when
the thread executes on the designated CPUs. Default is to monitor all CPUs.
+-N::
+--no-buildid-cache::
+Do not update the builid cache. This saves some overhead in situations
+where the information in the perf.data file (which includes buildids)
+is sufficient.
+
SEE ALSO
--------
linkperf:perf-stat[1], linkperf:perf-list[1]
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index 5efc3fc..86b1c3b 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -60,6 +60,7 @@ static bool call_graph = false;
static bool inherit_stat = false;
static bool no_samples = false;
static bool sample_address = false;
+static bool no_buildid = false;
static long samples = 0;
static u64 bytes_written = 0;
@@ -825,6 +826,8 @@ static const struct option options[] = {
"Sample addresses"),
OPT_BOOLEAN('n', "no-samples", &no_samples,
"don't sample"),
+ OPT_BOOLEAN('N', "no-buildid-cache", &no_buildid,
+ "do not update the buildid cache"),
OPT_END()
};
@@ -849,6 +852,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
}
symbol__init();
+ if (no_buildid)
+ disable_buildid_cache();
if (!nr_counters) {
nr_counters = 1;
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index 4a6a4b3..d7e67b1 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -16,6 +16,8 @@
#include "symbol.h"
#include "debug.h"
+static bool no_buildid_cache = false;
+
/*
* Create new perf.data header attribute:
*/
@@ -470,7 +472,8 @@ static int perf_header__adds_write(struct perf_header *self, int fd)
}
buildid_sec->size = lseek(fd, 0, SEEK_CUR) -
buildid_sec->offset;
- perf_session__cache_build_ids(session);
+ if (!no_buildid_cache)
+ perf_session__cache_build_ids(session);
}
lseek(fd, sec_start, SEEK_SET);
@@ -1189,3 +1192,8 @@ int event__process_build_id(event_t *self,
session);
return 0;
}
+
+void disable_buildid_cache(void)
+{
+ no_buildid_cache = true;
+}
diff --git a/tools/perf/util/util.h b/tools/perf/util/util.h
index de61441..f380fed 100644
--- a/tools/perf/util/util.h
+++ b/tools/perf/util/util.h
@@ -154,6 +154,7 @@ extern void set_die_routine(void (*routine)(const char *err, va_list params) NOR
extern int prefixcmp(const char *str, const char *prefix);
extern void set_buildid_dir(void);
+extern void disable_buildid_cache(void);
static inline const char *skip_prefix(const char *str, const char *prefix)
{
--
1.6.2.5
* Arnaldo Carvalho de Melo <[email protected]> wrote:
> Hi Ingo,
>
> Please pull from:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux-2.6 perf/core
>
> Regards,
>
> - Arnaldo
>
> Andy Isaacson (2):
> perf debug: fix hex dump partial final line
> perf session: fix error message on failure to open perf.data
>
> Chase Douglas (1):
> perf probe: Add kernel source path option
>
> Eric B Munson (1):
> perf symbols: Function descriptor symbol lookup
>
> Kirill Smelkov (1):
> perf tools: .gitignore += config.make config.make.autogen
>
> Stephane Eranian (2):
> perf record: Avoid synthesizing mmap() for all processes in per-thread mode
> perf record: Add option to avoid updating buildid cache
>
> tools/perf/.gitignore | 2 +
> tools/perf/Documentation/perf-probe.txt | 4 ++
> tools/perf/Documentation/perf-record.txt | 6 +++
> tools/perf/builtin-probe.c | 2 +
> tools/perf/builtin-record.c | 7 +++-
> tools/perf/util/debug.c | 10 ++---
> tools/perf/util/header.c | 10 +++++-
> tools/perf/util/probe-finder.c | 58 ++++++++++++++++++++++++++++--
> tools/perf/util/session.c | 6 ++-
> tools/perf/util/symbol.c | 37 +++++++++++++++++--
> tools/perf/util/symbol.h | 1 +
> tools/perf/util/util.h | 1 +
> 12 files changed, 128 insertions(+), 16 deletions(-)
Pulled, thanks Arnaldo!
Ingo