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
diff --git a/runtime/monitor_pool.h b/runtime/monitor_pool.h
index e07aa97..133cde0 100644
--- a/runtime/monitor_pool.h
+++ b/runtime/monitor_pool.h
@@ -189,12 +189,12 @@
// 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 @@
// 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.