diff options
author | Sverker Eriksson <[email protected]> | 2016-03-21 17:52:06 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2016-03-21 17:52:06 +0100 |
commit | 4642ca894bb553901bf03562f84fe5ad1485c8ad (patch) | |
tree | 9ff24394f4d3de096af0aaa046563a7d4b8ac414 | |
parent | f178adaeec2a6c103509763c3a19dca41aaac2c6 (diff) | |
parent | e5557304f49127ece23b9a524db24c20e43bea36 (diff) | |
download | otp-4642ca894bb553901bf03562f84fe5ad1485c8ad.tar.gz otp-4642ca894bb553901bf03562f84fe5ad1485c8ad.tar.bz2 otp-4642ca894bb553901bf03562f84fe5ad1485c8ad.zip |
Merge branch 'sverk/wait_for_deallocations'
-rw-r--r-- | erts/emulator/beam/erl_alloc.types | 2 | ||||
-rw-r--r-- | erts/emulator/beam/erl_process.c | 57 | ||||
-rw-r--r-- | lib/stdlib/test/ets_SUITE.erl | 13 |
3 files changed, 43 insertions, 29 deletions
diff --git a/erts/emulator/beam/erl_alloc.types b/erts/emulator/beam/erl_alloc.types index 2932adca84..14067283bd 100644 --- a/erts/emulator/beam/erl_alloc.types +++ b/erts/emulator/beam/erl_alloc.types @@ -343,6 +343,8 @@ type SSB SHORT_LIVED PROCESSES ssb +endif +type DEBUG SHORT_LIVED SYSTEM debugging + type DDLL_PROCESS STANDARD SYSTEM ddll_processes type MONITOR_LH STANDARD PROCESSES monitor_lh type NLINK_LH STANDARD PROCESSES nlink_lh diff --git a/erts/emulator/beam/erl_process.c b/erts/emulator/beam/erl_process.c index a706ebf595..d2185c4fbc 100644 --- a/erts/emulator/beam/erl_process.c +++ b/erts/emulator/beam/erl_process.c @@ -2211,8 +2211,7 @@ setup_thr_debug_wait_completed(void *vproc) if (debug_wait_completed_flags & ERTS_DEBUG_WAIT_COMPLETED_DEALLOCATIONS) { erts_alloc_fix_alloc_shrink(awdp->sched_id, 0); wait_flags |= (ERTS_SSI_AUX_WORK_DD - | ERTS_SSI_AUX_WORK_DD_THR_PRGR - | ERTS_SSI_AUX_WORK_THR_PRGR_LATER_OP); + | ERTS_SSI_AUX_WORK_DD_THR_PRGR); #ifdef ERTS_SMP aux_work_flags |= ERTS_SSI_AUX_WORK_DD; #endif @@ -2220,8 +2219,7 @@ setup_thr_debug_wait_completed(void *vproc) if (debug_wait_completed_flags & ERTS_DEBUG_WAIT_COMPLETED_TIMER_CANCELLATIONS) { wait_flags |= (ERTS_SSI_AUX_WORK_CNCLD_TMRS - | ERTS_SSI_AUX_WORK_CNCLD_TMRS_THR_PRGR - | ERTS_SSI_AUX_WORK_THR_PRGR_LATER_OP); + | ERTS_SSI_AUX_WORK_CNCLD_TMRS_THR_PRGR); #ifdef ERTS_SMP if (awdp->esdp && !ERTS_SCHEDULER_IS_DIRTY(awdp->esdp)) aux_work_flags |= ERTS_SSI_AUX_WORK_CNCLD_TMRS; @@ -2235,26 +2233,42 @@ setup_thr_debug_wait_completed(void *vproc) awdp->debug.wait_completed.arg = vproc; } -static void -prep_setup_thr_debug_wait_completed(void *vproc) +struct debug_lop { + ErtsThrPrgrLaterOp lop; + Process *proc; +}; + +static void later_thr_debug_wait_completed(void *vlop) { + struct debug_lop *lop = vlop; erts_aint32_t count = (erts_aint32_t) erts_no_schedulers; #ifdef ERTS_SMP count += 1; /* aux thread */ #endif if (erts_atomic32_dec_read_mb(&debug_wait_completed_count) == count) { - /* scheduler threads */ - erts_schedule_multi_misc_aux_work(0, - erts_no_schedulers, - setup_thr_debug_wait_completed, - vproc); + /* scheduler threads */ + erts_schedule_multi_misc_aux_work(0, + erts_no_schedulers, + setup_thr_debug_wait_completed, + lop->proc); #ifdef ERTS_SMP - /* aux_thread */ - erts_schedule_misc_aux_work(0, - setup_thr_debug_wait_completed, - vproc); + /* aux_thread */ + erts_schedule_misc_aux_work(0, + setup_thr_debug_wait_completed, + lop->proc); #endif } + erts_free(ERTS_ALC_T_DEBUG, lop); +} + + +static void +init_thr_debug_wait_completed(void *vproc) +{ + struct debug_lop* lop = erts_alloc(ERTS_ALC_T_DEBUG, + sizeof(struct debug_lop)); + lop->proc = vproc; + erts_schedule_thr_prgr_later_op(later_thr_debug_wait_completed, lop, &lop->lop); } @@ -2264,7 +2278,7 @@ erts_debug_wait_completed(Process *c_p, int flags) /* Only one process at a time can do this */ erts_aint32_t count = (erts_aint32_t) (2*erts_no_schedulers); #ifdef ERTS_SMP - count += 2; /* aux thread */ + count += 1; /* aux thread */ #endif if (0 == erts_atomic32_cmpxchg_mb(&debug_wait_completed_count, count, @@ -2272,17 +2286,12 @@ erts_debug_wait_completed(Process *c_p, int flags) debug_wait_completed_flags = flags; erts_suspend(c_p, ERTS_PROC_LOCK_MAIN, NULL); erts_proc_inc_refc(c_p); - /* scheduler threads */ + + /* First flush later-ops on all scheduler threads */ erts_schedule_multi_misc_aux_work(0, erts_no_schedulers, - prep_setup_thr_debug_wait_completed, + init_thr_debug_wait_completed, (void *) c_p); -#ifdef ERTS_SMP - /* aux_thread */ - erts_schedule_misc_aux_work(0, - prep_setup_thr_debug_wait_completed, - (void *) c_p); -#endif return 1; } return 0; diff --git a/lib/stdlib/test/ets_SUITE.erl b/lib/stdlib/test/ets_SUITE.erl index 678c225d25..fd0ff0e252 100644 --- a/lib/stdlib/test/ets_SUITE.erl +++ b/lib/stdlib/test/ets_SUITE.erl @@ -2497,9 +2497,10 @@ rename_unnamed_do(Opts) -> %% Rename a table with many fixations, and at the same time delete it. evil_rename(Config) when is_list(Config) -> - evil_rename_1(old_hash, new_hash, [public,named_table]), EtsMem = etsmem(), + evil_rename_1(old_hash, new_hash, [public,named_table]), evil_rename_1(old_tree, new_tree, [public,ordered_set,named_table]), + wait_for_test_procs(true), verify_etsmem(EtsMem). evil_rename_1(Old, New, Flags) -> @@ -2540,7 +2541,8 @@ crazy_fixtable_wait(N, Dracula) -> crazy_fixtable_1(0, _) -> ok; crazy_fixtable_1(N, Fun) -> - spawn_link(Fun), + %%FIXME my_spawn_link(Fun), + my_spawn_link(Fun), crazy_fixtable_1(N-1, Fun). evil_creater_destroyer() -> @@ -5752,10 +5754,11 @@ spawn_logger(Procs, FailedMemchecks) -> after 0 -> case Kill of true -> exit(Proc, kill); - _ -> ok + _ -> + erlang:display({"Waiting for 'DOWN' from", Proc, + process_info(Proc), + pid_status(Proc)}) end, - erlang:display({"Waiting for 'DOWN' from", Proc, - process_info(Proc), pid_status(Proc)}), receive {'DOWN', Mon, _, _, _} -> ok |