PartitionDirectMap() unlocks PartitionRoot's lock for performance.
However EnableShadowMetadata() relies on PartitionRoot's lock. So
While running PartitionDirectMap() in some thread,
EnableShadowMetadata() may be run in another thread.
So PartitionDirectMap() metadata will be broken.
To avoid the issue, we added SharedMutex which works like
std::shared_mutex and used shared lock for PartitionDirectMap and
unique_lock for EnableShadowMetadata().
The reason why we don't use std::shared_mutex is that it allocates
memory. To avoid memory allocation while memory allocation, we
need another shared mutex implementation.
Bug: 378809882,40238514
Change-Id: Ib9588df6ba0c6b2782627e72c098ec533be3a606
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/6019975
Reviewed-by: Yuki Shiino <yukishiino@chromium.org>
Commit-Queue: Takashi Sakamoto <tasak@google.com>
Cr-Commit-Position: refs/heads/main@{#1385495}