count * sc_page_size)
-def _nonresident_page_regions(status_bytes, max_region_len=None):
+def _nonresident_page_regions(status_bytes, incore_mask, max_region_len=None):
"""Return (start_page, count) pairs in ascending start_page order for
each contiguous region of nonresident pages indicated by the
mincore() status_bytes. Limit the number of pages in each region
assert(max_region_len is None or max_region_len > 0)
start = None
for i, x in enumerate(status_bytes):
- in_core = x & helpers.MINCORE_INCORE
+ in_core = x & incore_mask
if start is None:
if not in_core:
start = i
if _fmincore and hasattr(f, 'fileno'):
fd = f.fileno()
max_chunk = max(1, (8 * 1024 * 1024) / sc_page_size)
- rpr = _nonresident_page_regions(_fmincore(fd), max_chunk)
+ rpr = _nonresident_page_regions(_fmincore(fd),
+ helpers.MINCORE_INCORE, max_chunk)
rstart, rlen = next(rpr, (None, None))
while 1:
if progress:
def nr_regions(x, max_count=None):
- return list(hashsplit._nonresident_page_regions(bytearray(x), max_count))
+ return list(hashsplit._nonresident_page_regions(bytearray(x), 1, max_count))
+
@wvtest
def test_nonresident_page_regions():