Merge tag 'perf-urgent-for-mingo-4.18-20180625' of git://git.kernel.org/pub/scm/linux/kernel/git/acme/linux into perf/urgent
Pull perf/urgent fixes from Arnaldo Carvalho de Melo: perf bench: (Jiri Olsa): - Fix NUMA report output code handling of less than 1s runtimes. perf script: (Ravi Bangoria) - Add missing output fields in a 'perf script -h' hint. - Fix crash because of missing evsel->priv. - Fix crash caused by accessing feat_ops[HEADER_LAST_FEATURE], which is just a end of features header marker. perf stat: (Thomas Richter) - Remove duplicate event counting perf test: - Wire parsing error handling in 'parse events' test (Jiri Olsa) - Fix 'session topology' test on s/390 (Thomas Richter) eBPF: (Yonghong Song) - Fix a clang 7.0 compilation error when building perf linking with libclang intel-pt: (Adrian Hunter) - Fix packet decoding of CYC packets. Copies of kernel files: (Arnaldo Carvalho de Melo) - Synchronize drm/drm.h UAPI - Update x86's syscall_64.tbl, adding support for 'io_pgetevents' and 'rseq' in 'perf trace'. - Update powerpc uapi/asm/unistd.h, adding support for the 'rseq' syscall. - Update if_link.h and bpf.h, no effect on tool features. PowerPC: (Sandipan Das) - Fix crash if callchain is empty. s/390: (Thomas Richter) - Support random socked_id assignment in the perf header. - Support s390 random socket_id assignment in perf.data file. - Make PMU alias definitions taken from sysfs and JSON files comparable by normalizing them wrt spaces and newlines. Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
This commit is contained in:
@@ -146,8 +146,15 @@ getBPFObjectFromModule(llvm::Module *Module)
|
||||
raw_svector_ostream ostream(*Buffer);
|
||||
|
||||
legacy::PassManager PM;
|
||||
if (TargetMachine->addPassesToEmitFile(PM, ostream,
|
||||
TargetMachine::CGFT_ObjectFile)) {
|
||||
bool NotAdded;
|
||||
#if CLANG_VERSION_MAJOR < 7
|
||||
NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream,
|
||||
TargetMachine::CGFT_ObjectFile);
|
||||
#else
|
||||
NotAdded = TargetMachine->addPassesToEmitFile(PM, ostream, nullptr,
|
||||
TargetMachine::CGFT_ObjectFile);
|
||||
#endif
|
||||
if (NotAdded) {
|
||||
llvm::errs() << "TargetMachine can't emit a file of this type\n";
|
||||
return std::unique_ptr<llvm::SmallVectorImpl<char>>(nullptr);;
|
||||
}
|
||||
|
@@ -2129,6 +2129,7 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
|
||||
int cpu_nr = ff->ph->env.nr_cpus_avail;
|
||||
u64 size = 0;
|
||||
struct perf_header *ph = ff->ph;
|
||||
bool do_core_id_test = true;
|
||||
|
||||
ph->env.cpu = calloc(cpu_nr, sizeof(*ph->env.cpu));
|
||||
if (!ph->env.cpu)
|
||||
@@ -2183,6 +2184,13 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* On s390 the socket_id number is not related to the numbers of cpus.
|
||||
* The socket_id number might be higher than the numbers of cpus.
|
||||
* This depends on the configuration.
|
||||
*/
|
||||
if (ph->env.arch && !strncmp(ph->env.arch, "s390", 4))
|
||||
do_core_id_test = false;
|
||||
|
||||
for (i = 0; i < (u32)cpu_nr; i++) {
|
||||
if (do_read_u32(ff, &nr))
|
||||
goto free_cpu;
|
||||
@@ -2192,7 +2200,7 @@ static int process_cpu_topology(struct feat_fd *ff, void *data __maybe_unused)
|
||||
if (do_read_u32(ff, &nr))
|
||||
goto free_cpu;
|
||||
|
||||
if (nr != (u32)-1 && nr > (u32)cpu_nr) {
|
||||
if (do_core_id_test && nr != (u32)-1 && nr > (u32)cpu_nr) {
|
||||
pr_debug("socket_id number is too big."
|
||||
"You may need to upgrade the perf tool.\n");
|
||||
goto free_cpu;
|
||||
@@ -3456,7 +3464,7 @@ int perf_event__process_feature(struct perf_tool *tool,
|
||||
pr_warning("invalid record type %d in pipe-mode\n", type);
|
||||
return 0;
|
||||
}
|
||||
if (feat == HEADER_RESERVED || feat > HEADER_LAST_FEATURE) {
|
||||
if (feat == HEADER_RESERVED || feat >= HEADER_LAST_FEATURE) {
|
||||
pr_warning("invalid record type %d in pipe-mode\n", type);
|
||||
return -1;
|
||||
}
|
||||
|
@@ -366,7 +366,7 @@ static int intel_pt_get_cyc(unsigned int byte, const unsigned char *buf,
|
||||
if (len < offs)
|
||||
return INTEL_PT_NEED_MORE_BYTES;
|
||||
byte = buf[offs++];
|
||||
payload |= (byte >> 1) << shift;
|
||||
payload |= ((uint64_t)byte >> 1) << shift;
|
||||
}
|
||||
|
||||
packet->type = INTEL_PT_CYC;
|
||||
|
@@ -234,6 +234,74 @@ static int perf_pmu__parse_snapshot(struct perf_pmu_alias *alias,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void perf_pmu_assign_str(char *name, const char *field, char **old_str,
|
||||
char **new_str)
|
||||
{
|
||||
if (!*old_str)
|
||||
goto set_new;
|
||||
|
||||
if (*new_str) { /* Have new string, check with old */
|
||||
if (strcasecmp(*old_str, *new_str))
|
||||
pr_debug("alias %s differs in field '%s'\n",
|
||||
name, field);
|
||||
zfree(old_str);
|
||||
} else /* Nothing new --> keep old string */
|
||||
return;
|
||||
set_new:
|
||||
*old_str = *new_str;
|
||||
*new_str = NULL;
|
||||
}
|
||||
|
||||
static void perf_pmu_update_alias(struct perf_pmu_alias *old,
|
||||
struct perf_pmu_alias *newalias)
|
||||
{
|
||||
perf_pmu_assign_str(old->name, "desc", &old->desc, &newalias->desc);
|
||||
perf_pmu_assign_str(old->name, "long_desc", &old->long_desc,
|
||||
&newalias->long_desc);
|
||||
perf_pmu_assign_str(old->name, "topic", &old->topic, &newalias->topic);
|
||||
perf_pmu_assign_str(old->name, "metric_expr", &old->metric_expr,
|
||||
&newalias->metric_expr);
|
||||
perf_pmu_assign_str(old->name, "metric_name", &old->metric_name,
|
||||
&newalias->metric_name);
|
||||
perf_pmu_assign_str(old->name, "value", &old->str, &newalias->str);
|
||||
old->scale = newalias->scale;
|
||||
old->per_pkg = newalias->per_pkg;
|
||||
old->snapshot = newalias->snapshot;
|
||||
memcpy(old->unit, newalias->unit, sizeof(old->unit));
|
||||
}
|
||||
|
||||
/* Delete an alias entry. */
|
||||
static void perf_pmu_free_alias(struct perf_pmu_alias *newalias)
|
||||
{
|
||||
zfree(&newalias->name);
|
||||
zfree(&newalias->desc);
|
||||
zfree(&newalias->long_desc);
|
||||
zfree(&newalias->topic);
|
||||
zfree(&newalias->str);
|
||||
zfree(&newalias->metric_expr);
|
||||
zfree(&newalias->metric_name);
|
||||
parse_events_terms__purge(&newalias->terms);
|
||||
free(newalias);
|
||||
}
|
||||
|
||||
/* Merge an alias, search in alias list. If this name is already
|
||||
* present merge both of them to combine all information.
|
||||
*/
|
||||
static bool perf_pmu_merge_alias(struct perf_pmu_alias *newalias,
|
||||
struct list_head *alist)
|
||||
{
|
||||
struct perf_pmu_alias *a;
|
||||
|
||||
list_for_each_entry(a, alist, list) {
|
||||
if (!strcasecmp(newalias->name, a->name)) {
|
||||
perf_pmu_update_alias(a, newalias);
|
||||
perf_pmu_free_alias(newalias);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
|
||||
char *desc, char *val,
|
||||
char *long_desc, char *topic,
|
||||
@@ -241,9 +309,11 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
|
||||
char *metric_expr,
|
||||
char *metric_name)
|
||||
{
|
||||
struct parse_events_term *term;
|
||||
struct perf_pmu_alias *alias;
|
||||
int ret;
|
||||
int num;
|
||||
char newval[256];
|
||||
|
||||
alias = malloc(sizeof(*alias));
|
||||
if (!alias)
|
||||
@@ -262,6 +332,27 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Scan event and remove leading zeroes, spaces, newlines, some
|
||||
* platforms have terms specified as
|
||||
* event=0x0091 (read from files ../<PMU>/events/<FILE>
|
||||
* and terms specified as event=0x91 (read from JSON files).
|
||||
*
|
||||
* Rebuild string to make alias->str member comparable.
|
||||
*/
|
||||
memset(newval, 0, sizeof(newval));
|
||||
ret = 0;
|
||||
list_for_each_entry(term, &alias->terms, list) {
|
||||
if (ret)
|
||||
ret += scnprintf(newval + ret, sizeof(newval) - ret,
|
||||
",");
|
||||
if (term->type_val == PARSE_EVENTS__TERM_TYPE_NUM)
|
||||
ret += scnprintf(newval + ret, sizeof(newval) - ret,
|
||||
"%s=%#x", term->config, term->val.num);
|
||||
else if (term->type_val == PARSE_EVENTS__TERM_TYPE_STR)
|
||||
ret += scnprintf(newval + ret, sizeof(newval) - ret,
|
||||
"%s=%s", term->config, term->val.str);
|
||||
}
|
||||
|
||||
alias->name = strdup(name);
|
||||
if (dir) {
|
||||
/*
|
||||
@@ -285,9 +376,10 @@ static int __perf_pmu__new_alias(struct list_head *list, char *dir, char *name,
|
||||
snprintf(alias->unit, sizeof(alias->unit), "%s", unit);
|
||||
}
|
||||
alias->per_pkg = perpkg && sscanf(perpkg, "%d", &num) == 1 && num == 1;
|
||||
alias->str = strdup(val);
|
||||
alias->str = strdup(newval);
|
||||
|
||||
list_add_tail(&alias->list, list);
|
||||
if (!perf_pmu_merge_alias(alias, list))
|
||||
list_add_tail(&alias->list, list);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -303,6 +395,9 @@ static int perf_pmu__new_alias(struct list_head *list, char *dir, char *name, FI
|
||||
|
||||
buf[ret] = 0;
|
||||
|
||||
/* Remove trailing newline from sysfs file */
|
||||
rtrim(buf);
|
||||
|
||||
return __perf_pmu__new_alias(list, dir, name, NULL, buf, NULL, NULL, NULL,
|
||||
NULL, NULL, NULL);
|
||||
}
|
||||
|
Reference in New Issue
Block a user