Merge branch 'perf/urgent' into perf/core, to pick up fixes

Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
Ingo Molnar
2017-10-20 11:02:05 +02:00
779 changed files with 8073 additions and 4625 deletions

View File

@@ -685,6 +685,8 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
{
struct symbol *sym = node->sym;
u64 left, right;
struct dso *left_dso = NULL;
struct dso *right_dso = NULL;
if (callchain_param.key == CCKEY_SRCLINE) {
enum match_result match = match_chain_srcline(node, cnode);
@@ -696,12 +698,14 @@ static enum match_result match_chain(struct callchain_cursor_node *node,
if (cnode->ms.sym && sym && callchain_param.key == CCKEY_FUNCTION) {
left = cnode->ms.sym->start;
right = sym->start;
left_dso = cnode->ms.map->dso;
right_dso = node->map->dso;
} else {
left = cnode->ip;
right = node->ip;
}
if (left == right) {
if (left == right && left_dso == right_dso) {
if (node->branch) {
cnode->branch_count++;

View File

@@ -310,10 +310,11 @@ static char *get_config_name(struct list_head *head_terms)
static struct perf_evsel *
__add_event(struct list_head *list, int *idx,
struct perf_event_attr *attr,
char *name, struct cpu_map *cpus,
char *name, struct perf_pmu *pmu,
struct list_head *config_terms, bool auto_merge_stats)
{
struct perf_evsel *evsel;
struct cpu_map *cpus = pmu ? pmu->cpus : NULL;
event_attr_init(attr);
@@ -324,7 +325,7 @@ __add_event(struct list_head *list, int *idx,
(*idx)++;
evsel->cpus = cpu_map__get(cpus);
evsel->own_cpus = cpu_map__get(cpus);
evsel->system_wide = !!cpus;
evsel->system_wide = pmu ? pmu->is_uncore : false;
evsel->auto_merge_stats = auto_merge_stats;
if (name)
@@ -1240,7 +1241,7 @@ static int __parse_events_add_pmu(struct parse_events_state *parse_state,
if (!head_config) {
attr.type = pmu->type;
evsel = __add_event(list, &parse_state->idx, &attr, NULL, pmu->cpus, NULL, auto_merge_stats);
evsel = __add_event(list, &parse_state->idx, &attr, NULL, pmu, NULL, auto_merge_stats);
return evsel ? 0 : -ENOMEM;
}
@@ -1261,7 +1262,7 @@ static int __parse_events_add_pmu(struct parse_events_state *parse_state,
return -EINVAL;
evsel = __add_event(list, &parse_state->idx, &attr,
get_config_name(head_config), pmu->cpus,
get_config_name(head_config), pmu,
&config_terms, auto_merge_stats);
if (evsel) {
evsel->unit = info.unit;

View File

@@ -8,6 +8,9 @@
%{
#include <errno.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include "../perf.h"
#include "parse-events.h"
#include "parse-events-bison.h"
@@ -53,9 +56,8 @@ static int str(yyscan_t scanner, int token)
return token;
}
static bool isbpf(yyscan_t scanner)
static bool isbpf_suffix(char *text)
{
char *text = parse_events_get_text(scanner);
int len = strlen(text);
if (len < 2)
@@ -68,6 +70,17 @@ static bool isbpf(yyscan_t scanner)
return false;
}
static bool isbpf(yyscan_t scanner)
{
char *text = parse_events_get_text(scanner);
struct stat st;
if (!isbpf_suffix(text))
return false;
return stat(text, &st) == 0;
}
/*
* This function is called when the parser gets two kind of input:
*

View File

@@ -471,31 +471,10 @@ static void pmu_read_sysfs(void)
closedir(dir);
}
static struct cpu_map *pmu_cpumask(const char *name)
static struct cpu_map *__pmu_cpumask(const char *path)
{
struct stat st;
char path[PATH_MAX];
FILE *file;
struct cpu_map *cpus;
const char *sysfs = sysfs__mountpoint();
const char *templates[] = {
"%s/bus/event_source/devices/%s/cpumask",
"%s/bus/event_source/devices/%s/cpus",
NULL
};
const char **template;
if (!sysfs)
return NULL;
for (template = templates; *template; template++) {
snprintf(path, PATH_MAX, *template, sysfs, name);
if (stat(path, &st) == 0)
break;
}
if (!*template)
return NULL;
file = fopen(path, "r");
if (!file)
@@ -506,6 +485,51 @@ static struct cpu_map *pmu_cpumask(const char *name)
return cpus;
}
/*
* Uncore PMUs have a "cpumask" file under sysfs. CPU PMUs (e.g. on arm/arm64)
* may have a "cpus" file.
*/
#define CPUS_TEMPLATE_UNCORE "%s/bus/event_source/devices/%s/cpumask"
#define CPUS_TEMPLATE_CPU "%s/bus/event_source/devices/%s/cpus"
static struct cpu_map *pmu_cpumask(const char *name)
{
char path[PATH_MAX];
struct cpu_map *cpus;
const char *sysfs = sysfs__mountpoint();
const char *templates[] = {
CPUS_TEMPLATE_UNCORE,
CPUS_TEMPLATE_CPU,
NULL
};
const char **template;
if (!sysfs)
return NULL;
for (template = templates; *template; template++) {
snprintf(path, PATH_MAX, *template, sysfs, name);
cpus = __pmu_cpumask(path);
if (cpus)
return cpus;
}
return NULL;
}
static bool pmu_is_uncore(const char *name)
{
char path[PATH_MAX];
struct cpu_map *cpus;
const char *sysfs = sysfs__mountpoint();
snprintf(path, PATH_MAX, CPUS_TEMPLATE_UNCORE, sysfs, name);
cpus = __pmu_cpumask(path);
cpu_map__put(cpus);
return !!cpus;
}
/*
* Return the CPU id as a raw string.
*
@@ -638,6 +662,8 @@ static struct perf_pmu *pmu_lookup(const char *name)
pmu->cpus = pmu_cpumask(name);
pmu->is_uncore = pmu_is_uncore(name);
INIT_LIST_HEAD(&pmu->format);
INIT_LIST_HEAD(&pmu->aliases);
list_splice(&format, &pmu->format);

View File

@@ -22,6 +22,7 @@ struct perf_pmu {
char *name;
__u32 type;
bool selectable;
bool is_uncore;
struct perf_event_attr *default_config;
struct cpu_map *cpus;
struct list_head format; /* HEAD struct perf_pmu_format -> list */

View File

@@ -374,6 +374,8 @@ void perf_tool__fill_defaults(struct perf_tool *tool)
tool->mmap2 = process_event_stub;
if (tool->comm == NULL)
tool->comm = process_event_stub;
if (tool->namespaces == NULL)
tool->namespaces = process_event_stub;
if (tool->fork == NULL)
tool->fork = process_event_stub;
if (tool->exit == NULL)

View File

@@ -23,12 +23,12 @@ static inline void *xyarray__entry(struct xyarray *xy, int x, int y)
static inline int xyarray__max_y(struct xyarray *xy)
{
return xy->max_x;
return xy->max_y;
}
static inline int xyarray__max_x(struct xyarray *xy)
{
return xy->max_y;
return xy->max_x;
}
#endif /* _PERF_XYARRAY_H_ */