Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp267237pxa; Wed, 5 Aug 2020 00:06:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzQdyFcUKBTV/GmL8DTgvjibB3PcGbRe3HF+QQnh/aYO1FgIiDHUxPSlL/jW/t2T2Nj2xrp X-Received: by 2002:a05:6402:12d7:: with SMTP id k23mr1512220edx.312.1596611185273; Wed, 05 Aug 2020 00:06:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596611185; cv=none; d=google.com; s=arc-20160816; b=sNzJUwnWGMtchMuZHeHNwaED+CSKRRVlfSpoLb1GFFR7xnRQQYB5lX4X9YWol4Gx8L jb1XmYy+MUYiZxwhlGgUquSbKu59CL+rIJMwJVJliTuhomZ7mfJEmvJzPfoXSBNRjbER MxIb5jXQiY09JK7jKt6eG4pQwzMQ2BGIlHeKZx37sdHr2EeHMshtN3kdi2f66KU8fsqj MjMGbuzXBgHl4NqFu0QGN8wJaGOg52p59TJZo5GH2H/Em7al3vv5ATVIyhnO7Y0IpJRN WMY6s2CnDb7O0aaqgdkMviYwci7hfiyPodhz5ZOg+b/pbHeG0Xn025grziNS0pz2OZjQ 4GMg== 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:ironport-sdr:dkim-signature; bh=SDTWTIuns68067ycCo53gHcSzqHDZT2Wd+5vAeZKPQU=; b=sdmx/RFUD27Lp8x/NsNzRL7aUuE6VVg5l05mkfvwR9Aqr8/RnUjJ+jVgkiQO1Rpht1 wK8UprcQVVwUhcoVk+TYv3mpMdS4fNdUy6co6lZIYlTmwnOX/ZJPvkJLWkZqGWLeInC6 BksIbkIHIvofbHRuBxeQPYmYOr7uuAdjE+PCloJZOKhpRUNK/fqGBab/iYdntXmy6o2M OOUQWyzvinxhOOoUnN5xjt7y/v7RH/9DsEhlA4y5JxZ7AYTZ0i0vXdUt12r0DRv0OziR xnz/QlQoqjbYzHrrp8eYbNmGPv/Bt3tFogaLjywnGrXove3wM7WJE3087mKG0X34UlCH hQ1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=IxZtwhvO; 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 a25si817105edn.30.2020.08.05.00.06.02; Wed, 05 Aug 2020 00:06:25 -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=IxZtwhvO; 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 S1728299AbgHEHDf (ORCPT + 99 others); Wed, 5 Aug 2020 03:03:35 -0400 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:59114 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726627AbgHEHDe (ORCPT ); Wed, 5 Aug 2020 03:03:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1596611013; x=1628147013; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=SDTWTIuns68067ycCo53gHcSzqHDZT2Wd+5vAeZKPQU=; b=IxZtwhvOWVZzMkISnuBrMjszsPeCA3nFrIndmZOsn63zcp1yKTym94ds UxrMlza8q0dqkpy4SZKCugWaapyYhQC1/rcKJOUoTNgIVQADUhFOqlMhF ave6fegdwkC8qrjOGRuVAR9Gqoz3nXqUfkWF4jwJDMiHJMQ7O65D4ZjWt o=; IronPort-SDR: QMK5LcNseUorcF1JmclcIFRIzUsIaWvOLOM2nbo82TSPlY9nSU46rYmZJAMzI2PNYZfQZFmL+T vevD+PezMdCQ== X-IronPort-AV: E=Sophos;i="5.75,436,1589241600"; d="scan'208";a="47558917" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-9ec21598.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 05 Aug 2020 07:03:32 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1d-9ec21598.us-east-1.amazon.com (Postfix) with ESMTPS id CBFA2A235B; Wed, 5 Aug 2020 07:03:29 +0000 (UTC) Received: from EX13D31EUA001.ant.amazon.com (10.43.165.15) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 5 Aug 2020 07:03:29 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.160.26) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 5 Aug 2020 07:03:12 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC v6 08/10] tools/damon/record: Support physical memory monitoring Date: Wed, 5 Aug 2020 08:59:49 +0200 Message-ID: <20200805065951.18221-9-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200805065951.18221-1-sjpark@amazon.com> References: <20200805065951.18221-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.160.26] X-ClientProxiedBy: EX13D24UWB002.ant.amazon.com (10.43.161.159) To EX13D31EUA001.ant.amazon.com (10.43.165.15) 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..cf14a0d59b94 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 = -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') 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