diff options
author | Vladislav Khmelevsky <vladislav.khmelevskyi@huawei.com> | 2021-10-15 20:46:09 +0300 |
---|---|---|
committer | Maksim Panchenko <maks@fb.com> | 2021-10-15 20:46:09 +0300 |
commit | dcdd37fdc2ca2cc51b8671c828c5639e23d71d07 (patch) | |
tree | 9bf030cfb14f9446c0664e6d6f877a8b700beefe /bolt/runtime | |
parent | 2d431eefbf493b3bd7f88419ec39e28247de29a0 (diff) | |
download | llvm-dcdd37fdc2ca2cc51b8671c828c5639e23d71d07.tar.gz |
[PR] Instrumentation: Sync file on dump
Summary:
Sync the file with storage device on data dump to stabilize
instrumentation testing
Vladislav Khmelevsky,
Advanced Software Technology Lab, Huawei
(cherry picked from FBD31738021)
Diffstat (limited to 'bolt/runtime')
-rw-r--r-- | bolt/runtime/common.h | 10 | ||||
-rw-r--r-- | bolt/runtime/instr.cpp | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/bolt/runtime/common.h b/bolt/runtime/common.h index 2a312120d32e..19be0608495b 100644 --- a/bolt/runtime/common.h +++ b/bolt/runtime/common.h @@ -443,6 +443,16 @@ int __kill(uint64_t pid, int sig) { return ret; } +int __fsync(int fd) { + int ret; + __asm__ __volatile__("movq $74, %%rax\n" + "syscall\n" + : "=a"(ret) + : "D"(fd) + : "cc", "rcx", "r11", "memory"); + return ret; +} + #endif void reportError(const char *Msg, uint64_t Size) { diff --git a/bolt/runtime/instr.cpp b/bolt/runtime/instr.cpp index 7ff34409062f..21cf400bd64c 100644 --- a/bolt/runtime/instr.cpp +++ b/bolt/runtime/instr.cpp @@ -1485,6 +1485,7 @@ __bolt_instr_data_dump() { writeIndirectCallProfile(FD, Ctx); Ctx.CallFlowTable->forEachElement(visitCallFlowEntry, FD, &Ctx); + __fsync(FD); __close(FD); __munmap(Ctx.MMapPtr, Ctx.MMapSize); __close(Ctx.FileDesc); @@ -1509,6 +1510,7 @@ void watchProcess() { ppid = __getppid(); if (ppid == 1) { // Parent already dead + __bolt_instr_data_dump(); goto out; } } |