summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Hans Boehm <hboehm@google.com> 2022-08-23 11:05:42 -0700
committer Hans Boehm <hboehm@google.com> 2022-08-24 16:14:42 +0000
commite90c80308e402e3a3e71a0eb07be3b35e9b97a77 (patch)
tree7dbfb8c23c01f7466d1349beea0c4d6b12c9183b
parent0af80ada9195f6b3d18a2312eb69025d23a1765a (diff)
Remove misleading kPageSize dependency
Setting kChunkSize to kPageSize gave the misleading impression that the two are connected; they are not. Test: Boot AOSP with kChunkSize = 2048 Bug: 243105338 Change-Id: I3e0f61ea7d9e9398b2eaae61501df5997e849947
-rw-r--r--runtime/monitor_pool.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/runtime/monitor_pool.h b/runtime/monitor_pool.h
index e07aa9735f..133cde094d 100644
--- a/runtime/monitor_pool.h
+++ b/runtime/monitor_pool.h
@@ -189,12 +189,12 @@ class MonitorPool {
// Size of a monitor, rounded up to a multiple of alignment.
static constexpr size_t kAlignedMonitorSize = (sizeof(Monitor) + kMonitorAlignment - 1) &
-kMonitorAlignment;
- // As close to a page as we can get seems a good start.
- static constexpr size_t kChunkCapacity = kPageSize / kAlignedMonitorSize;
- // Chunk size that is referenced in the id. We can collapse this to the actually used storage
- // in a chunk, i.e., kChunkCapacity * kAlignedMonitorSize, but this will mean proper divisions.
- static constexpr size_t kChunkSize = kPageSize;
+ // Size of the chunks holding the actual monitors. The bottom bits of the monitor id are the
+ // index into such a chunk. We can collapse this to the actually used storage
+ // in a chunk, i.e., kChunkCapacity * kAlignedMonitorSize, but this would mean proper divisions.
+ static constexpr size_t kChunkSize = 4096;
static_assert(IsPowerOfTwo(kChunkSize), "kChunkSize must be power of 2");
+ static constexpr size_t kChunkCapacity = kChunkSize / kAlignedMonitorSize;
// The number of chunks of storage that can be referenced by the initial chunk list.
// The total number of usable monitor chunks is typically 255 times this number, so it
// should be large enough that we don't run out. We run out of address bits if it's > 512.
@@ -215,7 +215,7 @@ class MonitorPool {
// Array of pointers to lists (again arrays) of pointers to chunks containing monitors.
// Zeroth entry points to a list (array) of kInitialChunkStorage pointers to chunks.
// Each subsequent list as twice as large as the preceding one.
- // Monitor Ids are interpreted as follows:
+ // Monitor Ids are effectively interpreted as follows:
// Top 3 bits (of 28): index into monitor_chunks_.
// Next 16 bits: index into the chunk list, i.e. monitor_chunks_[i].
// Last 9 bits: offset within chunk, expressed as multiple of kMonitorAlignment.