def test_nr_regions(real_nr_regions, min_nr_regions, max_nr_regions): '''
Create process of the given 'real_nr_regions' regions, monitor it using
DAMON with given '{min,max}_nr_regions' monitoring parameter.
Exit with non-zero return code if the given {min,max}_nr_regions isnot
kept. '''
sz_region = 10 * 1024 * 1024
proc = subprocess.Popen(['./access_memory_even', '%d' % real_nr_regions, '%d' % sz_region])
# stat every monitored regions
kdamonds = _damon_sysfs.Kdamonds([_damon_sysfs.Kdamond(
contexts=[_damon_sysfs.DamonCtx(
monitoring_attrs=_damon_sysfs.DamonAttrs(
min_nr_regions=min_nr_regions,
max_nr_regions=max_nr_regions),
ops='vaddr',
targets=[_damon_sysfs.DamonTarget(pid=proc.pid)],
schemes=[_damon_sysfs.Damos(action='stat',
)] # schemes
)] # contexts
)]) # kdamonds
collected_nr_regions = [] while proc.poll() isNone:
time.sleep(0.1)
err = kdamonds.kdamonds[0].update_schemes_tried_regions() if err isnotNone:
proc.terminate()
print('tried regions update failed: %s' % err)
exit(1)
scheme = kdamonds.kdamonds[0].contexts[0].schemes[0] if scheme.tried_regions isNone:
proc.terminate()
print('tried regions is not collected')
exit(1)
nr_tried_regions = len(scheme.tried_regions) if nr_tried_regions <= 0:
proc.terminate()
print('tried regions is not created')
exit(1)
collected_nr_regions.append(nr_tried_regions) if len(collected_nr_regions) > 10: break
proc.terminate()
kdamonds.stop()
test_name = 'nr_regions test with %d/%d/%d real/min/max nr_regions' % (
real_nr_regions, min_nr_regions, max_nr_regions)
collected_nr_regions.sort() if (collected_nr_regions[0] < min_nr_regions or
collected_nr_regions[-1] > max_nr_regions):
print('fail %s' % test_name)
print('number of regions that collected are:') for nr in collected_nr_regions:
print(nr)
exit(1)
print('pass %s ' % test_name)
def main(): # test min_nr_regions larger than real nr regions
test_nr_regions(10, 20, 100)
# test max_nr_regions smaller than real nr regions
test_nr_regions(15, 3, 10)
# test online-tuned max_nr_regions that smaller than real nr regions
sz_region = 10 * 1024 * 1024
proc = subprocess.Popen(['./access_memory_even', '14', '%d' % sz_region])
# stat every monitored regions
kdamonds = _damon_sysfs.Kdamonds([_damon_sysfs.Kdamond(
contexts=[_damon_sysfs.DamonCtx(
monitoring_attrs=_damon_sysfs.DamonAttrs(
min_nr_regions=10, max_nr_regions=1000),
ops='vaddr',
targets=[_damon_sysfs.DamonTarget(pid=proc.pid)],
schemes=[_damon_sysfs.Damos(action='stat',
)] # schemes
)] # contexts
)]) # kdamonds
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.