[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)
This commit is contained in:
Vladislav Khmelevsky 2021-10-15 20:46:09 +03:00 committed by Maksim Panchenko
parent 2d431eefbf
commit dcdd37fdc2
2 changed files with 12 additions and 0 deletions

View file

@ -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) {

View file

@ -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;
}
}