Received: by 2002:a05:6a10:6744:0:0:0:0 with SMTP id w4csp203553pxu; Wed, 7 Oct 2020 00:21:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwidyi9YEHQ2kIWYS0cuEHJ4DnMQkIEDM1aMvUGusuIj7qvhUKxDiVKQ6gm3JXYtrJ1qFry X-Received: by 2002:aa7:dada:: with SMTP id x26mr2097687eds.167.1602055286832; Wed, 07 Oct 2020 00:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602055286; cv=none; d=google.com; s=arc-20160816; b=lLyCDDrI0u641GSFvLTl4WAH0u30/uLVIMoVp3wYbfRaXfUdeiz8/RFOdBbZiqGOhe fIuvoDgc3p0qST+Q3b18Hko73YwobBtKzk4F0I+/8Wv9iaBUJaw9JYFyh5vYvEnw1VzF 5/EZjGRUmRacitrxz1TijxdrSrUVVG6bvbQHtUyo1pBdzku6SfGOydjOnBUqnxh6P5P2 AuU22HhypGgS89QtHDNGvySEmVUrZklKrXsarSdzuBDNbw+NFZuKxPpsU7/oLiMHHJ4t 3JDi7tjhGOP0Q4zX5BhUuA1/kNFTaaZssmOKmL9ChO5Fm0TJTR967Jy6OBBulRZCA9lu cyaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=kg6Pid/S3uyECtsR9/ZQNoRBSFk6tXHhc71xqlOp1H8=; b=mcyzvJQ+2dlB5e8Pi/3MVcuUg1jfMmMREvaLsWndlzR00JXrepQD2O8CbjtlLD/JgG I4HGReeAhGZ1z8m0innbA9lTZLWOqAUBsIcug/Vmc2HFXgDRPH7S5PavyeVHyEuDLm1y UxmW63qrshXQWL0rNxXjTs1WAlcxiwLbWkbH7SCsEgSJ5/zC2ynDA5hmkVLMWFlWnFGz vKkaoDYUNTneNkE8GEam1VLin4/TAfPfDCrunS3/vyjMlYpGj+jdepGx7Fz+eKrEI4/u N074MYOmG8he2iqH8H1kIfsNWJIe/YBKZDZFQYqpszvbBnnlnDkzgeSJNHAfD4rMf46r 2lVg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=EvdSLF4O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o25si934116edz.114.2020.10.07.00.21.04; Wed, 07 Oct 2020 00:21:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=EvdSLF4O; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amazon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727735AbgJGHRe (ORCPT + 99 others); Wed, 7 Oct 2020 03:17:34 -0400 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:48354 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726771AbgJGHRd (ORCPT ); Wed, 7 Oct 2020 03:17:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1602055052; x=1633591052; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=kg6Pid/S3uyECtsR9/ZQNoRBSFk6tXHhc71xqlOp1H8=; b=EvdSLF4OE51VlLKsOURHIYW5dXBE57FJxnoDTDlMD/ucWT9I8VS0j2bW hyo/G9isLM7wsm9U0bAX21/vwpsJ7nKrNWfgejbNk+zU/2dFKMF/OIR4i Zt8kL40CFiMzwHJrCbzeVO5e3abvDGDVbnk1pCbL74+qcng/DElNdfisx U=; X-IronPort-AV: E=Sophos;i="5.77,345,1596499200"; d="scan'208";a="59960978" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 07 Oct 2020 07:17:31 +0000 Received: from EX13D31EUA004.ant.amazon.com (iad12-ws-svc-p26-lb9-vlan3.iad.amazon.com [10.40.163.38]) by email-inbound-relay-1a-e34f1ddc.us-east-1.amazon.com (Postfix) with ESMTPS id DEE0BA0576; Wed, 7 Oct 2020 07:17:19 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.162.73) by EX13D31EUA004.ant.amazon.com (10.43.165.161) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 7 Oct 2020 07:17:03 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC v9 08/10] tools/damon/record: Support physical memory monitoring Date: Wed, 7 Oct 2020 09:14:07 +0200 Message-ID: <20201007071409.12174-9-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201007071409.12174-1-sjpark@amazon.com> References: <20201007071409.12174-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.162.73] X-ClientProxiedBy: EX13D31UWA003.ant.amazon.com (10.43.160.130) To EX13D31EUA004.ant.amazon.com (10.43.165.161) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: SeongJae Park This commit allows users to record the data accesses on physical memory address space by passing 'paddr' as target to 'damo-record'. If the init regions are given, the regions will be monitored. Else, it will monitor biggest conitguous 'System RAM' region in '/proc/iomem' and monitor the region. Signed-off-by: SeongJae Park --- tools/damon/_damon.py | 2 ++ tools/damon/record.py | 29 ++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/tools/damon/_damon.py b/tools/damon/_damon.py index a22ec3777c16..6ff278117e84 100644 --- a/tools/damon/_damon.py +++ b/tools/damon/_damon.py @@ -27,6 +27,8 @@ def set_target(tid, init_regions=[]): if not os.path.exists(debugfs_init_regions): return 0 + if tid == 'paddr': + tid = 42 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') diff --git a/tools/damon/record.py b/tools/damon/record.py index 11fd54001472..6fd0b59c73e0 100644 --- a/tools/damon/record.py +++ b/tools/damon/record.py @@ -101,6 +101,29 @@ def set_argparser(parser): parser.add_argument('-o', '--out', metavar='', 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: -- 2.17.1