Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp876966pxk; Mon, 31 Aug 2020 03:54:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyqt9MxvuZF+Vuy9RfQqOoWI5vZzJzDJtFThQI4rgHVoNyi6hJMUGi776xyw7UnMMBXm7wp X-Received: by 2002:a17:906:a88a:: with SMTP id ha10mr597425ejb.532.1598871249654; Mon, 31 Aug 2020 03:54:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598871249; cv=none; d=google.com; s=arc-20160816; b=nraWzucd66irEex7sWSglozoGYlo1M4XB6kQr1yLRwivwuvTeXJ2CtJUqCbD3HYF5h 1jdvMAXNjVh0ewn+lPh+1/ylMg3YZv1FCnvqN0vBPnAWVT12x4ejWERdflyXsPKuqagq z+wpOFEwPyxGoYQlyp9ozjRPJ/slHskBMA5l34iLA4/owSY6U+t1SS2j2cFC60OpFcN+ hDrphf7QXPZuVtuOzOmMNWMuI3JieC2DfNtR5HzjDOHzarsCJo1Y5yt53IPj98hotE0A cJlMNJ6DRMTC6SZyvAZoiz/SYX5LvhOE3x7gpWiOMASww8qBgd6q/HMvwDh0RSypFjOz Q9+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=kg6Pid/S3uyECtsR9/ZQNoRBSFk6tXHhc71xqlOp1H8=; b=rqjkVeVkGbhZFPOHn0UQztesZNoTLIX/FxoHL1q2dnEN25Qpi4YQKLI1y+JFgCMFgY YDg+nvrL6RaXCOrLO48ZPxT+TjchCizraWZw1ChXjfcc29SvfiXhkp8z8NfjEQ9IRfqG 2N1JaY1565TRCLwzDpAol2PCGbB5kLRJpKM9aU4aqmcaVZyyVDJK8Yy79jUrIt2o6bXp UnP/bhKOyxvpfl00gCDPnmuvi5vjEXJlmixW/l874mJA19iZJEbIKZmrrcxFj4o2OdKT hNUrrMuybGyuZg/uJmQ2eDPTeW7BbRdncHJA3dBjYLx+UnE65vHdVy6iPPRrLPWrLIqk tk/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b="JeJyRUy/"; 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 s19si5656493eja.499.2020.08.31.03.53.47; Mon, 31 Aug 2020 03:54:09 -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="JeJyRUy/"; 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 S1727065AbgHaKun (ORCPT + 99 others); Mon, 31 Aug 2020 06:50:43 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:60178 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727044AbgHaKu1 (ORCPT ); Mon, 31 Aug 2020 06:50:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1598871026; x=1630407026; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=kg6Pid/S3uyECtsR9/ZQNoRBSFk6tXHhc71xqlOp1H8=; b=JeJyRUy/pvC6OqcelFYbIutWq32kst6p67ZYSct1AMSqrbrTBopRcgH2 ODI/WBs/kQhMeEBiBLRhZbWO6IIvbxYZaO2ISA2F+n06LpOnHREp8Cd9n UyQgcwuiWJzXqEM+WQuKGB9u35GaX/gsEBrjTv78SvL6a6XgbNNg9K7jh 8=; X-IronPort-AV: E=Sophos;i="5.76,375,1592870400"; d="scan'208";a="71144314" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2b-a7fdc47a.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 31 Aug 2020 10:50:25 +0000 Received: from EX13D31EUB001.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2b-a7fdc47a.us-west-2.amazon.com (Postfix) with ESMTPS id 33366C06C5; Mon, 31 Aug 2020 10:50:23 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.160.100) by EX13D31EUB001.ant.amazon.com (10.43.166.210) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 31 Aug 2020 10:50:05 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC v8 08/10] tools/damon/record: Support physical memory monitoring Date: Mon, 31 Aug 2020 12:47:28 +0200 Message-ID: <20200831104730.28970-9-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200831104730.28970-1-sjpark@amazon.com> References: <20200831104730.28970-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.160.100] X-ClientProxiedBy: EX13D49UWB002.ant.amazon.com (10.43.163.68) To EX13D31EUB001.ant.amazon.com (10.43.166.210) Sender: linux-kernel-owner@vger.kernel.org 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