Skip to content
This repository was archived by the owner on Oct 5, 2018. It is now read-only.

Commit 1aff59b

Browse files
Yunlong Songacmel
authored andcommitted
perf sched replay: Handle the dead halt of sem_wait when create_tasks() fails for any task
Since there is sem_wait for each task in the wait_for_tasks(), e.g. sem_wait(&task->work_done_sem). The sem_wait can continue only when work_done_sem is greater than 0, or it will be blocked. For perf sched replay, one task may sem_post the work_done_sem of another task, which causes the work_done_sem of that task processed in a reasonable sequence, e.g. sem_post, sem_wait, sem_wait, sem_post... This sequence simulates the sched process of the running tasks at the time when perf sched record runs. As a result, all the tasks are required and their threads must be successfully created. If any one (task A) of the tasks fails to create its thread, then another task (task B), whose work_done_sem needs sem_post from that failed task A, may likely block itself due to seg_wait. And this is a dead halt, since task B's thread_func cannot continue at all. To solve this problem, perf sched replay should exit once any task fails to create its thread. Example: Test environment: x86_64 with 160 cores Before this patch: $ perf sched replay ... Error: sys_perf_event_open() syscall returned with -1 (Too many open files) ------------------------------------------------------------ <- dead halt After this patch: $ perf sched replay ... task 1551 ( <unknown>: 0), nr_events: 10 Error: sys_perf_event_open() syscall returned with -1 (Too many open files) $ As shown above, perf sched replay finishes the process after printing an error message and does not block itself. Signed-off-by: Yunlong Song <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Wang Nan <[email protected]> Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 08097ab commit 1aff59b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

tools/perf/builtin-sched.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,10 +451,12 @@ static int self_open_counters(void)
451451
fd = sys_perf_event_open(&attr, 0, -1, -1,
452452
perf_event_open_cloexec_flag());
453453

454-
if (fd < 0)
454+
if (fd < 0) {
455455
pr_err("Error: sys_perf_event_open() syscall returned "
456456
"with %d (%s)\n", fd,
457457
strerror_r(errno, sbuf, sizeof(sbuf)));
458+
exit(EXIT_FAILURE);
459+
}
458460
return fd;
459461
}
460462

0 commit comments

Comments
 (0)