We had intended to guard the use of MINCORE_INCORE with tests for the
presence of the underlying function call, but we missed the hashsplit
tests.
Fix it by allowing the tests to pass in the mask value they already
depend on (i.e. 1).
Thanks to Michael March for reporting the problem, Patrick Rouleau for
confirming it, and Markus for proposing an alternate solution.
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
-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
"""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):
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 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)
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:
rstart, rlen = next(rpr, (None, None))
while 1:
if progress:
def nr_regions(x, max_count=None):
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():
@wvtest
def test_nonresident_page_regions():