[BOLT][Instrumentation] Put Allocator itslef in shared memory by default
authorDenis Revunov <revunov.denis@huawei-partners.com>
Tue, 20 Jun 2023 15:00:36 +0000 (15:00 +0000)
committerDenis Revunov <rnovds@gmail.com>
Thu, 29 Jun 2023 22:03:52 +0000 (01:03 +0300)
commitad4e0770ca7ebbc4dd6635b17421819b2393aa33
treea67b66eda0a03d9416844ac59bd47cc1d58aba3e
parent02c3724d43840339fdc91d21747e96b5f7405bb0
[BOLT][Instrumentation] Put Allocator itslef in shared memory by default

In absence of instrumentation-file-append-pid option,
global allocator uses shared pages for allocation. However, since it is a
global variable, it gets COW'd after fork if instrumentation-sleep-time
is used, or if a process forks by itself. This means it handles the same
pages to every process which causes hash table corruption. Thus, if we
want shared pages, we need to put the allocator itself in a shared page,
which we do in this commit in __bolt_instr_setup.
I also added a couple of assertions to sanity-check the hash table.

Reviewed By: rafauler, Amir
Differential Revision: https://reviews.llvm.org/D153771
bolt/runtime/instr.cpp