Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 613d8602 authored by Ingo Molnar's avatar Ingo Molnar
Browse files

perf record: Fix fast task-exit race



Recording with -a (or with -p) can race with tasks going away:

   couldn't open /proc/8440/maps

Causing an early exit() and no recording done.

Do not abort the recording session - instead just skip that task.

Also, only print the warnings under -v.

Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Mike Galbraith <efault@gmx.de>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
LKML-Reference: <new-submission>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 038e836e
Loading
Loading
Loading
Loading
+12 −4
Original line number Original line Diff line number Diff line
@@ -202,8 +202,12 @@ static void pid_synthesize_comm_event(pid_t pid, int full)


	fd = open(filename, O_RDONLY);
	fd = open(filename, O_RDONLY);
	if (fd < 0) {
	if (fd < 0) {
		/*
		 * We raced with a task exiting - just return:
		 */
		if (verbose)
			fprintf(stderr, "couldn't open %s\n", filename);
			fprintf(stderr, "couldn't open %s\n", filename);
		exit(EXIT_FAILURE);
		return;
	}
	}
	if (read(fd, bf, sizeof(bf)) < 0) {
	if (read(fd, bf, sizeof(bf)) < 0) {
		fprintf(stderr, "couldn't read %s\n", filename);
		fprintf(stderr, "couldn't read %s\n", filename);
@@ -273,8 +277,12 @@ static void pid_synthesize_mmap_samples(pid_t pid)


	fp = fopen(filename, "r");
	fp = fopen(filename, "r");
	if (fp == NULL) {
	if (fp == NULL) {
		/*
		 * We raced with a task exiting - just return:
		 */
		if (verbose)
			fprintf(stderr, "couldn't open %s\n", filename);
			fprintf(stderr, "couldn't open %s\n", filename);
		exit(EXIT_FAILURE);
		return;
	}
	}
	while (1) {
	while (1) {
		char bf[BUFSIZ], *pbf = bf;
		char bf[BUFSIZ], *pbf = bf;