@@ -27,6 +27,8 @@ def set_target(tid, init_regions=[]):
if not os.path.exists(debugfs_init_regions):
return 0
+ if tid == 'paddr':
+ tid = -1
string = ' '.join(['%s %d %d' % (tid, r[0], r[1]) for r in init_regions])
return subprocess.call('echo "%s" > %s' % (string, debugfs_init_regions),
shell=True, executable='/bin/bash')
@@ -101,6 +101,29 @@ def set_argparser(parser):
parser.add_argument('-o', '--out', metavar='<file path>', type=str,
default='damon.data', help='output file path')
+def default_paddr_region():
+ "Largest System RAM region becomes the default"
+ ret = []
+ with open('/proc/iomem', 'r') as f:
+ # example of the line: '100000000-42b201fff : System RAM'
+ for line in f:
+ fields = line.split(':')
+ if len(fields) != 2:
+ continue
+ name = fields[1].strip()
+ if name != 'System RAM':
+ continue
+ addrs = fields[0].split('-')
+ if len(addrs) != 2:
+ continue
+ start = int(addrs[0], 16)
+ end = int(addrs[1], 16)
+
+ sz_region = end - start
+ if not ret or sz_region > (ret[1] - ret[0]):
+ ret = [start, end]
+ return ret
+
def main(args=None):
global orig_attrs
if not args:
@@ -122,7 +145,11 @@ def main(args=None):
target = args.target
target_fields = target.split()
- if not subprocess.call('which %s &> /dev/null' % target_fields[0],
+ if target == 'paddr': # physical memory address space
+ if not init_regions:
+ init_regions = [default_paddr_region()]
+ do_record(target, False, init_regions, new_attrs, orig_attrs, pidfd)
+ elif not subprocess.call('which %s &> /dev/null' % target_fields[0],
shell=True, executable='/bin/bash'):
do_record(target, True, init_regions, new_attrs, orig_attrs, pidfd)
else: