Fix xray fdr mode to allow multiple flushes

Reviewed By: dberris

Differential Revision: https://reviews.llvm.org/D96382
This commit is contained in:
Todd Lipcon 2021-02-10 12:54:00 +11:00 committed by Dean Michael Berris
parent 483ec136da
commit 5dd29d9922
No known key found for this signature in database
GPG Key ID: 0463F512E8EF2E5B
2 changed files with 19 additions and 18 deletions

View File

@ -284,13 +284,12 @@ XRayLogFlushStatus fdrLoggingFlush() XRAY_NEVER_INSTRUMENT {
return XRayLogFlushStatus::XRAY_LOG_NOT_FLUSHING;
}
s32 Result = XRayLogFlushStatus::XRAY_LOG_NOT_FLUSHING;
if (!atomic_compare_exchange_strong(&LogFlushStatus, &Result,
XRayLogFlushStatus::XRAY_LOG_FLUSHING,
memory_order_release)) {
if (atomic_exchange(&LogFlushStatus, XRayLogFlushStatus::XRAY_LOG_FLUSHING,
memory_order_release) ==
XRayLogFlushStatus::XRAY_LOG_FLUSHING) {
if (Verbosity())
Report("Not flushing log, implementation is still finalizing.\n");
return static_cast<XRayLogFlushStatus>(Result);
Report("Not flushing log, implementation is still flushing.\n");
return XRayLogFlushStatus::XRAY_LOG_NOT_FLUSHING;
}
if (BQ == nullptr) {

View File

@ -49,21 +49,23 @@ int main(int argc, char *argv[]) {
auto flush_status = __xray_log_flushLog();
assert(flush_status == XRayLogFlushStatus::XRAY_LOG_FLUSHED);
// Without doing anything else, we should re-initialize.
init_status = __xray_log_init_mode("xray-fdr", kConfig);
assert(init_status == XRayLogInitStatus::XRAY_LOG_INITIALIZED);
for (auto trial = 0; trial < 3; trial++) {
// Without doing anything else, we should re-initialize.
init_status = __xray_log_init_mode("xray-fdr", kConfig);
assert(init_status == XRayLogInitStatus::XRAY_LOG_INITIALIZED);
// Then we spin for a bit again calling func() enough times.
for (auto i = 0; i < 1 << 20; ++i)
func();
// Then we spin for a bit again calling func() enough times.
for (auto i = 0; i < 1 << 20; ++i)
func();
// Then immediately finalize the implementation.
finalize_status = __xray_log_finalize();
assert(finalize_status == XRayLogInitStatus::XRAY_LOG_FINALIZED);
// Then immediately finalize the implementation.
finalize_status = __xray_log_finalize();
assert(finalize_status == XRayLogInitStatus::XRAY_LOG_FINALIZED);
// Once we're here, we should then flush.
flush_status = __xray_log_flushLog();
assert(flush_status == XRayLogFlushStatus::XRAY_LOG_FLUSHED);
// Once we're here, we should then flush.
flush_status = __xray_log_flushLog();
assert(flush_status == XRayLogFlushStatus::XRAY_LOG_FLUSHED);
}
// Finally, we should signal the sibling thread to stop.
keep_going.clear(std::memory_order_release);