Skip to content

Commit

Permalink
[release-1.11] fix GC race bug in pool sweep
Browse files Browse the repository at this point in the history
  • Loading branch information
d-netto committed Aug 13, 2024
1 parent 34c3a63 commit b46f879
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ STATIC_INLINE void gc_dump_page_utilization_data(void) JL_NOTSAFEPOINT
}
}

int64_t buffered_pages = 0;
_Atomic(int64_t) buffered_pages = 0;

// Returns pointer to terminal pointer of list rooted at *pfl.
static void gc_sweep_page(gc_page_profiler_serializer_t *s, jl_gc_pool_t *p, jl_gc_page_stack_t *allocd, jl_gc_page_stack_t *buffered,
Expand Down Expand Up @@ -1461,8 +1461,8 @@ static void gc_sweep_page(gc_page_profiler_serializer_t *s, jl_gc_pool_t *p, jl_
// the eager one uses less memory.
// FIXME - need to do accounting on a per-thread basis
// on quick sweeps, keep a few pages empty but allocated for performance
if (!current_sweep_full && buffered_pages <= default_collect_interval / GC_PAGE_SZ) {
buffered_pages++;
if (!current_sweep_full && jl_atomic_load_relaxed(&buffered_pages) <= default_collect_interval / GC_PAGE_SZ) {
jl_atomic_fetch_add_relaxed(&buffered_pages, 1);
keep_as_local_buffer = 1;
}
#endif
Expand Down
1 change: 0 additions & 1 deletion src/gc.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ extern jl_gc_num_t gc_num;
extern bigval_t *big_objects_marked;
extern arraylist_t finalizer_list_marked;
extern arraylist_t to_finalize;
extern int64_t buffered_pages;
extern int gc_first_tid;
extern int gc_n_threads;
extern jl_ptls_t* gc_all_tls_states;
Expand Down

0 comments on commit b46f879

Please sign in to comment.