summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/Documentation/perf-annotate.txt14
-rw-r--r--tools/perf/Documentation/perf-buildid-list.txt6
-rw-r--r--tools/perf/Documentation/perf-report.txt3
-rw-r--r--tools/perf/Documentation/perf-sched.txt6
-rw-r--r--tools/perf/Documentation/perf-stat.txt16
-rw-r--r--tools/perf/builtin-annotate.c8
-rw-r--r--tools/perf/builtin-buildid-list.c52
-rw-r--r--tools/perf/builtin-record.c19
-rw-r--r--tools/perf/builtin-report.c7
-rw-r--r--tools/perf/builtin-stat.c190
-rw-r--r--tools/perf/builtin-top.c34
-rwxr-xr-xtools/perf/scripts/python/bin/net_dropmonitor-record2
-rwxr-xr-xtools/perf/scripts/python/bin/net_dropmonitor-report4
-rwxr-xr-xtools/perf/scripts/python/net_dropmonitor.py72
-rw-r--r--tools/perf/util/annotate.c11
-rw-r--r--tools/perf/util/annotate.h2
-rw-r--r--tools/perf/util/color.c2
-rw-r--r--tools/perf/util/map.c98
-rw-r--r--tools/perf/util/map.h42
-rw-r--r--tools/perf/util/symbol.c2
-rw-r--r--tools/perf/util/symbol.h4
-rw-r--r--tools/perf/util/top.h3
-rw-r--r--tools/perf/util/ui/browsers/top.c28
23 files changed, 458 insertions, 167 deletions
diff --git a/tools/perf/Documentation/perf-annotate.txt b/tools/perf/Documentation/perf-annotate.txt
index 85c5f026930d..0102d83600db 100644
--- a/tools/perf/Documentation/perf-annotate.txt
+++ b/tools/perf/Documentation/perf-annotate.txt
@@ -72,6 +72,20 @@ OPTIONS
CPUs are specified with -: 0-2. Default is to report samples on all
CPUs.
+--asm-raw::
+ Show raw instruction encoding of assembly instructions. They
+ are displayed by default, disable with --no-asm-raw.
+
+--source::
+ Interleave source code with assembly code. Enabled by default,
+ disable with --no-source.
+
+--symfs=<directory>::
+ Look for files with symbols relative to this directory.
+
+-M::
+--disassembler-style=:: Set disassembler style for objdump.
+
SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-report[1]
diff --git a/tools/perf/Documentation/perf-buildid-list.txt b/tools/perf/Documentation/perf-buildid-list.txt
index 5eaac6f26d51..cc22325ffd1b 100644
--- a/tools/perf/Documentation/perf-buildid-list.txt
+++ b/tools/perf/Documentation/perf-buildid-list.txt
@@ -16,6 +16,9 @@ This command displays the buildids found in a perf.data file, so that other
tools can be used to fetch packages with matching symbol tables for use by
perf report.
+It can also be used to show the build id of the running kernel or in an ELF
+file using -i/--input.
+
OPTIONS
-------
-H::
@@ -27,6 +30,9 @@ OPTIONS
-f::
--force::
Don't do ownership validation.
+-k::
+--kernel::
+ Show running kernel build id.
-v::
--verbose::
Be more verbose.
diff --git a/tools/perf/Documentation/perf-report.txt b/tools/perf/Documentation/perf-report.txt
index 04253c07d19a..6349b6c0e3ec 100644
--- a/tools/perf/Documentation/perf-report.txt
+++ b/tools/perf/Documentation/perf-report.txt
@@ -134,6 +134,9 @@ OPTIONS
CPUs are specified with -: 0-2. Default is to report samples on all
CPUs.
+-M::
+--disassembler-style=:: Set disassembler style for objdump.
+
SEE ALSO
--------
linkperf:perf-stat[1]
diff --git a/tools/perf/Documentation/perf-sched.txt b/tools/perf/Documentation/perf-sched.txt
index 46822d5fde1c..5b212b57f70b 100644
--- a/tools/perf/Documentation/perf-sched.txt
+++ b/tools/perf/Documentation/perf-sched.txt
@@ -8,7 +8,7 @@ perf-sched - Tool to trace/measure scheduler properties (latencies)
SYNOPSIS
--------
[verse]
-'perf sched' {record|latency|map|replay|trace}
+'perf sched' {record|latency|map|replay|script}
DESCRIPTION
-----------
@@ -20,8 +20,8 @@ There are five variants of perf sched:
'perf sched latency' to report the per task scheduling latencies
and other scheduling properties of the workload.
- 'perf sched trace' to see a detailed trace of the workload that
- was recorded.
+ 'perf sched script' to see a detailed trace of the workload that
+ was recorded (aliased to 'perf script' for now).
'perf sched replay' to simulate the workload that was recorded
via perf sched record. (this is done by starting up mockup threads
diff --git a/tools/perf/Documentation/perf-stat.txt b/tools/perf/Documentation/perf-stat.txt
index 918cc38ee6d1..8966b9ab2014 100644
--- a/tools/perf/Documentation/perf-stat.txt
+++ b/tools/perf/Documentation/perf-stat.txt
@@ -94,6 +94,22 @@ an empty cgroup (monitor all the time) using, e.g., -G foo,,bar. Cgroups must ha
corresponding events, i.e., they always refer to events defined earlier on the command
line.
+-o file::
+--output file::
+Print the output into the designated file.
+
+--append::
+Append to the output file designated with the -o option. Ignored if -o is not specified.
+
+--log-fd::
+
+Log output to fd, instead of stderr. Complementary to --output, and mutually exclusive
+with it. --append may be used here. Examples:
+ 3>results perf stat --log-fd 3 -- $cmd
+ 3>>results perf stat --log-fd 3 --append -- $cmd
+
+
+
EXAMPLES
--------
diff --git a/tools/perf/builtin-annotate.c b/tools/perf/builtin-annotate.c
index 555aefd7fe01..cf68819f7453 100644
--- a/tools/perf/builtin-annotate.c
+++ b/tools/perf/builtin-annotate.c
@@ -267,6 +267,14 @@ static const struct option options[] = {
OPT_BOOLEAN('P', "full-paths", &full_paths,
"Don't shorten the displayed pathnames"),
OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"),
+ OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
+ "Look for files with symbols relative to this directory"),
+ OPT_BOOLEAN('0', "source", &symbol_conf.annotate_src,
+ "Interleave source code with assembly code (default)"),
+ OPT_BOOLEAN('0', "asm-raw", &symbol_conf.annotate_asm_raw,
+ "Display raw encoding of assembly instructions (default)"),
+ OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
+ "Specify disassembler style (e.g. -M intel for intel syntax)"),
OPT_END()
};
diff --git a/tools/perf/builtin-buildid-list.c b/tools/perf/builtin-buildid-list.c
index 5af32ae9031e..cb690a65bf02 100644
--- a/tools/perf/builtin-buildid-list.c
+++ b/tools/perf/builtin-buildid-list.c
@@ -1,7 +1,8 @@
/*
* builtin-buildid-list.c
*
- * Builtin buildid-list command: list buildids in perf.data
+ * Builtin buildid-list command: list buildids in perf.data, in the running
+ * kernel and in ELF files.
*
* Copyright (C) 2009, Red Hat Inc.
* Copyright (C) 2009, Arnaldo Carvalho de Melo <acme@redhat.com>
@@ -15,8 +16,11 @@
#include "util/session.h"
#include "util/symbol.h"
+#include <libelf.h>
+
static char const *input_name = "perf.data";
static bool force;
+static bool show_kernel;
static bool with_hits;
static const char * const buildid_list_usage[] = {
@@ -29,12 +33,13 @@ static const struct option options[] = {
OPT_STRING('i', "input", &input_name, "file",
"input file name"),
OPT_BOOLEAN('f', "force", &force, "don't complain, do it"),
+ OPT_BOOLEAN('k', "kernel", &show_kernel, "Show current kernel build id"),
OPT_INCR('v', "verbose", &verbose,
"be more verbose"),
OPT_END()
};
-static int __cmd_buildid_list(void)
+static int perf_session__list_build_ids(void)
{
struct perf_session *session;
@@ -52,6 +57,49 @@ static int __cmd_buildid_list(void)
return 0;
}
+static int sysfs__fprintf_build_id(FILE *fp)
+{
+ u8 kallsyms_build_id[BUILD_ID_SIZE];
+ char sbuild_id[BUILD_ID_SIZE * 2 + 1];
+
+ if (sysfs__read_build_id("/sys/kernel/notes", kallsyms_build_id,
+ sizeof(kallsyms_build_id)) != 0)
+ return -1;
+
+ build_id__sprintf(kallsyms_build_id, sizeof(kallsyms_build_id),
+ sbuild_id);
+ fprintf(fp, "%s\n", sbuild_id);
+ return 0;
+}
+
+static int filename__fprintf_build_id(const char *name, FILE *fp)
+{
+ u8 build_id[BUILD_ID_SIZE];
+ char sbuild_id[BUILD_ID_SIZE * 2 + 1];
+
+ if (filename__read_build_id(name, build_id,
+ sizeof(build_id)) != sizeof(build_id))
+ return 0;
+
+ build_id__sprintf(build_id, sizeof(build_id), sbuild_id);
+ return fprintf(fp, "%s\n", sbuild_id);
+}
+
+static int __cmd_buildid_list(void)
+{
+ if (show_kernel)
+ return sysfs__fprintf_build_id(stdout);
+
+ elf_version(EV_CURRENT);
+ /*
+ * See if this is an ELF file first:
+ */
+ if (filename__fprintf_build_id(input_name, stdout))
+ return 0;
+
+ return perf_session__list_build_ids();
+}
+
int cmd_buildid_list(int argc, const char **argv, const char *prefix __used)
{
argc = parse_options(argc, argv, options, buildid_list_usage, 0);
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c
index f4c3fbee4bad..dd6467872f60 100644
--- a/tools/perf/builtin-record.c
+++ b/tools/perf/builtin-record.c
@@ -73,6 +73,7 @@ static off_t post_processing_offset;
static struct perf_session *session;
static const char *cpu_list;
+static const char *progname;
static void advance_output(size_t size)
{
@@ -137,17 +138,29 @@ static void mmap_read(struct perf_mmap *md)
static volatile int done = 0;
static volatile int signr = -1;
+static volatile int child_finished = 0;
static void sig_handler(int sig)
{
+ if (sig == SIGCHLD)
+ child_finished = 1;
+
done = 1;
signr = sig;
}
static void sig_atexit(void)
{
- if (child_pid > 0)
- kill(child_pid, SIGTERM);
+ int status;
+
+ if (child_pid > 0) {
+ if (!child_finished)
+ kill(child_pid, SIGTERM);
+
+ wait(&status);
+ if (WIFSIGNALED(status))
+ psignal(WTERMSIG(status), progname);
+ }
if (signr == -1 || signr == SIGUSR1)
return;
@@ -446,6 +459,8 @@ static int __cmd_record(int argc, const char **argv)
char buf;
struct machine *machine;
+ progname = argv[0];
+
page_size = sysconf(_SC_PAGE_SIZE);
atexit(sig_atexit);
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c
index d7ff277bdb78..3d58334909a5 100644
--- a/tools/perf/builtin-report.c
+++ b/tools/perf/builtin-report.c
@@ -229,10 +229,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
list_for_each_entry(pos, &evlist->entries, node) {
struct hists *hists = &pos->hists;
- const char *evname = NULL;
-
- if (rb_first(&hists->entries) != rb_last(&hists->entries))
- evname = event_name(pos);
+ const char *evname = event_name(pos);
hists__fprintf_nr_sample_events(hists, evname, stdout);
hists__fprintf(hists, NULL, false, stdout);
@@ -487,6 +484,8 @@ static const struct option options[] = {
OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
"Look for files with symbols relative to this directory"),
OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"),
+ OPT_STRING('M', "disassembler-style", &disassembler_style, "disassembler style",
+ "Specify disassembler style (e.g. -M intel for intel syntax)"),
OPT_END()
};
diff --git a/tools/perf/builtin-stat.c b/tools/perf/builtin-stat.c
index 5deb17d9e795..7ce65f52415e 100644
--- a/tools/perf/builtin-stat.c
+++ b/tools/perf/builtin-stat.c
@@ -194,6 +194,9 @@ static const char *cpu_list;
static const char *csv_sep = NULL;
static bool csv_output = false;
static bool group = false;
+static const char *output_name = NULL;
+static FILE *output = NULL;
+static int output_fd;
static volatile int done = 0;
@@ -251,8 +254,13 @@ static double avg_stats(struct stats *stats)
*/
static double stddev_stats(struct stats *stats)
{
- double variance = stats->M2 / (stats->n - 1);
- double variance_mean = variance / stats->n;
+ double variance, variance_mean;
+
+ if (!stats->n)
+ return 0.0;
+
+ variance = stats->M2 / (stats->n - 1);
+ variance_mean = variance / stats->n;
return sqrt(variance_mean);
}
@@ -352,7 +360,7 @@ static int read_counter_aggr(struct perf_evsel *counter)
update_stats(&ps->res_stats[i], count[i]);
if (verbose) {
- fprintf(stderr, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
+ fprintf(output, "%s: %" PRIu64 " %" PRIu64 " %" PRIu64 "\n",
event_name(counter), count[0], count[1], count[2]);
}
@@ -487,6 +495,8 @@ static int run_perf_stat(int argc __used, const char **argv)
if (forks) {
close(go_pipe[1]);
wait(&status);
+ if (WIFSIGNALED(status))
+ psignal(WTERMSIG(status), argv[0]);
} else {
while(!done) sleep(1);
}
@@ -519,9 +529,9 @@ static void print_noise_pct(double total, double avg)
pct = 100.0*total/avg;
if (csv_output)
- fprintf(stderr, "%s%.2f%%", csv_sep, pct);
- else
- fprintf(stderr, " ( +-%6.2f%% )", pct);
+ fprintf(output, "%s%.2f%%", csv_sep, pct);
+ else if (pct)
+ fprintf(output, " ( +-%6.2f%% )", pct);
}
static void print_noise(struct perf_evsel *evsel, double avg)
@@ -546,16 +556,17 @@ static void nsec_printout(int cpu, struct perf_evsel *evsel, double avg)
csv_output ? 0 : -4,
evsel_list->cpus->map[cpu], csv_sep);
- fprintf(stderr, fmt, cpustr, msecs, csv_sep, event_name(evsel));
+ fprintf(output, fmt, cpustr, msecs, csv_sep, event_name(evsel));
if (evsel->cgrp)
- fprintf(stderr, "%s%s", csv_sep, evsel->cgrp->name);
+ fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
if (csv_output)
return;
if (perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK))
- fprintf(stderr, " # %8.3f CPUs utilized ", avg / avg_stats(&walltime_nsecs_stats));
+ fprintf(output, " # %8.3f CPUs utilized ",
+ avg / avg_stats(&walltime_nsecs_stats));
}
static void print_stalled_cycles_frontend(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -576,9 +587,9 @@ static void print_stalled_cycles_frontend(int cpu, struct perf_evsel *evsel __us
else if (ratio > 10.0)
color = PERF_COLOR_YELLOW;
- fprintf(stderr, " # ");
- color_fprintf(stderr, color, "%6.2f%%", ratio);
- fprintf(stderr, " frontend cycles idle ");
+ fprintf(output, " # ");
+ color_fprintf(output, color, "%6.2f%%", ratio);
+ fprintf(output, " frontend cycles idle ");
}
static void print_stalled_cycles_backend(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -599,9 +610,9 @@ static void print_stalled_cycles_backend(int cpu, struct perf_evsel *evsel __use
else if (ratio > 20.0)
color = PERF_COLOR_YELLOW;
- fprintf(stderr, " # ");
- color_fprintf(stderr, color, "%6.2f%%", ratio);
- fprintf(stderr, " backend cycles idle ");
+ fprintf(output, " # ");
+ color_fprintf(output, color, "%6.2f%%", ratio);
+ fprintf(output, " backend cycles idle ");
}
static void print_branch_misses(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -622,9 +633,9 @@ static void print_branch_misses(int cpu, struct perf_evsel *evsel __used, double
else if (ratio > 5.0)
color = PERF_COLOR_YELLOW;
- fprintf(stderr, " # ");
- color_fprintf(stderr, color, "%6.2f%%", ratio);
- fprintf(stderr, " of all branches ");
+ fprintf(output, " # ");
+ color_fprintf(output, color, "%6.2f%%", ratio);
+ fprintf(output, " of all branches ");
}
static void print_l1_dcache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -645,9 +656,9 @@ static void print_l1_dcache_misses(int cpu, struct perf_evsel *evsel __used, dou
else if (ratio > 5.0)
color = PERF_COLOR_YELLOW;
- fprintf(stderr, " # ");
- color_fprintf(stderr, color, "%6.2f%%", ratio);
- fprintf(stderr, " of all L1-dcache hits ");
+ fprintf(output, " # ");
+ color_fprintf(output, color, "%6.2f%%", ratio);
+ fprintf(output, " of all L1-dcache hits ");
}
static void print_l1_icache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -668,9 +679,9 @@ static void print_l1_icache_misses(int cpu, struct perf_evsel *evsel __used, dou
else if (ratio > 5.0)
color = PERF_COLOR_YELLOW;
- fprintf(stderr, " # ");
- color_fprintf(stderr, color, "%6.2f%%", ratio);
- fprintf(stderr, " of all L1-icache hits ");
+ fprintf(output, " # ");
+ color_fprintf(output, color, "%6.2f%%", ratio);
+ fprintf(output, " of all L1-icache hits ");
}
static void print_dtlb_cache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -691,9 +702,9 @@ static void print_dtlb_cache_misses(int cpu, struct perf_evsel *evsel __used, do
else if (ratio > 5.0)
color = PERF_COLOR_YELLOW;
- fprintf(stderr, " # ");
- color_fprintf(stderr, color, "%6.2f%%", ratio);
- fprintf(stderr, " of all dTLB cache hits ");
+ fprintf(output, " # ");
+ color_fprintf(output, color, "%6.2f%%", ratio);
+ fprintf(output, " of all dTLB cache hits ");
}
static void print_itlb_cache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -714,9 +725,9 @@ static void print_itlb_cache_misses(int cpu, struct perf_evsel *evsel __used, do
else if (ratio > 5.0)
color = PERF_COLOR_YELLOW;
- fprintf(stderr, " # ");
- color_fprintf(stderr, color, "%6.2f%%", ratio);
- fprintf(stderr, " of all iTLB cache hits ");
+ fprintf(output, " # ");
+ color_fprintf(output, color, "%6.2f%%", ratio);
+ fprintf(output, " of all iTLB cache hits ");
}
static void print_ll_cache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
@@ -737,9 +748,9 @@ static void print_ll_cache_misses(int cpu, struct perf_evsel *evsel __used, doub
else if (ratio > 5.0)
color = PERF_COLOR_YELLOW;
- fprintf(stderr, " # ");
- color_fprintf(stderr, color, "%6.2f%%", ratio);
- fprintf(stderr, " of all LL-cache hits ");
+ fprintf(output, " # ");
+ color_fprintf(output, color, "%6.2f%%", ratio);
+ fprintf(output, " of all LL-cache hits ");
}
static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
@@ -762,10 +773,10 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
else
cpu = 0;
- fprintf(stderr, fmt, cpustr, avg, csv_sep, event_name(evsel));
+ fprintf(output, fmt, cpustr, avg, csv_sep, event_name(evsel));
if (evsel->cgrp)
- fprintf(stderr, "%s%s", csv_sep, evsel->cgrp->name);
+ fprintf(output, "%s%s", csv_sep, evsel->cgrp->name);
if (csv_output)
return;
@@ -776,14 +787,14 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
if (total)
ratio = avg / total;
- fprintf(stderr, " # %5.2f insns per cycle ", ratio);
+ fprintf(output, " # %5.2f insns per cycle ", ratio);
total = avg_stats(&runtime_stalled_cycles_front_stats[cpu]);
total = max(total, avg_stats(&runtime_stalled_cycles_back_stats[cpu]));
if (total && avg) {
ratio = total / avg;
- fprintf(stderr, "\n # %5.2f stalled cycles per insn", ratio);
+ fprintf(output, "\n # %5.2f stalled cycles per insn", ratio);
}
} else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES) &&
@@ -831,7 +842,7 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
if (total)
ratio = avg * 100 / total;
- fprintf(stderr, " # %8.3f %% of all cache refs ", ratio);
+ fprintf(output, " # %8.3f %% of all cache refs ", ratio);
} else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_FRONTEND)) {
print_stalled_cycles_frontend(cpu, evsel, avg);
@@ -843,16 +854,16 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
if (total)
ratio = 1.0 * avg / total;
- fprintf(stderr, " # %8.3f GHz ", ratio);
+ fprintf(output, " # %8.3f GHz ", ratio);
} else if (runtime_nsecs_stats[cpu].n != 0) {
total = avg_stats(&runtime_nsecs_stats[cpu]);
if (total)
ratio = 1000.0 * avg / total;
- fprintf(stderr, " # %8.3f M/sec ", ratio);
+ fprintf(output, " # %8.3f M/sec ", ratio);
} else {
- fprintf(stderr, " ");
+ fprintf(output, " ");
}
}
@@ -867,7 +878,7 @@ static void print_counter_aggr(struct perf_evsel *counter)
int scaled = counter->counts->scaled;
if (scaled == -1) {
- fprintf(stderr, "%*s%s%*s",
+ fprintf(output, "%*s%s%*s",
csv_output ? 0 : 18,
counter->supported ? CNTR_NOT_COUNTED : CNTR_NOT_SUPPORTED,
csv_sep,
@@ -875,9 +886,9 @@ static void print_counter_aggr(struct perf_evsel *counter)
event_name(counter));
if (counter->cgrp)
- fprintf(stderr, "%s%s", csv_sep, counter->cgrp->name);
+ fprintf(output, "%s%s", csv_sep, counter->cgrp->name);
- fputc('\n', stderr);
+ fputc('\n', output);
return;
}
@@ -889,7 +900,7 @@ static void print_counter_aggr(struct perf_evsel *counter)
print_noise(counter, avg);
if (csv_output) {
- fputc('\n', stderr);
+ fputc('\n', output);
return;
}
@@ -899,9 +910,9 @@ static void print_counter_aggr(struct perf_evsel *counter)
avg_enabled = avg_stats(&ps->res_stats[1]);
avg_running = avg_stats(&ps->res_stats[2]);
- fprintf(stderr, " [%5.2f%%]", 100 * avg_running / avg_enabled);
+ fprintf(output, " [%5.2f%%]", 100 * avg_running / avg_enabled);
}
- fprintf(stderr, "\n");
+ fprintf(output, "\n");
}
/*
@@ -918,7 +929,7 @@ static void print_counter(struct perf_evsel *counter)
ena = counter->counts->cpu[cpu].ena;
run = counter->counts->cpu[cpu].run;
if (run == 0 || ena == 0) {
- fprintf(stderr, "CPU%*d%s%*s%s%*s",
+ fprintf(output, "CPU%*d%s%*s%s%*s",
csv_output ? 0 : -4,
evsel_list->cpus->map[cpu], csv_sep,
csv_output ? 0 : 18,
@@ -928,9 +939,10 @@ static void print_counter(struct perf_evsel *counter)
event_name(counter));
if (counter->cgrp)
- fprintf(stderr, "%s%s", csv_sep, counter->cgrp->name);
+ fprintf(output, "%s%s",
+ csv_sep, counter->cgrp->name);
- fputc('\n', stderr);
+ fputc('\n', output);
continue;
}
@@ -943,9 +955,10 @@ static void print_counter(struct perf_evsel *counter)
print_noise(counter, 1.0);
if (run != ena)
- fprintf(stderr, " (%.2f%%)", 100.0 * run / ena);
+ fprintf(output, " (%.2f%%)",
+ 100.0 * run / ena);
}
- fputc('\n', stderr);
+ fputc('\n', output);
}
}
@@ -957,21 +970,21 @@ static void print_stat(int argc, const char **argv)
fflush(stdout);
if (!csv_output) {
- fprintf(stderr, "\n");
- fprintf(stderr, " Performance counter stats for ");
+ fprintf(output, "\n");
+ fprintf(output, " Performance counter stats for ");
if(target_pid == -1 && target_tid == -1) {
- fprintf(stderr, "\'%s", argv[0]);
+ fprintf(output, "\'%s", argv[0]);
for (i = 1; i < argc; i++)
- fprintf(stderr, " %s", argv[i]);
+ fprintf(output, " %s", argv[i]);
} else if (target_pid != -1)
- fprintf(stderr, "process id \'%d", target_pid);
+ fprintf(output, "process id \'%d", target_pid);
else
- fprintf(stderr, "thread id \'%d", target_tid);
+ fprintf(output, "thread id \'%d", target_tid);
- fprintf(stderr, "\'");
+ fprintf(output, "\'");
if (run_count > 1)
- fprintf(stderr, " (%d runs)", run_count);
- fprintf(stderr, ":\n\n");
+ fprintf(output, " (%d runs)", run_count);
+ fprintf(output, ":\n\n");
}
if (no_aggr) {
@@ -984,15 +997,15 @@ static void print_stat(int argc, const char **argv)
if (!csv_output) {
if (!null_run)
- fprintf(stderr, "\n");
- fprintf(stderr, " %17.9f seconds time elapsed",
+ fprintf(output, "\n");
+ fprintf(output, " %17.9f seconds time elapsed",
avg_stats(&walltime_nsecs_stats)/1e9);
if (run_count > 1) {
- fprintf(stderr, " ");
+ fprintf(output, " ");
print_noise_pct(stddev_stats(&walltime_nsecs_stats),
avg_stats(&walltime_nsecs_stats));
}
- fprintf(stderr, "\n\n");
+ fprintf(output, "\n\n");
}
}
@@ -1030,6 +1043,8 @@ static int stat__set_big_num(const struct option *opt __used,
return 0;
}
+static bool append_file;
+
static const struct option options[] = {
OPT_CALLBACK('e', "event", &evsel_list, "event",
"event selector. use 'perf list' to list available events",
@@ -1070,6 +1085,11 @@ static const struct option options[] = {
OPT_CALLBACK('G', "cgroup", &evsel_list, "name",
"monitor event in cgroup name only",
parse_cgroups),
+ OPT_STRING('o', "output", &output_name, "file",
+ "output file name"),
+ OPT_BOOLEAN(0, "append", &append_file, "append to the output file"),
+ OPT_INTEGER(0, "log-fd", &output_fd,
+ "log output to fd, instead of stderr"),
OPT_END()
};
@@ -1141,6 +1161,7 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
{
struct perf_evsel *pos;
int status = -ENOMEM;
+ const char *mode;
setlocale(LC_ALL, "");
@@ -1151,16 +1172,46 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
argc = parse_options(argc, argv, options, stat_usage,
PARSE_OPT_STOP_AT_NON_OPTION);
- if (csv_sep)
+ output = stderr;
+ if (output_name && strcmp(output_name, "-"))
+ output = NULL;
+
+ if (output_name && output_fd) {
+ fprintf(stderr, "cannot use both --output and --log-fd\n");
+ usage_with_options(stat_usage, options);
+ }
+ if (!output) {
+ struct timespec tm;
+ mode = append_file ? "a" : "w";
+
+ output = fopen(output_name, mode);
+ if (!output) {
+ perror("failed to create output file");
+ exit(-1);
+ }
+ clock_gettime(CLOCK_REALTIME, &tm);
+ fprintf(output, "# started on %s\n", ctime(&tm.tv_sec));
+ } else if (output_fd != 2) {
+ mode = append_file ? "a" : "w";
+ output = fdopen(output_fd, mode);
+ if (!output) {
+ perror("Failed opening logfd");
+ return -errno;
+ }
+ }
+
+ if (csv_sep) {
csv_output = true;
- else
+ if (!strcmp(csv_sep, "\\t"))
+ csv_sep = "\t";
+ } else
csv_sep = DEFAULT_SEPARATOR;
/*
* let the spreadsheet do the pretty-printing
*/
if (csv_output) {
- /* User explicitely passed -B? */
+ /* User explicitly passed -B? */
if (big_num_opt == 1) {
fprintf(stderr, "-B option not supported with -x\n");
usage_with_options(stat_usage, options);
@@ -1226,7 +1277,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
status = 0;
for (run_idx = 0; run_idx < run_count; run_idx++) {
if (run_count != 1 && verbose)
- fprintf(stderr, "[ perf stat: executing run #%d ... ]\n", run_idx + 1);
+ fprintf(output, "[ perf stat: executing run #%d ... ]\n",
+ run_idx + 1);
if (sync_run)
sync();
diff --git a/tools/perf/builtin-top.c b/tools/perf/builtin-top.c
index d28013b7d61c..5ede7d7c9239 100644
--- a/tools/perf/builtin-top.c
+++ b/tools/perf/builtin-top.c
@@ -251,7 +251,7 @@ static void __list_insert_active_sym(struct sym_entry *syme)
list_add(&syme->node, &top.active_symbols);
}
-static void print_sym_table(struct perf_session *session)
+static void print_sym_table(void)
{
char bf[160];
int printed = 0;
@@ -271,10 +271,11 @@ static void print_sym_table(struct perf_session *session)
printf("%-*.*s\n", win_width, win_width, graph_dotted_line);
- if (session->hists.stats.total_lost != 0) {
+ if (top.total_lost_warned != top.session->hists.stats.total_lost) {
+ top.total_lost_warned = top.session->hists.stats.total_lost;
color_fprintf(stdout, PERF_COLOR_RED, "WARNING:");
printf(" LOST %" PRIu64 " events, Check IO/CPU overload\n",
- session->hists.stats.total_lost);
+ top.total_lost_warned);
}
if (top.sym_filter_entry) {
@@ -475,7 +476,7 @@ static int key_mapped(int c)
return 0;
}
-static void handle_keypress(struct perf_session *session, int c)
+static void handle_keypress(int c)
{
if (!key_mapped(c)) {
struct pollfd stdin_poll = { .fd = 0, .events = POLLIN };
@@ -551,7 +552,7 @@ static void handle_keypress(struct perf_session *session, int c)
case 'Q':
printf("exiting.\n");
if (dump_symtab)
- perf_session__fprintf_dsos(session, stderr);
+ perf_session__fprintf_dsos(top.session, stderr);
exit(0);
case 's':
prompt_symbol(&top.sym_filter_entry, "Enter details symbol");
@@ -603,7 +604,6 @@ static void *display_thread(void *arg __used)
struct pollfd stdin_poll = { .fd = 0, .events = POLLIN };
struct termios tc, save;
int delay_msecs, c;
- struct perf_session *session = (struct perf_session *) arg;
tcgetattr(0, &save);
tc = save;
@@ -618,13 +618,13 @@ repeat:
getc(stdin);
do {
- print_sym_table(session);
+ print_sym_table();
} while (!poll(&stdin_poll, 1, delay_msecs) == 1);
c = getc(stdin);
tcsetattr(0, TCSAFLUSH, &save);
- handle_keypress(session, c);
+ handle_keypress(c);
goto repeat;
return NULL;
@@ -936,27 +936,27 @@ static int __cmd_top(void)
* FIXME: perf_session__new should allow passing a O_MMAP, so that all this
* mmap reading, etc is encapsulated in it. Use O_WRONLY for now.
*/
- struct perf_session *session = perf_session__new(NULL, O_WRONLY, false, false, NULL);
- if (session == NULL)
+ top.session = perf_session__new(NULL, O_WRONLY, false, false, NULL);
+ if (top.session == NULL)
return -ENOMEM;
if (top.target_tid != -1)
perf_event__synthesize_thread_map(top.evlist->threads,
- perf_event__process, session);
+ perf_event__process, top.session);
else
- perf_event__synthesize_threads(perf_event__process, session);
+ perf_event__synthesize_threads(perf_event__process, top.session);
start_counters(top.evlist);
- session->evlist = top.evlist;
- perf_session__update_sample_type(session);
+ top.session->evlist = top.evlist;
+ perf_session__update_sample_type(top.session);
/* Wait for a minimal set of events before starting the snapshot */
poll(top.evlist->pollfd, top.evlist->nr_fds, 100);
- perf_session__mmap_read(session);
+ perf_session__mmap_read(top.session);
if (pthread_create(&thread, NULL, (use_browser > 0 ? display_thread_tui :
- display_thread), session)) {
+ display_thread), NULL)) {
printf("Could not create display thread.\n");
exit(-1);
}
@@ -974,7 +974,7 @@ static int __cmd_top(void)
while (1) {
u64 hits = top.samples;
- perf_session__mmap_read(session);
+ perf_session__mmap_read(top.session);
if (hits == top.samples)
ret = poll(top.evlist->pollfd, top.evlist->nr_fds, 100);
diff --git a/tools/perf/scripts/python/bin/net_dropmonitor-record b/tools/perf/scripts/python/bin/net_dropmonitor-record
new file mode 100755
index 000000000000..423fb81dadae
--- /dev/null
+++ b/tools/perf/scripts/python/bin/net_dropmonitor-record
@@ -0,0 +1,2 @@
+#!/bin/bash
+perf record -e skb:kfree_skb $@
diff --git a/tools/perf/scripts/python/bin/net_dropmonitor-report b/tools/perf/scripts/python/bin/net_dropmonitor-report
new file mode 100755
index 000000000000..8d698f5a06aa
--- /dev/null
+++ b/tools/perf/scripts/python/bin/net_dropmonitor-report
@@ -0,0 +1,4 @@
+#!/bin/bash
+# description: display a table of dropped frames
+
+perf script -s "$PERF_EXEC_PATH"/scripts/python/net_dropmonitor.py $@
diff --git a/tools/perf/scripts/python/net_dropmonitor.py b/tools/perf/scripts/python/net_dropmonitor.py
new file mode 100755
index 000000000000..a4ffc9500023
--- /dev/null
+++ b/tools/perf/scripts/python/net_dropmonitor.py
@@ -0,0 +1,72 @@
+# Monitor the system for dropped packets and proudce a report of drop locations and counts
+
+import os
+import sys
+
+sys.path.append(os.environ['PERF_EXEC_PATH'] + \
+ '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
+
+from perf_trace_context import *
+from Core import *
+from Util import *
+
+drop_log = {}
+kallsyms = []
+
+def get_kallsyms_table():
+ global kallsyms
+ try:
+ f = open("/proc/kallsyms", "r")
+ linecount = 0
+ for line in f:
+ linecount = linecount+1
+ f.seek(0)
+ except:
+ return
+
+
+ j = 0
+ for line in f:
+ loc = int(line.split()[0], 16)
+ name = line.split()[2]
+ j = j +1
+ if ((j % 100) == 0):
+ print "\r" + str(j) + "/" + str(linecount),
+ kallsyms.append({ 'loc': loc, 'name' : name})
+
+ print "\r" + str(j) + "/" + str(linecount)
+ kallsyms.sort()
+ return
+
+def get_sym(sloc):
+ loc = int(sloc)
+ for i in kallsyms:
+ if (i['loc'] >= loc):
+ return (i['name'], i['loc']-loc)
+ return (None, 0)
+
+def print_drop_table():
+ print "%25s %25s %25s" % ("LOCATION", "OFFSET", "COUNT")
+ for i in drop_log.keys():
+ (sym, off) = get_sym(i)
+ if sym == None:
+ sym = i
+ print "%25s %25s %25s" % (sym, off, drop_log[i])
+
+
+def trace_begin():
+ print "Starting trace (Ctrl-C to dump results)"
+
+def trace_end():
+ print "Gathering kallsyms data"
+ get_kallsyms_table()
+ print_drop_table()
+
+# called from perf, when it finds a correspoinding event
+def skb__kfree_skb(name, context, cpu, sec, nsec, pid, comm,
+ skbaddr, protocol, location):
+ slocation = str(location)
+ try:
+ drop_log[slocation] = drop_log[slocation] + 1
+ except:
+ drop_log[slocation] = 1
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c
index e01af2b1a469..bc8f4773d4d8 100644
--- a/tools/perf/util/annotate.c
+++ b/tools/perf/util/annotate.c
@@ -16,6 +16,8 @@
#include "annotate.h"
#include <pthread.h>
+const char *disassembler_style;
+
int symbol__annotate_init(struct map *map __used, struct symbol *sym)
{
struct annotation *notes = symbol__annotation(sym);
@@ -323,10 +325,15 @@ fallback:
dso, dso->long_name, sym, sym->name);
snprintf(command, sizeof(command),
- "objdump --start-address=0x%016" PRIx64
- " --stop-address=0x%016" PRIx64 " -dS -C %s|grep -v %s|expand",
+ "objdump %s%s --start-address=0x%016" PRIx64
+ " --stop-address=0x%016" PRIx64
+ " -d %s %s -C %s|grep -v %s|expand",
+ disassembler_style ? "-M " : "",
+ disassembler_style ? disassembler_style : "",
map__rip_2objdump(map, sym->start),
map__rip_2objdump(map, sym->end),
+ symbol_conf.annotate_asm_raw ? "" : "--no-show-raw",
+ symbol_conf.annotate_src ? "-S" : "",
symfs_filename, filename);
pr_debug("Executing: %s\n", command);
diff --git a/tools/perf/util/annotate.h b/tools/perf/util/annotate.h
index c2c286896801..6ede1286ee71 100644
--- a/tools/perf/util/annotate.h
+++ b/tools/perf/util/annotate.h
@@ -100,4 +100,6 @@ int symbol__tui_annotate(struct symbol *sym, struct map *map, int evidx,
int refresh);
#endif
+extern const char *disassembler_style;
+
#endif /* __PERF_ANNOTATE_H */
diff --git a/tools/perf/util/color.c b/tools/perf/util/color.c
index e191eb9a667f..521c38a79190 100644
--- a/tools/perf/util/color.c
+++ b/tools/perf/util/color.c
@@ -200,7 +200,7 @@ static int __color_vfprintf(FILE *fp, const char *color, const char *fmt,
* Auto-detect:
*/
if (perf_use_color_default < 0) {
- if (isatty(1) || pager_in_use())
+ if (isatty(fileno(fp)) || pager_in_use())
perf_use_color_default = 1;
else
perf_use_color_default = 0;
diff --git a/tools/perf/util/map.c b/tools/perf/util/map.c
index a16ecab5229d..9cf0d4393c8d 100644
--- a/tools/perf/util/map.c
+++ b/tools/perf/util/map.c
@@ -18,6 +18,13 @@ static inline int is_anon_memory(const char *filename)
return strcmp(filename, "//anon") == 0;
}
+static inline int is_no_dso_memory(const char *filename)
+{
+ return !strcmp(filename, "[stack]") ||
+ !strcmp(filename, "[vdso]") ||
+ !strcmp(filename, "[heap]");
+}
+
void map__init(struct map *self, enum map_type type,
u64 start, u64 end, u64 pgoff, struct dso *dso)
{
@@ -42,9 +49,10 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
if (self != NULL) {
char newfilename[PATH_MAX];
struct dso *dso;
- int anon;
+ int anon, no_dso;
anon = is_anon_memory(filename);
+ no_dso = is_no_dso_memory(filename);
if (anon) {
snprintf(newfilename, sizeof(newfilename), "/tmp/perf-%d.map", pid);
@@ -57,12 +65,16 @@ struct map *map__new(struct list_head *dsos__list, u64 start, u64 len,
map__init(self, type, start, start + len, pgoff, dso);
- if (anon) {
-set_identity:
+ if (anon || no_dso) {
self->map_ip = self->unmap_ip = identity__map_ip;
- } else if (strcmp(filename, "[vdso]") == 0) {
- dso__set_loaded(dso, self->type);
- goto set_identity;
+
+ /*
+ * Set memory without DSO as loaded. All map__find_*
+ * functions still return NULL, and we avoid the
+ * unnecessary map__load warning.
+ */
+ if (no_dso)
+ dso__set_loaded(dso, self->type);
}
}
return self;
@@ -220,55 +232,55 @@ u64 map__objdump_2ip(struct map *map, u64 addr)
return ip;
}
-void map_groups__init(struct map_groups *self)
+void map_groups__init(struct map_groups *mg)
{
int i;
for (i = 0; i < MAP__NR_TYPES; ++i) {
- self->maps[i] = RB_ROOT;
- INIT_LIST_HEAD(&self->removed_maps[i]);
+ mg->maps[i] = RB_ROOT;
+ INIT_LIST_HEAD(&mg->removed_maps[i]);
}
- self->machine = NULL;
+ mg->machine = NULL;
}
-static void maps__delete(struct rb_root *self)
+static void maps__delete(struct rb_root *maps)
{
- struct rb_node *next = rb_first(self);
+ struct rb_node *next = rb_first(maps);
while (next) {
struct map *pos = rb_entry(next, struct map, rb_node);
next = rb_next(&pos->rb_node);
- rb_erase(&pos->rb_node, self);
+ rb_erase(&pos->rb_node, maps);
map__delete(pos);
}
}
-static void maps__delete_removed(struct list_head *self)
+static void maps__delete_removed(struct list_head *maps)
{
struct map *pos, *n;
- list_for_each_entry_safe(pos, n, self, node) {
+ list_for_each_entry_safe(pos, n, maps, node) {
list_del(&pos->node);
map__delete(pos);
}
}
-void map_groups__exit(struct map_groups *self)
+void map_groups__exit(struct map_groups *mg)
{
int i;
for (i = 0; i < MAP__NR_TYPES; ++i) {
- maps__delete(&self->maps[i]);
- maps__delete_removed(&self->removed_maps[i]);
+ maps__delete(&mg->maps[i]);
+ maps__delete_removed(&mg->removed_maps[i]);
}
}
-void map_groups__flush(struct map_groups *self)
+void map_groups__flush(struct map_groups *mg)
{
int type;
for (type = 0; type < MAP__NR_TYPES; type++) {
- struct rb_root *root = &self->maps[type];
+ struct rb_root *root = &mg->maps[type];
struct rb_node *next = rb_first(root);
while (next) {
@@ -280,17 +292,17 @@ void map_groups__flush(struct map_groups *self)
* instance in some hist_entry instances, so
* just move them to a separate list.
*/
- list_add_tail(&pos->node, &self->removed_maps[pos->type]);
+ list_add_tail(&pos->node, &mg->removed_maps[pos->type]);
}
}
}
-struct symbol *map_groups__find_symbol(struct map_groups *self,
+struct symbol *map_groups__find_symbol(struct map_groups *mg,
enum map_type type, u64 addr,
struct map **mapp,
symbol_filter_t filter)
{
- struct map *map = map_groups__find(self, type, addr);
+ struct map *map = map_groups__find(mg, type, addr);
if (map != NULL) {
if (mapp != NULL)
@@ -301,7 +313,7 @@ struct symbol *map_groups__find_symbol(struct map_groups *self,
return NULL;
}
-struct symbol *map_groups__find_symbol_by_name(struct map_groups *self,
+struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg,
enum map_type type,
const char *name,
struct map **mapp,
@@ -309,7 +321,7 @@ struct symbol *map_groups__find_symbol_by_name(struct map_groups *self,
{
struct rb_node *nd;
- for (nd = rb_first(&self->maps[type]); nd; nd = rb_next(nd)) {
+ for (nd = rb_first(&mg->maps[type]); nd; nd = rb_next(nd)) {
struct map *pos = rb_entry(nd, struct map, rb_node);
struct symbol *sym = map__find_symbol_by_name(pos, name, filter);
@@ -323,13 +335,13 @@ struct symbol *map_groups__find_symbol_by_name(struct map_groups *self,
return NULL;
}
-size_t __map_groups__fprintf_maps(struct map_groups *self,
+size_t __map_groups__fprintf_maps(struct map_groups *mg,
enum map_type type, int verbose, FILE *fp)
{
size_t printed = fprintf(fp, "%s:\n", map_type__name[type]);
struct rb_node *nd;
- for (nd = rb_first(&self->maps[type]); nd; nd = rb_next(nd)) {
+ for (nd = rb_first(&mg->maps[type]); nd; nd = rb_next(nd)) {
struct map *pos = rb_entry(nd, struct map, rb_node);
printed += fprintf(fp, "Map:");
printed += map__fprintf(pos, fp);
@@ -342,22 +354,22 @@ size_t __map_groups__fprintf_maps(struct map_groups *self,
return printed;
}
-size_t map_groups__fprintf_maps(struct map_groups *self, int verbose, FILE *fp)
+size_t map_groups__fprintf_maps(struct map_groups *mg, int verbose, FILE *fp)
{
size_t printed = 0, i;
for (i = 0; i < MAP__NR_TYPES; ++i)
- printed += __map_groups__fprintf_maps(self, i, verbose, fp);
+ printed += __map_groups__fprintf_maps(mg, i, verbose, fp);
return printed;
}
-static size_t __map_groups__fprintf_removed_maps(struct map_groups *self,
+static size_t __map_groups__fprintf_removed_maps(struct map_groups *mg,
enum map_type type,
int verbose, FILE *fp)
{
struct map *pos;
size_t printed = 0;
- list_for_each_entry(pos, &self->removed_maps[type], node) {
+ list_for_each_entry(pos, &mg->removed_maps[type], node) {
printed += fprintf(fp, "Map:");
printed += map__fprintf(pos, fp);
if (verbose > 1) {
@@ -368,26 +380,26 @@ static size_t __map_groups__fprintf_removed_maps(struct map_groups *self,
return printed;
}
-static size_t map_groups__fprintf_removed_maps(struct map_groups *self,
+static size_t map_groups__fprintf_removed_maps(struct map_groups *mg,
int verbose, FILE *fp)
{
size_t printed = 0, i;
for (i = 0; i < MAP__NR_TYPES; ++i)
- printed += __map_groups__fprintf_removed_maps(self, i, verbose, fp);
+ printed += __map_groups__fprintf_removed_maps(mg, i, verbose, fp);
return printed;
}
-size_t map_groups__fprintf(struct map_groups *self, int verbose, FILE *fp)
+size_t map_groups__fprintf(struct map_groups *mg, int verbose, FILE *fp)
{
- size_t printed = map_groups__fprintf_maps(self, verbose, fp);
+ size_t printed = map_groups__fprintf_maps(mg, verbose, fp);
printed += fprintf(fp, "Removed maps:\n");
- return printed + map_groups__fprintf_removed_maps(self, verbose, fp);
+ return printed + map_groups__fprintf_removed_maps(mg, verbose, fp);
}
-int map_groups__fixup_overlappings(struct map_groups *self, struct map *map,
+int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map,
int verbose, FILE *fp)
{
- struct rb_root *root = &self->maps[map->type];
+ struct rb_root *root = &mg->maps[map->type];
struct rb_node *next = rb_first(root);
int err = 0;
@@ -418,7 +430,7 @@ int map_groups__fixup_overlappings(struct map_groups *self, struct map *map,
}
before->end = map->start - 1;
- map_groups__insert(self, before);
+ map_groups__insert(mg, before);
if (verbose >= 2)
map__fprintf(before, fp);
}
@@ -432,7 +444,7 @@ int map_groups__fixup_overlappings(struct map_groups *self, struct map *map,
}
after->start = map->end + 1;
- map_groups__insert(self, after);
+ map_groups__insert(mg, after);
if (verbose >= 2)
map__fprintf(after, fp);
}
@@ -441,7 +453,7 @@ move_map:
* If we have references, just move them to a separate list.
*/
if (pos->referenced)
- list_add_tail(&pos->node, &self->removed_maps[map->type]);
+ list_add_tail(&pos->node, &mg->removed_maps[map->type]);
else
map__delete(pos);
@@ -455,7 +467,7 @@ move_map:
/*
* XXX This should not really _copy_ te maps, but refcount them.
*/
-int map_groups__clone(struct map_groups *self,
+int map_groups__clone(struct map_groups *mg,
struct map_groups *parent, enum map_type type)
{
struct rb_node *nd;
@@ -464,7 +476,7 @@ int map_groups__clone(struct map_groups *self,
struct map *new = map__clone(map);
if (new == NULL)
return -ENOMEM;
- map_groups__insert(self, new);
+ map_groups__insert(mg, new);
}
return 0;
}
diff --git a/tools/perf/util/map.h b/tools/perf/util/map.h
index b397c0383728..890d85545d0f 100644
--- a/tools/perf/util/map.h
+++ b/tools/perf/util/map.h
@@ -123,17 +123,17 @@ void map__fixup_end(struct map *self);
void map__reloc_vmlinux(struct map *self);
-size_t __map_groups__fprintf_maps(struct map_groups *self,
+size_t __map_groups__fprintf_maps(struct map_groups *mg,
enum map_type type, int verbose, FILE *fp);
void maps__insert(struct rb_root *maps, struct map *map);
-void maps__remove(struct rb_root *self, struct map *map);
+void maps__remove(struct rb_root *maps, struct map *map);
struct map *maps__find(struct rb_root *maps, u64 addr);
-void map_groups__init(struct map_groups *self);
-void map_groups__exit(struct map_groups *self);
-int map_groups__clone(struct map_groups *self,
+void map_groups__init(struct map_groups *mg);
+void map_groups__exit(struct map_groups *mg);
+int map_groups__clone(struct map_groups *mg,
struct map_groups *parent, enum map_type type);
-size_t map_groups__fprintf(struct map_groups *self, int verbose, FILE *fp);
-size_t map_groups__fprintf_maps(struct map_groups *self, int verbose, FILE *fp);
+size_t map_groups__fprintf(struct map_groups *mg, int verbose, FILE *fp);
+size_t map_groups__fprintf_maps(struct map_groups *mg, int verbose, FILE *fp);
typedef void (*machine__process_t)(struct machine *self, void *data);
@@ -162,29 +162,29 @@ static inline bool machine__is_host(struct machine *self)
return self ? self->pid == HOST_KERNEL_ID : false;
}
-static inline void map_groups__insert(struct map_groups *self, struct map *map)
+static inline void map_groups__insert(struct map_groups *mg, struct map *map)
{
- maps__insert(&self->maps[map->type], map);
- map->groups = self;
+ maps__insert(&mg->maps[map->type], map);
+ map->groups = mg;
}
-static inline void map_groups__remove(struct map_groups *self, struct map *map)
+static inline void map_groups__remove(struct map_groups *mg, struct map *map)
{
- maps__remove(&self->maps[map->type], map);
+ maps__remove(&mg->maps[map->type], map);
}
-static inline struct map *map_groups__find(struct map_groups *self,
+static inline struct map *map_groups__find(struct map_groups *mg,
enum map_type type, u64 addr)
{
- return maps__find(&self->maps[type], addr);
+ return maps__find(&mg->maps[type], addr);
}
-struct symbol *map_groups__find_symbol(struct map_groups *self,
+struct symbol *map_groups__find_symbol(struct map_groups *mg,
enum map_type type, u64 addr,
struct map **mapp,
symbol_filter_t filter);
-struct symbol *map_groups__find_symbol_by_name(struct map_groups *self,
+struct symbol *map_groups__find_symbol_by_name(struct map_groups *mg,
enum map_type type,
const char *name,
struct map **mapp,
@@ -208,11 +208,11 @@ struct symbol *machine__find_kernel_function(struct machine *self, u64 addr,
}
static inline
-struct symbol *map_groups__find_function_by_name(struct map_groups *self,
+struct symbol *map_groups__find_function_by_name(struct map_groups *mg,
const char *name, struct map **mapp,
symbol_filter_t filter)
{
- return map_groups__find_symbol_by_name(self, MAP__FUNCTION, name, mapp, filter);
+ return map_groups__find_symbol_by_name(mg, MAP__FUNCTION, name, mapp, filter);
}
static inline
@@ -225,13 +225,13 @@ struct symbol *machine__find_kernel_function_by_name(struct machine *self,
filter);
}
-int map_groups__fixup_overlappings(struct map_groups *self, struct map *map,
+int map_groups__fixup_overlappings(struct map_groups *mg, struct map *map,
int verbose, FILE *fp);
-struct map *map_groups__find_by_name(struct map_groups *self,
+struct map *map_groups__find_by_name(struct map_groups *mg,
enum map_type type, const char *name);
struct map *machine__new_module(struct machine *self, u64 start, const char *filename);
-void map_groups__flush(struct map_groups *self);
+void map_groups__flush(struct map_groups *mg);
#endif /* __PERF_MAP_H */
diff --git a/tools/perf/util/symbol.c b/tools/perf/util/symbol.c
index 40eeaf07725b..077df15ee705 100644
--- a/tools/perf/util/symbol.c
+++ b/tools/perf/util/symbol.c
@@ -46,6 +46,8 @@ struct symbol_conf symbol_conf = {
.exclude_other = true,
.use_modules = true,
.try_vmlinux_path = true,
+ .annotate_asm_raw = true,
+ .annotate_src = true,
.symfs = "",
};
diff --git a/tools/perf/util/symbol.h b/tools/perf/util/symbol.h
index 4f377d92e75a..7733f0b3cd41 100644
--- a/tools/perf/util/symbol.h
+++ b/tools/perf/util/symbol.h
@@ -76,7 +76,9 @@ struct symbol_conf {
exclude_other,
show_cpu_utilization,
initialized,
- kptr_restrict;
+ kptr_restrict,
+ annotate_asm_raw,
+ annotate_src;
const char *vmlinux_name,
*kallsyms_name,
*source_prefix,
diff --git a/tools/perf/util/top.h b/tools/perf/util/top.h
index bfbf95bcc603..b07b0410463c 100644
--- a/tools/perf/util/top.h
+++ b/tools/perf/util/top.h
@@ -10,6 +10,7 @@
struct perf_evlist;
struct perf_evsel;
+struct perf_session;
struct sym_entry {
struct rb_node rb_node;
@@ -38,6 +39,7 @@ struct perf_top {
u64 kernel_samples, us_samples;
u64 exact_samples;
u64 guest_us_samples, guest_kernel_samples;
+ u64 total_lost_warned;
int print_entries, count_filter, delay_secs;
int display_weighted, freq, rb_entries;
pid_t target_pid, target_tid;
@@ -45,6 +47,7 @@ struct perf_top {
const char *cpu_list;
struct sym_entry *sym_filter_entry;
struct perf_evsel *sym_evsel;
+ struct perf_session *session;
};
size_t perf_top__header_snprintf(struct perf_top *top, char *bf, size_t size);
diff --git a/tools/perf/util/ui/browsers/top.c b/tools/perf/util/ui/browsers/top.c
index 88403cf8396a..9b6b43b32ac8 100644
--- a/tools/perf/util/ui/browsers/top.c
+++ b/tools/perf/util/ui/browsers/top.c
@@ -11,10 +11,12 @@
#include "../helpline.h"
#include "../libslang.h"
#include "../util.h"
+#include "../ui.h"
#include "../../evlist.h"
#include "../../hist.h"
#include "../../sort.h"
#include "../../symbol.h"
+#include "../../session.h"
#include "../../top.h"
struct perf_top_browser {
@@ -43,10 +45,10 @@ static void perf_top_browser__write(struct ui_browser *browser, void *entry, int
if (top->evlist->nr_entries == 1 || !top->display_weighted) {
slsmg_printf("%20.2f ", syme->weight);
- width -= 24;
+ width -= 21;
} else {
slsmg_printf("%9.1f %10ld ", syme->weight, syme->snap_count);
- width -= 23;
+ width -= 20;
}
slsmg_printf("%4.1f%%", pcnt);
@@ -143,6 +145,25 @@ do_annotation:
symbol__tui_annotate(sym, syme->map, 0, top->delay_secs * 1000);
}
+static void perf_top_browser__warn_lost(struct perf_top_browser *browser)
+{
+ struct perf_top *top = browser->b.priv;
+ char msg[128];
+ int len;
+
+ top->total_lost_warned = top->session->hists.stats.total_lost;
+ pthread_mutex_lock(&ui__lock);
+ ui_browser__set_color(&browser->b, HE_COLORSET_TOP);
+ len = snprintf(msg, sizeof(msg),
+ " WARNING: LOST %" PRIu64 " events, Check IO/CPU overload",
+ top->total_lost_warned);
+ if (len > browser->b.width)
+ len = browser->b.width;
+ SLsmg_gotorc(0, browser->b.width - len);
+ slsmg_write_nstring(msg, len);
+ pthread_mutex_unlock(&ui__lock);
+}
+
static int perf_top_browser__run(struct perf_top_browser *browser)
{
int key;
@@ -174,6 +195,9 @@ static int perf_top_browser__run(struct perf_top_browser *browser)
ui_browser__set_color(&browser->b, NEWT_COLORSET_ROOT);
SLsmg_gotorc(0, 0);
slsmg_write_nstring(title, browser->b.width);
+
+ if (top->total_lost_warned != top->session->hists.stats.total_lost)
+ perf_top_browser__warn_lost(browser);
break;
case 'a':
case NEWT_KEY_RIGHT: