<html><head><meta http-equiv="Content-Type" content="text/html; charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Hi Zequan,<div class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Jul 27, 2021, at 6:50 PM, Zequan Wu <<a href="mailto:zequanwu@google.com" class="">zequanwu@google.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Hi,<div class=""><br class=""></div><div class="">When merging is disabled, a possible solution is to unmap the mapped file region, copy the old profile file to the new file, and then mmap the CounterBegin to the new file region. Does this sound correct?</div></div></div></blockquote><div><br class=""></div><div>If the instrumented program is multithreaded, it might be possible for a thread to racily update a counter in the un-<span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class="">mmap'd region.</span></div><div><span style="caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);" class=""><br class=""></span></div><div><font color="#000000" class=""><span style="caret-color: rgb(0, 0, 0);" class="">Do you think it's viable to sidestep the issue by restricting how/when __llvm_profile_set_file_object can be called, e.g. either by documenting or requiring that no other threads are active at the time of the call?</span></font></div><div><br class=""></div><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="">When merging is enabled, multiple profile files will be created. I'm not sure how to set the file object in this case as only one file descriptor is passed to __llvm_profile_set_file_object.</div></div></div></blockquote><div><br class=""></div><div>Can you share how __llvm_profile_set_file_object(..., EnableMerge = true) works in non-continuous mode? It's not something I'm familiar with.</div><div><br class=""></div><div>thanks,</div><div>vedant</div></div></div></body></html>