aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2014-02-23 18:26:38 +0100
committerLukas Larsson <[email protected]>2014-02-24 15:16:07 +0100
commita35d0f5f82f8152f1b953eda039807a7d4f4e9b9 (patch)
tree0410287577061d3ed630e76608bc865613c2b19d /erts/emulator
parent2bf4f22a9488d94ac1fc3c72a4e9d84151744004 (diff)
downloadotp-a35d0f5f82f8152f1b953eda039807a7d4f4e9b9.tar.gz
otp-a35d0f5f82f8152f1b953eda039807a7d4f4e9b9.tar.bz2
otp-a35d0f5f82f8152f1b953eda039807a7d4f4e9b9.zip
ose: Thread priorities configurable from lmconf
The pattern used for getting the priority from the lmconf is based on the name of the process created. The pattern is: ERTS_%%PROCESS_NAME%%_PRIO with the %%PROCESS_NAME%% replaced by the prefix of the process the priority applies to. eg: ERTS_SCHEDULER_PRIO=24 applies to processes with name SCHEDULER_1, SCHEDULER_2 etc.
Diffstat (limited to 'erts/emulator')
-rw-r--r--erts/emulator/beam/erl_async.c14
-rw-r--r--erts/emulator/beam/erl_process.c38
-rw-r--r--erts/emulator/beam/erl_trace.c5
-rw-r--r--erts/emulator/drivers/ose/ose_signal_drv.c2
-rw-r--r--erts/emulator/sys/ose/default.lmconf6
-rw-r--r--erts/emulator/sys/ose/sys.c10
6 files changed, 53 insertions, 22 deletions
diff --git a/erts/emulator/beam/erl_async.c b/erts/emulator/beam/erl_async.c
index afb5bc302f..b3dc327704 100644
--- a/erts/emulator/beam/erl_async.c
+++ b/erts/emulator/beam/erl_async.c
@@ -166,6 +166,7 @@ async_ready_q(Uint sched_id)
#endif
+
void
erts_init_async(void)
{
@@ -226,18 +227,23 @@ erts_init_async(void)
thr_opts.suggested_stack_size
= erts_async_thread_suggested_stack_size;
-#ifdef ETHR_HAVE_THREAD_NICENESS
- thr_opts.prio += 2;
-#endif
#ifdef ETHR_HAVE_THREAD_NAMES
- thr_opts.name = "async_thread";
+ thr_opts.name = malloc(sizeof(char)*(strlen("async_XXXX")+1));
#endif
for (i = 0; i < erts_async_max_threads; i++) {
ErtsAsyncQ *aq = async_q(i);
+
+#ifdef ETHR_HAVE_THREAD_NAMES
+ sprintf(thr_opts.name, "async_%d", i+1);
+#endif
+
erts_thr_create(&aq->thr_id, async_main, (void*) aq, &thr_opts);
}
+#ifdef ETHR_HAVE_THREAD_NAMES
+ free(thr_opts.name);
+#endif
/* Wait for async threads to initialize... */
erts_mtx_lock(&async->init.data.mtx);
diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c
index a4241c6d43..83856ab983 100644
--- a/erts/emulator/beam/erl_process.c
+++ b/erts/emulator/beam/erl_process.c
@@ -6830,9 +6830,16 @@ erts_start_schedulers(void)
opts.detached = 1;
+#ifdef ETHR_HAVE_THREAD_NAMES
+ opts.name = malloc(80);
+#endif
+
#ifdef ERTS_SMP
if (erts_runq_supervision_interval) {
opts.suggested_stack_size = 16;
+#ifdef ETHR_HAVE_THREAD_NAMES
+ sprintf(opts.name, "runq_supervisor");
+#endif
erts_atomic_init_nob(&runq_supervisor_sleeping, 0);
if (0 != ethr_event_init(&runq_supervision_event))
erl_exit(1, "Failed to create run-queue supervision event\n");
@@ -6854,17 +6861,13 @@ erts_start_schedulers(void)
res = ENOTSUP;
}
-#ifdef ETHR_HAVE_THREAD_NAMES
- opts.name = malloc(sizeof(char)*(strlen("scheduler_XXXX")+1));
-#endif
-
for (actual = 0; actual < wanted; actual++) {
ErtsSchedulerData *esdp = ERTS_SCHEDULER_IX(actual);
ASSERT(actual == esdp->no - 1);
#ifdef ETHR_HAVE_THREAD_NAMES
- sprintf(opts.name,"scheduler_%d", actual+1);
+ sprintf(opts.name, "scheduler_%d", actual + 1);
#endif
#ifdef __OSE__
@@ -6872,14 +6875,13 @@ erts_start_schedulers(void)
opts.coreNo = (actual+1) % ose_num_cpus();
#endif
- res = ethr_thr_create(&esdp->tid, sched_thread_func,(void*)esdp,&opts);
+ res = ethr_thr_create(&esdp->tid, sched_thread_func, (void*)esdp, &opts);
if (res != 0) {
break;
}
-
}
-
+
erts_no_schedulers = actual;
#ifdef ERTS_DIRTY_SCHEDULERS
@@ -6888,12 +6890,18 @@ erts_start_schedulers(void)
int ix;
for (ix = 0; ix < erts_no_dirty_cpu_schedulers; ix++) {
ErtsSchedulerData *esdp = ERTS_DIRTY_CPU_SCHEDULER_IX(ix);
+#ifdef ETHR_HAVE_THREAD_NAMES
+ sprintf(opts.name,"dirty_cpu_scheduler_%d", ix + 1);
+#endif
res = ethr_thr_create(&esdp->tid,sched_dirty_cpu_thread_func,(void*)esdp,&opts);
if (res != 0)
erl_exit(1, "Failed to create dirty cpu scheduler thread %d\n", ix);
}
for (ix = 0; ix < erts_no_dirty_io_schedulers; ix++) {
ErtsSchedulerData *esdp = ERTS_DIRTY_IO_SCHEDULER_IX(ix);
+#ifdef ETHR_HAVE_THREAD_NAMES
+ sprintf(opts.name,"dirty_io_scheduler_%d", ix + 1);
+#endif
res = ethr_thr_create(&esdp->tid,sched_dirty_io_thread_func,(void*)esdp,&opts);
if (res != 0)
erl_exit(1, "Failed to create dirty io scheduler thread %d\n", ix);
@@ -6903,16 +6911,14 @@ erts_start_schedulers(void)
#endif
ERTS_THR_MEMORY_BARRIER;
+
#ifdef ETHR_HAVE_THREAD_NAMES
- free(opts.name);
- opts.name = "aux_thread";
+ sprintf(opts.name, "aux");
#endif
+
#ifdef __OSE__
opts.coreNo = 0;
-#endif
-#ifdef ETHR_HAVE_THREAD_NICENESS
- opts.prio++;
-#endif
+#endif /* __OSE__ */
res = ethr_thr_create(&aux_tid, aux_thread, NULL, &opts);
if (res != 0)
@@ -6933,6 +6939,10 @@ erts_start_schedulers(void)
actual, actual == 1 ? " was" : "s were");
erts_send_error_to_logger_nogl(dsbufp);
}
+
+#ifdef ETHR_HAVE_THREAD_NAMES
+ free(opts.name);
+#endif
}
#endif /* ERTS_SMP */
diff --git a/erts/emulator/beam/erl_trace.c b/erts/emulator/beam/erl_trace.c
index 43e7435d2a..6978a5f11a 100644
--- a/erts/emulator/beam/erl_trace.c
+++ b/erts/emulator/beam/erl_trace.c
@@ -3478,12 +3478,11 @@ init_sys_msg_dispatcher(void)
sys_message_queue_end = NULL;
erts_smp_cnd_init(&smq_cnd);
erts_smp_mtx_init(&smq_mtx, "sys_msg_q");
+
#ifdef ETHR_HAVE_THREAD_NAMES
thr_opts.name = "sys_msg_dispatcher";
#endif
-#ifdef ETHR_HAVE_THREAD_NICENESS
- thr_opts.prio++;
-#endif
+
erts_smp_thr_create(&sys_msg_dispatcher_tid,
sys_msg_dispatcher_func,
NULL,
diff --git a/erts/emulator/drivers/ose/ose_signal_drv.c b/erts/emulator/drivers/ose/ose_signal_drv.c
index 46890a1503..1335bffe18 100644
--- a/erts/emulator/drivers/ose/ose_signal_drv.c
+++ b/erts/emulator/drivers/ose/ose_signal_drv.c
@@ -29,6 +29,7 @@
#include "erl_driver.h"
#include "ose.h"
+
#ifdef HAVE_OSE_SPI_H
#include "ose_spi/ose_spi.h"
#endif
@@ -363,6 +364,7 @@ static OS_PROCESS(driver_proxy_process) {
}
}
+
/**
* Init routine for the driver
**/
diff --git a/erts/emulator/sys/ose/default.lmconf b/erts/emulator/sys/ose/default.lmconf
index 17b7a1e5fa..a66b0ece56 100644
--- a/erts/emulator/sys/ose/default.lmconf
+++ b/erts/emulator/sys/ose/default.lmconf
@@ -13,6 +13,12 @@ HEAP_SMALL_BUF_INIT_SIZE=64000000
HEAP_LARGE_BUF_THRESHOLD=16000000
HEAP_LOCK_TYPE=2
+ERTS_DEFAULT_PRIO=24
+ERTS_SCHEDULER_PRIO=24
+ERTS_ASYNC_PRIO=22
+ERTS_AUX_PRIO=24
+ERTS_SYS_MSG_DISPATCHER_PRIO=21
+
# Setting the environment variable EFS_RESOLVE_TMO on the block to 0.
# This will eliminiate delays when trying to open files on not mounted
# volumes.
diff --git a/erts/emulator/sys/ose/sys.c b/erts/emulator/sys/ose/sys.c
index beb7f5944f..88dbd7fcf8 100644
--- a/erts/emulator/sys/ose/sys.c
+++ b/erts/emulator/sys/ose/sys.c
@@ -50,6 +50,14 @@
#include "efs.h"
#include "erl_printf.h"
+/* Set the define to 1 to get some logging */
+#if 0
+#include "ramlog.h"
+#define LOG(output) ramlog_printf output
+#else
+#define LOG(output)
+#endif
+
extern char **environ;
static erts_smp_rwmtx_t environ_rwmtx;
@@ -68,7 +76,7 @@ static erts_smp_rwmtx_t environ_rwmtx;
#include "erl_cpu_topology.h"
/* The priority for reader/writer processes */
-#define FD_PROC_PRI 20
+#define FD_PROC_PRI get_pri(current_process())
typedef struct ErtsSysReportExit_ ErtsSysReportExit;
struct ErtsSysReportExit_ {