Skip to content
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

make SIP not on by default #73434

Merged
merged 2 commits into from
Aug 6, 2022
Merged
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
15 changes: 12 additions & 3 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2660,7 +2660,9 @@ bool gc_heap::use_large_pages_p = 0;
#ifdef HEAP_BALANCE_INSTRUMENTATION
size_t gc_heap::last_gc_end_time_us = 0;
#endif //HEAP_BALANCE_INSTRUMENTATION
#ifndef USE_REGIONS
#ifdef USE_REGIONS
bool gc_heap::enable_special_regions_p = false;
#else //USE_REGIONS
size_t gc_heap::min_segment_size = 0;
size_t gc_heap::min_uoh_segment_size = 0;
#endif //!USE_REGIONS
Expand Down Expand Up @@ -5622,7 +5624,6 @@ gc_heap::soh_get_segment_to_expand()
dprintf (GTC_LOG, ("(gen%d)creating new segment %Ix", settings.condemned_generation, result));
return result;
}
#endif //!USE_REGIONS

//returns 0 in case of allocation failure
heap_segment*
Expand Down Expand Up @@ -5768,6 +5769,7 @@ void gc_heap::release_segment (heap_segment* sg)
FIRE_EVENT(GCFreeSegment_V1, heap_segment_mem(sg));
virtual_free (sg, (uint8_t*)heap_segment_reserved (sg)-(uint8_t*)sg, sg);
}
#endif //!USE_REGIONS

heap_segment* gc_heap::get_segment_for_uoh (int gen_number, size_t size
#ifdef MULTIPLE_HEAPS
Expand Down Expand Up @@ -8886,6 +8888,7 @@ void gc_heap::set_fgm_result (failure_get_memory f, size_t s, BOOL loh_p)
#endif //MULTIPLE_HEAPS
}

#ifndef USE_REGIONS
//returns 0 for success, -1 otherwise
// We are doing all the decommitting here because we want to make sure we have
// enough memory to do so - if we do this during copy_brick_card_table and
Expand Down Expand Up @@ -9195,6 +9198,7 @@ int gc_heap::grow_brick_card_tables (uint8_t* start,

return 0;
}
#endif //!USE_REGIONS

//copy all of the arrays managed by the card table for a page aligned range
void gc_heap::copy_brick_card_range (uint8_t* la, uint32_t* old_card_table,
Expand Down Expand Up @@ -11146,7 +11150,6 @@ void gc_heap::clear_region_info (heap_segment* region)
}

// Note that returning a region to free does not decommit.
// REGIONS PERF TODO: should decommit if needed.
void gc_heap::return_free_region (heap_segment* region)
{
gc_oh_num oh = heap_segment_oh (region);
Expand Down Expand Up @@ -30797,6 +30800,11 @@ void gc_heap::update_start_tail_regions (generation* gen,
inline
bool gc_heap::should_sweep_in_plan (heap_segment* region)
{
if (!enable_special_regions_p)
{
return false;
}

if (settings.reason == reason_induced_aggressive)
{
return false;
Expand Down Expand Up @@ -44327,6 +44335,7 @@ HRESULT GCHeap::Initialize()
GCConfig::SetHeapCount(static_cast<int64_t>(nhp));

#ifdef USE_REGIONS
gc_heap::enable_special_regions_p = (bool)GCConfig::GetGCEnableSpecialRegions();
size_t gc_region_size = (size_t)GCConfig::GetGCRegionSize();
if (!power_of_two_p(gc_region_size) || ((gc_region_size * nhp * 19) > gc_heap::regions_range))
{
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/gc/gcconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class GCConfigStringHolder
INT_CONFIG (GCTotalPhysicalMemory, "GCTotalPhysicalMemory", NULL, 0, "Specifies what the GC should consider to be total physical memory") \
INT_CONFIG (GCRegionRange, "GCRegionRange", NULL, 0, "Specifies the range for the GC heap") \
INT_CONFIG (GCRegionSize, "GCRegionSize", NULL, 4194304, "Specifies the size for a basic GC region") \
INT_CONFIG (GCEnableSpecialRegions, "GCEnableSpecialRegions", NULL, 0, "Specifies to enable special handling some regions like SIP") \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we want to document this, or is it only for certain workloads we know would benefit from SIP?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for now it's just special workloads so I thought I'd leave it as an experimental thing (so not supported in runtimeconfig). we can decide whether to support in runtimeconmfig in the next release when we have experimented with it more. does that sound reasonable?

STRING_CONFIG(LogFile, "GCLogFile", NULL, "Specifies the name of the GC log file") \
STRING_CONFIG(ConfigLogFile, "GCConfigLogFile", NULL, "Specifies the name of the GC config log file") \
INT_CONFIG (BGCFLTuningEnabled, "BGCFLTuningEnabled", NULL, 0, "Enables FL tuning") \
Expand Down
17 changes: 10 additions & 7 deletions src/coreclr/gc/gcpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1596,24 +1596,24 @@ class gc_heap
static
void get_card_table_element_sizes (uint8_t* start, uint8_t* end, size_t bookkeeping_sizes[total_bookkeeping_elements]);

static
void set_fgm_result (failure_get_memory f, size_t s, BOOL loh_p);

#ifdef USE_REGIONS
static
bool on_used_changed (uint8_t* left);

static
bool inplace_commit_card_table (uint8_t* from, uint8_t* to);
#endif //USE_REGIONS

static
void set_fgm_result (failure_get_memory f, size_t s, BOOL loh_p);

#else //USE_REGIONS
static
int grow_brick_card_tables (uint8_t* start,
uint8_t* end,
size_t size,
heap_segment* new_seg,
gc_heap* hp,
BOOL loh_p);
#endif //USE_REGIONS

PER_HEAP_ISOLATED
BOOL is_mark_set (uint8_t* o);
Expand Down Expand Up @@ -2001,11 +2001,11 @@ class gc_heap
#ifndef USE_REGIONS
PER_HEAP
heap_segment* soh_get_segment_to_expand();
#endif //!USE_REGIONS
PER_HEAP
heap_segment* get_segment (size_t size, gc_oh_num oh);
PER_HEAP_ISOLATED
void release_segment (heap_segment* sg);
#endif //!USE_REGIONS
PER_HEAP_ISOLATED
void seg_mapping_table_add_segment (heap_segment* seg, gc_heap* hp);
PER_HEAP_ISOLATED
Expand Down Expand Up @@ -4040,7 +4040,10 @@ class gc_heap
size_t last_gc_end_time_us;
#endif //HEAP_BALANCE_INSTRUMENTATION

#ifndef USE_REGIONS
#ifdef USE_REGIONS
PER_HEAP_ISOLATED
bool enable_special_regions_p;
#else //USE_REGIONS
PER_HEAP_ISOLATED
size_t min_segment_size;

Expand Down