File 0700-Avoid-reschedule-from-dirty-to-normal-scheduler-on-s.patch of Package erlang
From 18b1938132de3fb8b4481cdf9bfb9aaffc35c61b Mon Sep 17 00:00:00 2001
From: Rickard Green <rickard@erlang.org>
Date: Thu, 30 Jan 2020 17:39:06 +0100
Subject: [PATCH] Avoid reschedule from dirty to normal scheduler on signals
---
erts/emulator/beam/erl_process.c | 56 ++++++++++++++++++++++++++--------------
1 file changed, 37 insertions(+), 19 deletions(-)
diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c
index d7d242ca86..2d04428b21 100644
--- a/erts/emulator/beam/erl_process.c
+++ b/erts/emulator/beam/erl_process.c
@@ -9793,25 +9793,33 @@ Process *erts_schedule(ErtsSchedulerData *esdp, Process *p, int calls)
}
}
else {
- if (!(state & ERTS_PSFLGS_DIRTY_WORK)) {
- /* Dirty work completed... */
- goto sunlock_sched_out_proc;
+ /* On dirty scheduler */
+ if (!(state & ERTS_PSFLGS_DIRTY_WORK)
+ | !!(state & (ERTS_PSFLG_SYS_TASKS
+ | ERTS_PSFLG_EXITING
+ | ERTS_PSFLG_DIRTY_ACTIVE_SYS))) {
+
+ if (!(state & ERTS_PSFLGS_DIRTY_WORK)) {
+ /* Dirty work completed... */
+ goto sunlock_sched_out_proc;
+ }
+ if (state & (ERTS_PSFLG_SYS_TASKS
+ | ERTS_PSFLG_EXITING)) {
+ /*
+ * IMPORTANT! We need to take care of
+ * scheduled check-process-code requests
+ * before continuing with dirty execution!
+ */
+ /* Migrate to normal scheduler... */
+ goto sunlock_sched_out_proc;
+ }
+ if ((state & ERTS_PSFLG_DIRTY_ACTIVE_SYS)
+ && rq == ERTS_DIRTY_IO_RUNQ) {
+ /* Migrate to dirty cpu scheduler... */
+ goto sunlock_sched_out_proc;
+ }
+
}
- if (state & (ERTS_PSFLG_ACTIVE_SYS
- | ERTS_PSFLG_EXITING)) {
- /*
- * IMPORTANT! We need to take care of
- * scheduled check-process-code requests
- * before continuing with dirty execution!
- */
- /* Migrate to normal scheduler... */
- goto sunlock_sched_out_proc;
- }
- if ((state & ERTS_PSFLG_DIRTY_ACTIVE_SYS)
- && rq == ERTS_DIRTY_IO_RUNQ) {
- /* Migrate to dirty cpu scheduler... */
- goto sunlock_sched_out_proc;
- }
ASSERT(rq == ERTS_DIRTY_CPU_RUNQ
? (state & (ERTS_PSFLG_DIRTY_CPU_PROC
@@ -9825,7 +9833,17 @@ Process *erts_schedule(ErtsSchedulerData *esdp, Process *p, int calls)
if (IS_TRACED(p))
trace_schedule_in(p, state);
- if (is_normal_sched) {
+ if (!is_normal_sched) {
+ /* On dirty scheduler */
+ if (!!(state & ERTS_PSFLG_DIRTY_RUNNING)
+ & !!(state & (ERTS_PSFLG_SIG_Q|ERTS_PSFLG_SIG_IN_Q))) {
+ /* Ensure signals are handled while executing dirty... */
+ int prio = ERTS_PSFLGS_GET_ACT_PRIO(state);
+ erts_make_dirty_proc_handled(p->common.id, state, prio);
+ }
+ }
+ else {
+ /* On normal scheduler */
if (state & ERTS_PSFLG_RUNNING_SYS) {
if (state & (ERTS_PSFLG_SIG_Q|ERTS_PSFLG_SIG_IN_Q)) {
int local_only = (!!(p->flags & F_LOCAL_SIGS_ONLY)
--
2.16.4