Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp459030pxb; Wed, 24 Feb 2021 06:46:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJzr7kq5aNkWcal718sfSCY24uA4Jv06H4FsJq52iVHgv2bSO1GYnBZaoOimDFUFbqme93Qo X-Received: by 2002:a17:906:4e57:: with SMTP id g23mr2791841ejw.47.1614178019610; Wed, 24 Feb 2021 06:46:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614178019; cv=none; d=google.com; s=arc-20160816; b=eHNBDWMi9fCIWZldHD97UqLar+xaHn0ZWLht/ghjFunBkVnK+9Wkf1E2EQzJ3UFelR rf/HKjydhUTtFRwunEhxI7Ea0VmA6iPhSkfuCCG54PIZEQ2U8VEVm2MBwlRMzV3uq34n AwRt4JdKdp9QqiyhlmTRckEKDhkEqp5sEAOMLAxJAYevba7wuEMo6ZwUz0LyvNz9k1uz q7z8++HxEQ6FAOy4fyWOMQFdK7lQ/hlsLcJlTv2v9rRwMtMvowDBjX8lwhDm/LKCTaTx YChJflDuuZuW+XvtPGqYuQLAP6A8RVHYA2pxBRuUAJZglAyRttez+XXXZvmTs/9jL4T1 N7fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=XgvjsOMBy0W2i8h9nrIbreu3UIpB0UjjUMV8skAtoL0=; b=IY41b3ndeRvFY+aW6jsSWTU0N8eBmg7fNkaHza9dqygqsDlct+CYQHti+xPQ23A69P mBRhwC/UVWJBQlvwA7DTxL7LGNB20mEhnCsrY8p6quUp0x93eDnZena+mEt3kKncML8j BzPpUNzCU+cLrZsvVwdmvtks1xzm33pbSX3jD/rJ3us9pf5hFZ4opd7snPwtmtcQb/lp wjHLpbYgGoOwu6e/gNmlKMrakf/KMfnH1pgGVaPi/taXQwNEhTZbSp63AtoxWSnG3N68 /783WqW911icMnMzxXjfgG2aKSZjbboKGEthWPeSqVKGUtwROAe4t9vyAFHN6A+0HSx1 u6bQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amazon.com header.s=amazon201209 header.b=udqcbbUY; 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 j23si1411675eje.347.2021.02.24.06.46.27; Wed, 24 Feb 2021 06:46:59 -0800 (PST) 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=udqcbbUY; 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 S238145AbhBXOlT (ORCPT + 99 others); Wed, 24 Feb 2021 09:41:19 -0500 Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:23954 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232662AbhBXNcH (ORCPT ); Wed, 24 Feb 2021 08:32:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1614173524; x=1645709524; h=from:to:cc:subject:date:message-id:in-reply-to: mime-version; bh=XgvjsOMBy0W2i8h9nrIbreu3UIpB0UjjUMV8skAtoL0=; b=udqcbbUYxbyau3hJAdgoCmvFBAwbVD2mX1s8jzEPGg1/01bS+IUztZSt 3OCzRlW421Sa3gUPQRXaay2mkSRrBKmQjfGff3zmJ5kcYdhoGbVbKRa2K SsO2Dy3CErN4C7LW3ovCDNoGX+Tqyy/xiptI6VdnFAPUfMB2/Ksw/V1VM Y=; X-IronPort-AV: E=Sophos;i="5.81,203,1610409600"; d="scan'208";a="91700011" Received: from iad12-co-svc-p1-lb1-vlan2.amazon.com (HELO email-inbound-relay-2a-d0be17ee.us-west-2.amazon.com) ([10.43.8.2]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 24 Feb 2021 13:30:46 +0000 Received: from EX13D31EUA001.ant.amazon.com (pdx1-ws-svc-p6-lb9-vlan3.pdx.amazon.com [10.236.137.198]) by email-inbound-relay-2a-d0be17ee.us-west-2.amazon.com (Postfix) with ESMTPS id 5DD37A1900; Wed, 24 Feb 2021 13:30:43 +0000 (UTC) Received: from u3f2cd687b01c55.ant.amazon.com (10.43.160.207) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 24 Feb 2021 13:30:26 +0000 From: SeongJae Park To: SeongJae Park CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: Re: [PATCH v24 00/14] Subject: Introduce Data Access MONitor (DAMON) Date: Wed, 24 Feb 2021 14:30:05 +0100 Message-ID: <20210224133005.9265-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210204153150.15948-1-sjpark@amazon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.43.160.207] X-ClientProxiedBy: EX13D23UWC001.ant.amazon.com (10.43.162.196) To EX13D31EUA001.ant.amazon.com (10.43.165.15) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 4 Feb 2021 16:31:36 +0100 SeongJae Park wrote: > From: SeongJae Park > [...] > > Introduction > ============ > > DAMON is a data access monitoring framework for the Linux kernel. The core > mechanisms of DAMON called 'region based sampling' and 'adaptive regions > adjustment' (refer to 'mechanisms.rst' in the 11th patch of this patchset for > the detail) make it > > - accurate (The monitored information is useful for DRAM level memory > management. It might not appropriate for Cache-level accuracy, though.), > - light-weight (The monitoring overhead is low enough to be applied online > while making no impact on the performance of the target workloads.), and > - scalable (the upper-bound of the instrumentation overhead is controllable > regardless of the size of target workloads.). > > Using this framework, therefore, several memory management mechanisms such as > reclamation and THP can be optimized to aware real data access patterns. > Experimental access pattern aware memory management optimization works that > incurring high instrumentation overhead will be able to have another try. > > Though DAMON is for kernel subsystems, it can be easily exposed to the user > space by writing a DAMON-wrapper kernel subsystem. Then, user space users who > have some special workloads will be able to write personalized tools or > applications for deeper understanding and specialized optimizations of their > systems. > I realized I didn't introduce a good, intuitive example use case of DAMON for profiling so far, though DAMON is not for only profiling. One straightforward and realistic usage of DAMON as a profiling tool would be recording the monitoring results with callstack and visualize those by timeline together. For example, below link shows that visualization for a realistic workload, namely 'fft' in SPLASH-2X benchmark suite. From that, you can know there are three memory access bursting phases in the workload and 'FFT1DOnce.cons::prop.2()' looks responsible for the first and second hot phase, while 'Transpose()' is responsible for the last one. Now the programmer can take a deep look in the functions and optimize the code (e.g., adding madvise() or mlock() calls). https://damonitor.github.io/temporal/damon_callstack.png We used the approach for 'mlock()'-based optimization of a range of other realistic benchmark workloads. The optimized versions achieved up to about 2.5x performance improvement under memory pressure[1]. Note: I made the uppermost two figures in above 'fft' visualization (working set size and access frequency of each memory region by time) via the DAMON user space tool[2], while the lowermost one (callstack by time) is made using perf and speedscope[3]. We have no descent and totally automated tool for that yet (will be implemented soon, maybe under perf as a perf-script[4]), but you could reproduce that with below commands. $ # run the workload $ sudo damo record $(pidof ) & $ sudo perf record -g $(pidof ) $ # after your workload finished (you should also finish perf on your own) $ damo report wss --sortby time --plot wss.pdf $ damo report heats --heatmap freq.pdf $ sudo perf script | speedscope - $ # open wss.pdf and freq.pdf with our favorite pdf viewer [1] https://linuxplumbersconf.org/event/4/contributions/548/attachments/311/590/damon_ksummit19.pdf [2] https://lore.kernel.org/linux-mm/20201215115448.25633-8-sjpark@amazon.com/ [3] https://www.speedscope.app/ [4] https://lore.kernel.org/linux-mm/20210107120729.22328-1-sjpark@amazon.com/