Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2480936ybt; Tue, 16 Jun 2020 07:14:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywHQ3fkjq4J7bT5OEjaV5AQCZut+CUzfl5bGftzUkxK0mv2hU+EH8gMA9t4Q2zUKF2Dm42 X-Received: by 2002:a17:906:7e5a:: with SMTP id z26mr3123711ejr.263.1592316882405; Tue, 16 Jun 2020 07:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592316882; cv=none; d=google.com; s=arc-20160816; b=PIwHqRO/R9oo2GkRxOypIxw9Snbx9x1FbLq1Ev42nWJBG8NP6F1cNj4NmCaLUa/8co ayusaRizkRF0Idkk+lNcAyCLmgd3JFhYi9GxyM+gT1A0x2mFJKiajRgZDLGHVMyOhugu /UEewiKJBYHZvNC0lweFb3enk7wge28Ltsklj8DlqDB0831eawYsSD8dwZpir0CovSg5 dAlxI8ZdkAGaycHgGXrWsUYAeysObvbG6fditwxZs22SYglhE7FRwatr+YfaIye+vuCn kyZpdL8773jQFW0XxrxPvo1C+3CNkU//0xBDSagZoBb/1ViB2t2wnu9AB5eXMVM7ET+a 8QrQ== 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=yZsP+2MDDOAEhOHByG2L4aevktrrIinncvOO9W1OMx9DzeTE2m3WC/8jUIMALXUhl3 0JbNf+BWSEbbEXYJi5lUWYXGlvLb0IbB7ps8gXT0K2Ur8M21CXrOLE7HLRzJx4vwyngG NULkVlcHBnUWPyXqC6dr9QOsjMfm48LlApShtEaIm0z2e9unvXO+amQCicSz3N1JAwOz kQznvggg0xx8/g7MWWXqAoQvU/C3P0MUZhwrzT/puz11fbi6Pmld3CC+ekneJT9l4Bqw 8Z2HKwnvOqWIScPW4woOg6cYZ51LNI+Aj5zS7jC0c88qh+EjgGPuTJOyKJwuUEZ6sWSv pZSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=U+XMYBKk; 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 u5si10294988ejz.120.2020.06.16.07.14.19; Tue, 16 Jun 2020 07:14:42 -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=U+XMYBKk; 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 S1729389AbgFPOM2 (ORCPT + 99 others); Tue, 16 Jun 2020 10:12:28 -0400 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]:43387 "EHLO smtp-fw-33001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726606AbgFPOM0 (ORCPT ); Tue, 16 Jun 2020 10:12:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1592316745; x=1623852745; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=w1Wrf62e73x+SRZTs2supCzGH7vYA1IEmIfHRiOCQt8=; b=U+XMYBKkQxWtMChQYipgYhNytgEWZ/EBfACBwNB/Bad40dvu7Wpqby15 gAr+Z+LinTR0RRrzHw7lfVyFTICBJHD7cFP3+Vlx2YZyg0WsT4cwkVKvm dYwK16HEMe8/NUk3T2T0Md81i2tLLnSbSgmJMaRlBI3r+o1DxDrSf0qbE g=; IronPort-SDR: Q7vc99IXsCqljdqDle+7g6R/Hu+R7fF3+WAAXICsYy4e3/KZpWColZqgNokHRGLbDyKGPSQQW/ BKv5fjpf3ILQ== X-IronPort-AV: E=Sophos;i="5.73,518,1583193600"; d="scan'208";a="51356971" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2b-859fe132.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 16 Jun 2020 14:12:23 +0000 Received: from EX13MTAUEA002.ant.amazon.com (pdx4-ws-svc-p6-lb7-vlan2.pdx.amazon.com [10.170.41.162]) by email-inbound-relay-2b-859fe132.us-west-2.amazon.com (Postfix) with ESMTPS id 922C12218D4; Tue, 16 Jun 2020 14:12:20 +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, 16 Jun 2020 14:12:20 +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, 16 Jun 2020 14:11:52 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC v4 7/8] tools/damon/record: Support physical memory address spce Date: Tue, 16 Jun 2020 16:08:12 +0200 Message-ID: <20200616140813.17863-8-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200616140813.17863-1-sjpark@amazon.com> References: <20200616140813.17863-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.162.109] X-ClientProxiedBy: EX13D01UWB004.ant.amazon.com (10.43.161.157) 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