Skip to content

Commit

Permalink
Merge tag 'perf-core-for-mingo' of git://git.kernel.org/pub/scm/linux…
Browse files Browse the repository at this point in the history
…/kernel/git/acme/linux into perf/core

Pull perf/core improvement and fixes from Arnaldo Carvalho de Melo:

User visible changes:

  - Add new compaction-times python script. (Tony Jones)

  - Make the --[no-]-demangle/--[no-]-demangle-kernel command line
    options available in 'perf script' too. (Mark Drayton)

  - Allow for negative numbers in libtraceevent's print format,
    fixing up misformatting in some tracepoints. (Steven Rostedt)

Infrastructure changes:

  - perf_env/perf_evlist changes to allow accessing the data
    structure with the environment where some perf data was
    collected in functions not necessarily related to perf.data
    file processing. (Kan Liang)

  - Cleanups for the tracepoint definition location paths routines. (Jiri Olsa)

  - Introduce sysfs/filename__sprintf_build_id, removing code
    duplication. (Masami Hiramatsu)

Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Signed-off-by: Ingo Molnar <[email protected]>
  • Loading branch information
Ingo Molnar committed Aug 31, 2015
2 parents 02b643b + 2c07144 commit bac2e4a
Show file tree
Hide file tree
Showing 29 changed files with 433 additions and 102 deletions.
1 change: 1 addition & 0 deletions tools/lib/traceevent/event-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -4828,6 +4828,7 @@ static void pretty_print(struct trace_seq *s, void *data, int size, struct event
case 'z':
case 'Z':
case '0' ... '9':
case '-':
goto cont_process;
case 'p':
if (pevent->long_size == 4)
Expand Down
7 changes: 7 additions & 0 deletions tools/perf/Documentation/perf-script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,13 @@ OPTIONS
Display context switch events i.e. events of type PERF_RECORD_SWITCH or
PERF_RECORD_SWITCH_CPU_WIDE.

--demangle::
Demangle symbol names to human readable form. It's enabled by default,
disable with --no-demangle.

--demangle-kernel::
Demangle kernel symbol names to human readable form (for C++ kernels).

--header
Show perf.data header.

Expand Down
4 changes: 2 additions & 2 deletions tools/perf/arch/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ static const char *normalize_arch(char *arch)
return arch;
}

static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
static int perf_session_env__lookup_binutils_path(struct perf_env *env,
const char *name,
const char **path)
{
Expand Down Expand Up @@ -206,7 +206,7 @@ static int perf_session_env__lookup_binutils_path(struct perf_session_env *env,
return -1;
}

int perf_session_env__lookup_objdump(struct perf_session_env *env)
int perf_session_env__lookup_objdump(struct perf_env *env)
{
/*
* For live mode, env->arch will be NULL and we can use
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/arch/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@

extern const char *objdump_path;

int perf_session_env__lookup_objdump(struct perf_session_env *env);
int perf_session_env__lookup_objdump(struct perf_env *env);

#endif /* ARCH_PERF_COMMON_H */
14 changes: 2 additions & 12 deletions tools/perf/builtin-buildid-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid)
{
char root_dir[PATH_MAX];
char notes[PATH_MAX];
u8 build_id[BUILD_ID_SIZE];
char *p;

strlcpy(root_dir, proc_dir, sizeof(root_dir));
Expand All @@ -35,15 +33,7 @@ static int build_id_cache__kcore_buildid(const char *proc_dir, char *sbuildid)
if (!p)
return -1;
*p = '\0';

scnprintf(notes, sizeof(notes), "%s/sys/kernel/notes", root_dir);

if (sysfs__read_build_id(notes, build_id, sizeof(build_id)))
return -1;

build_id__sprintf(build_id, sizeof(build_id), sbuildid);

return 0;
return sysfs__sprintf_build_id(root_dir, sbuildid);
}

static int build_id_cache__kcore_dir(char *dir, size_t sz)
Expand Down Expand Up @@ -138,7 +128,7 @@ static int build_id_cache__add_kcore(const char *filename, bool force)
return -1;
*p = '\0';

if (build_id_cache__kcore_buildid(from_dir, sbuildid))
if (build_id_cache__kcore_buildid(from_dir, sbuildid) < 0)
return -1;

scnprintf(to_dir, sizeof(to_dir), "%s/[kernel.kcore]/%s",
Expand Down
24 changes: 10 additions & 14 deletions tools/perf/builtin-buildid-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,29 +19,25 @@

static int sysfs__fprintf_build_id(FILE *fp)
{
u8 kallsyms_build_id[BUILD_ID_SIZE];
char sbuild_id[SBUILD_ID_SIZE];
int ret;

if (sysfs__read_build_id("/sys/kernel/notes", kallsyms_build_id,
sizeof(kallsyms_build_id)) != 0)
return -1;
ret = sysfs__sprintf_build_id("/", sbuild_id);
if (ret != sizeof(sbuild_id))
return ret < 0 ? ret : -EINVAL;

build_id__sprintf(kallsyms_build_id, sizeof(kallsyms_build_id),
sbuild_id);
fprintf(fp, "%s\n", sbuild_id);
return 0;
return fprintf(fp, "%s\n", sbuild_id);
}

static int filename__fprintf_build_id(const char *name, FILE *fp)
{
u8 build_id[BUILD_ID_SIZE];
char sbuild_id[SBUILD_ID_SIZE];
int ret;

if (filename__read_build_id(name, build_id,
sizeof(build_id)) != sizeof(build_id))
return 0;
ret = filename__sprintf_build_id(name, sbuild_id);
if (ret != sizeof(sbuild_id))
return ret < 0 ? ret : -EINVAL;

build_id__sprintf(build_id, sizeof(build_id), sbuild_id);
return fprintf(fp, "%s\n", sbuild_id);
}

Expand All @@ -63,7 +59,7 @@ static int perf_session__list_build_ids(bool force, bool with_hits)
/*
* See if this is an ELF file first:
*/
if (filename__fprintf_build_id(input_name, stdout))
if (filename__fprintf_build_id(input_name, stdout) > 0)
goto out;

session = perf_session__new(&file, false, &build_id__mark_dso_hit_ops);
Expand Down
5 changes: 5 additions & 0 deletions tools/perf/builtin-script.c
Original file line number Diff line number Diff line change
Expand Up @@ -1671,6 +1671,11 @@ int cmd_script(int argc, const char **argv, const char *prefix __maybe_unused)
itrace_parse_synth_opts),
OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename,
"Show full source file name path for source lines"),
OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
"Enable symbol demangling"),
OPT_BOOLEAN(0, "demangle-kernel", &symbol_conf.demangle_kernel,
"Enable kernel symbol demangling"),

OPT_END()
};
const char * const script_subcommands[] = { "record", "report", NULL };
Expand Down
19 changes: 19 additions & 0 deletions tools/perf/builtin-trace.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* builtin-trace.c
*
* Builtin 'trace' command:
*
* Display a continuously updated trace of any workload, CPU, specific PID,
* system wide, etc. Default format is loosely strace like, but any other
* event may be specified using --event.
*
* Copyright (C) 2012, 2013, 2014, 2015 Red Hat Inc, Arnaldo Carvalho de Melo <[email protected]>
*
* Initially based on the 'trace' prototype by Thomas Gleixner:
*
* http://lwn.net/Articles/415728/ ("Announcing a new utility: 'trace'")
*
* Released under the GPL v2. (and only v2, not any later version)
*/

#include <traceevent/event-parse.h>
#include "builtin.h"
#include "util/color.h"
Expand Down Expand Up @@ -27,6 +45,7 @@

#ifndef MADV_HWPOISON
# define MADV_HWPOISON 100

#endif

#ifndef MADV_MERGEABLE
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/perf.c
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)
(*argc)--;
} else if (!prefixcmp(cmd, CMD_DEBUGFS_DIR)) {
perf_debugfs_set_path(cmd + strlen(CMD_DEBUGFS_DIR));
fprintf(stderr, "dir: %s\n", debugfs_mountpoint);
fprintf(stderr, "dir: %s\n", tracing_path);
if (envchanged)
*envchanged = 1;
} else if (!strcmp(cmd, "--list-cmds")) {
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/scripts/python/bin/compaction-times-record
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
perf record -e compaction:mm_compaction_begin -e compaction:mm_compaction_end -e compaction:mm_compaction_migratepages -e compaction:mm_compaction_isolate_migratepages -e compaction:mm_compaction_isolate_freepages $@
4 changes: 4 additions & 0 deletions tools/perf/scripts/python/bin/compaction-times-report
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/bash
#description: display time taken by mm compaction
#args: [-h] [-u] [-p|-pv] [-t | [-m] [-fs] [-ms]] [pid|pid-range|comm-regex]
perf script -s "$PERF_EXEC_PATH"/scripts/python/compaction-times.py $@
Loading

0 comments on commit bac2e4a

Please sign in to comment.