public final class MonotonePageResource extends PageResource
Modifier and Type | Field and Description |
---|---|
private static int |
CONCURRENT_ZEROING_BLOCKSIZE |
private Address |
currentChunk |
private Address |
cursor |
private int |
metaDataPagesPerRegion |
private Address |
sentinel |
private Address |
zeroingCursor |
private Address |
zeroingSentinel |
committed, contiguous, reserved, space, start, zeroConcurrent, zeroingContext, zeroNT
Constructor and Description |
---|
MonotonePageResource(Space space,
Address start,
Extent bytes,
int metaDataPagesPerRegion)
Constructor
Contiguous monotone resource.
|
MonotonePageResource(Space space,
int metaDataPagesPerRegion)
Constructor
Discontiguous monotone resource.
|
Modifier and Type | Method and Description |
---|---|
int |
adjustForMetaData(int pages)
Adjust a page request to include metadata requirements for a request
of the given size.
|
int |
adjustForMetaData(int pages,
Address begin)
Adjust a page request to include metadata requirements, if any.
|
protected Address |
allocPages(int reservedPages,
int requiredPages,
boolean zeroed)
Allocate
pages pages from this resource. |
void |
concurrentZeroing()
The entry point for the concurrent zeroing context.
|
int |
getAvailablePhysicalPages()
Return the number of available physical pages for this resource.
|
private static Address |
getRegionStart(Address addr) |
private boolean |
moveToNextChunk()
Adjust the currentChunk and cursor fields to point to the next chunk
in the linked list of chunks tied down by this page resource.
|
private void |
releasePages()
Release all pages associated with this page resource, optionally
zeroing on release and optionally memory protecting on release.
|
private void |
releasePages(Address first,
Extent bytes)
Releases a range of pages associated with this page resource, optionally
zeroing on release and optionally memory protecting on release.
|
void |
reset()
Reset this page resource, freeing all pages and resetting
reserved and committed pages appropriately.
|
void |
reusePages(int pages)
Notify that previously unused pages are in use again.
|
void |
unusePages(int pages)
Notify that several pages are no longer in use.
|
clearRequest, commitPages, committedPages, cumulativeCommittedPages, getNewPages, lock, reservedPages, reservePages, skipConcurrentZeroing, triggerConcurrentZeroing, unlock, updateZeroingApproach
private final int metaDataPagesPerRegion
private Address currentChunk
private volatile Address zeroingCursor
private Address zeroingSentinel
private static int CONCURRENT_ZEROING_BLOCKSIZE
public MonotonePageResource(Space space, Address start, Extent bytes, int metaDataPagesPerRegion)
space
- The space to which this resource is attachedstart
- The start of the address range allocated to this resourcebytes
- The size of the address rage allocated to this resourcemetaDataPagesPerRegion
- The number of pages of meta data
that are embedded in each region.public MonotonePageResource(Space space, int metaDataPagesPerRegion)
space
- The space to which this resource is attachedmetaDataPagesPerRegion
- The number of pages of meta data
that are embedded in each region.public int getAvailablePhysicalPages()
PageResource
Note: This just considers physical pages (ie virtual memory pages allocated for use by this resource). This calculation is orthogonal to and does not consider any restrictions on the number of pages this resource may actually use at any time (ie the number of committed and reserved pages).
Note: The calculation is made on the assumption that all space that could be assigned to this resource would be assigned to this resource (ie the unused discontiguous space could just as likely be assigned to another competing resource).
getAvailablePhysicalPages
in class PageResource
protected Address allocPages(int reservedPages, int requiredPages, boolean zeroed)
pages
pages from this resource. Simply
bump the cursor, and fail if we hit the sentinel.If the request can be satisfied, then ensure the pages are mmpapped and zeroed before returning the address of the start of the region. If the request cannot be satisfied, return zero.
allocPages
in class PageResource
reservedPages
- The number of pages reserved due to the initial request.requiredPages
- The number of pages required to be allocated.public int adjustForMetaData(int pages)
In this case we simply report the expected page cost. We can't use worst case here because we would exhaust our budget every time.
adjustForMetaData
in class PageResource
pages
- The size of the pending allocation in pagespublic int adjustForMetaData(int pages, Address begin)
Note that there could be a race here, with multiple threads each adjusting their request on account of the same single metadata region. This should not be harmful, as the failing requests will just retry, and if multiple requests succeed, only one of them will actually have the metadata accounted against it, the others will simply have more space than they originally requested.
pages
- The size of the pending allocation in pagesbegin
- The start address of the region assigned to this pending
requestprivate static Address getRegionStart(Address addr)
public void reset()
public void unusePages(int pages)
pages
- The number of pagespublic void reusePages(int pages)
pages
- The number of pagesprivate void releasePages()
private boolean moveToNextChunk()
true
if we moved to the next chunk; false
if we hit the
end of the linked list.private void releasePages(Address first, Extent bytes)
first
- start address of memory to be releasedbytes
- number of bytes in the memory regionpublic void concurrentZeroing()
PageResource
concurrentZeroing
in class PageResource