Commit ecd380b8 authored by Ingo Molnar's avatar Ingo Molnar

Merge tag 'perf-core-for-mingo-4.17-20180319' of...

Merge tag 'perf-core-for-mingo-4.17-20180319' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/core

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

- Fixes for problems experienced with new GCC 8 warnings, that treated
  as errors, broke the build, related to snprintf and casting issues.
  (Arnaldo Carvalho de Melo, Jiri Olsa, Josh Poinboeuf)

- Fix build of new breakpoint 'perf test' entry with clang < 6, noticed
  on fedora 25, 26 and 27 (Arnaldo Carvalho de Melo)

- Workaround problem with symbol resolution in 'perf annotate', using
  the symbol name already present in the objdump output (Arnaldo Carvalho de Melo)

- Document 'perf top --ignore-vmlinux' (Arnaldo Carvalho de Melo)

- Fix out of bounds access on array fd when cnt is 100 in one of the
  'perf test' entries, detected using 'cpptest' (Colin Ian King)

- Add support for the forced leader feature, i.e. 'perf report --group'
  for a group of events not really grouped when scheduled (without using
  {} to enclose the list of events in the command line) in pipe mode,
  e.g.:

    $ perf record -e cycles,instructions -o - kill | perf report --group -i -

- Use right type to access array elements in 'perf probe' (Masami Hiramatsu)

- Update POWER9 vendor events (those described in JSON format) (Sukadev Bhattiprolu)

- Discard head in overwrite_rb_find_range() (Yisheng Xie)

- Avoid setting 'quiet' to 'true' unnecessarily (Yisheng Xie)
Signed-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarIngo Molnar <mingo@kernel.org>
parents 134933e5 1cd61883
......@@ -22,6 +22,6 @@ char *str_error_r(int errnum, char *buf, size_t buflen)
{
int err = strerror_r(errnum, buf, buflen);
if (err)
snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, %p, %zd)=%d", errnum, buf, buflen, err);
snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, [buf], %zd)=%d", errnum, buflen, err);
return buf;
}
......@@ -116,7 +116,7 @@ and calls standard perf record command.
Following perf record options are configured by default:
(check perf record man page for details)
-W,-d,--sample-cpu
-W,-d,--phys-data,--sample-cpu
Unless specified otherwise with '-e' option, following events are monitored by
default:
......
......@@ -67,6 +67,9 @@ Default is to monitor all CPUS.
--vmlinux=<path>::
Path to vmlinux. Required for annotation functionality.
--ignore-vmlinux::
Ignore vmlinux files.
-m <pages>::
--mmap-pages=<pages>::
Number of mmap data pages (must be a power of two) or size
......
......@@ -75,7 +75,7 @@ endif
# Disable it on all other architectures in case libdw unwind
# support is detected in system. Add supported architectures
# to the check.
ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm powerpc s390))
ifneq ($(SRCARCH),$(filter $(SRCARCH),x86 arm arm64 powerpc s390))
NO_LIBDW_DWARF_UNWIND := 1
endif
......
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef ARCH_TESTS_H
#define ARCH_TESTS_H
#ifdef HAVE_DWARF_UNWIND_SUPPORT
struct thread;
struct perf_sample;
#endif
extern struct test arch_tests[];
#endif
libperf-y += regs_load.o
libperf-y += dwarf-unwind.o
libperf-y += arch-tests.o
// SPDX-License-Identifier: GPL-2.0
#include <string.h>
#include "tests/tests.h"
#include "arch-tests.h"
struct test arch_tests[] = {
#ifdef HAVE_DWARF_UNWIND_SUPPORT
{
.desc = "DWARF unwind",
.func = test__dwarf_unwind,
},
#endif
{
.func = NULL,
},
};
......@@ -2,6 +2,7 @@ libperf-y += header.o
libperf-y += sym-handling.o
libperf-$(CONFIG_DWARF) += dwarf-regs.o
libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
libperf-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o \
../../arm/util/auxtrace.o \
......
// SPDX-License-Identifier: GPL-2.0
#include <elfutils/libdwfl.h>
#include "../../util/unwind-libdw.h"
#include "../../util/perf_regs.h"
#include "../../util/event.h"
bool libdw__arch_set_initial_registers(Dwfl_Thread *thread, void *arg)
{
struct unwind_info *ui = arg;
struct regs_dump *user_regs = &ui->sample->user_regs;
Dwarf_Word dwarf_regs[PERF_REG_ARM64_MAX], dwarf_pc;
#define REG(r) ({ \
Dwarf_Word val = 0; \
perf_reg_value(&val, user_regs, PERF_REG_ARM64_##r); \
val; \
})
dwarf_regs[0] = REG(X0);
dwarf_regs[1] = REG(X1);
dwarf_regs[2] = REG(X2);
dwarf_regs[3] = REG(X3);
dwarf_regs[4] = REG(X4);
dwarf_regs[5] = REG(X5);
dwarf_regs[6] = REG(X6);
dwarf_regs[7] = REG(X7);
dwarf_regs[8] = REG(X8);
dwarf_regs[9] = REG(X9);
dwarf_regs[10] = REG(X10);
dwarf_regs[11] = REG(X11);
dwarf_regs[12] = REG(X12);
dwarf_regs[13] = REG(X13);
dwarf_regs[14] = REG(X14);
dwarf_regs[15] = REG(X15);
dwarf_regs[16] = REG(X16);
dwarf_regs[17] = REG(X17);
dwarf_regs[18] = REG(X18);
dwarf_regs[19] = REG(X19);
dwarf_regs[20] = REG(X20);
dwarf_regs[21] = REG(X21);
dwarf_regs[22] = REG(X22);
dwarf_regs[23] = REG(X23);
dwarf_regs[24] = REG(X24);
dwarf_regs[25] = REG(X25);
dwarf_regs[26] = REG(X26);
dwarf_regs[27] = REG(X27);
dwarf_regs[28] = REG(X28);
dwarf_regs[29] = REG(X29);
dwarf_regs[30] = REG(LR);
dwarf_regs[31] = REG(SP);
if (!dwfl_thread_state_registers(thread, 0, PERF_REG_ARM64_MAX,
dwarf_regs))
return false;
dwarf_pc = REG(PC);
dwfl_thread_state_register_pc(thread, dwarf_pc);
return true;
}
This diff is collapsed.
......@@ -754,13 +754,10 @@ static int record__synthesize(struct record *rec, bool tail)
return 0;
if (data->is_pipe) {
err = perf_event__synthesize_features(
tool, session, rec->evlist, process_synthesized_event);
if (err < 0) {
pr_err("Couldn't synthesize features.\n");
return err;
}
/*
* We need to synthesize events first, because some
* features works on top of them (on report side).
*/
err = perf_event__synthesize_attrs(tool, session,
process_synthesized_event);
if (err < 0) {
......@@ -768,6 +765,13 @@ static int record__synthesize(struct record *rec, bool tail)
goto out;
}
err = perf_event__synthesize_features(tool, session, rec->evlist,
process_synthesized_event);
if (err < 0) {
pr_err("Couldn't synthesize features.\n");
return err;
}
if (have_tracepoints(&rec->evlist->entries)) {
/*
* FIXME err <= 0 here actually means that
......@@ -1279,10 +1283,12 @@ static int perf_record_config(const char *var, const char *value, void *cb)
return -1;
return 0;
}
if (!strcmp(var, "record.call-graph"))
var = "call-graph.record-mode"; /* fall-through */
if (!strcmp(var, "record.call-graph")) {
var = "call-graph.record-mode";
return perf_default_config(var, value, cb);
}
return 0;
}
struct clockid_map {
......
......@@ -68,6 +68,7 @@ struct report {
bool header;
bool header_only;
bool nonany_branch_mode;
bool group_set;
int max_stack;
struct perf_read_values show_threads_values;
const char *pretty_printing_style;
......@@ -193,6 +194,45 @@ static int hist_iter__branch_callback(struct hist_entry_iter *iter,
return err;
}
/*
* Events in data file are not collect in groups, but we still want
* the group display. Set the artificial group and set the leader's
* forced_leader flag to notify the display code.
*/
static void setup_forced_leader(struct report *report,
struct perf_evlist *evlist)
{
if (report->group_set && !evlist->nr_groups) {
struct perf_evsel *leader = perf_evlist__first(evlist);
perf_evlist__set_leader(evlist);
leader->forced_leader = true;
}
}
static int process_feature_event(struct perf_tool *tool,
union perf_event *event,
struct perf_session *session __maybe_unused)
{
struct report *rep = container_of(tool, struct report, tool);
if (event->feat.feat_id < HEADER_LAST_FEATURE)
return perf_event__process_feature(tool, event, session);
if (event->feat.feat_id != HEADER_LAST_FEATURE) {
pr_err("failed: wrong feature ID: %" PRIu64 "\n",
event->feat.feat_id);
return -1;
}
/*
* All features are received, we can force the
* group if needed.
*/
setup_forced_leader(rep, session->evlist);
return 0;
}
static int process_sample_event(struct perf_tool *tool,
union perf_event *event,
struct perf_sample *sample,
......@@ -940,7 +980,6 @@ int cmd_report(int argc, const char **argv)
"perf report [<options>]",
NULL
};
bool group_set = false;
struct report report = {
.tool = {
.sample = process_sample_event,
......@@ -958,7 +997,7 @@ int cmd_report(int argc, const char **argv)
.id_index = perf_event__process_id_index,
.auxtrace_info = perf_event__process_auxtrace_info,
.auxtrace = perf_event__process_auxtrace,
.feature = perf_event__process_feature,
.feature = process_feature_event,
.ordered_events = true,
.ordering_requires_timestamps = true,
},
......@@ -1060,7 +1099,7 @@ int cmd_report(int argc, const char **argv)
"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_BOOLEAN_SET(0, "group", &symbol_conf.event_group, &group_set,
OPT_BOOLEAN_SET(0, "group", &symbol_conf.event_group, &report.group_set,
"Show event group information together"),
OPT_CALLBACK_NOOPT('b', "branch-stack", &branch_mode, "",
"use branch records for per branch histogram filling",
......@@ -1177,17 +1216,7 @@ int cmd_report(int argc, const char **argv)
has_br_stack = perf_header__has_feat(&session->header,
HEADER_BRANCH_STACK);
/*
* Events in data file are not collect in groups, but we still want
* the group display. Set the artificial group and set the leader's
* forced_leader flag to notify the display code.
*/
if (group_set && !session->evlist->nr_groups) {
struct perf_evsel *leader = perf_evlist__first(session->evlist);
perf_evlist__set_leader(session->evlist);
leader->forced_leader = true;
}
setup_forced_leader(&report, session->evlist);
if (itrace_synth_opts.last_branch)
has_br_stack = true;
......
......@@ -2674,7 +2674,7 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
}
for_each_lang(scripts_path, scripts_dir, lang_dirent) {
snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
scnprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
lang_dirent->d_name);
lang_dir = opendir(lang_path);
if (!lang_dir)
......@@ -2684,7 +2684,7 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
script_root = get_script_root(script_dirent, REPORT_SUFFIX);
if (script_root) {
desc = script_desc__findnew(script_root);
snprintf(script_path, MAXPATHLEN, "%s/%s",
scnprintf(script_path, MAXPATHLEN, "%s/%s",
lang_path, script_dirent->d_name);
read_script_info(desc, script_path);
free(script_root);
......@@ -2721,7 +2721,7 @@ static int check_ev_match(char *dir_name, char *scriptname,
int match, len;
FILE *fp;
sprintf(filename, "%s/bin/%s-record", dir_name, scriptname);
scnprintf(filename, MAXPATHLEN, "%s/bin/%s-record", dir_name, scriptname);
fp = fopen(filename, "r");
if (!fp)
......@@ -2799,7 +2799,7 @@ int find_scripts(char **scripts_array, char **scripts_path_array)
}
for_each_lang(scripts_path, scripts_dir, lang_dirent) {
snprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path,
scnprintf(lang_path, MAXPATHLEN, "%s/%s", scripts_path,
lang_dirent->d_name);
#ifdef NO_LIBPERL
if (strstr(lang_path, "perl"))
......@@ -2855,7 +2855,7 @@ static char *get_script_path(const char *script_root, const char *suffix)
return NULL;
for_each_lang(scripts_path, scripts_dir, lang_dirent) {
snprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
scnprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
lang_dirent->d_name);
lang_dir = opendir(lang_path);
if (!lang_dir)
......@@ -2867,7 +2867,7 @@ static char *get_script_path(const char *script_root, const char *suffix)
free(__script_root);
closedir(lang_dir);
closedir(scripts_dir);
snprintf(script_path, MAXPATHLEN, "%s/%s",
scnprintf(script_path, MAXPATHLEN, "%s/%s",
lang_path, script_dirent->d_name);
return strdup(script_path);
}
......
......@@ -2331,11 +2331,16 @@ static int add_default_attributes(void)
return 0;
if (transaction_run) {
struct parse_events_error errinfo;
if (pmu_have_event("cpu", "cycles-ct") &&
pmu_have_event("cpu", "el-start"))
err = parse_events(evsel_list, transaction_attrs, NULL);
err = parse_events(evsel_list, transaction_attrs,
&errinfo);
else
err = parse_events(evsel_list, transaction_limited_attrs, NULL);
err = parse_events(evsel_list,
transaction_limited_attrs,
&errinfo);
if (err) {
fprintf(stderr, "Cannot set up transaction events\n");
return -1;
......
......@@ -1223,8 +1223,10 @@ parse_callchain_opt(const struct option *opt, const char *arg, int unset)
static int perf_top_config(const char *var, const char *value, void *cb __maybe_unused)
{
if (!strcmp(var, "top.call-graph"))
var = "call-graph.record-mode"; /* fall-through */
if (!strcmp(var, "top.call-graph")) {
var = "call-graph.record-mode";
return perf_default_config(var, value, cb);
}
if (!strcmp(var, "top.children")) {
symbol_conf.cumulate_callchain = perf_config_bool(var, value);
return 0;
......
hostprogs := jevents
jevents-y += json.o jsmn.o jevents.o
CHOSTFLAGS_jevents.o = -I$(srctree)/tools/include
pmu-events-y += pmu-events.o
JDIR = pmu-events/arch/$(SRCARCH)
JSON = $(shell [ -d $(JDIR) ] && \
find $(JDIR) -name '*.json' -o -name 'mapfile.csv')
#
# Locate/process JSON files in pmu-events/arch/
# directory and create tables in pmu-events.c.
......
......@@ -11,12 +11,17 @@ tree tools/perf/pmu-events/arch/foo.
- Regular files with '.json' extension in the name are assumed to be
JSON files, each of which describes a set of PMU events.
- Regular files with basename starting with 'mapfile.csv' are assumed
to be a CSV file that maps a specific CPU to its set of PMU events.
(see below for mapfile format)
- The CSV file that maps a specific CPU to its set of PMU events is to
be named 'mapfile.csv' (see below for mapfile format).
- Directories are traversed, but all other files are ignored.
- To reduce JSON event duplication per architecture, platform JSONs may
use "ArchStdEvent" keyword to dereference an "Architecture standard
events", defined in architecture standard JSONs.
Architecture standard JSONs must be located in the architecture root
folder. Matching is based on the "EventName" field.
The PMU events supported by a CPU model are expected to grouped into topics
such as Pipelining, Cache, Memory, Floating-point etc. All events for a topic
should be placed in a separate JSON file - where the file name identifies
......@@ -29,6 +34,10 @@ sub directory. Thus for the Silvermont X86 CPU:
Cache.json Memory.json Virtual-Memory.json
Frontend.json Pipeline.json
The JSONs folder for a CPU model/family may be placed in the root arch
folder, or may be placed in a vendor sub-folder under the arch folder
for instances where the arch and vendor are not the same.
Using the JSON files and the mapfile, 'jevents' generates the C source file,
'pmu-events.c', which encodes the two sets of tables:
......
[
{,
"EventCode": "0x7A",
"EventName": "BR_INDIRECT_SPEC",
"BriefDescription": "Branch speculatively executed - Indirect branch"
{
"ArchStdEvent": "BR_INDIRECT_SPEC",
},
{,
{
"EventCode": "0xC9",
"EventName": "BR_COND",
"BriefDescription": "Conditional branch executed"
},
{,
{
"EventCode": "0xCA",
"EventName": "BR_INDIRECT_MISPRED",
"BriefDescription": "Indirect branch mispredicted"
},
{,
{
"EventCode": "0xCB",
"EventName": "BR_INDIRECT_MISPRED_ADDR",
"BriefDescription": "Indirect branch mispredicted because of address miscompare"
},
{,
{
"EventCode": "0xCC",
"EventName": "BR_COND_MISPRED",
"BriefDescription": "Conditional branch mispredicted"
......
[
{
"ArchStdEvent": "BUS_ACCESS_RD",
},
{
"ArchStdEvent": "BUS_ACCESS_WR",
}
]
[
{
"EventCode": "0xC2",
"EventName": "PREFETCH_LINEFILL",
"BriefDescription": "Linefill because of prefetch"
},
{
"EventCode": "0xC3",
"EventName": "PREFETCH_LINEFILL_DROP",
"BriefDescription": "Instruction Cache Throttle occurred"
},
{
"EventCode": "0xC4",
"EventName": "READ_ALLOC_ENTER",
"BriefDescription": "Entering read allocate mode"
},
{
"EventCode": "0xC5",
"EventName": "READ_ALLOC",
"BriefDescription": "Read allocate mode"
},
{
"EventCode": "0xC8",
"EventName": "EXT_SNOOP",
"BriefDescription": "SCU Snooped data from another CPU for this CPU"
}
]
[
{,
"EventCode": "0x60",
"EventName": "BUS_ACCESS_LD",
"BriefDescription": "Bus access - Read"
},
{,
"EventCode": "0x61",
"EventName": "BUS_ACCESS_ST",
"BriefDescription": "Bus access - Write"
},
{,
{
"EventCode": "0xC0",
"EventName": "EXT_MEM_REQ",
"BriefDescription": "External memory request"
},
{,
{
"EventCode": "0xC1",
"EventName": "EXT_MEM_REQ_NC",
"BriefDescription": "Non-cacheable external memory request"
......
[
{
"ArchStdEvent": "EXC_IRQ",
},
{
"ArchStdEvent": "EXC_FIQ",
},
{
"EventCode": "0xC6",
"EventName": "PRE_DECODE_ERR",
"BriefDescription": "Pre-decode error"
},
{
"EventCode": "0xD0",
"EventName": "L1I_CACHE_ERR",
"BriefDescription": "L1 Instruction Cache (data or tag) memory error"
},
{
"EventCode": "0xD1",
"EventName": "L1D_CACHE_ERR",
"BriefDescription": "L1 Data Cache (data, tag or dirty) memory error, correctable or non-correctable"
},
{
"EventCode": "0xD2",
"EventName": "TLB_ERR",
"BriefDescription": "TLB memory error"
}
]
[
{,
{
"EventCode": "0xC7",
"EventName": "STALL_SB_FULL",
"BriefDescription": "Data Write operation that stalls the pipeline because the store buffer is full"
},
{,
{
"EventCode": "0xE0",
"EventName": "OTHER_IQ_DEP_STALL",
"BriefDescription": "Cycles that the DPU IQ is empty and that is not because of a recent micro-TLB miss, instruction cache miss or pre-decode error"
},
{,
{
"EventCode": "0xE1",
"EventName": "IC_DEP_STALL",
"BriefDescription": "Cycles the DPU IQ is empty and there is an instruction cache miss being processed"
},
{,
{
"EventCode": "0xE2",
"EventName": "IUTLB_DEP_STALL",
"BriefDescription": "Cycles the DPU IQ is empty and there is an instruction micro-TLB miss being processed"
},
{,
{
"EventCode": "0xE3",
"EventName": "DECODE_DEP_STALL",
"BriefDescription": "Cycles the DPU IQ is empty and there is a pre-decode error being processed"
},
{,
{
"EventCode": "0xE4",
"EventName": "OTHER_INTERLOCK_STALL",
"BriefDescription": "Cycles there is an interlock other than Advanced SIMD/Floating-point instructions or load/store instruction"
},
{,
{
"EventCode": "0xE5",
"EventName": "AGU_DEP_STALL",
"BriefDescription": "Cycles there is an interlock for a load/store instruction waiting for data to calculate the address in the AGU"
},
{,
{
"EventCode": "0xE6",
"EventName": "SIMD_DEP_STALL",
"BriefDescription": "Cycles there is an interlock for an Advanced SIMD/Floating-point operation."
},
{,
{
"EventCode": "0xE7",
"EventName": "LD_DEP_STALL",
"BriefDescription": "Cycles there is a stall in the Wr stage because of a load miss"
},
{,
{
"EventCode": "0xE8",
"EventName": "ST_DEP_STALL",
"BriefDescription": "Cycles there is a stall in the Wr stage because of a store"
......
This diff is collapsed.
[
{
"PublicDescription": "Attributable Level 1 data cache access, read",
"EventCode": "0x40",
"EventName": "l1d_cache_rd",
"BriefDescription": "L1D cache read",
},
{
"PublicDescription": "Attributable Level 1 data cache access, write ",
"EventCode": "0x41",
"EventName": "l1d_cache_wr",
"BriefDescription": "L1D cache write",
},
{
"PublicDescription": "Attributable Level 1 data cache refill, read",
"EventCode": "0x42",
"EventName": "l1d_cache_refill_rd",
"BriefDescription": "L1D cache refill read",
},
{
"PublicDescription": "Attributable Level 1 data cache refill, write",
"EventCode": "0x43",
"EventName": "l1d_cache_refill_wr",
"BriefDescription": "L1D refill write",
},
{
"PublicDescription": "Attributable Level 1 data TLB refill, read",
"EventCode": "0x4C",
"EventName": "l1d_tlb_refill_rd",
"BriefDescription": "L1D tlb refill read",
},
{
"PublicDescription": "Attributable Level 1 data TLB refill, write",
"EventCode": "0x4D",
"EventName": "l1d_tlb_refill_wr",
"BriefDescription": "L1D tlb refill write",
},
{
"PublicDescription": "Attributable Level 1 data or unified TLB access, read",
"EventCode": "0x4E",
"EventName": "l1d_tlb_rd",
"BriefDescription": "L1D tlb read",
},
{
"PublicDescription": "Attributable Level 1 data or unified TLB access, write",
"EventCode": "0x4F",
"EventName": "l1d_tlb_wr",
"BriefDescription": "L1D tlb write",
},
{
"PublicDescription": "Bus access read",
"EventCode": "0x60",
"EventName": "bus_access_rd",
"BriefDescription": "Bus access read",
},
{
"PublicDescription": "Bus access write",
"EventCode": "0x61",
"EventName": "bus_access_wr",
"BriefDescription": "Bus access write",
}
]
[
{
"ArchStdEvent": "L1D_CACHE_RD",
},
{
"ArchStdEvent": "L1D_CACHE_WR",
},
{
"ArchStdEvent": "L1D_CACHE_REFILL_RD",
},
{
"ArchStdEvent": "L1D_CACHE_REFILL_WR",
},
{
"ArchStdEvent": "L1D_TLB_REFILL_RD",
},
{
"ArchStdEvent": "L1D_TLB_REFILL_WR",
},
{
"ArchStdEvent": "L1D_TLB_RD",
},
{
"ArchStdEvent": "L1D_TLB_WR",
},
{
"ArchStdEvent": "BUS_ACCESS_RD",
},
{
"ArchStdEvent": "BUS_ACCESS_WR",
}
]
[
{,
"EventCode": "0x60",
"EventName": "BUS_ACCESS_LD",
"BriefDescription": "Bus access - Read"
},
{,
"EventCode": "0x61",
"EventName": "BUS_ACCESS_ST",
"BriefDescription": "Bus access - Write"
},
{,
"EventCode": "0xC0",
"EventName": "EXT_MEM_REQ",
"BriefDescription": "External memory request"
},
{,
"EventCode": "0xC1",
"EventName": "EXT_MEM_REQ_NC",
"BriefDescription": "Non-cacheable external memory request"
}
]
[
{,
"EventCode": "0xC2",
"EventName": "PREFETCH_LINEFILL",
"BriefDescription": "Linefill because of prefetch"
},
{,
"EventCode": "0xC3",
"EventName": "PREFETCH_LINEFILL_DROP",
"BriefDescription": "Instruction Cache Throttle occurred"
},
{,
"EventCode": "0xC4",
"EventName": "READ_ALLOC_ENTER",
"BriefDescription": "Entering read allocate mode"
},
{,
"EventCode": "0xC5",
"EventName": "READ_ALLOC",
"BriefDescription": "Read allocate mode"
},
{,
"EventCode": "0xC8",
"EventName": "EXT_SNOOP",
"BriefDescription": "SCU Snooped data from another CPU for this CPU"
}
]
[
{,
"EventCode": "0x86",
"EventName": "EXC_IRQ",
"BriefDescription": "Exception taken, IRQ"
},
{,
"EventCode": "0x87",
"EventName": "EXC_FIQ",
"BriefDescription": "Exception taken, FIQ"
},
{,
"EventCode": "0xC6",
"EventName": "PRE_DECODE_ERR",
"BriefDescription": "Pre-decode error"
},
{,
"EventCode": "0xD0",
"EventName": "L1I_CACHE_ERR",
"BriefDescription": "L1 Instruction Cache (data or tag) memory error"
},
{,
"EventCode": "0xD1",
"EventName": "L1D_CACHE_ERR",
"BriefDescription": "L1 Data Cache (data, tag or dirty) memory error, correctable or non-correctable"
},
{,
"EventCode": "0xD2",
"EventName": "TLB_ERR",
"BriefDescription": "TLB memory error"
}
]
[
{
"ArchStdEvent": "L1D_CACHE_RD",
},
{
"ArchStdEvent": "L1D_CACHE_WR",
},
{
"ArchStdEvent": "L1D_CACHE_REFILL_RD",
},
{
"ArchStdEvent": "L1D_CACHE_REFILL_WR",
},
{
"ArchStdEvent": "L1D_CACHE_WB_VICTIM",
},
{
"ArchStdEvent": "L1D_CACHE_WB_CLEAN",
},
{
"ArchStdEvent": "L1D_CACHE_INVAL",
},
{
"ArchStdEvent": "L1D_TLB_REFILL_RD",
},
{
"ArchStdEvent": "L1D_TLB_REFILL_WR",
},
{
"ArchStdEvent": "L1D_TLB_RD",
},
{
"ArchStdEvent": "L1D_TLB_WR",
},
{
"ArchStdEvent": "L2D_CACHE_RD",
},
{
"ArchStdEvent": "L2D_CACHE_WR",
},
{
"ArchStdEvent": "L2D_CACHE_REFILL_RD",
},
{
"ArchStdEvent": "L2D_CACHE_REFILL_WR",
},
{
"ArchStdEvent": "L2D_CACHE_WB_VICTIM",
},
{
"ArchStdEvent": "L2D_CACHE_WB_CLEAN",
},
{
"ArchStdEvent": "L2D_CACHE_INVAL",
},
{
"PublicDescription": "Level 1 instruction cache prefetch access count",
"EventCode": "0x102e",
"EventName": "L1I_CACHE_PRF",
"BriefDescription": "L1I cache prefetch access count",
},
{
"PublicDescription": "Level 1 instruction cache miss due to prefetch access count",
"EventCode": "0x102f",
"EventName": "L1I_CACHE_PRF_REFILL",
"BriefDescription": "L1I cache miss due to prefetch access count",
},
{
"PublicDescription": "Instruction queue is empty",
"EventCode": "0x1043",
"EventName": "IQ_IS_EMPTY",
"BriefDescription": "Instruction queue is empty",
},
{
"PublicDescription": "Instruction fetch stall cycles",
"EventCode": "0x1044",
"EventName": "IF_IS_STALL",
"BriefDescription": "Instruction fetch stall cycles",
},
{
"PublicDescription": "Instructions can receive, but not send",
"EventCode": "0x2014",
"EventName": "FETCH_BUBBLE",
"BriefDescription": "Instructions can receive, but not send",
},
{
"PublicDescription": "Prefetch request from LSU",
"EventCode": "0x6013",
"EventName": "PRF_REQ",
"BriefDescription": "Prefetch request from LSU",
},
{
"PublicDescription": "Hit on prefetched data",
"EventCode": "0x6014",
"EventName": "HIT_ON_PRF",
"BriefDescription": "Hit on prefetched data",
},
{
"PublicDescription": "Cycles of that the number of issuing micro operations are less than 4",
"EventCode": "0x7001",
"EventName": "EXE_STALL_CYCLE",
"BriefDescription": "Cycles of that the number of issue ups are less than 4",
},
{
"PublicDescription": "No any micro operation is issued and meanwhile any load operation is not resolved",
"EventCode": "0x7004",
"EventName": "MEM_STALL_ANYLOAD",
"BriefDescription": "No any micro operation is issued and meanwhile any load operation is not resolved",
},
{
"PublicDescription": "No any micro operation is issued and meanwhile there is any load operation missing L1 cache and pending data refill",
"EventCode": "0x7006",
"EventName": "MEM_STALL_L1MISS",
"BriefDescription": "No any micro operation is issued and meanwhile there is any load operation missing L1 cache and pending data refill",
},
{
"PublicDescription": "No any micro operation is issued and meanwhile there is any load operation missing both L1 and L2 cache and pending data refill from L3 cache",
"EventCode": "0x7007",
"EventName": "MEM_STALL_L2MISS",
"BriefDescription": "No any micro operation is issued and meanwhile there is any load operation missing both L1 and L2 cache and pending data refill from L3 cache",
},
]
......@@ -12,5 +12,7 @@
#
#
#Family-model,Version,Filename,EventType
0x00000000420f5160,v1,cavium,core
0x00000000410fd03[[:xdigit:]],v1,cortex-a53,core
0x00000000410fd03[[:xdigit:]],v1,arm/cortex-a53,core
0x00000000420f5160,v1,cavium/thunderx2,core
0x00000000430f0af0,v1,cavium/thunderx2,core
0x00000000480fd010,v1,hisilicon/hip08,core
......@@ -19,11 +19,6 @@
"EventName": "PM_CMPLU_STALL_FXU",
"BriefDescription": "Finish stall due to a scalar fixed point or CR instruction in the execution pipeline. These instructions get routed to the ALU, ALU2, and DIV pipes"
},
{,
"EventCode": "0x1D15C",
"EventName": "PM_MRK_DTLB_MISS_1G",
"BriefDescription": "Marked Data TLB reload (after a miss) page size 2M. Implies radix translation was used"
},
{,
"EventCode": "0x4D12A",
"EventName": "PM_MRK_DATA_FROM_RL4_CYC",
......@@ -79,21 +74,6 @@
"EventName": "PM_THRESH_EXC_4096",
"BriefDescription": "Threshold counter exceed a count of 4096"
},
{,
"EventCode": "0x3D156",
"EventName": "PM_MRK_DTLB_MISS_64K",
"BriefDescription": "Marked Data TLB Miss page size 64K"
},
{,
"EventCode": "0x4C15E",
"EventName": "PM_MRK_DTLB_MISS_16M",
"BriefDescription": "Marked Data TLB Miss page size 16M"
},
{,
"EventCode": "0x2D15E",
"EventName": "PM_MRK_DTLB_MISS_16G",
"BriefDescription": "Marked Data TLB Miss page size 16G"
},
{,
"EventCode": "0x3F14A",
"EventName": "PM_MRK_DPTEG_FROM_RMEM",
......@@ -123,10 +103,5 @@
"EventCode": "0x1002A",
"EventName": "PM_CMPLU_STALL_LARX",
"BriefDescription": "Finish stall because the NTF instruction was a larx waiting to be satisfied"
},
{,
"EventCode": "0x1C058",
"EventName": "PM_DTLB_MISS_16G",
"BriefDescription": "Data TLB Miss page size 16G"
}
]
\ No newline at end of file
......@@ -154,11 +154,6 @@
"EventName": "PM_MRK_DATA_FROM_RL2L3_SHR_CYC",
"BriefDescription": "Duration in cycles to reload with Shared (S) data from another chip's L2 or L3 on the same Node or Group (Remote), as this chip due to a marked load"
},
{,
"EventCode": "0x3C056",
"EventName": "PM_DTLB_MISS_64K",
"BriefDescription": "Data TLB Miss page size 64K"
},
{,
"EventCode": "0x30060",
"EventName": "PM_TM_TRANS_RUN_INST",
......@@ -344,11 +339,6 @@
"EventName": "PM_MRK_LARX_FIN",
"BriefDescription": "Larx finished"
},
{,
"EventCode": "0x4C056",
"EventName": "PM_DTLB_MISS_16M",
"BriefDescription": "Data TLB Miss page size 16M"
},
{,
"EventCode": "0x1003A",
"EventName": "PM_CMPLU_STALL_LSU_FIN",
......
......@@ -529,11 +529,6 @@
"EventName": "PM_L1_ICACHE_RELOADED_ALL",
"BriefDescription": "Counts all Icache reloads includes demand, prefetch, prefetch turned into demand and demand turned into prefetch"
},
{,
"EventCode": "0x4003C",
"EventName": "PM_DISP_HELD_SYNC_HOLD",
"BriefDescription": "Cycles in which dispatch is held because of a synchronizing instruction in the pipeline"
},
{,
"EventCode": "0x3003C",
"EventName": "PM_CMPLU_STALL_NESTED_TEND",
......
......@@ -44,11 +44,6 @@
"EventName": "PM_LD_CMPL",
"BriefDescription": "count of Loads completed"
},
{,
"EventCode": "0x2D156",
"EventName": "PM_MRK_DTLB_MISS_4K",
"BriefDescription": "Marked Data TLB Miss page size 4k"
},
{,
"EventCode": "0x4C042",
"EventName": "PM_DATA_FROM_L3",
......
......@@ -64,11 +64,6 @@
"EventName": "PM_DISP_HELD",
"BriefDescription": "Dispatch Held"
},
{,
"EventCode": "0x3D154",
"EventName": "PM_MRK_DERAT_MISS_16M",
"BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 16M"
},
{,
"EventCode": "0x200F8",
"EventName": "PM_EXT_INT",
......@@ -119,6 +114,11 @@
"EventName": "PM_MRK_DPTEG_FROM_L3_MEPF",
"BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L3 without dispatch conflicts hit on Mepf state. due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
},
{,
"EventCode": "0x4C15C",
"EventName": "PM_MRK_DERAT_MISS_16G_1G",
"BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 16G (hpt mode) and 1G (radix mode)"
},
{,
"EventCode": "0x10024",
"EventName": "PM_PMC5_OVERFLOW",
......@@ -154,11 +154,6 @@
"EventName": "PM_ICT_NOSLOT_IC_MISS",
"BriefDescription": "Ict empty for this thread due to Icache Miss"
},
{,
"EventCode": "0x3D152",
"EventName": "PM_MRK_DERAT_MISS_1G",
"BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 1G. Implies radix translation"
},
{,
"EventCode": "0x4F14A",
"EventName": "PM_MRK_DPTEG_FROM_OFF_CHIP_CACHE",
......@@ -184,11 +179,6 @@
"EventName": "PM_MRK_DPTEG_FROM_L2_NO_CONFLICT",
"BriefDescription": "A Page Table Entry was loaded into the TLB from local core's L2 without conflict due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
},
{,
"EventCode": "0x2C05A",
"EventName": "PM_DERAT_MISS_1G",
"BriefDescription": "Data ERAT Miss (Data TLB Access) page size 1G. Implies radix translation"
},
{,
"EventCode": "0x1F058",
"EventName": "PM_RADIX_PWC_L2_PTE_FROM_L2",
......@@ -239,11 +229,6 @@
"EventName": "PM_DTLB_MISS",
"BriefDescription": "Data PTEG reload"
},
{,
"EventCode": "0x2D152",
"EventName": "PM_MRK_DERAT_MISS_2M",
"BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 2M. Implies radix translation"
},
{,
"EventCode": "0x2C046",
"EventName": "PM_DATA_FROM_RL2L3_MOD",
......@@ -289,6 +274,11 @@
"EventName": "PM_CMPLU_STALL_DFU",
"BriefDescription": "Finish stall because the NTF instruction was issued to the Decimal Floating Point execution pipe and waiting to finish. Includes decimal floating point instructions + 128 bit binary floating point instructions. Not qualified by multicycle"
},
{,
"EventCode": "0x3C054",
"EventName": "PM_DERAT_MISS_16M_2M",
"BriefDescription": "Data ERAT Miss (Data TLB Access) page size 16M (HPT mode) or 2M (Radix mode)"
},
{,
"EventCode": "0x4C04C",
"EventName": "PM_DATA_FROM_DMEM",
......@@ -359,11 +349,6 @@
"EventName": "PM_INST_FROM_MEMORY",
"BriefDescription": "The processor's Instruction cache was reloaded from a memory location including L4 from local remote or distant due to an instruction fetch (not prefetch)"
},
{,
"EventCode": "0x1C05A",
"EventName": "PM_DERAT_MISS_2M",
"BriefDescription": "Data ERAT Miss (Data TLB Access) page size 2M. Implies radix translation"
},
{,
"EventCode": "0x30024",
"EventName": "PM_PMC6_OVERFLOW",
......@@ -374,6 +359,11 @@
"EventName": "PM_BRU_FIN",
"BriefDescription": "Branch Instruction Finished"
},
{,
"EventCode": "0x3D154",
"EventName": "PM_MRK_DERAT_MISS_16M_2M",
"BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 16M (hpt mode) or 2M (radix mode)"
},
{,
"EventCode": "0x30020",
"EventName": "PM_PMC2_REWIND",
......@@ -409,11 +399,6 @@
"EventName": "PM_MRK_DPTEG_FROM_L31_MOD",
"BriefDescription": "A Page Table Entry was loaded into the TLB with Modified (M) data from another core's L3 on the same chip due to a marked data side request. When using Radix Page Translation, this count excludes PDE reloads. Only PTE reloads are included"
},
{,
"EventCode": "0x4C15C",
"EventName": "PM_MRK_DERAT_MISS_16G",
"BriefDescription": "Marked Data ERAT Miss (Data TLB Access) page size 16G"
},
{,
"EventCode": "0x14052",
"EventName": "PM_INST_GRP_PUMP_MPRED_RTY",
......@@ -444,11 +429,6 @@
"EventName": "PM_IC_DEMAND_CYC",
"BriefDescription": "Icache miss demand cycles"
},
{,
"EventCode": "0x3C054",
"EventName": "PM_DERAT_MISS_16M",
"BriefDescription": "Data ERAT Miss (Data TLB Access) page size 16M"
},
{,
"EventCode": "0x2D14E",
"EventName": "PM_MRK_DATA_FROM_L21_SHR",
......
......@@ -9,11 +9,6 @@
"EventName": "PM_MEM_LOC_THRESH_LSU_HIGH",
"BriefDescription": "Local memory above threshold for LSU medium"
},
{,
"EventCode": "0x2C056",
"EventName": "PM_DTLB_MISS_4K",
"BriefDescription": "Data TLB Miss page size 4k"
},
{,
"EventCode": "0x40118",
"EventName": "PM_MRK_DCACHE_RELOAD_INTV",
......
......@@ -29,11 +29,6 @@
"EventName": "PM_ST_FIN",
"BriefDescription": "Store finish count. Includes speculative activity"
},
{,
"EventCode": "0x44042",
"EventName": "PM_INST_FROM_L3",
"BriefDescription": "The processor's Instruction cache was reloaded from local core's L3 due to an instruction fetch (not prefetch)"
},
{,
"EventCode": "0x1504A",
"EventName": "PM_IPTEG_FROM_RL2L3_SHR",
......@@ -124,6 +119,11 @@
"EventName": "PM_PMC1_SAVED",
"BriefDescription": "PMC1 Rewind Value saved"
},
{,
"EventCode": "0x44042",
"EventName": "PM_INST_FROM_L3",
"BriefDescription": "The processor's Instruction cache was reloaded from local core's L3 due to an instruction fetch (not prefetch)"
},
{,
"EventCode": "0x200FE",
"EventName": "PM_DATA_FROM_L2MISS",
......
This diff is collapsed.
......@@ -48,6 +48,7 @@ perf-y += bitmap.o
perf-y += perf-hooks.o
perf-y += clang.o
perf-y += unit_number__scnprintf.o
perf-y += mem2node.o
$(OUTPUT)tests/llvm-src-base.c: tests/bpf-script-example.c tests/Build
$(call rule_mkdir)
......
......@@ -170,7 +170,7 @@ static int run_dir(const char *d, const char *perf)
if (verbose > 0)
vcnt++;
snprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
scnprintf(cmd, 3*PATH_MAX, PYTHON " %s/attr.py -d %s/attr/ -p %s %.*s",
d, d, perf, vcnt, v);
return system(cmd) ? TEST_FAIL : TEST_OK;
......
......@@ -103,20 +103,18 @@ static int bp_accounting(int wp_cnt, int share)
static int detect_cnt(bool is_x)
{
struct perf_event_attr attr;
void *addr = is_x ? test_function : (void *) &the_var;
void *addr = is_x ? (void *)test_function : (void *)&the_var;
int fd[100], cnt = 0, i;
while (1) {
fd[cnt] = __event(is_x, addr, &attr);
if (fd[cnt] < 0)
break;
if (cnt == 100) {
pr_debug("way too many debug registers, fix the test\n");
return 0;
}
fd[cnt] = __event(is_x, addr, &attr);
if (fd[cnt] < 0)
break;
cnt++;
}
......
......@@ -274,6 +274,10 @@ static struct test generic_tests[] = {
.desc = "unit_number__scnprintf",
.func = test__unit_number__scnprint,
},
{
.desc = "mem2node",
.func = test__mem2node,
},
{
.func = NULL,
},
......
......@@ -16,7 +16,7 @@ static int check(union perf_mem_data_src data_src,
n = perf_mem__snp_scnprintf(out, sizeof out, &mi);
n += perf_mem__lvl_scnprintf(out + n, sizeof out - n, &mi);
snprintf(failure, sizeof failure, "unexpected %s", out);
scnprintf(failure, sizeof failure, "unexpected %s", out);
TEST_ASSERT_VAL(failure, !strcmp(string, out));
return 0;
}
......
#include <linux/compiler.h>
#include <linux/bitmap.h>
#include "cpumap.h"
#include "mem2node.h"
#include "tests.h"
static struct node {
int node;
const char *map;
} test_nodes[] = {
{ .node = 0, .map = "0" },
{ .node = 1, .map = "1-2" },
{ .node = 3, .map = "5-7,9" },
};
#define T TEST_ASSERT_VAL
static unsigned long *get_bitmap(const char *str, int nbits)
{
struct cpu_map *map = cpu_map__new(str);
unsigned long *bm = NULL;
int i;
bm = bitmap_alloc(nbits);
if (map && bm) {
bitmap_zero(bm, nbits);
for (i = 0; i < map->nr; i++) {
set_bit(map->map[i], bm);
}
}
if (map)
cpu_map__put(map);
else
free(bm);
return bm && map ? bm : NULL;
}
int test__mem2node(struct test *t __maybe_unused, int subtest __maybe_unused)
{
struct mem2node map;
struct memory_node nodes[3];
struct perf_env env = {
.memory_nodes = (struct memory_node *) &nodes[0],
.nr_memory_nodes = ARRAY_SIZE(nodes),
.memory_bsize = 0x100,
};
unsigned int i;
for (i = 0; i < ARRAY_SIZE(nodes); i++) {
nodes[i].node = test_nodes[i].node;
nodes[i].size = 10;
T("failed: alloc bitmap",
(nodes[i].set = get_bitmap(test_nodes[i].map, 10)));
}
T("failed: mem2node__init", !mem2node__init(&map, &env));
T("failed: mem2node__node", 0 == mem2node__node(&map, 0x50));
T("failed: mem2node__node", 1 == mem2node__node(&map, 0x100));
T("failed: mem2node__node", 1 == mem2node__node(&map, 0x250));
T("failed: mem2node__node", 3 == mem2node__node(&map, 0x500));
T("failed: mem2node__node", 3 == mem2node__node(&map, 0x650));
T("failed: mem2node__node", -1 == mem2node__node(&map, 0x450));
T("failed: mem2node__node", -1 == mem2node__node(&map, 0x1050));
for (i = 0; i < ARRAY_SIZE(nodes); i++)
free(nodes[i].set);
mem2node__exit(&map);
return 0;
}
......@@ -98,7 +98,7 @@ static char *test_format_dir_get(void)
struct test_format *format = &test_formats[i];
FILE *file;
snprintf(name, PATH_MAX, "%s/%s", dir, format->name);
scnprintf(name, PATH_MAX, "%s/%s", dir, format->name);
file = fopen(name, "w");
if (!file)
......
......@@ -47,7 +47,10 @@ trace_libc_inet_pton_backtrace() {
[ -z "${expected[$idx]}" ] && break
done
rm -f $file
# If any statements are executed from this point onwards,
# the exit code of the last among these will be reflected
# in err below. If the exit code is 0, the test will pass
# even if the perf script output does not match.
}
# Check for IPv6 interface existence
......
......@@ -103,6 +103,7 @@ int test__clang(struct test *test, int subtest);
const char *test__clang_subtest_get_desc(int subtest);
int test__clang_subtest_get_nr(void);
int test__unit_number__scnprint(struct test *test, int subtest);
int test__mem2node(struct test *t, int subtest);
bool test__bp_signal_is_supported(void);
......
......@@ -840,15 +840,11 @@ size_t events_stats__fprintf(struct events_stats *stats, FILE *fp)
for (i = 0; i < PERF_RECORD_HEADER_MAX; ++i) {
const char *name;
if (stats->nr_events[i] == 0)
continue;
name = perf_event__name(i);
if (!strcmp(name, "UNKNOWN"))
continue;
ret += fprintf(fp, "%16s events: %10d\n", name,
stats->nr_events[i]);
ret += fprintf(fp, "%16s events: %10d\n", name, stats->nr_events[i]);
}
return ret;
......
......@@ -106,6 +106,7 @@ libperf-y += units.o
libperf-y += time-utils.o
libperf-y += expr-bison.o
libperf-y += branch.o
libperf-y += mem2node.o
libperf-$(CONFIG_LIBBPF) += bpf-loader.o
libperf-$(CONFIG_BPF_PROLOGUE) += bpf-prologue.o
......
......@@ -238,6 +238,9 @@ static int call__scnprintf(struct ins *ins, char *bf, size_t size,
if (ops->target.addr == 0)
return ins__raw_scnprintf(ins, bf, size, ops);
if (ops->target.name)
return scnprintf(bf, size, "%-6s %s", ins->name, ops->target.name);
return scnprintf(bf, size, "%-6s *%" PRIx64, ins->name, ops->target.addr);
}
......@@ -1427,7 +1430,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
{
struct map *map = args->map;
struct dso *dso = map->dso;
char command[PATH_MAX * 2];
char *command;
FILE *file;
char symfs_filename[PATH_MAX];
struct kcore_extract kce;
......@@ -1468,7 +1471,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
strcpy(symfs_filename, tmp);
}
snprintf(command, sizeof(command),
err = asprintf(&command,
"%s %s%s --start-address=0x%016" PRIx64
" --stop-address=0x%016" PRIx64
" -l -d %s %s -C \"%s\" 2>/dev/null|grep -v \"%s:\"|expand",
......@@ -1481,12 +1484,17 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
symbol_conf.annotate_src ? "-S" : "",
symfs_filename, symfs_filename);
if (err < 0) {
pr_err("Failure allocating memory for the command to run\n");
goto out_remove_tmp;
}
pr_debug("Executing: %s\n", command);
err = -1;
if (pipe(stdout_fd) < 0) {
pr_err("Failure creating the pipe to run %s\n", command);
goto out_remove_tmp;
goto out_free_command;
}
pid = fork();
......@@ -1513,7 +1521,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
* If we were using debug info should retry with
* original binary.
*/
goto out_remove_tmp;
goto out_free_command;
}
nline = 0;
......@@ -1541,6 +1549,8 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
fclose(file);
err = 0;
out_free_command:
free(command);
out_remove_tmp:
close(stdout_fd[0]);
......@@ -1554,7 +1564,7 @@ static int symbol__disassemble(struct symbol *sym, struct annotate_args *args)
out_close_stdout:
close(stdout_fd[1]);
goto out_remove_tmp;
goto out_free_command;
}
static void calc_percent(struct sym_hist *hist,
......
......@@ -81,7 +81,7 @@ static int open_cgroup(const char *name)
if (cgroupfs_find_mountpoint(mnt, PATH_MAX + 1))
return -1;
snprintf(path, PATH_MAX, "%s/%s", mnt, name);
scnprintf(path, PATH_MAX, "%s/%s", mnt, name);
fd = open(path, O_RDONLY);
if (fd == -1)
......
......@@ -232,7 +232,6 @@ int perf_quiet_option(void)
var++;
}
quiet = true;
return 0;
}
......
......@@ -32,6 +32,10 @@ void perf_env__exit(struct perf_env *env)
for (i = 0; i < env->caches_cnt; i++)
cpu_cache_level__free(&env->caches[i]);
zfree(&env->caches);
for (i = 0; i < env->nr_memory_nodes; i++)
free(env->memory_nodes[i].set);
zfree(&env->memory_nodes);
}
int perf_env__set_cmdline(struct perf_env *env, int argc, const char *argv[])
......
......@@ -3415,8 +3415,17 @@ int perf_event__synthesize_features(struct perf_tool *tool,
return ret;
}
}
/* Send HEADER_LAST_FEATURE mark. */
fe = ff.buf;
fe->feat_id = HEADER_LAST_FEATURE;
fe->header.type = PERF_RECORD_HEADER_FEATURE;
fe->header.size = sizeof(*fe);
ret = process(tool, ff.buf, NULL, NULL);
free(ff.buf);
return 0;
return ret;
}
int perf_event__process_feature(struct perf_tool *tool,
......
......@@ -433,6 +433,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
char serr[STRERR_BUFSIZE];
char *kbuild_dir = NULL, *kbuild_include_opts = NULL;
const char *template = llvm_param.clang_bpf_cmd_template;
char *command_echo, *command_out;
if (path[0] != '-' && realpath(path, abspath) == NULL) {
err = errno;
......@@ -487,6 +488,16 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
(path[0] == '-') ? path : abspath);
pr_debug("llvm compiling command template: %s\n", template);
if (asprintf(&command_echo, "echo -n \"%s\"", template) < 0)
goto errout;
err = read_from_pipe(command_echo, (void **) &command_out, NULL);
if (err)
goto errout;
pr_debug("llvm compiling command : %s\n", command_out);
err = read_from_pipe(template, &obj_buf, &obj_buf_sz);
if (err) {
pr_err("ERROR:\tunable to compile %s\n", path);
......@@ -497,6 +508,8 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
goto errout;
}
free(command_echo);
free(command_out);
free(kbuild_dir);
free(kbuild_include_opts);
......@@ -509,6 +522,7 @@ int llvm__compile_bpf(const char *path, void **p_obj_buf,
*p_obj_buf_sz = obj_buf_sz;
return 0;
errout:
free(command_echo);
free(kbuild_dir);
free(kbuild_include_opts);
free(obj_buf);
......
......@@ -50,21 +50,13 @@ static void machine__threads_init(struct machine *machine)
static int machine__set_mmap_name(struct machine *machine)
{
if (machine__is_host(machine)) {
if (symbol_conf.vmlinux_name)
machine->mmap_name = strdup(symbol_conf.vmlinux_name);
else
if (machine__is_host(machine))
machine->mmap_name = strdup("[kernel.kallsyms]");
} else if (machine__is_default_guest(machine)) {
if (symbol_conf.default_guest_vmlinux_name)
machine->mmap_name = strdup(symbol_conf.default_guest_vmlinux_name);
else
else if (machine__is_default_guest(machine))
machine->mmap_name = strdup("[guest.kernel.kallsyms]");
} else {
if (asprintf(&machine->mmap_name, "[guest.kernel.kallsyms.%d]",
else if (asprintf(&machine->mmap_name, "[guest.kernel.kallsyms.%d]",
machine->pid) < 0)
machine->mmap_name = NULL;
}
return machine->mmap_name ? 0 : -ENOMEM;
}
......@@ -794,9 +786,15 @@ static struct dso *machine__get_kernel(struct machine *machine)
struct dso *kernel;
if (machine__is_host(machine)) {
if (symbol_conf.vmlinux_name)
vmlinux_name = symbol_conf.vmlinux_name;
kernel = machine__findnew_kernel(machine, vmlinux_name,
"[kernel]", DSO_TYPE_KERNEL);
} else {
if (symbol_conf.default_guest_vmlinux_name)
vmlinux_name = symbol_conf.default_guest_vmlinux_name;
kernel = machine__findnew_kernel(machine, vmlinux_name,
"[guest.kernel]",
DSO_TYPE_GUEST_KERNEL);
......
#include <errno.h>
#include <inttypes.h>
#include <linux/bitmap.h>
#include "mem2node.h"
#include "util.h"
struct phys_entry {
struct rb_node rb_node;
u64 start;
u64 end;
u64 node;
};
static void phys_entry__insert(struct phys_entry *entry, struct rb_root *root)
{
struct rb_node **p = &root->rb_node;
struct rb_node *parent = NULL;
struct phys_entry *e;
while (*p != NULL) {
parent = *p;
e = rb_entry(parent, struct phys_entry, rb_node);
if (entry->start < e->start)
p = &(*p)->rb_left;
else
p = &(*p)->rb_right;
}
rb_link_node(&entry->rb_node, parent, p);
rb_insert_color(&entry->rb_node, root);
}
static void
phys_entry__init(struct phys_entry *entry, u64 start, u64 bsize, u64 node)
{
entry->start = start;
entry->end = start + bsize;
entry->node = node;
RB_CLEAR_NODE(&entry->rb_node);
}
int mem2node__init(struct mem2node *map, struct perf_env *env)
{
struct memory_node *n, *nodes = &env->memory_nodes[0];
struct phys_entry *entries, *tmp_entries;
u64 bsize = env->memory_bsize;
int i, j = 0, max = 0;
memset(map, 0x0, sizeof(*map));
map->root = RB_ROOT;
for (i = 0; i < env->nr_memory_nodes; i++) {
n = &nodes[i];
max += bitmap_weight(n->set, n->size);
}
entries = zalloc(sizeof(*entries) * max);
if (!entries)
return -ENOMEM;
for (i = 0; i < env->nr_memory_nodes; i++) {
u64 bit;
n = &nodes[i];
for (bit = 0; bit < n->size; bit++) {
u64 start;
if (!test_bit(bit, n->set))
continue;
start = bit * bsize;
/*
* Merge nearby areas, we walk in order
* through the bitmap, so no need to sort.
*/
if (j > 0) {
struct phys_entry *prev = &entries[j - 1];
if ((prev->end == start) &&
(prev->node == n->node)) {
prev->end += bsize;
continue;
}
}
phys_entry__init(&entries[j++], start, bsize, n->node);
}
}
/* Cut unused entries, due to merging. */
tmp_entries = realloc(entries, sizeof(*entries) * j);
if (tmp_entries)
entries = tmp_entries;
for (i = 0; i < j; i++) {
pr_debug("mem2node %03" PRIu64 " [0x%016" PRIx64 "-0x%016" PRIx64 "]\n",
entries[i].node, entries[i].start, entries[i].end);
phys_entry__insert(&entries[i], &map->root);
}
map->entries = entries;
return 0;
}
void mem2node__exit(struct mem2node *map)
{
zfree(&map->entries);
}
int mem2node__node(struct mem2node *map, u64 addr)
{
struct rb_node **p, *parent = NULL;
struct phys_entry *entry;
p = &map->root.rb_node;
while (*p != NULL) {
parent = *p;
entry = rb_entry(parent, struct phys_entry, rb_node);
if (addr < entry->start)
p = &(*p)->rb_left;
else if (addr >= entry->end)
p = &(*p)->rb_right;
else
goto out;
}
entry = NULL;
out:
return entry ? (int) entry->node : -1;
}
#ifndef __MEM2NODE_H
#define __MEM2NODE_H
#include <linux/rbtree.h>
#include "env.h"
struct phys_entry;
struct mem2node {
struct rb_root root;
struct phys_entry *entries;
int cnt;
};
int mem2node__init(struct mem2node *map, struct perf_env *env);
void mem2node__exit(struct mem2node *map);
int mem2node__node(struct mem2node *map, u64 addr);
#endif /* __MEM2NODE_H */
......@@ -199,19 +199,18 @@ int perf_mmap__mmap(struct perf_mmap *map, struct mmap_params *mp, int fd)
return 0;
}
static int overwrite_rb_find_range(void *buf, int mask, u64 head, u64 *start, u64 *end)
static int overwrite_rb_find_range(void *buf, int mask, u64 *start, u64 *end)
{
struct perf_event_header *pheader;
u64 evt_head = head;
u64 evt_head = *start;
int size = mask + 1;
pr_debug2("overwrite_rb_find_range: buf=%p, head=%"PRIx64"\n", buf, head);
pheader = (struct perf_event_header *)(buf + (head & mask));
*start = head;
pr_debug2("%s: buf=%p, start=%"PRIx64"\n", __func__, buf, *start);
pheader = (struct perf_event_header *)(buf + (*start & mask));
while (true) {
if (evt_head - head >= (unsigned int)size) {
if (evt_head - *start >= (unsigned int)size) {
pr_debug("Finished reading overwrite ring buffer: rewind\n");
if (evt_head - head > (unsigned int)size)
if (evt_head - *start > (unsigned int)size)
evt_head -= pheader->size;
*end = evt_head;
return 0;
......@@ -262,7 +261,7 @@ int perf_mmap__read_init(struct perf_mmap *md)
* Backward ring buffer is full. We still have a chance to read
* most of data from it.
*/
if (overwrite_rb_find_range(data, md->mask, head, &md->start, &md->end))
if (overwrite_rb_find_range(data, md->mask, &md->start, &md->end))
return -EINVAL;
}
......
......@@ -206,7 +206,7 @@ struct tracepoint_path *tracepoint_id_to_path(u64 config)
for_each_event(sys_dirent, evt_dir, evt_dirent) {
snprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path,
scnprintf(evt_path, MAXPATHLEN, "%s/%s/id", dir_path,
evt_dirent->d_name);
fd = open(evt_path, O_RDONLY);
if (fd < 0)
......
......@@ -351,7 +351,7 @@ static int pmu_aliases_parse(char *dir, struct list_head *head)
if (pmu_alias_info_file(name))
continue;
snprintf(path, PATH_MAX, "%s/%s", dir, name);
scnprintf(path, PATH_MAX, "%s/%s", dir, name);
file = fopen(path, "r");
if (!file) {
......
......@@ -423,20 +423,20 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
pr_warning("Failed to get the type of %s.\n", varname);
return -ENOENT;
}
pr_debug2("Var real type: (%x)\n", (unsigned)dwarf_dieoffset(&type));
pr_debug2("Var real type: %s (%x)\n", dwarf_diename(&type),
(unsigned)dwarf_dieoffset(&type));
tag = dwarf_tag(&type);
if (field->name[0] == '[' &&
(tag == DW_TAG_array_type || tag == DW_TAG_pointer_type)) {
if (field->next)
/* Save original type for next field */
/* Save original type for next field or type */
memcpy(die_mem, &type, sizeof(*die_mem));
/* Get the type of this array */
if (die_get_real_type(&type, &type) == NULL) {
pr_warning("Failed to get the type of %s.\n", varname);
return -ENOENT;
}
pr_debug2("Array real type: (%x)\n",
pr_debug2("Array real type: %s (%x)\n", dwarf_diename(&type),
(unsigned)dwarf_dieoffset(&type));
if (tag == DW_TAG_pointer_type) {
ref = zalloc(sizeof(struct probe_trace_arg_ref));
......@@ -448,9 +448,6 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
*ref_ptr = ref;
}
ref->offset += dwarf_bytesize(&type) * field->index;
if (!field->next)
/* Save vr_die for converting types */
memcpy(die_mem, vr_die, sizeof(*die_mem));
goto next;
} else if (tag == DW_TAG_pointer_type) {
/* Check the pointer and dereference */
......
......@@ -28,6 +28,8 @@ class install_lib(_install_lib):
cflags = getenv('CFLAGS', '').split()
# switch off several checks (need to be at the end of cflags list)
cflags += ['-fno-strict-aliasing', '-Wno-write-strings', '-Wno-unused-parameter' ]
if cc != "clang":
cflags += ['-Wno-cast-function-type' ]
src_perf = getenv('srctree') + '/tools/perf'
build_lib = getenv('PYTHON_EXTBUILD_LIB')
......
......@@ -92,7 +92,7 @@ static const char *id_str[PERF_STAT_EVSEL_ID__MAX] = {
};
#undef ID
void perf_stat_evsel_id_init(struct perf_evsel *evsel)
static void perf_stat_evsel_id_init(struct perf_evsel *evsel)
{
struct perf_stat_evsel *ps = evsel->stats;
int i;
......
......@@ -128,8 +128,6 @@ bool __perf_evsel_stat__is(struct perf_evsel *evsel,
#define perf_stat_evsel__is(evsel, id) \
__perf_evsel_stat__is(evsel, PERF_STAT_EVSEL_ID__ ## id)
void perf_stat_evsel_id_init(struct perf_evsel *evsel);
extern struct runtime_stat rt_stat;
extern struct stats walltime_nsecs_stats;
......
......@@ -50,7 +50,7 @@ static int __report_module(struct addr_location *al, u64 ip,
if (!mod)
mod = dwfl_report_elf(ui->dwfl, dso->short_name,
dso->long_name, -1, al->map->start,
(dso->symsrc_filename ? dso->symsrc_filename : dso->long_name), -1, al->map->start,
false);
return mod && dwfl_addrmodule(ui->dwfl, ip) == mod ? 0 : -1;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment