File 1636-erts-Fix-reds-counting-in-execute_sys_tasks-cleanup_.patch of Package erlang
From fb0d47d3984c0c36f0c9236005efaec7e2dd844f Mon Sep 17 00:00:00 2001
From: Rickard Green <rickard@erlang.org>
Date: Thu, 7 Jul 2022 02:37:55 +0200
Subject: [PATCH] [erts] Fix reds counting in
execute_sys_tasks()/cleanup_sys_tasks()
---
erts/emulator/beam/erl_process.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c
index d0ae08793a..669d4890c8 100644
--- a/erts/emulator/beam/erl_process.c
+++ b/erts/emulator/beam/erl_process.c
@@ -10397,7 +10397,7 @@ execute_sys_tasks(Process *c_p, erts_aint32_t *statep, int in_reds)
}
if (st)
- reds += notify_sys_task_executed(c_p, st, st_res, 1);
+ reds -= notify_sys_task_executed(c_p, st, st_res, 1);
state = erts_atomic32_read_acqb(&c_p->state);
} while (qmask && reds > 0);
@@ -10414,8 +10414,7 @@ static int
cleanup_sys_tasks(Process *c_p, erts_aint32_t in_state, int in_reds)
{
erts_aint32_t state = in_state;
- int max_reds = in_reds;
- int reds = 0;
+ int reds = in_reds;
int qmask = 1; /* Set to 1 to force looping as long as there
* are dirty tasks.
*/
@@ -10464,10 +10463,10 @@ cleanup_sys_tasks(Process *c_p, erts_aint32_t in_state, int in_reds)
break;
}
- reds += notify_sys_task_executed(c_p, st, st_res, 1);
+ reds -= notify_sys_task_executed(c_p, st, st_res, 1);
state = erts_atomic32_read_acqb(&c_p->state);
- } while (qmask && reds < max_reds);
+ } while (qmask && reds > 0);
return reds;
}
--
2.35.3