Skip to content

Commit

Permalink
Merge branch 'perf/core' of git://github.com/acmel/linux into perf/core
Browse files Browse the repository at this point in the history
  • Loading branch information
Ingo Molnar committed Oct 10, 2011
2 parents d48b0e1 + 64c6f0c commit 7588bad
Show file tree
Hide file tree
Showing 35 changed files with 2,124 additions and 804 deletions.
3 changes: 1 addition & 2 deletions tools/perf/Documentation/perf-annotate.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ OPTIONS
CPUs.

--asm-raw::
Show raw instruction encoding of assembly instructions. They
are displayed by default, disable with --no-asm-raw.
Show raw instruction encoding of assembly instructions.

--source::
Interleave source code with assembly code. Enabled by default,
Expand Down
17 changes: 16 additions & 1 deletion tools/perf/Documentation/perf-report.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,21 @@ OPTIONS
-M::
--disassembler-style=:: Set disassembler style for objdump.

--source::
Interleave source code with assembly code. Enabled by default,
disable with --no-source.

--asm-raw::
Show raw instruction encoding of assembly instructions.

--show-total-period:: Show a column with the sum of periods.

-I::
--show-info::
Display extended information about the perf.data file. This adds
information which may be very large and thus may clutter the display.
It currently includes: cpu and numa topology of the host system.

SEE ALSO
--------
linkperf:perf-stat[1]
linkperf:perf-stat[1], linkperf:perf-annotate[1]
7 changes: 7 additions & 0 deletions tools/perf/Documentation/perf-script.txt
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ OPTIONS
CPUs are specified with -: 0-2. Default is to report samples on all
CPUs.

-I::
--show-info::
Display extended information about the perf.data file. This adds
information which may be very large and thus may clutter the display.
It currently includes: cpu and numa topology of the host system.
It can only be used with the perf script report mode.

SEE ALSO
--------
linkperf:perf-record[1], linkperf:perf-script-perl[1],
Expand Down
48 changes: 45 additions & 3 deletions tools/perf/Documentation/perf-top.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,51 @@ Default is to monitor all CPUS.
--zero::
Zero history across display updates.

-s::
--sort::
Sort by key(s): pid, comm, dso, symbol, parent

-n::
--show-nr-samples::
Show a column with the number of samples.

--show-total-period::
Show a column with the sum of periods.

--dsos::
Only consider symbols in these dsos.

--comms::
Only consider symbols in these comms.

--symbols::
Only consider these symbols.

-M::
--disassembler-style=:: Set disassembler style for objdump.

--source::
Interleave source code with assembly code. Enabled by default,
disable with --no-source.

--asm-raw::
Show raw instruction encoding of assembly instructions.

-G [type,min,order]::
--call-graph::
Display call chains using type, min percent threshold and order.
type can be either:
- flat: single column, linear exposure of call chains.
- graph: use a graph tree, displaying absolute overhead rates.
- fractal: like graph, but displays relative rates. Each branch of
the tree is considered as a new profiled object.

order can be either:
- callee: callee based call graph.
- caller: inverted caller based call graph.

Default: fractal,0.5,callee.

INTERACTIVE PROMPTING KEYS
--------------------------

Expand All @@ -130,9 +175,6 @@ INTERACTIVE PROMPTING KEYS
[S]::
Stop annotation, return to full profile display.

[w]::
Toggle between weighted sum and individual count[E]r profile.

[z]::
Toggle event count zeroing across display updates.

Expand Down
4 changes: 0 additions & 4 deletions tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ else
LIB_OBJS += $(OUTPUT)util/ui/browsers/annotate.o
LIB_OBJS += $(OUTPUT)util/ui/browsers/hists.o
LIB_OBJS += $(OUTPUT)util/ui/browsers/map.o
LIB_OBJS += $(OUTPUT)util/ui/browsers/top.o
LIB_OBJS += $(OUTPUT)util/ui/helpline.o
LIB_OBJS += $(OUTPUT)util/ui/progress.o
LIB_OBJS += $(OUTPUT)util/ui/util.o
Expand Down Expand Up @@ -729,9 +728,6 @@ $(OUTPUT)util/ui/browser.o: util/ui/browser.c $(OUTPUT)PERF-CFLAGS
$(OUTPUT)util/ui/browsers/annotate.o: util/ui/browsers/annotate.c $(OUTPUT)PERF-CFLAGS
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<

$(OUTPUT)util/ui/browsers/top.o: util/ui/browsers/top.c $(OUTPUT)PERF-CFLAGS
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<

$(OUTPUT)util/ui/browsers/hists.o: util/ui/browsers/hists.c $(OUTPUT)PERF-CFLAGS
$(QUIET_CC)$(CC) -o $@ -c $(ALL_CFLAGS) -DENABLE_SLFUTURE_CONST $<

Expand Down
1 change: 1 addition & 0 deletions tools/perf/arch/powerpc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ ifndef NO_DWARF
PERF_HAVE_DWARF_REGS := 1
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
endif
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
36 changes: 36 additions & 0 deletions tools/perf/arch/powerpc/util/header.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "../../util/header.h"

#define __stringify_1(x) #x
#define __stringify(x) __stringify_1(x)

#define mfspr(rn) ({unsigned long rval; \
asm volatile("mfspr %0," __stringify(rn) \
: "=r" (rval)); rval; })

#define SPRN_PVR 0x11F /* Processor Version Register */
#define PVR_VER(pvr) (((pvr) >> 16) & 0xFFFF) /* Version field */
#define PVR_REV(pvr) (((pvr) >> 0) & 0xFFFF) /* Revison field */

int
get_cpuid(char *buffer, size_t sz)
{
unsigned long pvr;
int nb;

pvr = mfspr(SPRN_PVR);

nb = snprintf(buffer, sz, "%lu,%lu$", PVR_VER(pvr), PVR_REV(pvr));

/* look for end marker to ensure the entire data fit */
if (strchr(buffer, '$')) {
buffer[nb-1] = '\0';
return 0;
}
return -1;
}
1 change: 1 addition & 0 deletions tools/perf/arch/x86/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ ifndef NO_DWARF
PERF_HAVE_DWARF_REGS := 1
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/dwarf-regs.o
endif
LIB_OBJS += $(OUTPUT)arch/$(ARCH)/util/header.o
59 changes: 59 additions & 0 deletions tools/perf/arch/x86/util/header.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "../../util/header.h"

static inline void
cpuid(unsigned int op, unsigned int *a, unsigned int *b, unsigned int *c,
unsigned int *d)
{
__asm__ __volatile__ (".byte 0x53\n\tcpuid\n\t"
"movl %%ebx, %%esi\n\t.byte 0x5b"
: "=a" (*a),
"=S" (*b),
"=c" (*c),
"=d" (*d)
: "a" (op));
}

int
get_cpuid(char *buffer, size_t sz)
{
unsigned int a, b, c, d, lvl;
int family = -1, model = -1, step = -1;
int nb;
char vendor[16];

cpuid(0, &lvl, &b, &c, &d);
strncpy(&vendor[0], (char *)(&b), 4);
strncpy(&vendor[4], (char *)(&d), 4);
strncpy(&vendor[8], (char *)(&c), 4);
vendor[12] = '\0';

if (lvl >= 1) {
cpuid(1, &a, &b, &c, &d);

family = (a >> 8) & 0xf; /* bits 11 - 8 */
model = (a >> 4) & 0xf; /* Bits 7 - 4 */
step = a & 0xf;

/* extended family */
if (family == 0xf)
family += (a >> 20) & 0xff;

/* extended model */
if (family >= 0x6)
model += ((a >> 16) & 0xf) << 4;
}
nb = snprintf(buffer, sz, "%s,%u,%u,%u$", vendor, family, model, step);

/* look for end marker to ensure the entire data fit */
if (strchr(buffer, '$')) {
buffer[nb-1] = '\0';
return 0;
}
return -1;
}
13 changes: 8 additions & 5 deletions tools/perf/builtin-annotate.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ static int hist_entry__tty_annotate(struct hist_entry *he, int evidx)
print_line, full_paths, 0, 0);
}

static void hists__find_annotations(struct hists *self, int evidx)
static void hists__find_annotations(struct hists *self, int evidx,
int nr_events)
{
struct rb_node *nd = rb_first(&self->entries), *next;
int key = KEY_RIGHT;
Expand All @@ -137,7 +138,8 @@ static void hists__find_annotations(struct hists *self, int evidx)
}

if (use_browser > 0) {
key = hist_entry__tui_annotate(he, evidx);
key = hist_entry__tui_annotate(he, evidx, nr_events,
NULL, NULL, 0);
switch (key) {
case KEY_RIGHT:
next = rb_next(nd);
Expand Down Expand Up @@ -215,7 +217,8 @@ static int __cmd_annotate(void)
total_nr_samples += nr_samples;
hists__collapse_resort(hists);
hists__output_resort(hists);
hists__find_annotations(hists, pos->idx);
hists__find_annotations(hists, pos->idx,
session->evlist->nr_entries);
}
}

Expand Down Expand Up @@ -269,9 +272,9 @@ static const struct option options[] = {
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,
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,
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)"),
Expand Down
2 changes: 1 addition & 1 deletion tools/perf/builtin-diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ static int __cmd_diff(void)

hists__match(&session[0]->hists, &session[1]->hists);
hists__fprintf(&session[1]->hists, &session[0]->hists,
show_displacement, stdout);
show_displacement, true, 0, 0, stdout);
out_delete:
for (i = 0; i < 2; ++i)
perf_session__delete(session[i]);
Expand Down
15 changes: 15 additions & 0 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,19 @@ static int __cmd_record(int argc, const char **argv)
if (have_tracepoints(&evsel_list->entries))
perf_header__set_feat(&session->header, HEADER_TRACE_INFO);

perf_header__set_feat(&session->header, HEADER_HOSTNAME);
perf_header__set_feat(&session->header, HEADER_OSRELEASE);
perf_header__set_feat(&session->header, HEADER_ARCH);
perf_header__set_feat(&session->header, HEADER_CPUDESC);
perf_header__set_feat(&session->header, HEADER_NRCPUS);
perf_header__set_feat(&session->header, HEADER_EVENT_DESC);
perf_header__set_feat(&session->header, HEADER_CMDLINE);
perf_header__set_feat(&session->header, HEADER_VERSION);
perf_header__set_feat(&session->header, HEADER_CPU_TOPOLOGY);
perf_header__set_feat(&session->header, HEADER_TOTAL_MEM);
perf_header__set_feat(&session->header, HEADER_NUMA_TOPOLOGY);
perf_header__set_feat(&session->header, HEADER_CPUID);

/* 512 kiB: default amount of unprivileged mlocked memory */
if (mmap_pages == UINT_MAX)
mmap_pages = (512 * 1024) / page_size;
Expand Down Expand Up @@ -800,6 +813,8 @@ int cmd_record(int argc, const char **argv, const char *prefix __used)
int err = -ENOMEM;
struct perf_evsel *pos;

perf_header__set_cmdline(argc, argv);

evsel_list = perf_evlist__new(NULL, NULL);
if (evsel_list == NULL)
return -ENOMEM;
Expand Down
21 changes: 17 additions & 4 deletions tools/perf/builtin-report.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ static char const *input_name = "perf.data";
static bool force, use_tui, use_stdio;
static bool hide_unresolved;
static bool dont_use_callchains;
static bool show_full_info;

static bool show_threads;
static struct perf_read_values show_threads_values;
Expand Down Expand Up @@ -232,7 +233,7 @@ static int perf_evlist__tty_browse_hists(struct perf_evlist *evlist,
const char *evname = event_name(pos);

hists__fprintf_nr_sample_events(hists, evname, stdout);
hists__fprintf(hists, NULL, false, stdout);
hists__fprintf(hists, NULL, false, true, 0, 0, stdout);
fprintf(stdout, "\n\n");
}

Expand Down Expand Up @@ -273,6 +274,9 @@ static int __cmd_report(void)
goto out_delete;
}

if (use_browser <= 0)
perf_session__fprintf_info(session, stdout, show_full_info);

if (show_threads)
perf_read_values_init(&show_threads_values);

Expand Down Expand Up @@ -327,9 +331,10 @@ static int __cmd_report(void)
goto out_delete;
}

if (use_browser > 0)
perf_evlist__tui_browse_hists(session->evlist, help);
else
if (use_browser > 0) {
perf_evlist__tui_browse_hists(session->evlist, help,
NULL, NULL, 0);
} else
perf_evlist__tty_browse_hists(session->evlist, help);

out_delete:
Expand Down Expand Up @@ -484,8 +489,16 @@ 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_BOOLEAN('I', "show-info", &show_full_info,
"Display extended information about perf.data file"),
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_BOOLEAN(0, "show-total-period", &symbol_conf.show_total_period,
"Show a column with the sum of periods"),
OPT_END()
};

Expand Down
6 changes: 5 additions & 1 deletion tools/perf/builtin-script.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ static u64 last_timestamp;
static u64 nr_unordered;
extern const struct option record_options[];
static bool no_callchain;
static bool show_full_info;
static const char *cpu_list;
static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);

Expand Down Expand Up @@ -1083,7 +1084,8 @@ static const struct option options[] = {
"comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,ip,sym,dso,addr",
parse_output_fields),
OPT_STRING('c', "cpu", &cpu_list, "cpu", "list of cpus to profile"),

OPT_BOOLEAN('I', "show-info", &show_full_info,
"display extended information from perf.data file"),
OPT_END()
};

Expand Down Expand Up @@ -1268,6 +1270,8 @@ int cmd_script(int argc, const char **argv, const char *prefix __used)
return -1;
}

perf_session__fprintf_info(session, stdout, show_full_info);

if (!no_callchain)
symbol_conf.use_callchain = true;
else
Expand Down
Loading

0 comments on commit 7588bad

Please sign in to comment.