[PATCH] D153771: [BOLT][Instrumentation] Fix hash table memory corruption and append-pid option
Denis Revunov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 29 15:05:26 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rG02c3724d4384: [BOLT][Instrumentation] Don't share counters when using append-pid (authored by treapster).
Changed prior to commit:
https://reviews.llvm.org/D153771?vs=535701&id=536017#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153771/new/
https://reviews.llvm.org/D153771
Files:
bolt/runtime/instr.cpp
Index: bolt/runtime/instr.cpp
===================================================================
--- bolt/runtime/instr.cpp
+++ bolt/runtime/instr.cpp
@@ -1541,6 +1541,9 @@
/// Initialization code
extern "C" void __attribute((force_align_arg_pointer)) __bolt_instr_setup() {
+ __bolt_ind_call_counter_func_pointer = __bolt_instr_indirect_call;
+ __bolt_ind_tailcall_counter_func_pointer = __bolt_instr_indirect_tailcall;
+
const uint64_t CountersStart =
reinterpret_cast<uint64_t>(&__bolt_instr_locations[0]);
const uint64_t CountersEnd = alignTo(
@@ -1548,18 +1551,19 @@
0x1000);
DEBUG(reportNumber("replace mmap start: ", CountersStart, 16));
DEBUG(reportNumber("replace mmap stop: ", CountersEnd, 16));
- assert (CountersEnd > CountersStart, "no counters");
- // Maps our counters to be shared instead of private, so we keep counting for
- // forked processes
+ assert(CountersEnd > CountersStart, "no counters");
+
+ const bool Shared = !__bolt_instr_use_pid;
+ const uint64_t MapPrivateOrShared = Shared ? MAP_SHARED : MAP_PRIVATE;
+
void *Ret =
__mmap(CountersStart, CountersEnd - CountersStart, PROT_READ | PROT_WRITE,
- MAP_ANONYMOUS | MAP_SHARED | MAP_FIXED, -1, 0);
+ MAP_ANONYMOUS | MapPrivateOrShared | MAP_FIXED, -1, 0);
assert(Ret != MAP_FAILED, "__bolt_instr_setup: Failed to mmap counters!");
- __bolt_ind_call_counter_func_pointer = __bolt_instr_indirect_call;
- __bolt_ind_tailcall_counter_func_pointer = __bolt_instr_indirect_tailcall;
+
// Conservatively reserve 100MiB shared pages
GlobalAlloc.setMaxSize(0x6400000);
- GlobalAlloc.setShared(true);
+ GlobalAlloc.setShared(Shared);
GlobalWriteProfileMutex = new (GlobalAlloc, 0) Mutex();
if (__bolt_instr_num_ind_calls > 0)
GlobalIndCallCounters =
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153771.536017.patch
Type: text/x-patch
Size: 1815 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230629/5e1de2c6/attachment-0001.bin>
More information about the llvm-commits
mailing list