aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRickard Green <[email protected]>2011-12-08 18:14:04 +0100
committerRickard Green <[email protected]>2011-12-08 18:14:04 +0100
commit88616f04e25f71ae288837585cc31c8dc706cdcc (patch)
tree0b31853b03357ab75004a61c1f06281892e6fa3a
parentf7dac4d873cc90c9c6512e724e1b79c4d65deb38 (diff)
parent970224fc70aec4bf96e668f61b0bf41eef7af545 (diff)
downloadotp-88616f04e25f71ae288837585cc31c8dc706cdcc.tar.gz
otp-88616f04e25f71ae288837585cc31c8dc706cdcc.tar.bz2
otp-88616f04e25f71ae288837585cc31c8dc706cdcc.zip
Merge branch 'rickard/alloc-opt/OTP-7775'
* rickard/alloc-opt/OTP-7775: Fix erts_thr_progress_wakeup()
-rw-r--r--erts/emulator/beam/erl_thr_progress.c31
1 files changed, 23 insertions, 8 deletions
diff --git a/erts/emulator/beam/erl_thr_progress.c b/erts/emulator/beam/erl_thr_progress.c
index 9324bcde51..02f36fc75e 100644
--- a/erts/emulator/beam/erl_thr_progress.c
+++ b/erts/emulator/beam/erl_thr_progress.c
@@ -80,12 +80,12 @@
#ifdef ERTS_SMP
-/*
- * We use a 64-bit value for thread progress. By this wrapping of
- * the thread progress will more or less never occur.
- *
- * On 32-bit systems we therefore need a double word atomic.
- */
+#define ERTS_THR_PRGR_DBG_CHK_WAKEUP_REQUEST_VALUE 0
+
+#ifdef DEBUG
+#undef ERTS_THR_PRGR_DBG_CHK_WAKEUP_REQUEST_VALUE
+#define ERTS_THR_PRGR_DBG_CHK_WAKEUP_REQUEST_VALUE 1
+#endif
#define ERTS_THR_PRGR_PRINT_LEADER 0
#define ERTS_THR_PRGR_PRINT_VAL 0
@@ -106,6 +106,13 @@
|ERTS_THR_PRGR_LFLG_ACTIVE_MASK)) \
== ERTS_THR_PRGR_LFLG_NO_LEADER)
+/*
+ * We use a 64-bit value for thread progress. By this wrapping of
+ * the thread progress will more or less never occur.
+ *
+ * On 32-bit systems we therefore need a double word atomic.
+ */
+
#define read_acqb erts_thr_prgr_read_acqb__
#ifdef ARCH_64
@@ -937,8 +944,10 @@ request_wakeup_managed(ErtsThrPrgrData *tpd, ErtsThrPrgrVal value)
ASSERT(tpd->is_managed);
ASSERT(tpd->previous.local != ERTS_THR_PRGR_VAL_WAITING);
- if (has_reached_wakeup(value))
+ if (has_reached_wakeup(value)) {
wakeup_managed(tpd->id);
+ return;
+ }
wix = ERTS_THR_PRGR_WAKEUP_IX(value);
if (tpd->wakeup_request[wix] == value)
@@ -976,6 +985,10 @@ request_wakeup_managed(ErtsThrPrgrData *tpd, ErtsThrPrgrVal value)
mwd = intrnl->managed.data[wix];
ix = erts_atomic32_inc_read_nob(&mwd->len) - 1;
+#if ERTS_THR_PRGR_DBG_CHK_WAKEUP_REQUEST_VALUE
+ if (ix >= intrnl->managed.no)
+ erl_exit(ERTS_ABORT_EXIT, "Internal error: Too many wakeup requests\n");
+#endif
mwd->id[ix] = tpd->id;
ASSERT(!erts_thr_progress_has_reached(value));
@@ -1001,8 +1014,10 @@ request_wakeup_unmanaged(ErtsThrPrgrData *tpd, ErtsThrPrgrVal value)
* we are writing the request.
*/
- if (has_reached_wakeup(value))
+ if (has_reached_wakeup(value)) {
wakeup_unmanaged(tpd->id);
+ return;
+ }
wix = ERTS_THR_PRGR_WAKEUP_IX(value);