From patchwork Mon May 18 10:00:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 11555127 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9B6CD1668 for ; Mon, 18 May 2020 10:01:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 383B2207F5 for ; Mon, 18 May 2020 10:01:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=amazon.com header.i=@amazon.com header.b="VT2DdtvT" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 383B2207F5 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 4FB0080006; Mon, 18 May 2020 06:01:20 -0400 (EDT) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 4AE7E900002; Mon, 18 May 2020 06:01:20 -0400 (EDT) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 39A5C80006; Mon, 18 May 2020 06:01:20 -0400 (EDT) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0030.hostedemail.com [216.40.44.30]) by kanga.kvack.org (Postfix) with ESMTP id 0C396900002 for ; Mon, 18 May 2020 06:01:20 -0400 (EDT) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id AE325D21D for ; Mon, 18 May 2020 10:01:19 +0000 (UTC) X-FDA: 76829397078.06.peace39_b812e661bc18 X-Spam-Summary: 1,0,0,,d41d8cd98f00b204,prvs=400471693=sjpark@amazon.com,,RULES_HIT:30003:30004:30005:30012:30016:30030:30034:30051:30054:30055:30056:30064:30070:30075:30090,0,RBL:52.95.49.90:@amazon.com:.lbl8.mailshell.net-64.10.201.10 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:none,Custom_rules:0:1:0,LFtime:23,LUA_SUMMARY:none X-HE-Tag: peace39_b812e661bc18 X-Filterd-Recvd-Size: 38910 Received: from smtp-fw-6002.amazon.com (smtp-fw-6002.amazon.com [52.95.49.90]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Mon, 18 May 2020 10:01:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1589796080; x=1621332080; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=H6IHlxrW8wf5RuLp1oV1N02JEXYd3seCA/5xz6mN4cg=; b=VT2DdtvTKL0K1LhfdQ/c8CT6YLTFr1CL/R1Yvkc4nHOlg0rLsIqcSKlj SNjgDIedOy7Odw5irSKvR5eFXD/GeF32mAC7eLJ6AI1QctSlJCNbl49rW 7dGDxOeWdjM3Fp/sv23P8vwVkEk+diE1rgsUC1kqwvN1v1nwTxj9FT4mc s=; IronPort-SDR: 8XqJfZ+xrtUP5DZCfvngbU3i6tSrPn3ZUt2tqno3AJvs/GqWimwGlZZgcxvnqF7YJdbgIZioD4 UPxNG/8UmKVA== X-IronPort-AV: E=Sophos;i="5.73,406,1583193600"; d="scan'208";a="30702429" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-1e-a70de69e.us-east-1.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6002.iad6.amazon.com with ESMTP; 18 May 2020 10:01:06 +0000 Received: from EX13MTAUEA002.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-a70de69e.us-east-1.amazon.com (Postfix) with ESMTPS id 7C91DA2471; Mon, 18 May 2020 10:00:54 +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; Mon, 18 May 2020 10:00:53 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.160.90) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 18 May 2020 10:00:37 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [PATCH v12 00/16] Introduce Data Access MONitor (DAMON) Date: Mon, 18 May 2020 12:00:02 +0200 Message-ID: <20200518100018.2293-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.43.160.90] X-ClientProxiedBy: EX13D04UWA003.ant.amazon.com (10.43.160.212) To EX13D31EUA001.ant.amazon.com (10.43.165.15) 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 Introduction ============ DAMON is a data access monitoring framework subsystem for the Linux kernel. The core mechanisms of DAMON called 'region based sampling' and adaptive regions adjustment' (refer to :doc:`mechanisms` for the detail) make it accurate, efficient, and scalable. Using this framework, therefore, the kernel's core memory management mechanisms including reclamation and THP can be optimized for better memory management. The memory management optimization works that have not merged into the mainline due to their high data access monitoring overhead will be able to have another try. In user space, meanwhile, users who have some special workloads will be able to write personalized tools or applications for more understanding and specialized optimizations of their systems using the DAMON as a framework. More Information ================ We prepared a showcase web site[1] that you can get more information of DAMON. There are - the official documentation of DAMON[2], - the heatmap format dynamic access pattern of various realistic workloads for heap area[3], mmap()-ed area[4], and stack[5] area, - the dynamic working set size distribution[6] and chronological working set size changes[7], and - the latest performance test results[8]. [1] https://damonitor.github.io [2] https://damonitor.github.io/doc/html/latest [3] https://damonitor.github.io/test/result/visual/latest/heatmap.0.html [4] https://damonitor.github.io/test/result/visual/latest/heatmap.1.html [5] https://damonitor.github.io/test/result/visual/latest/heatmap.2.html [6] https://damonitor.github.io/test/result/visual/latest/wss_sz.html [7] https://damonitor.github.io/test/result/visual/latest/wss_time.html [8] https://damonitor.github.io/test/result/perf/latest/html/index.html Evaluations =========== We evaluated DAMON's overhead, monitoring quality and usefulness using 25 realistic workloads on my QEMU/KVM based virtual machine. DAMON is lightweight. It consumes only 0.03% more system memory and up to 1% CPU time. It makes target worloads only 0.7% slower. DAMON is accurate and useful for memory management optimizations. An experimental DAMON-based operation scheme for THP removes 63.12% of THP memory overheads while preserving 49.15% of THP speedup. Another experimental DAMON-based 'proactive reclamation' implementation reduces 85.85% of residentail sets and 21.98% of system memory footprint while incurring only 2.42% runtime overhead in best case (parsec3/freqmine). NOTE that the experimentail THP optimization and proactive reclamation are not for production, just only for proof of concepts. Please refer to 'Appendix C' for detailed evaluation setup and results. Baseline and Complete Git Trees =============================== The patches are based on the v5.6. You can also clone the complete git tree: $ git clone git://github.com/sjp38/linux -b damon/patches/v12 The web is also available: https://github.com/sjp38/linux/releases/tag/damon/patches/v12 There are a couple of trees for entire DAMON patchset series. The first one[1] contains the changes for latest release, while the other one[2] contains the changes for next release. [1] https://github.com/sjp38/linux/tree/damon/master [2] https://github.com/sjp38/linux/tree/damon/next Sequence Of Patches =================== The patches are organized in the following sequence. The first two patches are preparation of DAMON patchset. The 1st patch adds typos found in previous versions of DAMON patchset to 'scripts/spelling.txt' so that the typos can be caught by 'checkpatch.pl'. The 2nd patch exports 'lookup_page_ext()' to GPL modules so that it can be used by DAMON even though it is built as a loadable module. Next five patches implement the core of DAMON and it's programming interface. The 3rd patch introduces DAMON module, it's data structures, and data structure related common functions. Following four patches (4nd to 7th) implements the core mechanisms of DAMON, namely regions based sampling (patch 4), adaptive regions adjustment (patches 5-6), and dynamic memory mapping chage adoption (patch 7). Following four patches are for low level users of DAMON. The 8th patch implements callbacks for each of monitoring steps so that users can do whatever they want with the access patterns. The 9th one implements recording of access patterns in DAMON for better convenience and efficiency. Each of next two patches (10th and 11th) respectively adds a debugfs interface for privileged people and/or programs in user space, and a tracepoint for other tracepoints supporting tracers such as perf. Two patches for high level users of DAMON follows. To provide a minimal reference to the debugfs interface and for high level use/tests of the DAMON, the next patch (12th) implements an user space tool. The 13th patch adds a document for administrators of DAMON. Next two patches are for tests. The 14th and 15th patches provide unit tests (based on kunit) and user space tests (based on kselftest), respectively. Finally, the last patch (16th) updates the MAINTAINERS file. Patch History ============= Below are main changes for recent 5 versions of this patchset. Please refer to oldest patchset listed here to get older history. Changes from v11 (https://lore.kernel.org/linux-mm/20200511123302.12520-1-sjpark@amazon.com/) - Rewrite the document (Stefan Nuernberger) - Make 'damon_for_each_*' argument order consistent (Leonard Foerster) - Fix wrong comment in 'kdamond_merge_regions()' (Leonard Foerster) Changes from v10 (https://lore.kernel.org/linux-mm/20200505110815.10532-1-sjpark@amazon.com/) - Reduce aggressive split overhead by doing it only if required Changes from v9 (https://lore.kernel.org/linux-mm/20200427120442.24179-1-sjpark@amazon.com/) - Split each region into 4 subregions if possible (Jonathan Cameraon) - Update kunit test for the split code change Changes from v8 (https://lore.kernel.org/linux-mm/20200406130938.14066-1-sjpark@amazon.com/) - Make regions always aligned by minimal region size that can be changed (Stefan Nuernberger) - Store binary format version in the recording file (Stefan Nuernberger) - Use 'int' for pid instead of 'unsigned long' (Stefan Nuernberger) - Fix a race condition in damon thread termination (Stefan Nuernberger) - Optimize random value generation and recording (Stefan Nuernberger) - Clean up commit messages and comments (Stefan Nuernberger) - Clean up code (Stefan Nuernberger) - Use explicit signalling and 'do_exit()' for damon thread termination - Add more typos to spelling.txt - Update the performance evaluation results - Describe future plans in the cover letter Changes from v7 (https://lore.kernel.org/linux-mm/20200318112722.30143-1-sjpark@amazon.com/) - Cleanup variable names (Jonathan Cameron) - Split sampling address setup from access_check() (Jonathan Cameron) - Make sampling address to always locate in the region (Jonathan Cameron) - Make initial region's sampling addr to be old (Jonathan Cameron) - Split kdamond on/off function to seperate functions (Jonathan Cameron) - Fix wrong kernel doc comments (Jonathan Cameron) - Reset 'last_accessed' to false in kdamond_check_access() if necessary - Rebase on v5.6 SeongJae Park (16): scripts/spelling: Add a few more typos mm/page_ext: Export lookup_page_ext() to GPL modules mm: Introduce Data Access MONitor (DAMON) mm/damon: Implement region based sampling mm/damon: Adaptively adjust regions mm/damon: Split regions into 3 subregions if necessary mm/damon: Apply dynamic memory mapping changes mm/damon: Implement callbacks mm/damon: Implement access pattern recording mm/damon: Add debugfs interface mm/damon: Add tracepoints tools: Add a minimal user-space tool for DAMON Documentation/admin-guide/mm: Add a document for DAMON mm/damon: Add kunit tests mm/damon: Add user space selftests MAINTAINERS: Update for DAMON Documentation/admin-guide/mm/damon/api.rst | 9 + .../admin-guide/mm/damon/damon_heatmap.png | Bin 0 -> 8366 bytes .../admin-guide/mm/damon/damon_wss_change.png | Bin 0 -> 7211 bytes .../admin-guide/mm/damon/damon_wss_dist.png | Bin 0 -> 6173 bytes Documentation/admin-guide/mm/damon/faq.rst | 39 + .../admin-guide/mm/damon/freqmine_heatmap.png | Bin 0 -> 8687 bytes .../admin-guide/mm/damon/freqmine_wss_sz.png | Bin 0 -> 4986 bytes .../mm/damon/freqmine_wss_time.png | Bin 0 -> 6283 bytes Documentation/admin-guide/mm/damon/guide.rst | 196 +++ Documentation/admin-guide/mm/damon/index.rst | 50 + .../admin-guide/mm/damon/mechanisms.rst | 111 ++ Documentation/admin-guide/mm/damon/plans.rst | 49 + Documentation/admin-guide/mm/damon/start.rst | 119 ++ .../mm/damon/streamcluster_heatmap.png | Bin 0 -> 37916 bytes .../mm/damon/streamcluster_wss_sz.png | Bin 0 -> 5522 bytes .../mm/damon/streamcluster_wss_time.png | Bin 0 -> 6322 bytes Documentation/admin-guide/mm/damon/usage.rst | 305 ++++ Documentation/admin-guide/mm/index.rst | 1 + Documentation/index.rst | 176 +- MAINTAINERS | 12 + include/linux/damon.h | 78 + include/trace/events/damon.h | 43 + mm/Kconfig | 23 + mm/Makefile | 1 + mm/damon-test.h | 622 +++++++ mm/damon.c | 1511 +++++++++++++++++ mm/page_ext.c | 1 + scripts/spelling.txt | 8 + tools/damon/.gitignore | 1 + tools/damon/_dist.py | 36 + tools/damon/_recfile.py | 23 + tools/damon/bin2txt.py | 67 + tools/damon/damo | 37 + tools/damon/heats.py | 362 ++++ tools/damon/nr_regions.py | 91 + tools/damon/record.py | 212 +++ tools/damon/report.py | 45 + tools/damon/wss.py | 97 ++ tools/testing/selftests/damon/Makefile | 7 + .../selftests/damon/_chk_dependency.sh | 28 + tools/testing/selftests/damon/_chk_record.py | 108 ++ .../testing/selftests/damon/debugfs_attrs.sh | 139 ++ .../testing/selftests/damon/debugfs_record.sh | 50 + 43 files changed, 4489 insertions(+), 168 deletions(-) create mode 100644 Documentation/admin-guide/mm/damon/api.rst create mode 100644 Documentation/admin-guide/mm/damon/damon_heatmap.png create mode 100644 Documentation/admin-guide/mm/damon/damon_wss_change.png create mode 100644 Documentation/admin-guide/mm/damon/damon_wss_dist.png create mode 100644 Documentation/admin-guide/mm/damon/faq.rst create mode 100644 Documentation/admin-guide/mm/damon/freqmine_heatmap.png create mode 100644 Documentation/admin-guide/mm/damon/freqmine_wss_sz.png create mode 100644 Documentation/admin-guide/mm/damon/freqmine_wss_time.png create mode 100644 Documentation/admin-guide/mm/damon/guide.rst create mode 100644 Documentation/admin-guide/mm/damon/index.rst create mode 100644 Documentation/admin-guide/mm/damon/mechanisms.rst create mode 100644 Documentation/admin-guide/mm/damon/plans.rst create mode 100644 Documentation/admin-guide/mm/damon/start.rst create mode 100644 Documentation/admin-guide/mm/damon/streamcluster_heatmap.png create mode 100644 Documentation/admin-guide/mm/damon/streamcluster_wss_sz.png create mode 100644 Documentation/admin-guide/mm/damon/streamcluster_wss_time.png create mode 100644 Documentation/admin-guide/mm/damon/usage.rst create mode 100644 include/linux/damon.h create mode 100644 include/trace/events/damon.h create mode 100644 mm/damon-test.h create mode 100644 mm/damon.c create mode 100644 tools/damon/.gitignore create mode 100644 tools/damon/_dist.py create mode 100644 tools/damon/_recfile.py create mode 100644 tools/damon/bin2txt.py create mode 100755 tools/damon/damo create mode 100644 tools/damon/heats.py create mode 100644 tools/damon/nr_regions.py create mode 100644 tools/damon/record.py create mode 100644 tools/damon/report.py create mode 100644 tools/damon/wss.py create mode 100644 tools/testing/selftests/damon/Makefile create mode 100644 tools/testing/selftests/damon/_chk_dependency.sh create mode 100644 tools/testing/selftests/damon/_chk_record.py create mode 100755 tools/testing/selftests/damon/debugfs_attrs.sh create mode 100755 tools/testing/selftests/damon/debugfs_record.sh