Skip to content

[WIP] Synchronize the update to heap_segment_committed and heap_segment_used with allocation #41950

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions src/coreclr/src/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9797,12 +9797,13 @@ void gc_heap::decommit_heap_segment_pages (heap_segment* seg,
if (size >= max ((extra_space + 2*OS_PAGE_SIZE), MIN_DECOMMIT_SIZE))
{
page_start += max(extra_space, 32*OS_PAGE_SIZE);
decommit_heap_segment_pages_worker (seg, page_start);
decommit_heap_segment_pages_worker (seg, page_start, true);
}
}

size_t gc_heap::decommit_heap_segment_pages_worker (heap_segment* seg,
uint8_t* new_committed)
uint8_t* new_committed,
bool synchronized)
{
assert (!use_large_pages_p);
uint8_t* page_start = align_on_page (new_committed);
Expand All @@ -9816,11 +9817,21 @@ size_t gc_heap::decommit_heap_segment_pages_worker (heap_segment* seg,
(size_t)page_start,
(size_t)(page_start + size),
size));
bool uoh_p = heap_segment_oh(seg) != gc_oh_num::soh;
GCSpinLock* msl = uoh_p ? &more_space_lock_uoh : &more_space_lock_soh;
if (!synchronized)
{
enter_spin_lock(msl);
}
heap_segment_committed (seg) = page_start;
if (heap_segment_used (seg) > heap_segment_committed (seg))
{
heap_segment_used (seg) = heap_segment_committed (seg);
}
if (!synchronized)
{
leave_spin_lock(msl);
}
}
else
{
Expand Down Expand Up @@ -32583,7 +32594,7 @@ size_t gc_heap::decommit_ephemeral_segment_pages_step ()

// figure out where the new committed should be
uint8_t* new_committed = (committed - decommit_size);
size_t size = decommit_heap_segment_pages_worker (ephemeral_heap_segment, new_committed);
size_t size = decommit_heap_segment_pages_worker (ephemeral_heap_segment, new_committed, false);

#ifdef _DEBUG
ephemeral_heap_segment->saved_committed = committed - size;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/src/gc/gcpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1708,7 +1708,7 @@ class gc_heap
PER_HEAP
size_t decommit_ephemeral_segment_pages_step ();
PER_HEAP
size_t decommit_heap_segment_pages_worker (heap_segment* seg, uint8_t *new_committed);
size_t decommit_heap_segment_pages_worker (heap_segment* seg, uint8_t *new_committed, bool synchronized);
PER_HEAP_ISOLATED
bool decommit_step ();
PER_HEAP
Expand Down