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; return XRayLogFlushStatus::XRAY_LOG_NOT_FLUSHING;
} }
s32 Result = XRayLogFlushStatus::XRAY_LOG_NOT_FLUSHING; if (atomic_exchange(&LogFlushStatus, XRayLogFlushStatus::XRAY_LOG_FLUSHING,
if (!atomic_compare_exchange_strong(&LogFlushStatus, &Result, memory_order_release) ==
XRayLogFlushStatus::XRAY_LOG_FLUSHING, XRayLogFlushStatus::XRAY_LOG_FLUSHING) {
memory_order_release)) {
if (Verbosity()) if (Verbosity())
Report("Not flushing log, implementation is still finalizing.\n"); Report("Not flushing log, implementation is still flushing.\n");
return static_cast<XRayLogFlushStatus>(Result); return XRayLogFlushStatus::XRAY_LOG_NOT_FLUSHING;
} }
if (BQ == nullptr) { if (BQ == nullptr) {

View File

@ -49,6 +49,7 @@ int main(int argc, char *argv[]) {
auto flush_status = __xray_log_flushLog(); auto flush_status = __xray_log_flushLog();
assert(flush_status == XRayLogFlushStatus::XRAY_LOG_FLUSHED); assert(flush_status == XRayLogFlushStatus::XRAY_LOG_FLUSHED);
for (auto trial = 0; trial < 3; trial++) {
// Without doing anything else, we should re-initialize. // Without doing anything else, we should re-initialize.
init_status = __xray_log_init_mode("xray-fdr", kConfig); init_status = __xray_log_init_mode("xray-fdr", kConfig);
assert(init_status == XRayLogInitStatus::XRAY_LOG_INITIALIZED); assert(init_status == XRayLogInitStatus::XRAY_LOG_INITIALIZED);
@ -64,6 +65,7 @@ int main(int argc, char *argv[]) {
// Once we're here, we should then flush. // Once we're here, we should then flush.
flush_status = __xray_log_flushLog(); flush_status = __xray_log_flushLog();
assert(flush_status == XRayLogFlushStatus::XRAY_LOG_FLUSHED); assert(flush_status == XRayLogFlushStatus::XRAY_LOG_FLUSHED);
}
// Finally, we should signal the sibling thread to stop. // Finally, we should signal the sibling thread to stop.
keep_going.clear(std::memory_order_release); keep_going.clear(std::memory_order_release);