diff --git a/src/gc-stacks.c b/src/gc-stacks.c index c9d2b188f8836..2f6075b56b8ef 100644 --- a/src/gc-stacks.c +++ b/src/gc-stacks.c @@ -332,10 +332,6 @@ JL_DLLEXPORT jl_array_t *jl_live_tasks(void) size_t l = 0; // l is not reset on restart, so we keep getting more aggressive at making a big enough list everything it fails restart: for (size_t i = 0; i < nthreads; i++) { - // skip GC threads since they don't have tasks - if (gc_first_tid <= i && i < gc_first_tid + jl_n_gcthreads) { - continue; - } jl_ptls_t ptls2 = allstates[i]; if (ptls2 == NULL) continue; @@ -349,10 +345,6 @@ JL_DLLEXPORT jl_array_t *jl_live_tasks(void) allstates = jl_atomic_load_relaxed(&jl_all_tls_states); size_t j = 0; for (size_t i = 0; i < nthreads; i++) { - // skip GC threads since they don't have tasks - if (gc_first_tid <= i && i < gc_first_tid + jl_n_gcthreads) { - continue; - } jl_ptls_t ptls2 = allstates[i]; if (ptls2 == NULL) continue; diff --git a/src/gc.h b/src/gc.h index b49f81a5a0c5a..6ab1b4f816f2e 100644 --- a/src/gc.h +++ b/src/gc.h @@ -478,6 +478,16 @@ STATIC_INLINE int gc_is_parallel_collector_thread(int tid) JL_NOTSAFEPOINT return tid >= gc_first_tid && tid <= gc_last_parallel_collector_thread_id(); } +STATIC_INLINE int gc_is_concurrent_collector_thread(int tid) JL_NOTSAFEPOINT +{ + if (jl_n_sweepthreads == 0) { + return 0; + } + int last_parallel_collector_thread_id = gc_last_parallel_collector_thread_id(); + int concurrent_collector_thread_id = last_parallel_collector_thread_id + 1; + return tid == concurrent_collector_thread_id; +} + STATIC_INLINE int gc_random_parallel_collector_thread_id(jl_ptls_t ptls) JL_NOTSAFEPOINT { assert(jl_n_markthreads > 0); diff --git a/src/stackwalk.c b/src/stackwalk.c index 3dcb310c14d51..d6bed827e19ae 100644 --- a/src/stackwalk.c +++ b/src/stackwalk.c @@ -5,6 +5,7 @@ utilities for walking the stack and looking up information about code addresses */ #include +#include "gc.h" #include "julia.h" #include "julia_internal.h" #include "threading.h" @@ -1215,11 +1216,15 @@ JL_DLLEXPORT void jl_print_task_backtraces(int show_done) JL_NOTSAFEPOINT size_t nthreads = jl_atomic_load_acquire(&jl_n_threads); jl_ptls_t *allstates = jl_atomic_load_relaxed(&jl_all_tls_states); for (size_t i = 0; i < nthreads; i++) { - // skip GC threads since they don't have tasks - if (gc_first_tid <= i && i < gc_first_tid + jl_n_gcthreads) { + jl_ptls_t ptls2 = allstates[i]; + if (gc_is_parallel_collector_thread(i)) { + jl_safe_printf("==== Skipping backtrace for parallel GC thread %zu\n", i + 1); + continue; + } + if (gc_is_concurrent_collector_thread(i)) { + jl_safe_printf("==== Skipping backtrace for concurrent GC thread %zu\n", i + 1); continue; } - jl_ptls_t ptls2 = allstates[i]; if (ptls2 == NULL) { continue; }