Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp563390ybg; Tue, 9 Jun 2020 07:26:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz6z6R6F1gHvxZmTjttM8K4pF1Jd/cfmCmf8V4gLA09BHWOJaEj8K37+mX3C0stUt3TRx5F X-Received: by 2002:a05:6402:1a48:: with SMTP id bf8mr27575775edb.133.1591712812923; Tue, 09 Jun 2020 07:26:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591712812; cv=none; d=google.com; s=arc-20160816; b=LCdoRxhbiIQMfI/LDzmJGNwtAzZLoHmE4AR38JhGu+rNbGZrtsH4YACl5vbrV/27rB yn1KPXx7RNumVfUsjdhNQXhEU8ClI+aQsz/6EtRTInwtAREf6uXjUOS56tczVtI3VDwg ZRPdsfhB+/YV3uRN1ke9d3rKb6adg9OsZJfscc2ls4VtRSLQ+npsJz6Ka6uOwJcYovhT Mza04j+kTeCqdt0cxclQ93oKdDjc2RPra4ecej1sUDGPuu2euzFY3gLggjFTSDbC/xBy HaTQx+BqcfKvFv1C/wyLbWMT2E+6aZ6C5t7aat3KKZcG7kTGW1fyUvGH3PuQ3+xb7Svt dQmg== 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=w1Wrf62e73x+SRZTs2supCzGH7vYA1IEmIfHRiOCQt8=; b=xfJ/L+zM+eb1+NS9+KObBbEmoqIuH0hwieIiYwaX2AMZGL90FMqKlgTBoBlmuJr+8Z /tZlTfoukz5HObuS07FWdFZT12VMR9dLYgA2Dxf8AHplQSME6osOwbiModI6GRPta0jz r8YpnhTvM2apRV3dOZV2phn0rSCarzD4nul830zfK5vnun6hPq7lb6IK9NH2LvgvspaS wWpAcbTUPWVM18fjpbjGcP6H6AtK+mTjdAbuCAnmGhlV5lOPWtZMcywSgM4dlSHEMBxA rvaAnl7ZFP8cwAA9DhLnBj9MOEucglFn7HJDYNwtBIZzLoydjYMs+JsLBiHExI6jDBhe zbPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=s09lguO8; 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 bz17si10128246ejc.605.2020.06.09.07.26.30; Tue, 09 Jun 2020 07:26:52 -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=s09lguO8; 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 S1730537AbgFIOXg (ORCPT + 99 others); Tue, 9 Jun 2020 10:23:36 -0400 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:27021 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726967AbgFIOXf (ORCPT ); Tue, 9 Jun 2020 10:23:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1591712615; x=1623248615; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=w1Wrf62e73x+SRZTs2supCzGH7vYA1IEmIfHRiOCQt8=; b=s09lguO8/CV9QmhetNrma+OCcpkLC/Pto/35Me9yrnmWNzIvObopueNU s+NZO0tVpNbgDw7G5K6LEI32/KNg7StO5a/OwMESXE4Zyke4SSRMfD9lr ydhTdUgFYbfXHp+qISWRQcZO45lNcGhg3Pg+fjLt/pCuZ1YvCqhfDiqyU A=; IronPort-SDR: yJ7f98cY7UglrbJx40+DWO+UzQVdRhy7f7KWtH9D9Rg24eKV+ctgu91IcWa8GI4Pz9O/5wsC1Z CiDYOvc2lKQg== X-IronPort-AV: E=Sophos;i="5.73,492,1583193600"; d="scan'208";a="36626381" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1d-38ae4ad2.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 09 Jun 2020 14:23:34 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan3.iad.amazon.com [10.40.159.166]) by email-inbound-relay-1d-38ae4ad2.us-east-1.amazon.com (Postfix) with ESMTPS id F364BA2600; Tue, 9 Jun 2020 14:23:22 +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; Tue, 9 Jun 2020 14:23:22 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.162.109) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 9 Jun 2020 14:23:05 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC v3 09/10] tools/damon/record: Support physical memory address spce Date: Tue, 9 Jun 2020 16:19:40 +0200 Message-ID: <20200609141941.19184-10-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200609141941.19184-1-sjpark@amazon.com> References: <20200609141941.19184-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.162.109] X-ClientProxiedBy: EX13D30UWC004.ant.amazon.com (10.43.162.4) 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/heats.py | 2 +- tools/damon/record.py | 29 ++++++++++++++++++++++++++++- 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/tools/damon/_damon.py b/tools/damon/_damon.py index ad476cc61421..95d23c2ab6ee 100644 --- a/tools/damon/_damon.py +++ b/tools/damon/_damon.py @@ -27,6 +27,8 @@ def set_target(pid, init_regions=[]): if not os.path.exists(debugfs_init_regions): return 0 + if pid == 'paddr': + pid = -1 string = ' '.join(['%s %d %d' % (pid, 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/heats.py b/tools/damon/heats.py index 99837083874e..34dbcf1a839d 100644 --- a/tools/damon/heats.py +++ b/tools/damon/heats.py @@ -307,7 +307,7 @@ def plot_heatmap(data_file, output_file): set xrange [0:]; set yrange [0:]; set xlabel 'Time (ns)'; - set ylabel 'Virtual Address (bytes)'; + set ylabel 'Address (bytes)'; plot '%s' using 1:2:3 with image;""" % (terminal, output_file, data_file) subprocess.call(['gnuplot', '-e', gnuplot_cmd]) os.remove(data_file) diff --git a/tools/damon/record.py b/tools/damon/record.py index 6ce8721d782a..416dca940c1d 100644 --- a/tools/damon/record.py +++ b/tools/damon/record.py @@ -73,6 +73,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: @@ -93,7 +116,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) + 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) else: -- 2.17.1