ruby-changes:59326
From: Aaron <ko1@a...>
Date: Thu, 19 Dec 2019 02:08:54 +0900 (JST)
Subject: [ruby-changes:59326] 1e88f6eb95 (master): Refactor free page insertion
https://git.ruby-lang.org/ruby.git/commit/?id=1e88f6eb95 From 1e88f6eb95672cae2b0628895a9ee9a5d384e048 Mon Sep 17 00:00:00 2001 From: Aaron Patterson <tenderlove@r...> Date: Tue, 17 Dec 2019 17:26:11 -0800 Subject: Refactor free page insertion I am trying to fix this error: http://ci.rvm.jp/results/trunk-gc_compact@silicon-docker/2491596 Somehow we have a page in the `free_pages` list that is full. This commit refactors the code so that any time we add a page to the `free_pages` list, we do it via `heap_add_freepage`. That function then asserts that the free slots on that page are not 0. diff --git a/gc.c b/gc.c index f868709..0f9361a 100644 --- a/gc.c +++ b/gc.c @@ -1710,9 +1710,10 @@ heap_page_add_freeobj(rb_objspace_t *objspace, struct heap_page *page, VALUE obj https://github.com/ruby/ruby/blob/trunk/gc.c#L1710 } static inline void -heap_add_freepage(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *page) +heap_add_freepage(rb_heap_t *heap, struct heap_page *page) { asan_unpoison_memory_region(&page->freelist, sizeof(RVALUE*), false); + GC_ASSERT(page->free_slots != 0); if (page->freelist) { page->free_next = heap->free_pages; heap->free_pages = page; @@ -1920,7 +1921,7 @@ heap_assign_page(rb_objspace_t *objspace, rb_heap_t *heap) https://github.com/ruby/ruby/blob/trunk/gc.c#L1921 { struct heap_page *page = heap_page_create(objspace); heap_add_page(objspace, heap, page); - heap_add_freepage(objspace, heap, page); + heap_add_freepage(heap, page); } static void @@ -4320,11 +4321,11 @@ gc_sweep_step(rb_objspace_t *objspace, rb_heap_t *heap) https://github.com/ruby/ruby/blob/trunk/gc.c#L4321 } } else { - heap_add_freepage(objspace, heap, sweep_page); + heap_add_freepage(heap, sweep_page); break; } #else - heap_add_freepage(objspace, heap, sweep_page); + heap_add_freepage(heap, sweep_page); break; #endif } @@ -6271,8 +6272,7 @@ heap_move_pooled_pages_to_free_pages(rb_heap_t *heap) https://github.com/ruby/ruby/blob/trunk/gc.c#L6272 if (page) { heap->pooled_pages = page->free_next; - page->free_next = heap->free_pages; - heap->free_pages = page; + heap_add_freepage(heap, page); } return page; @@ -8576,7 +8576,7 @@ gc_compact_after_gc(rb_objspace_t *objspace, int use_toward_empty, int use_doubl https://github.com/ruby/ruby/blob/trunk/gc.c#L8576 struct heap_page *page = NULL; list_for_each(&heap_eden->pages, page, page_node) { if (page->free_slots > 0) { - heap_add_freepage(objspace, heap_eden, page); + heap_add_freepage(heap_eden, page); } else { page->free_next = NULL; } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/