aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/beam/erl_process.c
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2019-05-29 16:01:30 +0200
committerLukas Larsson <[email protected]>2019-06-27 16:27:19 +0200
commitdd98614bb826074b5ca88d1313eb800542f731e9 (patch)
treeefebd1da552c8ea15d289cb150adabeede5a68a4 /erts/emulator/beam/erl_process.c
parent0c463a974b2c7030d13058b8948d1e3a57afe4e6 (diff)
downloadotp-dd98614bb826074b5ca88d1313eb800542f731e9.tar.gz
otp-dd98614bb826074b5ca88d1313eb800542f731e9.tar.bz2
otp-dd98614bb826074b5ca88d1313eb800542f731e9.zip
erts: Cleanup start of all erts threads to ABORT when failing
Before this change erts used to crash dump and then abort, but a crash dump is not really usefull at this point and it caused all sort of lock problems when crash dumping that early in the system boot, so now it is changed to only dump core instead. Also in the process I cleaned up some the code so that it does not to a lot of things that are not needed.
Diffstat (limited to 'erts/emulator/beam/erl_process.c')
-rw-r--r--erts/emulator/beam/erl_process.c59
1 files changed, 16 insertions, 43 deletions
diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c
index 1f6adb98ef..6e8b9ebde0 100644
--- a/erts/emulator/beam/erl_process.c
+++ b/erts/emulator/beam/erl_process.c
@@ -8568,9 +8568,6 @@ erts_start_schedulers(void)
{
ethr_tid tid;
int res = 0;
- Uint actual;
- Uint wanted = erts_no_schedulers;
- Uint wanted_no_schedulers = erts_no_schedulers;
char name[16];
ethr_thr_opts opts = ETHR_THR_OPTS_DEFAULT_INITER;
int ix;
@@ -8584,40 +8581,34 @@ erts_start_schedulers(void)
erts_snprintf(opts.name, 16, "runq_supervisor");
erts_atomic_init_nob(&runq_supervisor_sleeping, 0);
if (0 != ethr_event_init(&runq_supervision_event))
- erts_exit(ERTS_ERROR_EXIT, "Failed to create run-queue supervision event\n");
+ erts_exit(ERTS_ABORT_EXIT, "Failed to create run-queue supervision event\n");
res = ethr_thr_create(&runq_supervisor_tid,
runq_supervisor,
NULL,
&opts);
if (0 != res)
- erts_exit(ERTS_ERROR_EXIT, "Failed to create run-queue supervision thread, "
+ erts_exit(ERTS_ABORT_EXIT, "Failed to create run-queue supervision thread, "
"error = %d\n", res);
}
opts.suggested_stack_size = erts_sched_thread_suggested_stack_size;
- if (wanted < 1)
- wanted = 1;
- if (wanted > ERTS_MAX_NO_OF_SCHEDULERS) {
- wanted = ERTS_MAX_NO_OF_SCHEDULERS;
- res = ENOTSUP;
- }
-
- for (actual = 0; actual < wanted; actual++) {
- ErtsSchedulerData *esdp = ERTS_SCHEDULER_IX(actual);
-
- ASSERT(actual == esdp->no - 1);
-
- erts_snprintf(opts.name, 16, "%lu_scheduler", actual + 1);
+ ASSERT(erts_no_schedulers > 0 && erts_no_schedulers <= ERTS_MAX_NO_OF_SCHEDULERS);
+ for (ix = 0; ix < erts_no_schedulers; ix++) {
+ ErtsSchedulerData *esdp = ERTS_SCHEDULER_IX(ix);
+ ASSERT(ix == esdp->no - 1);
+ erts_snprintf(opts.name, 16, "%lu_scheduler", ix + 1);
res = ethr_thr_create(&esdp->tid, sched_thread_func, (void*)esdp, &opts);
-
if (res != 0) {
- break;
+ erts_exit(ERTS_ABORT_EXIT, "Failed to create scheduler thread %d, error = %d\n", ix, res);
}
}
- erts_no_schedulers = actual;
+
+ /* Probably not needed as thread create will imply a memory barrier,
+ but we do one just to be safe. */
+ ERTS_THR_MEMORY_BARRIER;
{
for (ix = 0; ix < erts_no_dirty_cpu_schedulers; ix++) {
@@ -8626,7 +8617,7 @@ erts_start_schedulers(void)
opts.suggested_stack_size = erts_dcpu_sched_thread_suggested_stack_size;
res = ethr_thr_create(&esdp->tid,sched_dirty_cpu_thread_func,(void*)esdp,&opts);
if (res != 0)
- erts_exit(ERTS_ERROR_EXIT, "Failed to create dirty cpu scheduler thread %d, error = %d\n", ix, res);
+ erts_exit(ERTS_ABORT_EXIT, "Failed to create dirty cpu scheduler thread %d, error = %d\n", ix, res);
}
for (ix = 0; ix < erts_no_dirty_io_schedulers; ix++) {
ErtsSchedulerData *esdp = ERTS_DIRTY_IO_SCHEDULER_IX(ix);
@@ -8634,40 +8625,22 @@ erts_start_schedulers(void)
opts.suggested_stack_size = erts_dio_sched_thread_suggested_stack_size;
res = ethr_thr_create(&esdp->tid,sched_dirty_io_thread_func,(void*)esdp,&opts);
if (res != 0)
- erts_exit(ERTS_ERROR_EXIT, "Failed to create dirty io scheduler thread %d, error = %d\n", ix, res);
+ erts_exit(ERTS_ABORT_EXIT, "Failed to create dirty io scheduler thread %d, error = %d\n", ix, res);
}
}
- ERTS_THR_MEMORY_BARRIER;
-
erts_snprintf(opts.name, 16, "aux");
res = ethr_thr_create(&tid, aux_thread, NULL, &opts);
if (res != 0)
- erts_exit(ERTS_ERROR_EXIT, "Failed to create aux thread, error = %d\n", res);
+ erts_exit(ERTS_ABORT_EXIT, "Failed to create aux thread, error = %d\n", res);
for (ix = 0; ix < erts_no_poll_threads; ix++) {
erts_snprintf(opts.name, 16, "%d_poller", ix);
res = ethr_thr_create(&tid, poll_thread, (void*)(UWord)ix, &opts);
if (res != 0)
- erts_exit(ERTS_ERROR_EXIT, "Failed to create poll thread\n");
- }
-
- if (actual < 1)
- erts_exit(ERTS_ERROR_EXIT,
- "Failed to create any scheduler-threads: %s (%d)\n",
- erl_errno_id(res),
- res);
- if (res != 0) {
- erts_dsprintf_buf_t *dsbufp = erts_create_logger_dsbuf();
- ASSERT(actual != wanted_no_schedulers);
- erts_dsprintf(dsbufp,
- "Failed to create %beu scheduler-threads (%s:%d); "
- "only %beu scheduler-thread%s created.\n",
- wanted_no_schedulers, erl_errno_id(res), res,
- actual, actual == 1 ? " was" : "s were");
- erts_send_error_to_logger_nogl(dsbufp);
+ erts_exit(ERTS_ABORT_EXIT, "Failed to create poll thread\n");
}
}