From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDECFC433DF for ; Tue, 7 Jul 2020 14:50:03 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9D936206E2 for ; Tue, 7 Jul 2020 14:50:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="UO2uqGIf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9D936206E2 Authentication-Results: mail.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=amazon.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3767C8D0007; Tue, 7 Jul 2020 10:50:03 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 34D3E8D001D; Tue, 7 Jul 2020 10:50:03 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 26C578D0007; Tue, 7 Jul 2020 10:50:03 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 0E0BC8D0007 for ; Tue, 7 Jul 2020 10:50:03 -0400 (EDT) Received: from smtpin17.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 23865181AC217 for ; Tue, 7 Jul 2020 14:50:02 +0000 (UTC) X-FDA: 77011564644.17.sock54_18046a926eb5 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin17.hostedemail.com (Postfix) with ESMTP id 81844180D0199 for ; Tue, 7 Jul 2020 14:50:00 +0000 (UTC) X-HE-Tag: sock54_18046a926eb5 X-Filterd-Recvd-Size: 6791 Received: from smtp-fw-33001.amazon.com (smtp-fw-33001.amazon.com [207.171.190.10]) by imf36.hostedemail.com (Postfix) with ESMTP for ; Tue, 7 Jul 2020 14:49:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1594133400; x=1625669400; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=w1Wrf62e73x+SRZTs2supCzGH7vYA1IEmIfHRiOCQt8=; b=UO2uqGIfNtet/UThUdGH7vP4L+oM41GBfp+NYpgoCcpsKDz8tSwdst8G msWgROVI3dpuMQ4D7PTRqrYTa+6DVs4jDGccRtk0GE2N/RaajOGmJaXW/ 4ogCYZEydkUqYcd97ZQeV1fRttuGAL/Su2sLdeqck2np8UYKnHfXRXUM+ E=; IronPort-SDR: dpPcRpqQGrxcDDqD/s8tubFjQ0lYiq9WbUcEhqqEo5GcFzssdUy5czX4Y80KGJDUOWPSg7Iumi R8043BrqNdLA== X-IronPort-AV: E=Sophos;i="5.75,324,1589241600"; d="scan'208";a="56720496" Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-2b-c300ac87.us-west-2.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 07 Jul 2020 14:49:58 +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-c300ac87.us-west-2.amazon.com (Postfix) with ESMTPS id A847CA2266; Tue, 7 Jul 2020 14:49:56 +0000 (UTC) Received: from EX13D31EUA004.ant.amazon.com (10.43.165.161) by EX13MTAUEA002.ant.amazon.com (10.43.61.77) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 7 Jul 2020 14:49:56 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.161.214) by EX13D31EUA004.ant.amazon.com (10.43.165.161) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 7 Jul 2020 14:49:37 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC v5 09/11] tools/damon/record: Support physical memory monitoring Date: Tue, 7 Jul 2020 16:45:38 +0200 Message-ID: <20200707144540.21216-10-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200707144540.21216-1-sjpark@amazon.com> References: <20200707144540.21216-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.161.214] X-ClientProxiedBy: EX13D35UWC001.ant.amazon.com (10.43.162.197) To EX13D31EUA004.ant.amazon.com (10.43.165.161) X-Rspamd-Queue-Id: 81844180D0199 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam02 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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