You've already forked linux-apfs
mirror of
https://github.com/linux-apfs/linux-apfs.git
synced 2026-05-01 15:00:59 -07:00
perf tools: Add coresight etm PMU record capabilities
Coresight ETMs are IP blocks used to perform HW assisted tracing on a CPU core. This patch introduce the required auxiliary API functions allowing the perf core to interact with a tracer. Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Jiri Olsa <jolsa@kernel.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: linux-arm-kernel@lists.infradead.org Link: http://lkml.kernel.org/r/1474041004-13956-4-git-send-email-mathieu.poirier@linaro.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
committed by
Arnaldo Carvalho de Melo
parent
7e21b0d579
commit
a818c563ae
@@ -1124,6 +1124,10 @@ F: Documentation/trace/coresight.txt
|
||||
F: Documentation/devicetree/bindings/arm/coresight.txt
|
||||
F: Documentation/ABI/testing/sysfs-bus-coresight-devices-*
|
||||
F: tools/perf/arch/arm/util/pmu.c
|
||||
F: tools/perf/arch/arm/util/auxtrace.c
|
||||
F: tools/perf/arch/arm/util/cs-etm.c
|
||||
F: tools/perf/arch/arm/util/cs-etm.h
|
||||
F: tools/perf/util/cs-etm.h
|
||||
|
||||
ARM/CORGI MACHINE SUPPORT
|
||||
M: Richard Purdie <rpurdie@rpsys.net>
|
||||
|
||||
@@ -3,4 +3,4 @@ libperf-$(CONFIG_DWARF) += dwarf-regs.o
|
||||
libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
|
||||
libperf-$(CONFIG_LIBDW_DWARF_UNWIND) += unwind-libdw.o
|
||||
|
||||
libperf-$(CONFIG_AUXTRACE) += pmu.o
|
||||
libperf-$(CONFIG_AUXTRACE) += pmu.o auxtrace.o cs-etm.o
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright(C) 2015 Linaro Limited. All rights reserved.
|
||||
* Author: Mathieu Poirier <mathieu.poirier@linaro.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <linux/coresight-pmu.h>
|
||||
|
||||
#include "../../util/auxtrace.h"
|
||||
#include "../../util/evlist.h"
|
||||
#include "../../util/pmu.h"
|
||||
#include "cs-etm.h"
|
||||
|
||||
struct auxtrace_record
|
||||
*auxtrace_record__init(struct perf_evlist *evlist, int *err)
|
||||
{
|
||||
struct perf_pmu *cs_etm_pmu;
|
||||
struct perf_evsel *evsel;
|
||||
bool found_etm = false;
|
||||
|
||||
cs_etm_pmu = perf_pmu__find(CORESIGHT_ETM_PMU_NAME);
|
||||
|
||||
if (evlist) {
|
||||
evlist__for_each_entry(evlist, evsel) {
|
||||
if (cs_etm_pmu &&
|
||||
evsel->attr.type == cs_etm_pmu->type)
|
||||
found_etm = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (found_etm)
|
||||
return cs_etm_record_init(err);
|
||||
|
||||
/*
|
||||
* Clear 'err' even if we haven't found a cs_etm event - that way perf
|
||||
* record can still be used even if tracers aren't present. The NULL
|
||||
* return value will take care of telling the infrastructure HW tracing
|
||||
* isn't available.
|
||||
*/
|
||||
*err = 0;
|
||||
return NULL;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright(C) 2015 Linaro Limited. All rights reserved.
|
||||
* Author: Mathieu Poirier <mathieu.poirier@linaro.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE__PERF_CS_ETM_H__
|
||||
#define INCLUDE__PERF_CS_ETM_H__
|
||||
|
||||
struct auxtrace_record *cs_etm_record_init(int *err);
|
||||
|
||||
#endif
|
||||
@@ -1,4 +1,6 @@
|
||||
libperf-$(CONFIG_DWARF) += dwarf-regs.o
|
||||
libperf-$(CONFIG_LOCAL_LIBUNWIND) += unwind-libunwind.o
|
||||
|
||||
libperf-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o
|
||||
libperf-$(CONFIG_AUXTRACE) += ../../arm/util/pmu.o \
|
||||
../../arm/util/auxtrace.o \
|
||||
../../arm/util/cs-etm.o
|
||||
|
||||
@@ -892,6 +892,7 @@ int perf_event__process_auxtrace_info(struct perf_tool *tool __maybe_unused,
|
||||
return intel_pt_process_auxtrace_info(event, session);
|
||||
case PERF_AUXTRACE_INTEL_BTS:
|
||||
return intel_bts_process_auxtrace_info(event, session);
|
||||
case PERF_AUXTRACE_CS_ETM:
|
||||
case PERF_AUXTRACE_UNKNOWN:
|
||||
default:
|
||||
return -EINVAL;
|
||||
|
||||
@@ -41,6 +41,7 @@ enum auxtrace_type {
|
||||
PERF_AUXTRACE_UNKNOWN,
|
||||
PERF_AUXTRACE_INTEL_PT,
|
||||
PERF_AUXTRACE_INTEL_BTS,
|
||||
PERF_AUXTRACE_CS_ETM,
|
||||
};
|
||||
|
||||
enum itrace_period_type {
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright(C) 2015 Linaro Limited. All rights reserved.
|
||||
* Author: Mathieu Poirier <mathieu.poirier@linaro.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 as published by
|
||||
* the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
||||
* more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef INCLUDE__UTIL_PERF_CS_ETM_H__
|
||||
#define INCLUDE__UTIL_PERF_CS_ETM_H__
|
||||
|
||||
/* Versionning header in case things need tro change in the future. That way
|
||||
* decoding of old snapshot is still possible.
|
||||
*/
|
||||
enum {
|
||||
/* Starting with 0x0 */
|
||||
CS_HEADER_VERSION_0,
|
||||
/* PMU->type (32 bit), total # of CPUs (32 bit) */
|
||||
CS_PMU_TYPE_CPUS,
|
||||
CS_ETM_SNAPSHOT,
|
||||
CS_HEADER_VERSION_0_MAX,
|
||||
};
|
||||
|
||||
/* Beginning of header common to both ETMv3 and V4 */
|
||||
enum {
|
||||
CS_ETM_MAGIC,
|
||||
CS_ETM_CPU,
|
||||
};
|
||||
|
||||
/* ETMv3/PTM metadata */
|
||||
enum {
|
||||
/* Dynamic, configurable parameters */
|
||||
CS_ETM_ETMCR = CS_ETM_CPU + 1,
|
||||
CS_ETM_ETMTRACEIDR,
|
||||
/* RO, taken from sysFS */
|
||||
CS_ETM_ETMCCER,
|
||||
CS_ETM_ETMIDR,
|
||||
CS_ETM_PRIV_MAX,
|
||||
};
|
||||
|
||||
/* ETMv4 metadata */
|
||||
enum {
|
||||
/* Dynamic, configurable parameters */
|
||||
CS_ETMV4_TRCCONFIGR = CS_ETM_CPU + 1,
|
||||
CS_ETMV4_TRCTRACEIDR,
|
||||
/* RO, taken from sysFS */
|
||||
CS_ETMV4_TRCIDR0,
|
||||
CS_ETMV4_TRCIDR1,
|
||||
CS_ETMV4_TRCIDR2,
|
||||
CS_ETMV4_TRCIDR8,
|
||||
CS_ETMV4_TRCAUTHSTATUS,
|
||||
CS_ETMV4_PRIV_MAX,
|
||||
};
|
||||
|
||||
#define KiB(x) ((x) * 1024)
|
||||
#define MiB(x) ((x) * 1024 * 1024)
|
||||
|
||||
#define CS_ETM_HEADER_SIZE (CS_HEADER_VERSION_0_MAX * sizeof(u64))
|
||||
|
||||
static const u64 __perf_cs_etmv3_magic = 0x3030303030303030ULL;
|
||||
static const u64 __perf_cs_etmv4_magic = 0x4040404040404040ULL;
|
||||
#define CS_ETMV3_PRIV_SIZE (CS_ETM_PRIV_MAX * sizeof(u64))
|
||||
#define CS_ETMV4_PRIV_SIZE (CS_ETMV4_PRIV_MAX * sizeof(u64))
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user