Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip
* 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip: (107 commits) perf stat: Add more cache-miss percentage printouts perf stat: Add -d -d and -d -d -d options to show more CPU events ftrace/kbuild: Add recordmcount files to force full build ftrace: Add self-tests for multiple function trace users ftrace: Modify ftrace_set_filter/notrace to take ops ftrace: Allow dynamically allocated function tracers ftrace: Implement separate user function filtering ftrace: Free hash with call_rcu_sched() ftrace: Have global_ops store the functions that are to be traced ftrace: Add ops parameter to ftrace_startup/shutdown functions ftrace: Add enabled_functions file ftrace: Use counters to enable functions to trace ftrace: Separate hash allocation and assignment ftrace: Create a global_ops to hold the filter and notrace hashes ftrace: Use hash instead for FTRACE_FL_FILTER ftrace: Replace FTRACE_FL_NOTRACE flag with a hash of ignored functions perf bench, x86: Add alternatives-asm.h wrapper x86, 64-bit: Fix copy_[to/from]_user() checks for the userspace address limit x86, mem: memset_64.S: Optimize memset by enhanced REP MOVSB/STOSB x86, mem: memmove_64.S: Optimize memmove by enhanced REP MOVSB/STOSB ...
This commit is contained in:
commit
df48d8716e
78 changed files with 4086 additions and 1773 deletions
|
@ -113,13 +113,61 @@ OPTIONS
|
|||
Do various checks like samples ordering and lost events.
|
||||
|
||||
-f::
|
||||
--fields
|
||||
--fields::
|
||||
Comma separated list of fields to print. Options are:
|
||||
comm, tid, pid, time, cpu, event, trace, sym. Field
|
||||
list must be prepended with the type, trace, sw or hw,
|
||||
list can be prepended with the type, trace, sw or hw,
|
||||
to indicate to which event type the field list applies.
|
||||
e.g., -f sw:comm,tid,time,sym and -f trace:time,cpu,trace
|
||||
|
||||
perf script -f <fields>
|
||||
|
||||
is equivalent to:
|
||||
|
||||
perf script -f trace:<fields> -f sw:<fields> -f hw:<fields>
|
||||
|
||||
i.e., the specified fields apply to all event types if the type string
|
||||
is not given.
|
||||
|
||||
The arguments are processed in the order received. A later usage can
|
||||
reset a prior request. e.g.:
|
||||
|
||||
-f trace: -f comm,tid,time,sym
|
||||
|
||||
The first -f suppresses trace events (field list is ""), but then the
|
||||
second invocation sets the fields to comm,tid,time,sym. In this case a
|
||||
warning is given to the user:
|
||||
|
||||
"Overriding previous field request for all events."
|
||||
|
||||
Alternativey, consider the order:
|
||||
|
||||
-f comm,tid,time,sym -f trace:
|
||||
|
||||
The first -f sets the fields for all events and the second -f
|
||||
suppresses trace events. The user is given a warning message about
|
||||
the override, and the result of the above is that only S/W and H/W
|
||||
events are displayed with the given fields.
|
||||
|
||||
For the 'wildcard' option if a user selected field is invalid for an
|
||||
event type, a message is displayed to the user that the option is
|
||||
ignored for that type. For example:
|
||||
|
||||
$ perf script -f comm,tid,trace
|
||||
'trace' not valid for hardware events. Ignoring.
|
||||
'trace' not valid for software events. Ignoring.
|
||||
|
||||
Alternatively, if the type is given an invalid field is specified it
|
||||
is an error. For example:
|
||||
|
||||
perf script -v -f sw:comm,tid,trace
|
||||
'trace' not valid for software events.
|
||||
|
||||
At this point usage is displayed, and perf-script exits.
|
||||
|
||||
Finally, a user may not set fields to none for all event types.
|
||||
i.e., -f "" is not allowed.
|
||||
|
||||
-k::
|
||||
--vmlinux=<file>::
|
||||
vmlinux pathname
|
||||
|
|
|
@ -5,6 +5,8 @@ endif
|
|||
# The default target of this Makefile is...
|
||||
all:
|
||||
|
||||
include config/utilities.mak
|
||||
|
||||
ifneq ($(OUTPUT),)
|
||||
# check that the output directory actually exists
|
||||
OUTDIR := $(shell cd $(OUTPUT) && /bin/pwd)
|
||||
|
@ -13,6 +15,12 @@ endif
|
|||
|
||||
# Define V to have a more verbose compile.
|
||||
#
|
||||
# Define PYTHON to point to the python binary if the default
|
||||
# `python' is not correct; for example: PYTHON=python2
|
||||
#
|
||||
# Define PYTHON_CONFIG to point to the python-config binary if
|
||||
# the default `$(PYTHON)-config' is not correct.
|
||||
#
|
||||
# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
|
||||
#
|
||||
# Define DOCBOOK_XSL_172 if you want to format man pages with DocBook XSL v1.72.
|
||||
|
@ -134,7 +142,7 @@ INSTALL = install
|
|||
# explicitly what architecture to check for. Fix this up for yours..
|
||||
SPARSE_FLAGS = -D__BIG_ENDIAN__ -D__powerpc__
|
||||
|
||||
-include feature-tests.mak
|
||||
-include config/feature-tests.mak
|
||||
|
||||
ifeq ($(call try-cc,$(SOURCE_HELLO),-Werror -fstack-protector-all),y)
|
||||
CFLAGS := $(CFLAGS) -fstack-protector-all
|
||||
|
@ -169,12 +177,10 @@ grep-libs = $(filter -l%,$(1))
|
|||
strip-libs = $(filter-out -l%,$(1))
|
||||
|
||||
$(OUTPUT)python/perf.so: $(PYRF_OBJS)
|
||||
$(QUIET_GEN)( \
|
||||
export CFLAGS="$(BASIC_CFLAGS)"; \
|
||||
python util/setup.py --quiet build_ext --build-lib='$(OUTPUT)python' \
|
||||
--build-temp='$(OUTPUT)python/temp' \
|
||||
)
|
||||
|
||||
$(QUIET_GEN)CFLAGS='$(BASIC_CFLAGS)' $(PYTHON_WORD) util/setup.py \
|
||||
--quiet build_ext \
|
||||
--build-lib='$(OUTPUT)python' \
|
||||
--build-temp='$(OUTPUT)python/temp'
|
||||
#
|
||||
# No Perl scripts right now:
|
||||
#
|
||||
|
@ -479,24 +485,74 @@ else
|
|||
endif
|
||||
endif
|
||||
|
||||
ifdef NO_LIBPYTHON
|
||||
BASIC_CFLAGS += -DNO_LIBPYTHON
|
||||
disable-python = $(eval $(disable-python_code))
|
||||
define disable-python_code
|
||||
BASIC_CFLAGS += -DNO_LIBPYTHON
|
||||
$(if $(1),$(warning No $(1) was found))
|
||||
$(warning Python support won't be built)
|
||||
endef
|
||||
|
||||
override PYTHON := \
|
||||
$(call get-executable-or-default,PYTHON,python)
|
||||
|
||||
ifndef PYTHON
|
||||
$(call disable-python,python interpreter)
|
||||
python-clean :=
|
||||
else
|
||||
PYTHON_EMBED_LDOPTS = $(shell python-config --ldflags 2>/dev/null)
|
||||
PYTHON_EMBED_LDFLAGS = $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
|
||||
PYTHON_EMBED_LIBADD = $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
|
||||
PYTHON_EMBED_CCOPTS = `python-config --cflags 2>/dev/null`
|
||||
FLAGS_PYTHON_EMBED=$(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
|
||||
ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED)),y)
|
||||
msg := $(warning No Python.h found, install python-dev[el] to have python support in 'perf script' and to build the python bindings)
|
||||
BASIC_CFLAGS += -DNO_LIBPYTHON
|
||||
else
|
||||
ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
|
||||
EXTLIBS += $(PYTHON_EMBED_LIBADD)
|
||||
LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
|
||||
LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
|
||||
LANG_BINDINGS += $(OUTPUT)python/perf.so
|
||||
endif
|
||||
|
||||
PYTHON_WORD := $(call shell-wordify,$(PYTHON))
|
||||
|
||||
python-clean := $(PYTHON_WORD) util/setup.py clean \
|
||||
--build-lib='$(OUTPUT)python' \
|
||||
--build-temp='$(OUTPUT)python/temp'
|
||||
|
||||
ifdef NO_LIBPYTHON
|
||||
$(call disable-python)
|
||||
else
|
||||
|
||||
override PYTHON_CONFIG := \
|
||||
$(call get-executable-or-default,PYTHON_CONFIG,$(PYTHON)-config)
|
||||
|
||||
ifndef PYTHON_CONFIG
|
||||
$(call disable-python,python-config tool)
|
||||
else
|
||||
|
||||
PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
|
||||
|
||||
PYTHON_EMBED_LDOPTS := $(shell $(PYTHON_CONFIG_SQ) --ldflags 2>/dev/null)
|
||||
PYTHON_EMBED_LDFLAGS := $(call strip-libs,$(PYTHON_EMBED_LDOPTS))
|
||||
PYTHON_EMBED_LIBADD := $(call grep-libs,$(PYTHON_EMBED_LDOPTS))
|
||||
PYTHON_EMBED_CCOPTS := $(shell $(PYTHON_CONFIG_SQ) --cflags 2>/dev/null)
|
||||
FLAGS_PYTHON_EMBED := $(PYTHON_EMBED_CCOPTS) $(PYTHON_EMBED_LDOPTS)
|
||||
|
||||
ifneq ($(call try-cc,$(SOURCE_PYTHON_EMBED),$(FLAGS_PYTHON_EMBED)),y)
|
||||
$(call disable-python,Python.h (for Python 2.x))
|
||||
else
|
||||
|
||||
ifneq ($(call try-cc,$(SOURCE_PYTHON_VERSION),$(FLAGS_PYTHON_EMBED)),y)
|
||||
$(warning Python 3 is not yet supported; please set)
|
||||
$(warning PYTHON and/or PYTHON_CONFIG appropriately.)
|
||||
$(warning If you also have Python 2 installed, then)
|
||||
$(warning try something like:)
|
||||
$(warning $(and ,))
|
||||
$(warning $(and ,) make PYTHON=python2)
|
||||
$(warning $(and ,))
|
||||
$(warning Otherwise, disable Python support entirely:)
|
||||
$(warning $(and ,))
|
||||
$(warning $(and ,) make NO_LIBPYTHON=1)
|
||||
$(warning $(and ,))
|
||||
$(error $(and ,))
|
||||
else
|
||||
ALL_LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
|
||||
EXTLIBS += $(PYTHON_EMBED_LIBADD)
|
||||
LIB_OBJS += $(OUTPUT)util/scripting-engines/trace-event-python.o
|
||||
LIB_OBJS += $(OUTPUT)scripts/python/Perf-Trace-Util/Context.o
|
||||
LANG_BINDINGS += $(OUTPUT)python/perf.so
|
||||
endif
|
||||
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifdef NO_DEMANGLE
|
||||
|
@ -837,8 +893,7 @@ clean:
|
|||
$(RM) *.spec *.pyc *.pyo */*.pyc */*.pyo $(OUTPUT)common-cmds.h TAGS tags cscope*
|
||||
$(MAKE) -C Documentation/ clean
|
||||
$(RM) $(OUTPUT)PERF-VERSION-FILE $(OUTPUT)PERF-CFLAGS
|
||||
@python util/setup.py clean --build-lib='$(OUTPUT)python' \
|
||||
--build-temp='$(OUTPUT)python/temp'
|
||||
$(python-clean)
|
||||
|
||||
.PHONY: all install clean strip
|
||||
.PHONY: shell_compatibility_test please_set_SHELL_PATH_to_a_more_modern_shell
|
||||
|
|
|
@ -49,57 +49,169 @@ struct output_option {
|
|||
};
|
||||
|
||||
/* default set to maintain compatibility with current format */
|
||||
static u64 output_fields[PERF_TYPE_MAX] = {
|
||||
[PERF_TYPE_HARDWARE] = PERF_OUTPUT_COMM | PERF_OUTPUT_TID | \
|
||||
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME | \
|
||||
PERF_OUTPUT_EVNAME | PERF_OUTPUT_SYM,
|
||||
static struct {
|
||||
bool user_set;
|
||||
bool wildcard_set;
|
||||
u64 fields;
|
||||
u64 invalid_fields;
|
||||
} output[PERF_TYPE_MAX] = {
|
||||
|
||||
[PERF_TYPE_SOFTWARE] = PERF_OUTPUT_COMM | PERF_OUTPUT_TID | \
|
||||
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME | \
|
||||
PERF_OUTPUT_EVNAME | PERF_OUTPUT_SYM,
|
||||
[PERF_TYPE_HARDWARE] = {
|
||||
.user_set = false,
|
||||
|
||||
[PERF_TYPE_TRACEPOINT] = PERF_OUTPUT_COMM | PERF_OUTPUT_TID | \
|
||||
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME | \
|
||||
PERF_OUTPUT_EVNAME | PERF_OUTPUT_TRACE,
|
||||
.fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
|
||||
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
|
||||
PERF_OUTPUT_EVNAME | PERF_OUTPUT_SYM,
|
||||
|
||||
.invalid_fields = PERF_OUTPUT_TRACE,
|
||||
},
|
||||
|
||||
[PERF_TYPE_SOFTWARE] = {
|
||||
.user_set = false,
|
||||
|
||||
.fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
|
||||
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
|
||||
PERF_OUTPUT_EVNAME | PERF_OUTPUT_SYM,
|
||||
|
||||
.invalid_fields = PERF_OUTPUT_TRACE,
|
||||
},
|
||||
|
||||
[PERF_TYPE_TRACEPOINT] = {
|
||||
.user_set = false,
|
||||
|
||||
.fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
|
||||
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
|
||||
PERF_OUTPUT_EVNAME | PERF_OUTPUT_TRACE,
|
||||
},
|
||||
|
||||
[PERF_TYPE_RAW] = {
|
||||
.user_set = false,
|
||||
|
||||
.fields = PERF_OUTPUT_COMM | PERF_OUTPUT_TID |
|
||||
PERF_OUTPUT_CPU | PERF_OUTPUT_TIME |
|
||||
PERF_OUTPUT_EVNAME | PERF_OUTPUT_SYM,
|
||||
|
||||
.invalid_fields = PERF_OUTPUT_TRACE,
|
||||
},
|
||||
};
|
||||
|
||||
static bool output_set_by_user;
|
||||
|
||||
#define PRINT_FIELD(x) (output_fields[attr->type] & PERF_OUTPUT_##x)
|
||||
|
||||
static int perf_session__check_attr(struct perf_session *session,
|
||||
struct perf_event_attr *attr)
|
||||
static bool output_set_by_user(void)
|
||||
{
|
||||
int j;
|
||||
for (j = 0; j < PERF_TYPE_MAX; ++j) {
|
||||
if (output[j].user_set)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static const char *output_field2str(enum perf_output_field field)
|
||||
{
|
||||
int i, imax = ARRAY_SIZE(all_output_options);
|
||||
const char *str = "";
|
||||
|
||||
for (i = 0; i < imax; ++i) {
|
||||
if (all_output_options[i].field == field) {
|
||||
str = all_output_options[i].str;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
#define PRINT_FIELD(x) (output[attr->type].fields & PERF_OUTPUT_##x)
|
||||
|
||||
static int perf_event_attr__check_stype(struct perf_event_attr *attr,
|
||||
u64 sample_type, const char *sample_msg,
|
||||
enum perf_output_field field)
|
||||
{
|
||||
int type = attr->type;
|
||||
const char *evname;
|
||||
|
||||
if (attr->sample_type & sample_type)
|
||||
return 0;
|
||||
|
||||
if (output[type].user_set) {
|
||||
evname = __event_name(attr->type, attr->config);
|
||||
pr_err("Samples for '%s' event do not have %s attribute set. "
|
||||
"Cannot print '%s' field.\n",
|
||||
evname, sample_msg, output_field2str(field));
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* user did not ask for it explicitly so remove from the default list */
|
||||
output[type].fields &= ~field;
|
||||
evname = __event_name(attr->type, attr->config);
|
||||
pr_debug("Samples for '%s' event do not have %s attribute set. "
|
||||
"Skipping '%s' field.\n",
|
||||
evname, sample_msg, output_field2str(field));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int perf_evsel__check_attr(struct perf_evsel *evsel,
|
||||
struct perf_session *session)
|
||||
{
|
||||
struct perf_event_attr *attr = &evsel->attr;
|
||||
|
||||
if (PRINT_FIELD(TRACE) &&
|
||||
!perf_session__has_traces(session, "record -R"))
|
||||
return -EINVAL;
|
||||
|
||||
if (PRINT_FIELD(SYM)) {
|
||||
if (!(session->sample_type & PERF_SAMPLE_IP)) {
|
||||
pr_err("Samples do not contain IP data.\n");
|
||||
if (perf_event_attr__check_stype(attr, PERF_SAMPLE_IP, "IP",
|
||||
PERF_OUTPUT_SYM))
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (!no_callchain &&
|
||||
!(session->sample_type & PERF_SAMPLE_CALLCHAIN))
|
||||
!(attr->sample_type & PERF_SAMPLE_CALLCHAIN))
|
||||
symbol_conf.use_callchain = false;
|
||||
}
|
||||
|
||||
if ((PRINT_FIELD(PID) || PRINT_FIELD(TID)) &&
|
||||
!(session->sample_type & PERF_SAMPLE_TID)) {
|
||||
pr_err("Samples do not contain TID/PID data.\n");
|
||||
perf_event_attr__check_stype(attr, PERF_SAMPLE_TID, "TID",
|
||||
PERF_OUTPUT_TID|PERF_OUTPUT_PID))
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (PRINT_FIELD(TIME) &&
|
||||
!(session->sample_type & PERF_SAMPLE_TIME)) {
|
||||
pr_err("Samples do not contain timestamps.\n");
|
||||
perf_event_attr__check_stype(attr, PERF_SAMPLE_TIME, "TIME",
|
||||
PERF_OUTPUT_TIME))
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (PRINT_FIELD(CPU) &&
|
||||
!(session->sample_type & PERF_SAMPLE_CPU)) {
|
||||
pr_err("Samples do not contain cpu.\n");
|
||||
perf_event_attr__check_stype(attr, PERF_SAMPLE_CPU, "CPU",
|
||||
PERF_OUTPUT_CPU))
|
||||
return -EINVAL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* verify all user requested events exist and the samples
|
||||
* have the expected data
|
||||
*/
|
||||
static int perf_session__check_output_opt(struct perf_session *session)
|
||||
{
|
||||
int j;
|
||||
struct perf_evsel *evsel;
|
||||
|
||||
for (j = 0; j < PERF_TYPE_MAX; ++j) {
|
||||
evsel = perf_session__find_first_evtype(session, j);
|
||||
|
||||
/*
|
||||
* even if fields is set to 0 (ie., show nothing) event must
|
||||
* exist if user explicitly includes it on the command line
|
||||
*/
|
||||
if (!evsel && output[j].user_set && !output[j].wildcard_set) {
|
||||
pr_err("%s events do not exist. "
|
||||
"Remove corresponding -f option to proceed.\n",
|
||||
event_type(j));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (evsel && output[j].fields &&
|
||||
perf_evsel__check_attr(evsel, session))
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -168,10 +280,7 @@ static void process_event(union perf_event *event __unused,
|
|||
{
|
||||
struct perf_event_attr *attr = &evsel->attr;
|
||||
|
||||
if (output_fields[attr->type] == 0)
|
||||
return;
|
||||
|
||||
if (perf_session__check_attr(session, attr) < 0)
|
||||
if (output[attr->type].fields == 0)
|
||||
return;
|
||||
|
||||
print_sample_start(sample, thread, attr);
|
||||
|
@ -451,6 +560,7 @@ static int parse_output_fields(const struct option *opt __used,
|
|||
{
|
||||
char *tok;
|
||||
int i, imax = sizeof(all_output_options) / sizeof(struct output_option);
|
||||
int j;
|
||||
int rc = 0;
|
||||
char *str = strdup(arg);
|
||||
int type = -1;
|
||||
|
@ -458,52 +568,99 @@ static int parse_output_fields(const struct option *opt __used,
|
|||
if (!str)
|
||||
return -ENOMEM;
|
||||
|
||||
tok = strtok(str, ":");
|
||||
if (!tok) {
|
||||
fprintf(stderr,
|
||||
"Invalid field string - not prepended with type.");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* first word should state which event type user
|
||||
* is specifying the fields
|
||||
/* first word can state for which event type the user is specifying
|
||||
* the fields. If no type exists, the specified fields apply to all
|
||||
* event types found in the file minus the invalid fields for a type.
|
||||
*/
|
||||
if (!strcmp(tok, "hw"))
|
||||
type = PERF_TYPE_HARDWARE;
|
||||
else if (!strcmp(tok, "sw"))
|
||||
type = PERF_TYPE_SOFTWARE;
|
||||
else if (!strcmp(tok, "trace"))
|
||||
type = PERF_TYPE_TRACEPOINT;
|
||||
else {
|
||||
fprintf(stderr, "Invalid event type in field string.");
|
||||
return -EINVAL;
|
||||
tok = strchr(str, ':');
|
||||
if (tok) {
|
||||
*tok = '\0';
|
||||
tok++;
|
||||
if (!strcmp(str, "hw"))
|
||||
type = PERF_TYPE_HARDWARE;
|
||||
else if (!strcmp(str, "sw"))
|
||||
type = PERF_TYPE_SOFTWARE;
|
||||
else if (!strcmp(str, "trace"))
|
||||
type = PERF_TYPE_TRACEPOINT;
|
||||
else if (!strcmp(str, "raw"))
|
||||
type = PERF_TYPE_RAW;
|
||||
else {
|
||||
fprintf(stderr, "Invalid event type in field string.\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (output[type].user_set)
|
||||
pr_warning("Overriding previous field request for %s events.\n",
|
||||
event_type(type));
|
||||
|
||||
output[type].fields = 0;
|
||||
output[type].user_set = true;
|
||||
output[type].wildcard_set = false;
|
||||
|
||||
} else {
|
||||
tok = str;
|
||||
if (strlen(str) == 0) {
|
||||
fprintf(stderr,
|
||||
"Cannot set fields to 'none' for all event types.\n");
|
||||
rc = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (output_set_by_user())
|
||||
pr_warning("Overriding previous field request for all events.\n");
|
||||
|
||||
for (j = 0; j < PERF_TYPE_MAX; ++j) {
|
||||
output[j].fields = 0;
|
||||
output[j].user_set = true;
|
||||
output[j].wildcard_set = true;
|
||||
}
|
||||
}
|
||||
|
||||
output_fields[type] = 0;
|
||||
while (1) {
|
||||
tok = strtok(NULL, ",");
|
||||
if (!tok)
|
||||
break;
|
||||
tok = strtok(tok, ",");
|
||||
while (tok) {
|
||||
for (i = 0; i < imax; ++i) {
|
||||
if (strcmp(tok, all_output_options[i].str) == 0) {
|
||||
output_fields[type] |= all_output_options[i].field;
|
||||
if (strcmp(tok, all_output_options[i].str) == 0)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == imax) {
|
||||
fprintf(stderr, "Invalid field requested.");
|
||||
fprintf(stderr, "Invalid field requested.\n");
|
||||
rc = -EINVAL;
|
||||
break;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (type == -1) {
|
||||
/* add user option to all events types for
|
||||
* which it is valid
|
||||
*/
|
||||
for (j = 0; j < PERF_TYPE_MAX; ++j) {
|
||||
if (output[j].invalid_fields & all_output_options[i].field) {
|
||||
pr_warning("\'%s\' not valid for %s events. Ignoring.\n",
|
||||
all_output_options[i].str, event_type(j));
|
||||
} else
|
||||
output[j].fields |= all_output_options[i].field;
|
||||
}
|
||||
} else {
|
||||
if (output[type].invalid_fields & all_output_options[i].field) {
|
||||
fprintf(stderr, "\'%s\' not valid for %s events.\n",
|
||||
all_output_options[i].str, event_type(type));
|
||||
|
||||
rc = -EINVAL;
|
||||
goto out;
|
||||
}
|
||||
output[type].fields |= all_output_options[i].field;
|
||||
}
|
||||
|
||||
tok = strtok(NULL, ",");
|
||||
}
|
||||
|
||||
if (type >= 0) {
|
||||
if (output[type].fields == 0) {
|
||||
pr_debug("No fields requested for %s type. "
|
||||
"Events will not be displayed.\n", event_type(type));
|
||||
}
|
||||
}
|
||||
|
||||
if (output_fields[type] == 0) {
|
||||
pr_debug("No fields requested for %s type. "
|
||||
"Events will not be displayed\n", event_type(type));
|
||||
}
|
||||
|
||||
output_set_by_user = true;
|
||||
|
||||
out:
|
||||
free(str);
|
||||
return rc;
|
||||
}
|
||||
|
@ -829,7 +986,7 @@ static const struct option options[] = {
|
|||
OPT_STRING(0, "symfs", &symbol_conf.symfs, "directory",
|
||||
"Look for files with symbols relative to this directory"),
|
||||
OPT_CALLBACK('f', "fields", NULL, "str",
|
||||
"comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace. Fields: comm,tid,pid,time,cpu,event,trace,sym",
|
||||
"comma separated output fields prepend with 'type:'. Valid types: hw,sw,trace,raw. Fields: comm,tid,pid,time,cpu,event,trace,sym",
|
||||
parse_output_fields),
|
||||
|
||||
OPT_END()
|
||||
|
@ -1020,7 +1177,7 @@ int cmd_script(int argc, const char **argv, const char *prefix __used)
|
|||
struct stat perf_stat;
|
||||
int input;
|
||||
|
||||
if (output_set_by_user) {
|
||||
if (output_set_by_user()) {
|
||||
fprintf(stderr,
|
||||
"custom fields not supported for generated scripts");
|
||||
return -1;
|
||||
|
@ -1060,6 +1217,11 @@ int cmd_script(int argc, const char **argv, const char *prefix __used)
|
|||
pr_debug("perf script started with script %s\n\n", script_name);
|
||||
}
|
||||
|
||||
|
||||
err = perf_session__check_output_opt(session);
|
||||
if (err < 0)
|
||||
goto out;
|
||||
|
||||
err = __cmd_script(session);
|
||||
|
||||
perf_session__delete(session);
|
||||
|
|
|
@ -6,24 +6,28 @@
|
|||
*
|
||||
* Sample output:
|
||||
|
||||
$ perf stat ~/hackbench 10
|
||||
Time: 0.104
|
||||
$ perf stat ./hackbench 10
|
||||
|
||||
Performance counter stats for '/home/mingo/hackbench':
|
||||
Time: 0.118
|
||||
|
||||
1255.538611 task clock ticks # 10.143 CPU utilization factor
|
||||
54011 context switches # 0.043 M/sec
|
||||
385 CPU migrations # 0.000 M/sec
|
||||
17755 pagefaults # 0.014 M/sec
|
||||
3808323185 CPU cycles # 3033.219 M/sec
|
||||
1575111190 instructions # 1254.530 M/sec
|
||||
17367895 cache references # 13.833 M/sec
|
||||
7674421 cache misses # 6.112 M/sec
|
||||
Performance counter stats for './hackbench 10':
|
||||
|
||||
Wall-clock time elapsed: 123.786620 msecs
|
||||
1708.761321 task-clock # 11.037 CPUs utilized
|
||||
41,190 context-switches # 0.024 M/sec
|
||||
6,735 CPU-migrations # 0.004 M/sec
|
||||
17,318 page-faults # 0.010 M/sec
|
||||
5,205,202,243 cycles # 3.046 GHz
|
||||
3,856,436,920 stalled-cycles-frontend # 74.09% frontend cycles idle
|
||||
1,600,790,871 stalled-cycles-backend # 30.75% backend cycles idle
|
||||
2,603,501,247 instructions # 0.50 insns per cycle
|
||||
# 1.48 stalled cycles per insn
|
||||
484,357,498 branches # 283.455 M/sec
|
||||
6,388,934 branch-misses # 1.32% of all branches
|
||||
|
||||
0.154822978 seconds time elapsed
|
||||
|
||||
*
|
||||
* Copyright (C) 2008, Red Hat Inc, Ingo Molnar <mingo@redhat.com>
|
||||
* Copyright (C) 2008-2011, Red Hat Inc, Ingo Molnar <mingo@redhat.com>
|
||||
*
|
||||
* Improvements and fixes by:
|
||||
*
|
||||
|
@ -46,6 +50,7 @@
|
|||
#include "util/evlist.h"
|
||||
#include "util/evsel.h"
|
||||
#include "util/debug.h"
|
||||
#include "util/color.h"
|
||||
#include "util/header.h"
|
||||
#include "util/cpumap.h"
|
||||
#include "util/thread.h"
|
||||
|
@ -65,14 +70,107 @@ static struct perf_event_attr default_attrs[] = {
|
|||
{ .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_PAGE_FAULTS },
|
||||
|
||||
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CPU_CYCLES },
|
||||
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_STALLED_CYCLES_FRONTEND },
|
||||
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_STALLED_CYCLES_BACKEND },
|
||||
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_INSTRUCTIONS },
|
||||
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_INSTRUCTIONS },
|
||||
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_BRANCH_MISSES },
|
||||
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CACHE_REFERENCES },
|
||||
{ .type = PERF_TYPE_HARDWARE, .config = PERF_COUNT_HW_CACHE_MISSES },
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* Detailed stats (-d), covering the L1 and last level data caches:
|
||||
*/
|
||||
static struct perf_event_attr detailed_attrs[] = {
|
||||
|
||||
{ .type = PERF_TYPE_HW_CACHE,
|
||||
.config =
|
||||
PERF_COUNT_HW_CACHE_L1D << 0 |
|
||||
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
|
||||
(PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) },
|
||||
|
||||
{ .type = PERF_TYPE_HW_CACHE,
|
||||
.config =
|
||||
PERF_COUNT_HW_CACHE_L1D << 0 |
|
||||
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
|
||||
(PERF_COUNT_HW_CACHE_RESULT_MISS << 16) },
|
||||
|
||||
{ .type = PERF_TYPE_HW_CACHE,
|
||||
.config =
|
||||
PERF_COUNT_HW_CACHE_LL << 0 |
|
||||
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
|
||||
(PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) },
|
||||
|
||||
{ .type = PERF_TYPE_HW_CACHE,
|
||||
.config =
|
||||
PERF_COUNT_HW_CACHE_LL << 0 |
|
||||
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
|
||||
(PERF_COUNT_HW_CACHE_RESULT_MISS << 16) },
|
||||
};
|
||||
|
||||
/*
|
||||
* Very detailed stats (-d -d), covering the instruction cache and the TLB caches:
|
||||
*/
|
||||
static struct perf_event_attr very_detailed_attrs[] = {
|
||||
|
||||
{ .type = PERF_TYPE_HW_CACHE,
|
||||
.config =
|
||||
PERF_COUNT_HW_CACHE_L1I << 0 |
|
||||
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
|
||||
(PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) },
|
||||
|
||||
{ .type = PERF_TYPE_HW_CACHE,
|
||||
.config =
|
||||
PERF_COUNT_HW_CACHE_L1I << 0 |
|
||||
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
|
||||
(PERF_COUNT_HW_CACHE_RESULT_MISS << 16) },
|
||||
|
||||
{ .type = PERF_TYPE_HW_CACHE,
|
||||
.config =
|
||||
PERF_COUNT_HW_CACHE_DTLB << 0 |
|
||||
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
|
||||
(PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) },
|
||||
|
||||
{ .type = PERF_TYPE_HW_CACHE,
|
||||
.config =
|
||||
PERF_COUNT_HW_CACHE_DTLB << 0 |
|
||||
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
|
||||
(PERF_COUNT_HW_CACHE_RESULT_MISS << 16) },
|
||||
|
||||
{ .type = PERF_TYPE_HW_CACHE,
|
||||
.config =
|
||||
PERF_COUNT_HW_CACHE_ITLB << 0 |
|
||||
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
|
||||
(PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) },
|
||||
|
||||
{ .type = PERF_TYPE_HW_CACHE,
|
||||
.config =
|
||||
PERF_COUNT_HW_CACHE_ITLB << 0 |
|
||||
(PERF_COUNT_HW_CACHE_OP_READ << 8) |
|
||||
(PERF_COUNT_HW_CACHE_RESULT_MISS << 16) },
|
||||
|
||||
};
|
||||
|
||||
/*
|
||||
* Very, very detailed stats (-d -d -d), adding prefetch events:
|
||||
*/
|
||||
static struct perf_event_attr very_very_detailed_attrs[] = {
|
||||
|
||||
{ .type = PERF_TYPE_HW_CACHE,
|
||||
.config =
|
||||
PERF_COUNT_HW_CACHE_L1D << 0 |
|
||||
(PERF_COUNT_HW_CACHE_OP_PREFETCH << 8) |
|
||||
(PERF_COUNT_HW_CACHE_RESULT_ACCESS << 16) },
|
||||
|
||||
{ .type = PERF_TYPE_HW_CACHE,
|
||||
.config =
|
||||
PERF_COUNT_HW_CACHE_L1D << 0 |
|
||||
(PERF_COUNT_HW_CACHE_OP_PREFETCH << 8) |
|
||||
(PERF_COUNT_HW_CACHE_RESULT_MISS << 16) },
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct perf_evlist *evsel_list;
|
||||
|
||||
static bool system_wide = false;
|
||||
|
@ -86,6 +184,8 @@ static pid_t target_pid = -1;
|
|||
static pid_t target_tid = -1;
|
||||
static pid_t child_pid = -1;
|
||||
static bool null_run = false;
|
||||
static int detailed_run = 0;
|
||||
static bool sync_run = false;
|
||||
static bool big_num = true;
|
||||
static int big_num_opt = -1;
|
||||
static const char *cpu_list;
|
||||
|
@ -156,7 +256,15 @@ static double stddev_stats(struct stats *stats)
|
|||
|
||||
struct stats runtime_nsecs_stats[MAX_NR_CPUS];
|
||||
struct stats runtime_cycles_stats[MAX_NR_CPUS];
|
||||
struct stats runtime_stalled_cycles_front_stats[MAX_NR_CPUS];
|
||||
struct stats runtime_stalled_cycles_back_stats[MAX_NR_CPUS];
|
||||
struct stats runtime_branches_stats[MAX_NR_CPUS];
|
||||
struct stats runtime_cacherefs_stats[MAX_NR_CPUS];
|
||||
struct stats runtime_l1_dcache_stats[MAX_NR_CPUS];
|
||||
struct stats runtime_l1_icache_stats[MAX_NR_CPUS];
|
||||
struct stats runtime_ll_cache_stats[MAX_NR_CPUS];
|
||||
struct stats runtime_itlb_cache_stats[MAX_NR_CPUS];
|
||||
struct stats runtime_dtlb_cache_stats[MAX_NR_CPUS];
|
||||
struct stats walltime_nsecs_stats;
|
||||
|
||||
static int create_perf_stat_counter(struct perf_evsel *evsel)
|
||||
|
@ -192,6 +300,37 @@ static inline int nsec_counter(struct perf_evsel *evsel)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Update various tracking values we maintain to print
|
||||
* more semantic information such as miss/hit ratios,
|
||||
* instruction rates, etc:
|
||||
*/
|
||||
static void update_shadow_stats(struct perf_evsel *counter, u64 *count)
|
||||
{
|
||||
if (perf_evsel__match(counter, SOFTWARE, SW_TASK_CLOCK))
|
||||
update_stats(&runtime_nsecs_stats[0], count[0]);
|
||||
else if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
|
||||
update_stats(&runtime_cycles_stats[0], count[0]);
|
||||
else if (perf_evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_FRONTEND))
|
||||
update_stats(&runtime_stalled_cycles_front_stats[0], count[0]);
|
||||
else if (perf_evsel__match(counter, HARDWARE, HW_STALLED_CYCLES_BACKEND))
|
||||
update_stats(&runtime_stalled_cycles_back_stats[0], count[0]);
|
||||
else if (perf_evsel__match(counter, HARDWARE, HW_BRANCH_INSTRUCTIONS))
|
||||
update_stats(&runtime_branches_stats[0], count[0]);
|
||||
else if (perf_evsel__match(counter, HARDWARE, HW_CACHE_REFERENCES))
|
||||
update_stats(&runtime_cacherefs_stats[0], count[0]);
|
||||
else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_L1D))
|
||||
update_stats(&runtime_l1_dcache_stats[0], count[0]);
|
||||
else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_L1I))
|
||||
update_stats(&runtime_l1_icache_stats[0], count[0]);
|
||||
else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_LL))
|
||||
update_stats(&runtime_ll_cache_stats[0], count[0]);
|
||||
else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_DTLB))
|
||||
update_stats(&runtime_dtlb_cache_stats[0], count[0]);
|
||||
else if (perf_evsel__match(counter, HW_CACHE, HW_CACHE_ITLB))
|
||||
update_stats(&runtime_itlb_cache_stats[0], count[0]);
|
||||
}
|
||||
|
||||
/*
|
||||
* Read out the results of a single counter:
|
||||
* aggregate counts across CPUs in system-wide mode
|
||||
|
@ -217,12 +356,7 @@ static int read_counter_aggr(struct perf_evsel *counter)
|
|||
/*
|
||||
* Save the full runtime - to allow normalization during printout:
|
||||
*/
|
||||
if (perf_evsel__match(counter, SOFTWARE, SW_TASK_CLOCK))
|
||||
update_stats(&runtime_nsecs_stats[0], count[0]);
|
||||
if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
|
||||
update_stats(&runtime_cycles_stats[0], count[0]);
|
||||
if (perf_evsel__match(counter, HARDWARE, HW_BRANCH_INSTRUCTIONS))
|
||||
update_stats(&runtime_branches_stats[0], count[0]);
|
||||
update_shadow_stats(counter, count);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -242,12 +376,7 @@ static int read_counter(struct perf_evsel *counter)
|
|||
|
||||
count = counter->counts->cpu[cpu].values;
|
||||
|
||||
if (perf_evsel__match(counter, SOFTWARE, SW_TASK_CLOCK))
|
||||
update_stats(&runtime_nsecs_stats[cpu], count[0]);
|
||||
if (perf_evsel__match(counter, HARDWARE, HW_CPU_CYCLES))
|
||||
update_stats(&runtime_cycles_stats[cpu], count[0]);
|
||||
if (perf_evsel__match(counter, HARDWARE, HW_BRANCH_INSTRUCTIONS))
|
||||
update_stats(&runtime_branches_stats[cpu], count[0]);
|
||||
update_shadow_stats(counter, count);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -315,13 +444,18 @@ static int run_perf_stat(int argc __used, const char **argv)
|
|||
|
||||
list_for_each_entry(counter, &evsel_list->entries, node) {
|
||||
if (create_perf_stat_counter(counter) < 0) {
|
||||
if (errno == -EPERM || errno == -EACCES) {
|
||||
if (errno == EINVAL || errno == ENOSYS || errno == ENOENT) {
|
||||
if (verbose)
|
||||
ui__warning("%s event is not supported by the kernel.\n",
|
||||
event_name(counter));
|
||||
continue;
|
||||
}
|
||||
|
||||
if (errno == EPERM || errno == EACCES) {
|
||||
error("You may not have permission to collect %sstats.\n"
|
||||
"\t Consider tweaking"
|
||||
" /proc/sys/kernel/perf_event_paranoid or running as root.",
|
||||
system_wide ? "system-wide " : "");
|
||||
} else if (errno == ENOENT) {
|
||||
error("%s event is not supported. ", event_name(counter));
|
||||
} else {
|
||||
error("open_counter returned with %d (%s). "
|
||||
"/bin/dmesg may provide additional information.\n",
|
||||
|
@ -372,6 +506,16 @@ static int run_perf_stat(int argc __used, const char **argv)
|
|||
return WEXITSTATUS(status);
|
||||
}
|
||||
|
||||
static void print_noise_pct(double total, double avg)
|
||||
{
|
||||
double pct = 0.0;
|
||||
|
||||
if (avg)
|
||||
pct = 100.0*total/avg;
|
||||
|
||||
fprintf(stderr, " ( +-%6.2f%% )", pct);
|
||||
}
|
||||
|
||||
static void print_noise(struct perf_evsel *evsel, double avg)
|
||||
{
|
||||
struct perf_stat *ps;
|
||||
|
@ -380,15 +524,14 @@ static void print_noise(struct perf_evsel *evsel, double avg)
|
|||
return;
|
||||
|
||||
ps = evsel->priv;
|
||||
fprintf(stderr, " ( +- %7.3f%% )",
|
||||
100 * stddev_stats(&ps->res_stats[0]) / avg);
|
||||
print_noise_pct(stddev_stats(&ps->res_stats[0]), avg);
|
||||
}
|
||||
|
||||
static void nsec_printout(int cpu, struct perf_evsel *evsel, double avg)
|
||||
{
|
||||
double msecs = avg / 1e6;
|
||||
char cpustr[16] = { '\0', };
|
||||
const char *fmt = csv_output ? "%s%.6f%s%s" : "%s%18.6f%s%-24s";
|
||||
const char *fmt = csv_output ? "%s%.6f%s%s" : "%s%18.6f%s%-25s";
|
||||
|
||||
if (no_aggr)
|
||||
sprintf(cpustr, "CPU%*d%s",
|
||||
|
@ -404,8 +547,191 @@ static void nsec_printout(int cpu, struct perf_evsel *evsel, double avg)
|
|||
return;
|
||||
|
||||
if (perf_evsel__match(evsel, SOFTWARE, SW_TASK_CLOCK))
|
||||
fprintf(stderr, " # %10.3f CPUs ",
|
||||
avg / avg_stats(&walltime_nsecs_stats));
|
||||
fprintf(stderr, " # %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)
|
||||
{
|
||||
double total, ratio = 0.0;
|
||||
const char *color;
|
||||
|
||||
total = avg_stats(&runtime_cycles_stats[cpu]);
|
||||
|
||||
if (total)
|
||||
ratio = avg / total * 100.0;
|
||||
|
||||
color = PERF_COLOR_NORMAL;
|
||||
if (ratio > 50.0)
|
||||
color = PERF_COLOR_RED;
|
||||
else if (ratio > 30.0)
|
||||
color = PERF_COLOR_MAGENTA;
|
||||
else if (ratio > 10.0)
|
||||
color = PERF_COLOR_YELLOW;
|
||||
|
||||
fprintf(stderr, " # ");
|
||||
color_fprintf(stderr, color, "%6.2f%%", ratio);
|
||||
fprintf(stderr, " frontend cycles idle ");
|
||||
}
|
||||
|
||||
static void print_stalled_cycles_backend(int cpu, struct perf_evsel *evsel __used, double avg)
|
||||
{
|
||||
double total, ratio = 0.0;
|
||||
const char *color;
|
||||
|
||||
total = avg_stats(&runtime_cycles_stats[cpu]);
|
||||
|
||||
if (total)
|
||||
ratio = avg / total * 100.0;
|
||||
|
||||
color = PERF_COLOR_NORMAL;
|
||||
if (ratio > 75.0)
|
||||
color = PERF_COLOR_RED;
|
||||
else if (ratio > 50.0)
|
||||
color = PERF_COLOR_MAGENTA;
|
||||
else if (ratio > 20.0)
|
||||
color = PERF_COLOR_YELLOW;
|
||||
|
||||
fprintf(stderr, " # ");
|
||||
color_fprintf(stderr, color, "%6.2f%%", ratio);
|
||||
fprintf(stderr, " backend cycles idle ");
|
||||
}
|
||||
|
||||
static void print_branch_misses(int cpu, struct perf_evsel *evsel __used, double avg)
|
||||
{
|
||||
double total, ratio = 0.0;
|
||||
const char *color;
|
||||
|
||||
total = avg_stats(&runtime_branches_stats[cpu]);
|
||||
|
||||
if (total)
|
||||
ratio = avg / total * 100.0;
|
||||
|
||||
color = PERF_COLOR_NORMAL;
|
||||
if (ratio > 20.0)
|
||||
color = PERF_COLOR_RED;
|
||||
else if (ratio > 10.0)
|
||||
color = PERF_COLOR_MAGENTA;
|
||||
else if (ratio > 5.0)
|
||||
color = PERF_COLOR_YELLOW;
|
||||
|
||||
fprintf(stderr, " # ");
|
||||
color_fprintf(stderr, color, "%6.2f%%", ratio);
|
||||
fprintf(stderr, " of all branches ");
|
||||
}
|
||||
|
||||
static void print_l1_dcache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
|
||||
{
|
||||
double total, ratio = 0.0;
|
||||
const char *color;
|
||||
|
||||
total = avg_stats(&runtime_l1_dcache_stats[cpu]);
|
||||
|
||||
if (total)
|
||||
ratio = avg / total * 100.0;
|
||||
|
||||
color = PERF_COLOR_NORMAL;
|
||||
if (ratio > 20.0)
|
||||
color = PERF_COLOR_RED;
|
||||
else if (ratio > 10.0)
|
||||
color = PERF_COLOR_MAGENTA;
|
||||
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 ");
|
||||
}
|
||||
|
||||
static void print_l1_icache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
|
||||
{
|
||||
double total, ratio = 0.0;
|
||||
const char *color;
|
||||
|
||||
total = avg_stats(&runtime_l1_icache_stats[cpu]);
|
||||
|
||||
if (total)
|
||||
ratio = avg / total * 100.0;
|
||||
|
||||
color = PERF_COLOR_NORMAL;
|
||||
if (ratio > 20.0)
|
||||
color = PERF_COLOR_RED;
|
||||
else if (ratio > 10.0)
|
||||
color = PERF_COLOR_MAGENTA;
|
||||
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 ");
|
||||
}
|
||||
|
||||
static void print_dtlb_cache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
|
||||
{
|
||||
double total, ratio = 0.0;
|
||||
const char *color;
|
||||
|
||||
total = avg_stats(&runtime_dtlb_cache_stats[cpu]);
|
||||
|
||||
if (total)
|
||||
ratio = avg / total * 100.0;
|
||||
|
||||
color = PERF_COLOR_NORMAL;
|
||||
if (ratio > 20.0)
|
||||
color = PERF_COLOR_RED;
|
||||
else if (ratio > 10.0)
|
||||
color = PERF_COLOR_MAGENTA;
|
||||
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 ");
|
||||
}
|
||||
|
||||
static void print_itlb_cache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
|
||||
{
|
||||
double total, ratio = 0.0;
|
||||
const char *color;
|
||||
|
||||
total = avg_stats(&runtime_itlb_cache_stats[cpu]);
|
||||
|
||||
if (total)
|
||||
ratio = avg / total * 100.0;
|
||||
|
||||
color = PERF_COLOR_NORMAL;
|
||||
if (ratio > 20.0)
|
||||
color = PERF_COLOR_RED;
|
||||
else if (ratio > 10.0)
|
||||
color = PERF_COLOR_MAGENTA;
|
||||
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 ");
|
||||
}
|
||||
|
||||
static void print_ll_cache_misses(int cpu, struct perf_evsel *evsel __used, double avg)
|
||||
{
|
||||
double total, ratio = 0.0;
|
||||
const char *color;
|
||||
|
||||
total = avg_stats(&runtime_ll_cache_stats[cpu]);
|
||||
|
||||
if (total)
|
||||
ratio = avg / total * 100.0;
|
||||
|
||||
color = PERF_COLOR_NORMAL;
|
||||
if (ratio > 20.0)
|
||||
color = PERF_COLOR_RED;
|
||||
else if (ratio > 10.0)
|
||||
color = PERF_COLOR_MAGENTA;
|
||||
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 ");
|
||||
}
|
||||
|
||||
static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
|
||||
|
@ -417,9 +743,9 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
|
|||
if (csv_output)
|
||||
fmt = "%s%.0f%s%s";
|
||||
else if (big_num)
|
||||
fmt = "%s%'18.0f%s%-24s";
|
||||
fmt = "%s%'18.0f%s%-25s";
|
||||
else
|
||||
fmt = "%s%18.0f%s%-24s";
|
||||
fmt = "%s%18.0f%s%-25s";
|
||||
|
||||
if (no_aggr)
|
||||
sprintf(cpustr, "CPU%*d%s",
|
||||
|
@ -442,23 +768,83 @@ static void abs_printout(int cpu, struct perf_evsel *evsel, double avg)
|
|||
if (total)
|
||||
ratio = avg / total;
|
||||
|
||||
fprintf(stderr, " # %10.3f IPC ", ratio);
|
||||
fprintf(stderr, " # %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);
|
||||
}
|
||||
|
||||
} else if (perf_evsel__match(evsel, HARDWARE, HW_BRANCH_MISSES) &&
|
||||
runtime_branches_stats[cpu].n != 0) {
|
||||
total = avg_stats(&runtime_branches_stats[cpu]);
|
||||
print_branch_misses(cpu, evsel, avg);
|
||||
} else if (
|
||||
evsel->attr.type == PERF_TYPE_HW_CACHE &&
|
||||
evsel->attr.config == ( PERF_COUNT_HW_CACHE_L1D |
|
||||
((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
|
||||
((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
|
||||
runtime_l1_dcache_stats[cpu].n != 0) {
|
||||
print_l1_dcache_misses(cpu, evsel, avg);
|
||||
} else if (
|
||||
evsel->attr.type == PERF_TYPE_HW_CACHE &&
|
||||
evsel->attr.config == ( PERF_COUNT_HW_CACHE_L1I |
|
||||
((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
|
||||
((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
|
||||
runtime_l1_icache_stats[cpu].n != 0) {
|
||||
print_l1_icache_misses(cpu, evsel, avg);
|
||||
} else if (
|
||||
evsel->attr.type == PERF_TYPE_HW_CACHE &&
|
||||
evsel->attr.config == ( PERF_COUNT_HW_CACHE_DTLB |
|
||||
((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
|
||||
((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
|
||||
runtime_dtlb_cache_stats[cpu].n != 0) {
|
||||
print_dtlb_cache_misses(cpu, evsel, avg);
|
||||
} else if (
|
||||
evsel->attr.type == PERF_TYPE_HW_CACHE &&
|
||||
evsel->attr.config == ( PERF_COUNT_HW_CACHE_ITLB |
|
||||
((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
|
||||
((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
|
||||
runtime_itlb_cache_stats[cpu].n != 0) {
|
||||
print_itlb_cache_misses(cpu, evsel, avg);
|
||||
} else if (
|
||||
evsel->attr.type == PERF_TYPE_HW_CACHE &&
|
||||
evsel->attr.config == ( PERF_COUNT_HW_CACHE_LL |
|
||||
((PERF_COUNT_HW_CACHE_OP_READ) << 8) |
|
||||
((PERF_COUNT_HW_CACHE_RESULT_MISS) << 16)) &&
|
||||
runtime_ll_cache_stats[cpu].n != 0) {
|
||||
print_ll_cache_misses(cpu, evsel, avg);
|
||||
} else if (perf_evsel__match(evsel, HARDWARE, HW_CACHE_MISSES) &&
|
||||
runtime_cacherefs_stats[cpu].n != 0) {
|
||||
total = avg_stats(&runtime_cacherefs_stats[cpu]);
|
||||
|
||||
if (total)
|
||||
ratio = avg * 100 / total;
|
||||
|
||||
fprintf(stderr, " # %10.3f %% ", ratio);
|
||||
fprintf(stderr, " # %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);
|
||||
} else if (perf_evsel__match(evsel, HARDWARE, HW_STALLED_CYCLES_BACKEND)) {
|
||||
print_stalled_cycles_backend(cpu, evsel, avg);
|
||||
} else if (perf_evsel__match(evsel, HARDWARE, HW_CPU_CYCLES)) {
|
||||
total = avg_stats(&runtime_nsecs_stats[cpu]);
|
||||
|
||||
if (total)
|
||||
ratio = 1.0 * avg / total;
|
||||
|
||||
fprintf(stderr, " # %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, " # %10.3f M/sec", ratio);
|
||||
fprintf(stderr, " # %8.3f M/sec ", ratio);
|
||||
} else {
|
||||
fprintf(stderr, " ");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -505,8 +891,7 @@ 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, " (scaled from %.2f%%)",
|
||||
100 * avg_running / avg_enabled);
|
||||
fprintf(stderr, " [%5.2f%%]", 100 * avg_running / avg_enabled);
|
||||
}
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
@ -548,10 +933,8 @@ static void print_counter(struct perf_evsel *counter)
|
|||
if (!csv_output) {
|
||||
print_noise(counter, 1.0);
|
||||
|
||||
if (run != ena) {
|
||||
fprintf(stderr, " (scaled from %.2f%%)",
|
||||
100.0 * run / ena);
|
||||
}
|
||||
if (run != ena)
|
||||
fprintf(stderr, " (%.2f%%)", 100.0 * run / ena);
|
||||
}
|
||||
fputc('\n', stderr);
|
||||
}
|
||||
|
@ -591,13 +974,14 @@ static void print_stat(int argc, const char **argv)
|
|||
}
|
||||
|
||||
if (!csv_output) {
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " %18.9f seconds time elapsed",
|
||||
if (!null_run)
|
||||
fprintf(stderr, "\n");
|
||||
fprintf(stderr, " %17.9f seconds time elapsed",
|
||||
avg_stats(&walltime_nsecs_stats)/1e9);
|
||||
if (run_count > 1) {
|
||||
fprintf(stderr, " ( +- %7.3f%% )",
|
||||
100*stddev_stats(&walltime_nsecs_stats) /
|
||||
avg_stats(&walltime_nsecs_stats));
|
||||
fprintf(stderr, " ");
|
||||
print_noise_pct(stddev_stats(&walltime_nsecs_stats),
|
||||
avg_stats(&walltime_nsecs_stats));
|
||||
}
|
||||
fprintf(stderr, "\n\n");
|
||||
}
|
||||
|
@ -659,6 +1043,10 @@ static const struct option options[] = {
|
|||
"repeat command and print average + stddev (max: 100)"),
|
||||
OPT_BOOLEAN('n', "null", &null_run,
|
||||
"null run - dont start any counters"),
|
||||
OPT_INCR('d', "detailed", &detailed_run,
|
||||
"detailed run - start a lot of events"),
|
||||
OPT_BOOLEAN('S', "sync", &sync_run,
|
||||
"call sync() before starting a run"),
|
||||
OPT_CALLBACK_NOOPT('B', "big-num", NULL, NULL,
|
||||
"print large numbers with thousands\' separators",
|
||||
stat__set_big_num),
|
||||
|
@ -674,6 +1062,70 @@ static const struct option options[] = {
|
|||
OPT_END()
|
||||
};
|
||||
|
||||
/*
|
||||
* Add default attributes, if there were no attributes specified or
|
||||
* if -d/--detailed, -d -d or -d -d -d is used:
|
||||
*/
|
||||
static int add_default_attributes(void)
|
||||
{
|
||||
struct perf_evsel *pos;
|
||||
size_t attr_nr = 0;
|
||||
size_t c;
|
||||
|
||||
/* Set attrs if no event is selected and !null_run: */
|
||||
if (null_run)
|
||||
return 0;
|
||||
|
||||
if (!evsel_list->nr_entries) {
|
||||
for (c = 0; c < ARRAY_SIZE(default_attrs); c++) {
|
||||
pos = perf_evsel__new(default_attrs + c, c + attr_nr);
|
||||
if (pos == NULL)
|
||||
return -1;
|
||||
perf_evlist__add(evsel_list, pos);
|
||||
}
|
||||
attr_nr += c;
|
||||
}
|
||||
|
||||
/* Detailed events get appended to the event list: */
|
||||
|
||||
if (detailed_run < 1)
|
||||
return 0;
|
||||
|
||||
/* Append detailed run extra attributes: */
|
||||
for (c = 0; c < ARRAY_SIZE(detailed_attrs); c++) {
|
||||
pos = perf_evsel__new(detailed_attrs + c, c + attr_nr);
|
||||
if (pos == NULL)
|
||||
return -1;
|
||||
perf_evlist__add(evsel_list, pos);
|
||||
}
|
||||
attr_nr += c;
|
||||
|
||||
if (detailed_run < 2)
|
||||
return 0;
|
||||
|
||||
/* Append very detailed run extra attributes: */
|
||||
for (c = 0; c < ARRAY_SIZE(very_detailed_attrs); c++) {
|
||||
pos = perf_evsel__new(very_detailed_attrs + c, c + attr_nr);
|
||||
if (pos == NULL)
|
||||
return -1;
|
||||
perf_evlist__add(evsel_list, pos);
|
||||
}
|
||||
|
||||
if (detailed_run < 3)
|
||||
return 0;
|
||||
|
||||
/* Append very, very detailed run extra attributes: */
|
||||
for (c = 0; c < ARRAY_SIZE(very_very_detailed_attrs); c++) {
|
||||
pos = perf_evsel__new(very_very_detailed_attrs + c, c + attr_nr);
|
||||
if (pos == NULL)
|
||||
return -1;
|
||||
perf_evlist__add(evsel_list, pos);
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmd_stat(int argc, const char **argv, const char *prefix __used)
|
||||
{
|
||||
struct perf_evsel *pos;
|
||||
|
@ -719,17 +1171,8 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
|
|||
usage_with_options(stat_usage, options);
|
||||
}
|
||||
|
||||
/* Set attrs and nr_counters if no event is selected and !null_run */
|
||||
if (!null_run && !evsel_list->nr_entries) {
|
||||
size_t c;
|
||||
|
||||
for (c = 0; c < ARRAY_SIZE(default_attrs); ++c) {
|
||||
pos = perf_evsel__new(&default_attrs[c], c);
|
||||
if (pos == NULL)
|
||||
goto out;
|
||||
perf_evlist__add(evsel_list, pos);
|
||||
}
|
||||
}
|
||||
if (add_default_attributes())
|
||||
goto out;
|
||||
|
||||
if (target_pid != -1)
|
||||
target_tid = target_pid;
|
||||
|
@ -773,6 +1216,10 @@ int cmd_stat(int argc, const char **argv, const char *prefix __used)
|
|||
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);
|
||||
|
||||
if (sync_run)
|
||||
sync();
|
||||
|
||||
status = run_perf_stat(argc, argv);
|
||||
}
|
||||
|
||||
|
|
|
@ -79,9 +79,15 @@ endef
|
|||
endif
|
||||
|
||||
ifndef NO_LIBPYTHON
|
||||
define SOURCE_PYTHON_VERSION
|
||||
#include <Python.h>
|
||||
#if PY_VERSION_HEX >= 0x03000000
|
||||
#error
|
||||
#endif
|
||||
int main(void){}
|
||||
endef
|
||||
define SOURCE_PYTHON_EMBED
|
||||
#include <Python.h>
|
||||
|
||||
int main(void)
|
||||
{
|
||||
Py_Initialize();
|
||||
|
@ -120,11 +126,3 @@ int main(void)
|
|||
return 0;
|
||||
}
|
||||
endef
|
||||
|
||||
# try-cc
|
||||
# Usage: option = $(call try-cc, source-to-build, cc-options)
|
||||
try-cc = $(shell sh -c \
|
||||
'TMP="$(OUTPUT)$(TMPOUT).$$$$"; \
|
||||
echo "$(1)" | \
|
||||
$(CC) -x c - $(2) -o "$$TMP" > /dev/null 2>&1 && echo y; \
|
||||
rm -f "$$TMP"')
|
188
tools/perf/config/utilities.mak
Normal file
188
tools/perf/config/utilities.mak
Normal file
|
@ -0,0 +1,188 @@
|
|||
# This allows us to work with the newline character:
|
||||
define newline
|
||||
|
||||
|
||||
endef
|
||||
newline := $(newline)
|
||||
|
||||
# nl-escape
|
||||
#
|
||||
# Usage: escape = $(call nl-escape[,escape])
|
||||
#
|
||||
# This is used as the common way to specify
|
||||
# what should replace a newline when escaping
|
||||
# newlines; the default is a bizarre string.
|
||||
#
|
||||
nl-escape = $(or $(1),m822df3020w6a44id34bt574ctac44eb9f4n)
|
||||
|
||||
# escape-nl
|
||||
#
|
||||
# Usage: escaped-text = $(call escape-nl,text[,escape])
|
||||
#
|
||||
# GNU make's $(shell ...) function converts to a
|
||||
# single space each newline character in the output
|
||||
# produced during the expansion; this may not be
|
||||
# desirable.
|
||||
#
|
||||
# The only solution is to change each newline into
|
||||
# something that won't be converted, so that the
|
||||
# information can be recovered later with
|
||||
# $(call unescape-nl...)
|
||||
#
|
||||
escape-nl = $(subst $(newline),$(call nl-escape,$(2)),$(1))
|
||||
|
||||
# unescape-nl
|
||||
#
|
||||
# Usage: text = $(call unescape-nl,escaped-text[,escape])
|
||||
#
|
||||
# See escape-nl.
|
||||
#
|
||||
unescape-nl = $(subst $(call nl-escape,$(2)),$(newline),$(1))
|
||||
|
||||
# shell-escape-nl
|
||||
#
|
||||
# Usage: $(shell some-command | $(call shell-escape-nl[,escape]))
|
||||
#
|
||||
# Use this to escape newlines from within a shell call;
|
||||
# the default escape is a bizarre string.
|
||||
#
|
||||
# NOTE: The escape is used directly as a string constant
|
||||
# in an `awk' program that is delimited by shell
|
||||
# single-quotes, so be wary of the characters
|
||||
# that are chosen.
|
||||
#
|
||||
define shell-escape-nl
|
||||
awk 'NR==1 {t=$$0} NR>1 {t=t "$(nl-escape)" $$0} END {printf t}'
|
||||
endef
|
||||
|
||||
# shell-unescape-nl
|
||||
#
|
||||
# Usage: $(shell some-command | $(call shell-unescape-nl[,escape]))
|
||||
#
|
||||
# Use this to unescape newlines from within a shell call;
|
||||
# the default escape is a bizarre string.
|
||||
#
|
||||
# NOTE: The escape is used directly as an extended regular
|
||||
# expression constant in an `awk' program that is
|
||||
# delimited by shell single-quotes, so be wary
|
||||
# of the characters that are chosen.
|
||||
#
|
||||
# (The bash shell has a bug where `{gsub(...),...}' is
|
||||
# misinterpreted as a brace expansion; this can be
|
||||
# overcome by putting a space between `{' and `gsub').
|
||||
#
|
||||
define shell-unescape-nl
|
||||
awk 'NR==1 {t=$$0} NR>1 {t=t "\n" $$0} END { gsub(/$(nl-escape)/,"\n",t); printf t }'
|
||||
endef
|
||||
|
||||
# escape-for-shell-sq
|
||||
#
|
||||
# Usage: embeddable-text = $(call escape-for-shell-sq,text)
|
||||
#
|
||||
# This function produces text that is suitable for
|
||||
# embedding in a shell string that is delimited by
|
||||
# single-quotes.
|
||||
#
|
||||
escape-for-shell-sq = $(subst ','\'',$(1))
|
||||
|
||||
# shell-sq
|
||||
#
|
||||
# Usage: single-quoted-and-escaped-text = $(call shell-sq,text)
|
||||
#
|
||||
shell-sq = '$(escape-for-shell-sq)'
|
||||
|
||||
# shell-wordify
|
||||
#
|
||||
# Usage: wordified-text = $(call shell-wordify,text)
|
||||
#
|
||||
# For instance:
|
||||
#
|
||||
# |define text
|
||||
# |hello
|
||||
# |world
|
||||
# |endef
|
||||
# |
|
||||
# |target:
|
||||
# | echo $(call shell-wordify,$(text))
|
||||
#
|
||||
# At least GNU make gets confused by expanding a newline
|
||||
# within the context of a command line of a makefile rule
|
||||
# (this is in constrast to a `$(shell ...)' function call,
|
||||
# which can handle it just fine).
|
||||
#
|
||||
# This function avoids the problem by producing a string
|
||||
# that works as a shell word, regardless of whether or
|
||||
# not it contains a newline.
|
||||
#
|
||||
# If the text to be wordified contains a newline, then
|
||||
# an intrictate shell command substitution is constructed
|
||||
# to render the text as a single line; when the shell
|
||||
# processes the resulting escaped text, it transforms
|
||||
# it into the original unescaped text.
|
||||
#
|
||||
# If the text does not contain a newline, then this function
|
||||
# produces the same results as the `$(shell-sq)' function.
|
||||
#
|
||||
shell-wordify = $(if $(findstring $(newline),$(1)),$(_sw-esc-nl),$(shell-sq))
|
||||
define _sw-esc-nl
|
||||
"$$(echo $(call escape-nl,$(shell-sq),$(2)) | $(call shell-unescape-nl,$(2)))"
|
||||
endef
|
||||
|
||||
# is-absolute
|
||||
#
|
||||
# Usage: bool-value = $(call is-absolute,path)
|
||||
#
|
||||
is-absolute = $(shell echo $(shell-sq) | grep ^/ -q && echo y)
|
||||
|
||||
# lookup
|
||||
#
|
||||
# Usage: absolute-executable-path-or-empty = $(call lookup,path)
|
||||
#
|
||||
# (It's necessary to use `sh -c' because GNU make messes up by
|
||||
# trying too hard and getting things wrong).
|
||||
#
|
||||
lookup = $(call unescape-nl,$(shell sh -c $(_l-sh)))
|
||||
_l-sh = $(call shell-sq,command -v $(shell-sq) | $(call shell-escape-nl,))
|
||||
|
||||
# is-executable
|
||||
#
|
||||
# Usage: bool-value = $(call is-executable,path)
|
||||
#
|
||||
# (It's necessary to use `sh -c' because GNU make messes up by
|
||||
# trying too hard and getting things wrong).
|
||||
#
|
||||
is-executable = $(call _is-executable-helper,$(shell-sq))
|
||||
_is-executable-helper = $(shell sh -c $(_is-executable-sh))
|
||||
_is-executable-sh = $(call shell-sq,test -f $(1) -a -x $(1) && echo y)
|
||||
|
||||
# get-executable
|
||||
#
|
||||
# Usage: absolute-executable-path-or-empty = $(call get-executable,path)
|
||||
#
|
||||
# The goal is to get an absolute path for an executable;
|
||||
# the `command -v' is defined by POSIX, but it's not
|
||||
# necessarily very portable, so it's only used if
|
||||
# relative path resolution is requested, as determined
|
||||
# by the presence of a leading `/'.
|
||||
#
|
||||
get-executable = $(if $(1),$(if $(is-absolute),$(_ge-abspath),$(lookup)))
|
||||
_ge-abspath = $(if $(is-executable),$(1))
|
||||
|
||||
# get-supplied-or-default-executable
|
||||
#
|
||||
# Usage: absolute-executable-path-or-empty = $(call get-executable-or-default,variable,default)
|
||||
#
|
||||
define get-executable-or-default
|
||||
$(if $($(1)),$(call _ge_attempt,$($(1)),$(1)),$(call _ge_attempt,$(2)))
|
||||
endef
|
||||
_ge_attempt = $(or $(get-executable),$(_gea_warn),$(call _gea_err,$(2)))
|
||||
_gea_warn = $(warning The path '$(1)' is not executable.)
|
||||
_gea_err = $(if $(1),$(error Please set '$(1)' appropriately))
|
||||
|
||||
# try-cc
|
||||
# Usage: option = $(call try-cc, source-to-build, cc-options)
|
||||
try-cc = $(shell sh -c \
|
||||
'TMP="$(OUTPUT)$(TMPOUT).$$$$"; \
|
||||
echo "$(1)" | \
|
||||
$(CC) -x c - $(2) -o "$$TMP" > /dev/null 2>&1 && echo y; \
|
||||
rm -f "$$TMP"')
|
8
tools/perf/util/include/asm/alternative-asm.h
Normal file
8
tools/perf/util/include/asm/alternative-asm.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef _PERF_ASM_ALTERNATIVE_ASM_H
|
||||
#define _PERF_ASM_ALTERNATIVE_ASM_H
|
||||
|
||||
/* Just disable it so we can build arch/x86/lib/memcpy_64.S for perf bench: */
|
||||
|
||||
#define altinstruction_entry #
|
||||
|
||||
#endif
|
|
@ -31,34 +31,36 @@ char debugfs_path[MAXPATHLEN];
|
|||
#define CSW(x) .type = PERF_TYPE_SOFTWARE, .config = PERF_COUNT_SW_##x
|
||||
|
||||
static struct event_symbol event_symbols[] = {
|
||||
{ CHW(CPU_CYCLES), "cpu-cycles", "cycles" },
|
||||
{ CHW(INSTRUCTIONS), "instructions", "" },
|
||||
{ CHW(CACHE_REFERENCES), "cache-references", "" },
|
||||
{ CHW(CACHE_MISSES), "cache-misses", "" },
|
||||
{ CHW(BRANCH_INSTRUCTIONS), "branch-instructions", "branches" },
|
||||
{ CHW(BRANCH_MISSES), "branch-misses", "" },
|
||||
{ CHW(BUS_CYCLES), "bus-cycles", "" },
|
||||
{ CHW(CPU_CYCLES), "cpu-cycles", "cycles" },
|
||||
{ CHW(STALLED_CYCLES_FRONTEND), "stalled-cycles-frontend", "idle-cycles-frontend" },
|
||||
{ CHW(STALLED_CYCLES_BACKEND), "stalled-cycles-backend", "idle-cycles-backend" },
|
||||
{ CHW(INSTRUCTIONS), "instructions", "" },
|
||||
{ CHW(CACHE_REFERENCES), "cache-references", "" },
|
||||
{ CHW(CACHE_MISSES), "cache-misses", "" },
|
||||
{ CHW(BRANCH_INSTRUCTIONS), "branch-instructions", "branches" },
|
||||
{ CHW(BRANCH_MISSES), "branch-misses", "" },
|
||||
{ CHW(BUS_CYCLES), "bus-cycles", "" },
|
||||
|
||||
{ CSW(CPU_CLOCK), "cpu-clock", "" },
|
||||
{ CSW(TASK_CLOCK), "task-clock", "" },
|
||||
{ CSW(PAGE_FAULTS), "page-faults", "faults" },
|
||||
{ CSW(PAGE_FAULTS_MIN), "minor-faults", "" },
|
||||
{ CSW(PAGE_FAULTS_MAJ), "major-faults", "" },
|
||||
{ CSW(CONTEXT_SWITCHES), "context-switches", "cs" },
|
||||
{ CSW(CPU_MIGRATIONS), "cpu-migrations", "migrations" },
|
||||
{ CSW(ALIGNMENT_FAULTS), "alignment-faults", "" },
|
||||
{ CSW(EMULATION_FAULTS), "emulation-faults", "" },
|
||||
{ CSW(CPU_CLOCK), "cpu-clock", "" },
|
||||
{ CSW(TASK_CLOCK), "task-clock", "" },
|
||||
{ CSW(PAGE_FAULTS), "page-faults", "faults" },
|
||||
{ CSW(PAGE_FAULTS_MIN), "minor-faults", "" },
|
||||
{ CSW(PAGE_FAULTS_MAJ), "major-faults", "" },
|
||||
{ CSW(CONTEXT_SWITCHES), "context-switches", "cs" },
|
||||
{ CSW(CPU_MIGRATIONS), "cpu-migrations", "migrations" },
|
||||
{ CSW(ALIGNMENT_FAULTS), "alignment-faults", "" },
|
||||
{ CSW(EMULATION_FAULTS), "emulation-faults", "" },
|
||||
};
|
||||
|
||||
#define __PERF_EVENT_FIELD(config, name) \
|
||||
((config & PERF_EVENT_##name##_MASK) >> PERF_EVENT_##name##_SHIFT)
|
||||
|
||||
#define PERF_EVENT_RAW(config) __PERF_EVENT_FIELD(config, RAW)
|
||||
#define PERF_EVENT_RAW(config) __PERF_EVENT_FIELD(config, RAW)
|
||||
#define PERF_EVENT_CONFIG(config) __PERF_EVENT_FIELD(config, CONFIG)
|
||||
#define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE)
|
||||
#define PERF_EVENT_TYPE(config) __PERF_EVENT_FIELD(config, TYPE)
|
||||
#define PERF_EVENT_ID(config) __PERF_EVENT_FIELD(config, EVENT)
|
||||
|
||||
static const char *hw_event_names[] = {
|
||||
static const char *hw_event_names[PERF_COUNT_HW_MAX] = {
|
||||
"cycles",
|
||||
"instructions",
|
||||
"cache-references",
|
||||
|
@ -66,11 +68,13 @@ static const char *hw_event_names[] = {
|
|||
"branches",
|
||||
"branch-misses",
|
||||
"bus-cycles",
|
||||
"stalled-cycles-frontend",
|
||||
"stalled-cycles-backend",
|
||||
};
|
||||
|
||||
static const char *sw_event_names[] = {
|
||||
"cpu-clock-msecs",
|
||||
"task-clock-msecs",
|
||||
static const char *sw_event_names[PERF_COUNT_SW_MAX] = {
|
||||
"cpu-clock",
|
||||
"task-clock",
|
||||
"page-faults",
|
||||
"context-switches",
|
||||
"CPU-migrations",
|
||||
|
@ -307,7 +311,7 @@ const char *__event_name(int type, u64 config)
|
|||
|
||||
switch (type) {
|
||||
case PERF_TYPE_HARDWARE:
|
||||
if (config < PERF_COUNT_HW_MAX)
|
||||
if (config < PERF_COUNT_HW_MAX && hw_event_names[config])
|
||||
return hw_event_names[config];
|
||||
return "unknown-hardware";
|
||||
|
||||
|
@ -333,7 +337,7 @@ const char *__event_name(int type, u64 config)
|
|||
}
|
||||
|
||||
case PERF_TYPE_SOFTWARE:
|
||||
if (config < PERF_COUNT_SW_MAX)
|
||||
if (config < PERF_COUNT_SW_MAX && sw_event_names[config])
|
||||
return sw_event_names[config];
|
||||
return "unknown-software";
|
||||
|
||||
|
@ -648,13 +652,15 @@ static int check_events(const char *str, unsigned int i)
|
|||
int n;
|
||||
|
||||
n = strlen(event_symbols[i].symbol);
|
||||
if (!strncmp(str, event_symbols[i].symbol, n))
|
||||
if (!strncasecmp(str, event_symbols[i].symbol, n))
|
||||
return n;
|
||||
|
||||
n = strlen(event_symbols[i].alias);
|
||||
if (n)
|
||||
if (!strncmp(str, event_symbols[i].alias, n))
|
||||
if (n) {
|
||||
if (!strncasecmp(str, event_symbols[i].alias, n))
|
||||
return n;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -718,15 +724,22 @@ parse_numeric_event(const char **strp, struct perf_event_attr *attr)
|
|||
return EVT_FAILED;
|
||||
}
|
||||
|
||||
static enum event_result
|
||||
static int
|
||||
parse_event_modifier(const char **strp, struct perf_event_attr *attr)
|
||||
{
|
||||
const char *str = *strp;
|
||||
int exclude = 0;
|
||||
int eu = 0, ek = 0, eh = 0, precise = 0;
|
||||
|
||||
if (*str++ != ':')
|
||||
if (!*str)
|
||||
return 0;
|
||||
|
||||
if (*str == ',')
|
||||
return 0;
|
||||
|
||||
if (*str++ != ':')
|
||||
return -1;
|
||||
|
||||
while (*str) {
|
||||
if (*str == 'u') {
|
||||
if (!exclude)
|
||||
|
@ -747,14 +760,16 @@ parse_event_modifier(const char **strp, struct perf_event_attr *attr)
|
|||
|
||||
++str;
|
||||
}
|
||||
if (str >= *strp + 2) {
|
||||
*strp = str;
|
||||
attr->exclude_user = eu;
|
||||
attr->exclude_kernel = ek;
|
||||
attr->exclude_hv = eh;
|
||||
attr->precise_ip = precise;
|
||||
return 1;
|
||||
}
|
||||
if (str < *strp + 2)
|
||||
return -1;
|
||||
|
||||
*strp = str;
|
||||
|
||||
attr->exclude_user = eu;
|
||||
attr->exclude_kernel = ek;
|
||||
attr->exclude_hv = eh;
|
||||
attr->precise_ip = precise;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -797,7 +812,12 @@ parse_event_symbols(const struct option *opt, const char **str,
|
|||
return EVT_FAILED;
|
||||
|
||||
modifier:
|
||||
parse_event_modifier(str, attr);
|
||||
if (parse_event_modifier(str, attr) < 0) {
|
||||
fprintf(stderr, "invalid event modifier: '%s'\n", *str);
|
||||
fprintf(stderr, "Run 'perf list' for a list of valid events and modifiers\n");
|
||||
|
||||
return EVT_FAILED;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
@ -912,7 +932,7 @@ void print_tracepoint_events(const char *subsys_glob, const char *event_glob)
|
|||
|
||||
snprintf(evt_path, MAXPATHLEN, "%s:%s",
|
||||
sys_dirent.d_name, evt_dirent.d_name);
|
||||
printf(" %-42s [%s]\n", evt_path,
|
||||
printf(" %-50s [%s]\n", evt_path,
|
||||
event_type_descriptors[PERF_TYPE_TRACEPOINT]);
|
||||
}
|
||||
closedir(evt_dir);
|
||||
|
@ -977,7 +997,7 @@ void print_events_type(u8 type)
|
|||
else
|
||||
snprintf(name, sizeof(name), "%s", syms->symbol);
|
||||
|
||||
printf(" %-42s [%s]\n", name,
|
||||
printf(" %-50s [%s]\n", name,
|
||||
event_type_descriptors[type]);
|
||||
}
|
||||
}
|
||||
|
@ -995,11 +1015,10 @@ int print_hwcache_events(const char *event_glob)
|
|||
for (i = 0; i < PERF_COUNT_HW_CACHE_RESULT_MAX; i++) {
|
||||
char *name = event_cache_name(type, op, i);
|
||||
|
||||
if (event_glob != NULL &&
|
||||
!strglobmatch(name, event_glob))
|
||||
if (event_glob != NULL && !strglobmatch(name, event_glob))
|
||||
continue;
|
||||
|
||||
printf(" %-42s [%s]\n", name,
|
||||
printf(" %-50s [%s]\n", name,
|
||||
event_type_descriptors[PERF_TYPE_HW_CACHE]);
|
||||
++printed;
|
||||
}
|
||||
|
@ -1009,14 +1028,16 @@ int print_hwcache_events(const char *event_glob)
|
|||
return printed;
|
||||
}
|
||||
|
||||
#define MAX_NAME_LEN 100
|
||||
|
||||
/*
|
||||
* Print the help text for the event symbols:
|
||||
*/
|
||||
void print_events(const char *event_glob)
|
||||
{
|
||||
struct event_symbol *syms = event_symbols;
|
||||
unsigned int i, type, prev_type = -1, printed = 0, ntypes_printed = 0;
|
||||
char name[40];
|
||||
struct event_symbol *syms = event_symbols;
|
||||
char name[MAX_NAME_LEN];
|
||||
|
||||
printf("\n");
|
||||
printf("List of pre-defined events (to be used in -e):\n");
|
||||
|
@ -1036,10 +1057,10 @@ void print_events(const char *event_glob)
|
|||
continue;
|
||||
|
||||
if (strlen(syms->alias))
|
||||
sprintf(name, "%s OR %s", syms->symbol, syms->alias);
|
||||
snprintf(name, MAX_NAME_LEN, "%s OR %s", syms->symbol, syms->alias);
|
||||
else
|
||||
strcpy(name, syms->symbol);
|
||||
printf(" %-42s [%s]\n", name,
|
||||
strncpy(name, syms->symbol, MAX_NAME_LEN);
|
||||
printf(" %-50s [%s]\n", name,
|
||||
event_type_descriptors[type]);
|
||||
|
||||
prev_type = type;
|
||||
|
@ -1056,12 +1077,12 @@ void print_events(const char *event_glob)
|
|||
return;
|
||||
|
||||
printf("\n");
|
||||
printf(" %-42s [%s]\n",
|
||||
printf(" %-50s [%s]\n",
|
||||
"rNNN (see 'perf list --help' on how to encode it)",
|
||||
event_type_descriptors[PERF_TYPE_RAW]);
|
||||
printf("\n");
|
||||
|
||||
printf(" %-42s [%s]\n",
|
||||
printf(" %-50s [%s]\n",
|
||||
"mem:<addr>[:access]",
|
||||
event_type_descriptors[PERF_TYPE_BREAKPOINT]);
|
||||
printf("\n");
|
||||
|
|
|
@ -1471,6 +1471,38 @@ static int find_probe_point_by_func(struct probe_finder *pf)
|
|||
return _param.retval;
|
||||
}
|
||||
|
||||
struct pubname_callback_param {
|
||||
char *function;
|
||||
char *file;
|
||||
Dwarf_Die *cu_die;
|
||||
Dwarf_Die *sp_die;
|
||||
int found;
|
||||
};
|
||||
|
||||
static int pubname_search_cb(Dwarf *dbg, Dwarf_Global *gl, void *data)
|
||||
{
|
||||
struct pubname_callback_param *param = data;
|
||||
|
||||
if (dwarf_offdie(dbg, gl->die_offset, param->sp_die)) {
|
||||
if (dwarf_tag(param->sp_die) != DW_TAG_subprogram)
|
||||
return DWARF_CB_OK;
|
||||
|
||||
if (die_compare_name(param->sp_die, param->function)) {
|
||||
if (!dwarf_offdie(dbg, gl->cu_offset, param->cu_die))
|
||||
return DWARF_CB_OK;
|
||||
|
||||
if (param->file &&
|
||||
strtailcmp(param->file, dwarf_decl_file(param->sp_die)))
|
||||
return DWARF_CB_OK;
|
||||
|
||||
param->found = 1;
|
||||
return DWARF_CB_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
return DWARF_CB_OK;
|
||||
}
|
||||
|
||||
/* Find probe points from debuginfo */
|
||||
static int find_probes(int fd, struct probe_finder *pf)
|
||||
{
|
||||
|
@ -1498,6 +1530,28 @@ static int find_probes(int fd, struct probe_finder *pf)
|
|||
|
||||
off = 0;
|
||||
line_list__init(&pf->lcache);
|
||||
|
||||
/* Fastpath: lookup by function name from .debug_pubnames section */
|
||||
if (pp->function) {
|
||||
struct pubname_callback_param pubname_param = {
|
||||
.function = pp->function,
|
||||
.file = pp->file,
|
||||
.cu_die = &pf->cu_die,
|
||||
.sp_die = &pf->sp_die,
|
||||
.found = 0,
|
||||
};
|
||||
struct dwarf_callback_param probe_param = {
|
||||
.data = pf,
|
||||
};
|
||||
|
||||
dwarf_getpubnames(dbg, pubname_search_cb, &pubname_param, 0);
|
||||
if (pubname_param.found) {
|
||||
ret = probe_point_search_cb(&pf->sp_die, &probe_param);
|
||||
if (ret)
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
|
||||
/* Loop on CUs (Compilation Unit) */
|
||||
while (!dwarf_nextcu(dbg, off, &noff, &cuhl, NULL, NULL, NULL)) {
|
||||
/* Get the DIE(Debugging Information Entry) of this CU */
|
||||
|
@ -1525,6 +1579,8 @@ static int find_probes(int fd, struct probe_finder *pf)
|
|||
}
|
||||
off = noff;
|
||||
}
|
||||
|
||||
found:
|
||||
line_list__free(&pf->lcache);
|
||||
if (dwfl)
|
||||
dwfl_end(dwfl);
|
||||
|
@ -1946,6 +2002,22 @@ int find_line_range(int fd, struct line_range *lr)
|
|||
return -EBADF;
|
||||
}
|
||||
|
||||
/* Fastpath: lookup by function name from .debug_pubnames section */
|
||||
if (lr->function) {
|
||||
struct pubname_callback_param pubname_param = {
|
||||
.function = lr->function, .file = lr->file,
|
||||
.cu_die = &lf.cu_die, .sp_die = &lf.sp_die, .found = 0};
|
||||
struct dwarf_callback_param line_range_param = {
|
||||
.data = (void *)&lf, .retval = 0};
|
||||
|
||||
dwarf_getpubnames(dbg, pubname_search_cb, &pubname_param, 0);
|
||||
if (pubname_param.found) {
|
||||
line_range_search_cb(&lf.sp_die, &line_range_param);
|
||||
if (lf.found)
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
|
||||
/* Loop on CUs (Compilation Unit) */
|
||||
while (!lf.found && ret >= 0) {
|
||||
if (dwarf_nextcu(dbg, off, &noff, &cuhl, NULL, NULL, NULL) != 0)
|
||||
|
@ -1974,6 +2046,7 @@ int find_line_range(int fd, struct line_range *lr)
|
|||
off = noff;
|
||||
}
|
||||
|
||||
found:
|
||||
/* Store comp_dir */
|
||||
if (lf.found) {
|
||||
comp_dir = cu_get_comp_dir(&lf.cu_die);
|
||||
|
|
|
@ -49,6 +49,7 @@ struct probe_finder {
|
|||
Dwarf_Addr addr; /* Address */
|
||||
const char *fname; /* Real file name */
|
||||
Dwarf_Die cu_die; /* Current CU */
|
||||
Dwarf_Die sp_die;
|
||||
struct list_head lcache; /* Line cache for lazy match */
|
||||
|
||||
/* For variable searching */
|
||||
|
@ -83,6 +84,7 @@ struct line_finder {
|
|||
int lno_s; /* Start line number */
|
||||
int lno_e; /* End line number */
|
||||
Dwarf_Die cu_die; /* Current CU */
|
||||
Dwarf_Die sp_die;
|
||||
int found;
|
||||
};
|
||||
|
||||
|
|
|
@ -810,6 +810,9 @@ static struct {
|
|||
{ "COUNT_HW_CACHE_RESULT_ACCESS", PERF_COUNT_HW_CACHE_RESULT_ACCESS },
|
||||
{ "COUNT_HW_CACHE_RESULT_MISS", PERF_COUNT_HW_CACHE_RESULT_MISS },
|
||||
|
||||
{ "COUNT_HW_STALLED_CYCLES_FRONTEND", PERF_COUNT_HW_STALLED_CYCLES_FRONTEND },
|
||||
{ "COUNT_HW_STALLED_CYCLES_BACKEND", PERF_COUNT_HW_STALLED_CYCLES_BACKEND },
|
||||
|
||||
{ "COUNT_SW_CPU_CLOCK", PERF_COUNT_SW_CPU_CLOCK },
|
||||
{ "COUNT_SW_TASK_CLOCK", PERF_COUNT_SW_TASK_CLOCK },
|
||||
{ "COUNT_SW_PAGE_FAULTS", PERF_COUNT_SW_PAGE_FAULTS },
|
||||
|
|
|
@ -1156,6 +1156,18 @@ size_t perf_session__fprintf_nr_events(struct perf_session *session, FILE *fp)
|
|||
return ret;
|
||||
}
|
||||
|
||||
struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
|
||||
unsigned int type)
|
||||
{
|
||||
struct perf_evsel *pos;
|
||||
|
||||
list_for_each_entry(pos, &session->evlist->entries, node) {
|
||||
if (pos->attr.type == type)
|
||||
return pos;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void perf_session__print_symbols(union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct perf_session *session)
|
||||
|
|
|
@ -162,6 +162,9 @@ static inline int perf_session__parse_sample(struct perf_session *session,
|
|||
session->sample_id_all, sample);
|
||||
}
|
||||
|
||||
struct perf_evsel *perf_session__find_first_evtype(struct perf_session *session,
|
||||
unsigned int type);
|
||||
|
||||
void perf_session__print_symbols(union perf_event *event,
|
||||
struct perf_sample *sample,
|
||||
struct perf_session *session);
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -62,7 +62,7 @@ struct symbol {
|
|||
char name[0];
|
||||
};
|
||||
|
||||
void symbol__delete(struct symbol *self);
|
||||
void symbol__delete(struct symbol *sym);
|
||||
|
||||
struct strlist;
|
||||
|
||||
|
@ -96,9 +96,9 @@ struct symbol_conf {
|
|||
|
||||
extern struct symbol_conf symbol_conf;
|
||||
|
||||
static inline void *symbol__priv(struct symbol *self)
|
||||
static inline void *symbol__priv(struct symbol *sym)
|
||||
{
|
||||
return ((void *)self) - symbol_conf.priv_size;
|
||||
return ((void *)sym) - symbol_conf.priv_size;
|
||||
}
|
||||
|
||||
struct ref_reloc_sym {
|
||||
|
@ -155,43 +155,45 @@ struct dso {
|
|||
|
||||
struct dso *dso__new(const char *name);
|
||||
struct dso *dso__new_kernel(const char *name);
|
||||
void dso__delete(struct dso *self);
|
||||
void dso__delete(struct dso *dso);
|
||||
|
||||
int dso__name_len(const struct dso *self);
|
||||
int dso__name_len(const struct dso *dso);
|
||||
|
||||
bool dso__loaded(const struct dso *self, enum map_type type);
|
||||
bool dso__sorted_by_name(const struct dso *self, enum map_type type);
|
||||
bool dso__loaded(const struct dso *dso, enum map_type type);
|
||||
bool dso__sorted_by_name(const struct dso *dso, enum map_type type);
|
||||
|
||||
static inline void dso__set_loaded(struct dso *self, enum map_type type)
|
||||
static inline void dso__set_loaded(struct dso *dso, enum map_type type)
|
||||
{
|
||||
self->loaded |= (1 << type);
|
||||
dso->loaded |= (1 << type);
|
||||
}
|
||||
|
||||
void dso__sort_by_name(struct dso *self, enum map_type type);
|
||||
void dso__sort_by_name(struct dso *dso, enum map_type type);
|
||||
|
||||
struct dso *__dsos__findnew(struct list_head *head, const char *name);
|
||||
|
||||
int dso__load(struct dso *self, struct map *map, symbol_filter_t filter);
|
||||
int dso__load_vmlinux(struct dso *self, struct map *map,
|
||||
int dso__load(struct dso *dso, struct map *map, symbol_filter_t filter);
|
||||
int dso__load_vmlinux(struct dso *dso, struct map *map,
|
||||
const char *vmlinux, symbol_filter_t filter);
|
||||
int dso__load_vmlinux_path(struct dso *self, struct map *map,
|
||||
int dso__load_vmlinux_path(struct dso *dso, struct map *map,
|
||||
symbol_filter_t filter);
|
||||
int dso__load_kallsyms(struct dso *self, const char *filename, struct map *map,
|
||||
int dso__load_kallsyms(struct dso *dso, const char *filename, struct map *map,
|
||||
symbol_filter_t filter);
|
||||
int machine__load_kallsyms(struct machine *self, const char *filename,
|
||||
int machine__load_kallsyms(struct machine *machine, const char *filename,
|
||||
enum map_type type, symbol_filter_t filter);
|
||||
int machine__load_vmlinux_path(struct machine *self, enum map_type type,
|
||||
int machine__load_vmlinux_path(struct machine *machine, enum map_type type,
|
||||
symbol_filter_t filter);
|
||||
|
||||
size_t __dsos__fprintf(struct list_head *head, FILE *fp);
|
||||
|
||||
size_t machine__fprintf_dsos_buildid(struct machine *self, FILE *fp, bool with_hits);
|
||||
size_t machines__fprintf_dsos(struct rb_root *self, FILE *fp);
|
||||
size_t machines__fprintf_dsos_buildid(struct rb_root *self, FILE *fp, bool with_hits);
|
||||
|
||||
size_t dso__fprintf_buildid(struct dso *self, FILE *fp);
|
||||
size_t dso__fprintf_symbols_by_name(struct dso *self, enum map_type type, FILE *fp);
|
||||
size_t dso__fprintf(struct dso *self, enum map_type type, FILE *fp);
|
||||
size_t machine__fprintf_dsos_buildid(struct machine *machine,
|
||||
FILE *fp, bool with_hits);
|
||||
size_t machines__fprintf_dsos(struct rb_root *machines, FILE *fp);
|
||||
size_t machines__fprintf_dsos_buildid(struct rb_root *machines,
|
||||
FILE *fp, bool with_hits);
|
||||
size_t dso__fprintf_buildid(struct dso *dso, FILE *fp);
|
||||
size_t dso__fprintf_symbols_by_name(struct dso *dso,
|
||||
enum map_type type, FILE *fp);
|
||||
size_t dso__fprintf(struct dso *dso, enum map_type type, FILE *fp);
|
||||
|
||||
enum symtab_type {
|
||||
SYMTAB__KALLSYMS = 0,
|
||||
|
@ -207,34 +209,36 @@ enum symtab_type {
|
|||
SYMTAB__NOT_FOUND,
|
||||
};
|
||||
|
||||
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 machine *machine);
|
||||
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,
|
||||
char dso__symtab_origin(const struct dso *dso);
|
||||
void dso__set_long_name(struct dso *dso, char *name);
|
||||
void dso__set_build_id(struct dso *dso, void *build_id);
|
||||
void dso__read_running_kernel_build_id(struct dso *dso,
|
||||
struct machine *machine);
|
||||
struct symbol *dso__find_symbol(struct dso *dso, enum map_type type,
|
||||
u64 addr);
|
||||
struct symbol *dso__find_symbol_by_name(struct dso *dso, enum map_type type,
|
||||
const char *name);
|
||||
|
||||
int filename__read_build_id(const char *filename, void *bf, size_t size);
|
||||
int sysfs__read_build_id(const char *filename, void *bf, size_t size);
|
||||
bool __dsos__read_build_ids(struct list_head *head, bool with_hits);
|
||||
int build_id__sprintf(const u8 *self, int len, char *bf);
|
||||
int build_id__sprintf(const u8 *build_id, int len, char *bf);
|
||||
int kallsyms__parse(const char *filename, void *arg,
|
||||
int (*process_symbol)(void *arg, const char *name,
|
||||
char type, u64 start, u64 end));
|
||||
|
||||
void machine__destroy_kernel_maps(struct machine *self);
|
||||
int __machine__create_kernel_maps(struct machine *self, struct dso *kernel);
|
||||
int machine__create_kernel_maps(struct machine *self);
|
||||
void machine__destroy_kernel_maps(struct machine *machine);
|
||||
int __machine__create_kernel_maps(struct machine *machine, struct dso *kernel);
|
||||
int machine__create_kernel_maps(struct machine *machine);
|
||||
|
||||
int machines__create_kernel_maps(struct rb_root *self, pid_t pid);
|
||||
int machines__create_guest_kernel_maps(struct rb_root *self);
|
||||
void machines__destroy_guest_kernel_maps(struct rb_root *self);
|
||||
int machines__create_kernel_maps(struct rb_root *machines, pid_t pid);
|
||||
int machines__create_guest_kernel_maps(struct rb_root *machines);
|
||||
void machines__destroy_guest_kernel_maps(struct rb_root *machines);
|
||||
|
||||
int symbol__init(void);
|
||||
void symbol__exit(void);
|
||||
bool symbol_type__is_a(char symbol_type, enum map_type map_type);
|
||||
|
||||
size_t machine__fprintf_vmlinux_path(struct machine *self, FILE *fp);
|
||||
size_t machine__fprintf_vmlinux_path(struct machine *machine, FILE *fp);
|
||||
|
||||
#endif /* __PERF_SYMBOL */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue