Merge remote-tracking branch 'torvalds/master' into perf/core

To pick up fixes sent via perf/urgent and in the BPF tools/ directories.

Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Arnaldo Carvalho de Melo
2021-03-29 10:39:10 -03:00
1301 changed files with 11277 additions and 6798 deletions

View File

@@ -399,35 +399,42 @@ static pid_t handle_signalfd(struct daemon *daemon)
int status;
pid_t pid;
/*
* Take signal fd data as pure signal notification and check all
* the sessions state. The reason is that multiple signals can get
* coalesced in kernel and we can receive only single signal even
* if multiple SIGCHLD were generated.
*/
err = read(daemon->signal_fd, &si, sizeof(struct signalfd_siginfo));
if (err != sizeof(struct signalfd_siginfo))
if (err != sizeof(struct signalfd_siginfo)) {
pr_err("failed to read signal fd\n");
return -1;
}
list_for_each_entry(session, &daemon->sessions, list) {
if (session->pid != (int) si.ssi_pid)
if (session->pid == -1)
continue;
pid = waitpid(session->pid, &status, 0);
if (pid == session->pid) {
if (WIFEXITED(status)) {
pr_info("session '%s' exited, status=%d\n",
session->name, WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
pr_info("session '%s' killed (signal %d)\n",
session->name, WTERMSIG(status));
} else if (WIFSTOPPED(status)) {
pr_info("session '%s' stopped (signal %d)\n",
session->name, WSTOPSIG(status));
} else {
pr_info("session '%s' Unexpected status (0x%x)\n",
session->name, status);
}
pid = waitpid(session->pid, &status, WNOHANG);
if (pid <= 0)
continue;
if (WIFEXITED(status)) {
pr_info("session '%s' exited, status=%d\n",
session->name, WEXITSTATUS(status));
} else if (WIFSIGNALED(status)) {
pr_info("session '%s' killed (signal %d)\n",
session->name, WTERMSIG(status));
} else if (WIFSTOPPED(status)) {
pr_info("session '%s' stopped (signal %d)\n",
session->name, WSTOPSIG(status));
} else {
pr_info("session '%s' Unexpected status (0x%x)\n",
session->name, status);
}
session->state = KILL;
session->pid = -1;
return pid;
}
return 0;
@@ -440,7 +447,6 @@ static int daemon_session__wait(struct daemon_session *session, struct daemon *d
.fd = daemon->signal_fd,
.events = POLLIN,
};
pid_t wpid = 0, pid = session->pid;
time_t start;
start = time(NULL);
@@ -449,7 +455,7 @@ static int daemon_session__wait(struct daemon_session *session, struct daemon *d
int err = poll(&pollfd, 1, 1000);
if (err > 0) {
wpid = handle_signalfd(daemon);
handle_signalfd(daemon);
} else if (err < 0) {
perror("failed: poll\n");
return -1;
@@ -457,7 +463,7 @@ static int daemon_session__wait(struct daemon_session *session, struct daemon *d
if (start + secs < time(NULL))
return -1;
} while (wpid != pid);
} while (session->pid != -1);
return 0;
}
@@ -899,7 +905,9 @@ static void daemon_session__kill(struct daemon_session *session,
daemon_session__signal(session, SIGKILL);
break;
default:
break;
pr_err("failed to wait for session %s\n",
session->name);
return;
}
how++;
@@ -952,7 +960,8 @@ static void daemon__kill(struct daemon *daemon)
daemon__signal(daemon, SIGKILL);
break;
default:
break;
pr_err("failed to wait for sessions\n");
return;
}
how++;
@@ -1341,7 +1350,7 @@ out:
close(sock_fd);
if (conf_fd != -1)
close(conf_fd);
if (conf_fd != -1)
if (signal_fd != -1)
close(signal_fd);
pr_info("daemon exited\n");

View File

@@ -86,7 +86,7 @@ static struct {
.msg_load_fail = "check your vmlinux setting?",
.target_func = &epoll_pwait_loop,
.expect_result = (NR_ITERS + 1) / 2,
.pin = true,
.pin = true,
},
#ifdef HAVE_BPF_PROLOGUE
{
@@ -99,13 +99,6 @@ static struct {
.expect_result = (NR_ITERS + 1) / 4,
},
#endif
{
.prog_id = LLVM_TESTCASE_BPF_RELOCATION,
.desc = "BPF relocation checker",
.name = "[bpf_relocation_test]",
.msg_compile_fail = "fix 'perf test LLVM' first",
.msg_load_fail = "libbpf error when dealing with relocation",
},
};
static int do_test(struct bpf_object *obj, int (*func)(void),

View File

@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
# daemon operations
# SPDX-License-Identifier: GPL-2.0

View File

@@ -298,10 +298,6 @@ static int auxtrace_queues__queue_buffer(struct auxtrace_queues *queues,
queue->set = true;
queue->tid = buffer->tid;
queue->cpu = buffer->cpu;
} else if (buffer->cpu != queue->cpu || buffer->tid != queue->tid) {
pr_err("auxtrace queue conflict: cpu %d, tid %d vs cpu %d, tid %d\n",
queue->cpu, queue->tid, buffer->cpu, buffer->tid);
return -EINVAL;
}
buffer->buffer_nr = queues->next_buffer_nr++;

View File

@@ -196,25 +196,32 @@ static int perf_event__synthesize_one_bpf_prog(struct perf_session *session,
}
if (info_linear->info_len < offsetof(struct bpf_prog_info, prog_tags)) {
free(info_linear);
pr_debug("%s: the kernel is too old, aborting\n", __func__);
return -2;
}
info = &info_linear->info;
if (!info->jited_ksyms) {
free(info_linear);
return -1;
}
/* number of ksyms, func_lengths, and tags should match */
sub_prog_cnt = info->nr_jited_ksyms;
if (sub_prog_cnt != info->nr_prog_tags ||
sub_prog_cnt != info->nr_jited_func_lens)
sub_prog_cnt != info->nr_jited_func_lens) {
free(info_linear);
return -1;
}
/* check BTF func info support */
if (info->btf_id && info->nr_func_info && info->func_info_rec_size) {
/* btf func info number should be same as sub_prog_cnt */
if (sub_prog_cnt != info->nr_func_info) {
pr_debug("%s: mismatch in BPF sub program count and BTF function info count, aborting\n", __func__);
err = -1;
goto out;
free(info_linear);
return -1;
}
if (btf__get_from_id(info->btf_id, &btf)) {
pr_debug("%s: failed to get BTF of id %u, aborting\n", __func__, info->btf_id);

View File

@@ -356,6 +356,9 @@ __add_event(struct list_head *list, int *idx,
struct perf_cpu_map *cpus = pmu ? perf_cpu_map__get(pmu->cpus) :
cpu_list ? perf_cpu_map__new(cpu_list) : NULL;
if (pmu && attr->type == PERF_TYPE_RAW)
perf_pmu__warn_invalid_config(pmu, attr->config, name);
if (init_attr)
event_attr_init(attr);

View File

@@ -1812,3 +1812,36 @@ int perf_pmu__caps_parse(struct perf_pmu *pmu)
return nr_caps;
}
void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config,
char *name)
{
struct perf_pmu_format *format;
__u64 masks = 0, bits;
char buf[100];
unsigned int i;
list_for_each_entry(format, &pmu->format, list) {
if (format->value != PERF_PMU_FORMAT_VALUE_CONFIG)
continue;
for_each_set_bit(i, format->bits, PERF_PMU_FORMAT_BITS)
masks |= 1ULL << i;
}
/*
* Kernel doesn't export any valid format bits.
*/
if (masks == 0)
return;
bits = config & ~masks;
if (bits == 0)
return;
bitmap_scnprintf((unsigned long *)&bits, sizeof(bits) * 8, buf, sizeof(buf));
pr_warning("WARNING: event '%s' not valid (bits %s of config "
"'%llx' not supported by kernel)!\n",
name ?: "N/A", buf, config);
}

View File

@@ -123,4 +123,7 @@ int perf_pmu__convert_scale(const char *scale, char **end, double *sval);
int perf_pmu__caps_parse(struct perf_pmu *pmu);
void perf_pmu__warn_invalid_config(struct perf_pmu *pmu, __u64 config,
char *name);
#endif /* __PMU_H */

View File

@@ -424,7 +424,7 @@ int perf_event__synthesize_mmap_events(struct perf_tool *tool,
while (!io.eof) {
static const char anonstr[] = "//anon";
size_t size;
size_t size, aligned_size;
/* ensure null termination since stack will be reused. */
event->mmap2.filename[0] = '\0';
@@ -484,11 +484,12 @@ out:
}
size = strlen(event->mmap2.filename) + 1;
size = PERF_ALIGN(size, sizeof(u64));
aligned_size = PERF_ALIGN(size, sizeof(u64));
event->mmap2.len -= event->mmap.start;
event->mmap2.header.size = (sizeof(event->mmap2) -
(sizeof(event->mmap2.filename) - size));
memset(event->mmap2.filename + size, 0, machine->id_hdr_size);
(sizeof(event->mmap2.filename) - aligned_size));
memset(event->mmap2.filename + size, 0, machine->id_hdr_size +
(aligned_size - size));
event->mmap2.header.size += machine->id_hdr_size;
event->mmap2.pid = tgid;
event->mmap2.tid = pid;
@@ -758,7 +759,7 @@ static int __event__synthesize_thread(union perf_event *comm_event,
for (i = 0; i < n; i++) {
char *end;
pid_t _pid;
bool kernel_thread;
bool kernel_thread = false;
_pid = strtol(dirent[i]->d_name, &end, 10);
if (*end)

View File

@@ -133,6 +133,8 @@ static struct dso *__machine__addnew_vdso(struct machine *machine, const char *s
if (dso != NULL) {
__dsos__add(&machine->dsos, dso);
dso__set_long_name(dso, long_name, false);
/* Put dso here because __dsos_add already got it */
dso__put(dso);
}
return dso;