Skip to content

Commit

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

Pull perf tooling changes from Arnaldo Carvalho de Melo:

New features:

 - Port 'perf kvm stat' to PowerPC (Hemant Kumar)

Infrastructure changes:

 - Use the 'feature-dump' target to do the feature checks just once and then
   add code to reuse that in the tests/make makefile, speeding up the
   'make -C tools/perf build-test' target (Wang Nan)

 - Reduce the number of tests the 'build-test' target do to those that don't
   pollute the source tree (Arnaldo Carvalho de Melo)

 - Improve the output of the build tests a bit by aligning the name of the
   tests, more can be done to filter out uninteresting info in the output
   (Arnaldo Carvalho de Melo)

 - Add perf_evlist pointer to *info_priv_size(), more prep work for
   supporting the coresight architecture (Mathieu Poirier)

 - Improve the 'perf test bp_signal' test (Wang Nan)

 - Check environment before starting the BPF 'perf test', so that we can just
   'Skip' older kernels instead of 'FAIL'ing them (Wang Nan)

 - Fix cpumode of synthesized buildid event (Wang Nan)

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
  • Loading branch information
Ingo Molnar committed Feb 3, 2016
2 parents 402e8db + 814568d commit d072b89
Show file tree
Hide file tree
Showing 25 changed files with 688 additions and 122 deletions.
8 changes: 8 additions & 0 deletions tools/build/Makefile.feature
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@ ifeq ($(feature-all), 1)
# test-all.c passed - just set all the core feature flags to 1:
#
$(foreach feat,$(FEATURE_TESTS),$(call feature_set,$(feat)))
#
# test-all.c does not comprise these tests, so we need to
# for this case to get features proper values
#
$(call feature_check,compile-32)
$(call feature_check,compile-x32)
$(call feature_check,bionic)
$(call feature_check,libbabeltrace)
else
$(foreach feat,$(FEATURE_TESTS),$(call feature_check,$(feat)))
endif
Expand Down
2 changes: 2 additions & 0 deletions tools/build/feature/test-compile.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#include <stdio.h>
int main(void)
{
printf("Hello World!\n");
return 0;
}
11 changes: 9 additions & 2 deletions tools/perf/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,17 @@ clean:
$(make)

#
# The build-test target is not really parallel, don't print the jobs info:
# The build-test target is not really parallel, don't print the jobs info,
# it also uses only the tests/make targets that don't pollute the source
# repository, i.e. that uses O= or builds the tarpkg outside the source
# repo directories.
#
# For a full test, use:
#
# make -C tools/perf -f tests/make
#
build-test:
@$(MAKE) SHUF=1 -f tests/make --no-print-directory
@$(MAKE) SHUF=1 -f tests/make REUSE_FEATURES_DUMP=1 MK=Makefile --no-print-directory tarpkg out

#
# All other targets get passed through:
Expand Down
2 changes: 2 additions & 0 deletions tools/perf/arch/powerpc/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
ifndef NO_DWARF
PERF_HAVE_DWARF_REGS := 1
endif

HAVE_KVM_STAT_SUPPORT := 1
1 change: 1 addition & 0 deletions tools/perf/arch/powerpc/util/Build
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
libperf-y += header.o
libperf-y += sym-handling.o
libperf-y += kvm-stat.o

libperf-$(CONFIG_DWARF) += dwarf-regs.o
libperf-$(CONFIG_DWARF) += skip-callchain-idx.o
123 changes: 123 additions & 0 deletions tools/perf/arch/powerpc/util/book3s_hcalls.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#ifndef ARCH_PERF_BOOK3S_HV_HCALLS_H
#define ARCH_PERF_BOOK3S_HV_HCALLS_H

/*
* PowerPC HCALL codes : hcall code to name mapping
*/
#define kvm_trace_symbol_hcall \
{0x4, "H_REMOVE"}, \
{0x8, "H_ENTER"}, \
{0xc, "H_READ"}, \
{0x10, "H_CLEAR_MOD"}, \
{0x14, "H_CLEAR_REF"}, \
{0x18, "H_PROTECT"}, \
{0x1c, "H_GET_TCE"}, \
{0x20, "H_PUT_TCE"}, \
{0x24, "H_SET_SPRG0"}, \
{0x28, "H_SET_DABR"}, \
{0x2c, "H_PAGE_INIT"}, \
{0x30, "H_SET_ASR"}, \
{0x34, "H_ASR_ON"}, \
{0x38, "H_ASR_OFF"}, \
{0x3c, "H_LOGICAL_CI_LOAD"}, \
{0x40, "H_LOGICAL_CI_STORE"}, \
{0x44, "H_LOGICAL_CACHE_LOAD"}, \
{0x48, "H_LOGICAL_CACHE_STORE"}, \
{0x4c, "H_LOGICAL_ICBI"}, \
{0x50, "H_LOGICAL_DCBF"}, \
{0x54, "H_GET_TERM_CHAR"}, \
{0x58, "H_PUT_TERM_CHAR"}, \
{0x5c, "H_REAL_TO_LOGICAL"}, \
{0x60, "H_HYPERVISOR_DATA"}, \
{0x64, "H_EOI"}, \
{0x68, "H_CPPR"}, \
{0x6c, "H_IPI"}, \
{0x70, "H_IPOLL"}, \
{0x74, "H_XIRR"}, \
{0x78, "H_MIGRATE_DMA"}, \
{0x7c, "H_PERFMON"}, \
{0xdc, "H_REGISTER_VPA"}, \
{0xe0, "H_CEDE"}, \
{0xe4, "H_CONFER"}, \
{0xe8, "H_PROD"}, \
{0xec, "H_GET_PPP"}, \
{0xf0, "H_SET_PPP"}, \
{0xf4, "H_PURR"}, \
{0xf8, "H_PIC"}, \
{0xfc, "H_REG_CRQ"}, \
{0x100, "H_FREE_CRQ"}, \
{0x104, "H_VIO_SIGNAL"}, \
{0x108, "H_SEND_CRQ"}, \
{0x110, "H_COPY_RDMA"}, \
{0x114, "H_REGISTER_LOGICAL_LAN"}, \
{0x118, "H_FREE_LOGICAL_LAN"}, \
{0x11c, "H_ADD_LOGICAL_LAN_BUFFER"}, \
{0x120, "H_SEND_LOGICAL_LAN"}, \
{0x124, "H_BULK_REMOVE"}, \
{0x130, "H_MULTICAST_CTRL"}, \
{0x134, "H_SET_XDABR"}, \
{0x138, "H_STUFF_TCE"}, \
{0x13c, "H_PUT_TCE_INDIRECT"}, \
{0x14c, "H_CHANGE_LOGICAL_LAN_MAC"}, \
{0x150, "H_VTERM_PARTNER_INFO"}, \
{0x154, "H_REGISTER_VTERM"}, \
{0x158, "H_FREE_VTERM"}, \
{0x15c, "H_RESET_EVENTS"}, \
{0x160, "H_ALLOC_RESOURCE"}, \
{0x164, "H_FREE_RESOURCE"}, \
{0x168, "H_MODIFY_QP"}, \
{0x16c, "H_QUERY_QP"}, \
{0x170, "H_REREGISTER_PMR"}, \
{0x174, "H_REGISTER_SMR"}, \
{0x178, "H_QUERY_MR"}, \
{0x17c, "H_QUERY_MW"}, \
{0x180, "H_QUERY_HCA"}, \
{0x184, "H_QUERY_PORT"}, \
{0x188, "H_MODIFY_PORT"}, \
{0x18c, "H_DEFINE_AQP1"}, \
{0x190, "H_GET_TRACE_BUFFER"}, \
{0x194, "H_DEFINE_AQP0"}, \
{0x198, "H_RESIZE_MR"}, \
{0x19c, "H_ATTACH_MCQP"}, \
{0x1a0, "H_DETACH_MCQP"}, \
{0x1a4, "H_CREATE_RPT"}, \
{0x1a8, "H_REMOVE_RPT"}, \
{0x1ac, "H_REGISTER_RPAGES"}, \
{0x1b0, "H_DISABLE_AND_GETC"}, \
{0x1b4, "H_ERROR_DATA"}, \
{0x1b8, "H_GET_HCA_INFO"}, \
{0x1bc, "H_GET_PERF_COUNT"}, \
{0x1c0, "H_MANAGE_TRACE"}, \
{0x1d4, "H_FREE_LOGICAL_LAN_BUFFER"}, \
{0x1d8, "H_POLL_PENDING"}, \
{0x1e4, "H_QUERY_INT_STATE"}, \
{0x244, "H_ILLAN_ATTRIBUTES"}, \
{0x250, "H_MODIFY_HEA_QP"}, \
{0x254, "H_QUERY_HEA_QP"}, \
{0x258, "H_QUERY_HEA"}, \
{0x25c, "H_QUERY_HEA_PORT"}, \
{0x260, "H_MODIFY_HEA_PORT"}, \
{0x264, "H_REG_BCMC"}, \
{0x268, "H_DEREG_BCMC"}, \
{0x26c, "H_REGISTER_HEA_RPAGES"}, \
{0x270, "H_DISABLE_AND_GET_HEA"}, \
{0x274, "H_GET_HEA_INFO"}, \
{0x278, "H_ALLOC_HEA_RESOURCE"}, \
{0x284, "H_ADD_CONN"}, \
{0x288, "H_DEL_CONN"}, \
{0x298, "H_JOIN"}, \
{0x2a4, "H_VASI_STATE"}, \
{0x2b0, "H_ENABLE_CRQ"}, \
{0x2b8, "H_GET_EM_PARMS"}, \
{0x2d0, "H_SET_MPP"}, \
{0x2d4, "H_GET_MPP"}, \
{0x2ec, "H_HOME_NODE_ASSOCIATIVITY"}, \
{0x2f4, "H_BEST_ENERGY"}, \
{0x2fc, "H_XIRR_X"}, \
{0x300, "H_RANDOM"}, \
{0x304, "H_COP"}, \
{0x314, "H_GET_MPP_X"}, \
{0x31c, "H_SET_MODE"}, \
{0xf000, "H_RTAS"} \

#endif
33 changes: 33 additions & 0 deletions tools/perf/arch/powerpc/util/book3s_hv_exits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef ARCH_PERF_BOOK3S_HV_EXITS_H
#define ARCH_PERF_BOOK3S_HV_EXITS_H

/*
* PowerPC Interrupt vectors : exit code to name mapping
*/

#define kvm_trace_symbol_exit \
{0x0, "RETURN_TO_HOST"}, \
{0x100, "SYSTEM_RESET"}, \
{0x200, "MACHINE_CHECK"}, \
{0x300, "DATA_STORAGE"}, \
{0x380, "DATA_SEGMENT"}, \
{0x400, "INST_STORAGE"}, \
{0x480, "INST_SEGMENT"}, \
{0x500, "EXTERNAL"}, \
{0x501, "EXTERNAL_LEVEL"}, \
{0x502, "EXTERNAL_HV"}, \
{0x600, "ALIGNMENT"}, \
{0x700, "PROGRAM"}, \
{0x800, "FP_UNAVAIL"}, \
{0x900, "DECREMENTER"}, \
{0x980, "HV_DECREMENTER"}, \
{0xc00, "SYSCALL"}, \
{0xd00, "TRACE"}, \
{0xe00, "H_DATA_STORAGE"}, \
{0xe20, "H_INST_STORAGE"}, \
{0xe40, "H_EMUL_ASSIST"}, \
{0xf00, "PERFMON"}, \
{0xf20, "ALTIVEC"}, \
{0xf40, "VSX"}

#endif
170 changes: 170 additions & 0 deletions tools/perf/arch/powerpc/util/kvm-stat.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
#include "util/kvm-stat.h"
#include "util/parse-events.h"
#include "util/debug.h"

#include "book3s_hv_exits.h"
#include "book3s_hcalls.h"

#define NR_TPS 4

const char *vcpu_id_str = "vcpu_id";
const int decode_str_len = 40;
const char *kvm_entry_trace = "kvm_hv:kvm_guest_enter";
const char *kvm_exit_trace = "kvm_hv:kvm_guest_exit";

define_exit_reasons_table(hv_exit_reasons, kvm_trace_symbol_exit);
define_exit_reasons_table(hcall_reasons, kvm_trace_symbol_hcall);

/* Tracepoints specific to ppc_book3s_hv */
const char *ppc_book3s_hv_kvm_tp[] = {
"kvm_hv:kvm_guest_enter",
"kvm_hv:kvm_guest_exit",
"kvm_hv:kvm_hcall_enter",
"kvm_hv:kvm_hcall_exit",
NULL,
};

/* 1 extra placeholder for NULL */
const char *kvm_events_tp[NR_TPS + 1];
const char *kvm_exit_reason;

static void hcall_event_get_key(struct perf_evsel *evsel,
struct perf_sample *sample,
struct event_key *key)
{
key->info = 0;
key->key = perf_evsel__intval(evsel, sample, "req");
}

static const char *get_hcall_exit_reason(u64 exit_code)
{
struct exit_reasons_table *tbl = hcall_reasons;

while (tbl->reason != NULL) {
if (tbl->exit_code == exit_code)
return tbl->reason;
tbl++;
}

pr_debug("Unknown hcall code: %lld\n",
(unsigned long long)exit_code);
return "UNKNOWN";
}

static bool hcall_event_end(struct perf_evsel *evsel,
struct perf_sample *sample __maybe_unused,
struct event_key *key __maybe_unused)
{
return (!strcmp(evsel->name, kvm_events_tp[3]));
}

static bool hcall_event_begin(struct perf_evsel *evsel,
struct perf_sample *sample, struct event_key *key)
{
if (!strcmp(evsel->name, kvm_events_tp[2])) {
hcall_event_get_key(evsel, sample, key);
return true;
}

return false;
}
static void hcall_event_decode_key(struct perf_kvm_stat *kvm __maybe_unused,
struct event_key *key,
char *decode)
{
const char *hcall_reason = get_hcall_exit_reason(key->key);

scnprintf(decode, decode_str_len, "%s", hcall_reason);
}

static struct kvm_events_ops hcall_events = {
.is_begin_event = hcall_event_begin,
.is_end_event = hcall_event_end,
.decode_key = hcall_event_decode_key,
.name = "HCALL-EVENT",
};

static struct kvm_events_ops exit_events = {
.is_begin_event = exit_event_begin,
.is_end_event = exit_event_end,
.decode_key = exit_event_decode_key,
.name = "VM-EXIT"
};

struct kvm_reg_events_ops kvm_reg_events_ops[] = {
{ .name = "vmexit", .ops = &exit_events },
{ .name = "hcall", .ops = &hcall_events },
{ NULL, NULL },
};

const char * const kvm_skip_events[] = {
NULL,
};


static int is_tracepoint_available(const char *str, struct perf_evlist *evlist)
{
struct parse_events_error err;
int ret;

err.str = NULL;
ret = parse_events(evlist, str, &err);
if (err.str)
pr_err("%s : %s\n", str, err.str);
return ret;
}

static int ppc__setup_book3s_hv(struct perf_kvm_stat *kvm,
struct perf_evlist *evlist)
{
const char **events_ptr;
int i, nr_tp = 0, err = -1;

/* Check for book3s_hv tracepoints */
for (events_ptr = ppc_book3s_hv_kvm_tp; *events_ptr; events_ptr++) {
err = is_tracepoint_available(*events_ptr, evlist);
if (err)
return -1;
nr_tp++;
}

for (i = 0; i < nr_tp; i++)
kvm_events_tp[i] = ppc_book3s_hv_kvm_tp[i];

kvm_events_tp[i] = NULL;
kvm_exit_reason = "trap";
kvm->exit_reasons = hv_exit_reasons;
kvm->exit_reasons_isa = "HV";

return 0;
}

/* Wrapper to setup kvm tracepoints */
static int ppc__setup_kvm_tp(struct perf_kvm_stat *kvm)
{
struct perf_evlist *evlist = perf_evlist__new();

if (evlist == NULL)
return -ENOMEM;

/* Right now, only supported on book3s_hv */
return ppc__setup_book3s_hv(kvm, evlist);
}

int setup_kvm_events_tp(struct perf_kvm_stat *kvm)
{
return ppc__setup_kvm_tp(kvm);
}

int cpu_isa_init(struct perf_kvm_stat *kvm, const char *cpuid __maybe_unused)
{
int ret;

ret = ppc__setup_kvm_tp(kvm);
if (ret) {
kvm->exit_reasons = NULL;
kvm->exit_reasons_isa = NULL;
}

return ret;
}
Loading

0 comments on commit d072b89

Please sign in to comment.