Skip to content
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
19 changes: 11 additions & 8 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26685,16 +26685,19 @@ void gc_heap::add_to_hc_history_worker (hc_history* hist, int* current_index, hc
current_hist->concurrent_p = (bool)settings.concurrent;
current_hist->bgc_thread_running = (bool)bgc_thread_running;

#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS) && !defined(_DEBUG)
int bgc_thread_os_id = 0;

if (bgc_thread)
#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS) && !defined(_DEBUG) && !defined(FEATURE_NATIVEAOT)
if (GCConfig::GetGCLogBGCThreadId())
{
bgc_thread_os_id = (int)(*(size_t*)((uint8_t*)bgc_thread + 0x130));
}
int bgc_thread_os_id = 0;
Copy link
Member

Choose a reason for hiding this comment

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

This magic 0x130 constant is going to break in number of different scenarios. For example, mix and match standalone GC scenarios are going to break too.

How long do we expect to keep it?

Copy link
Member

Choose a reason for hiding this comment

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

I'm planning to make this into a GCToEEInterface call in main and possibly backport to 9.0 in a servicing release.

Copy link
Member

Choose a reason for hiding this comment

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

I think we should do the proper change now.

Copy link
Member

Choose a reason for hiding this comment

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

I'm only intending to use this with 9.0 so I'm fine not supporting mix/match standalone GC. other than coreclr actually changing the Thread object, how else can this break?

Copy link
Member Author

Choose a reason for hiding this comment

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

should we also consider instrumenting under a special config?

Copy link
Member

Choose a reason for hiding this comment

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

yep, we can put this under a config.

Copy link
Member Author

Choose a reason for hiding this comment

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

ok I can add that, just this piece or the entire instrumentation change?

Copy link
Member

Choose a reason for hiding this comment

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

I would only do the config for this. thanks!

Copy link
Member Author

Choose a reason for hiding this comment

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

added a config check for it.

Copy link
Member

Choose a reason for hiding this comment

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

LGTM.


if (bgc_thread)
{
bgc_thread_os_id = (int)(*(size_t*)((uint8_t*)bgc_thread + 0x130));
}

current_hist->bgc_thread_os_id = bgc_thread_os_id;
#endif //TARGET_AMD64 && TARGET_WINDOWS && !_DEBUG
current_hist->bgc_thread_os_id = bgc_thread_os_id;
}
#endif //TARGET_AMD64 && TARGET_WINDOWS && !_DEBUG && !FEATURE_NATIVEAOT
#endif //BACKGROUND_GC

*current_index = (*current_index + 1) % max_hc_history_count;
Expand Down
5 changes: 4 additions & 1 deletion src/coreclr/gc/gcconfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@ class GCConfigStringHolder
STRING_CONFIG(GCPath, "GCPath", "System.GC.Path", "Specifies the path of the standalone GC implementation.") \
INT_CONFIG (GCSpinCountUnit, "GCSpinCountUnit", NULL, 0, "Specifies the spin count unit used by the GC.") \
INT_CONFIG (GCDynamicAdaptationMode, "GCDynamicAdaptationMode", "System.GC.DynamicAdaptationMode", 1, "Enable the GC to dynamically adapt to application sizes.") \
INT_CONFIG (GCDTargetTCP, "GCDTargetTCP", "System.GC.DTargetTCP", 0, "Specifies the target tcp for DATAS")
INT_CONFIG (GCDTargetTCP, "GCDTargetTCP", "System.GC.DTargetTCP", 0, "Specifies the target tcp for DATAS") \
BOOL_CONFIG (GCLogBGCThreadId, "GCLogBGCThreadId", NULL, false, "Specifies if BGC ThreadId should be logged")


// This class is responsible for retreiving configuration information
// for how the GC should operate.
class GCConfig
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/gc/gcpriv.h
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ struct hc_history
// invalid fields on the Thread object such as m_OSThreadId. This is to help with debugging that problem so I
// only enable it for retail builds on Windows. We can extend this with a GCToEEInterface interface method to get the offset
// of that particular field on the Thread object.
#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS) && !defined(_DEBUG)
#if defined(TARGET_AMD64) && defined(TARGET_WINDOWS) && !defined(_DEBUG) && !defined(FEATURE_NATIVEAOT)
int bgc_thread_os_id;
#endif
short bgc_t_join_join_lock;
Expand Down