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=-7.4 required=3.0 tests=DKIM_ADSP_ALL,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 7E967C433E1 for ; Tue, 16 Jun 2020 07:39:25 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 35C5920663 for ; Tue, 16 Jun 2020 07:39:25 +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="Lvx2fP3I" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 35C5920663 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 D23EB6B0025; Tue, 16 Jun 2020 03:39:24 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CFC926B0026; Tue, 16 Jun 2020 03:39:24 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C11E36B0027; Tue, 16 Jun 2020 03:39:24 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0100.hostedemail.com [216.40.44.100]) by kanga.kvack.org (Postfix) with ESMTP id A926C6B0025 for ; Tue, 16 Jun 2020 03:39:24 -0400 (EDT) Received: from smtpin03.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 66ED83571 for ; Tue, 16 Jun 2020 07:39:24 +0000 (UTC) X-FDA: 76934274648.03.tramp48_5c0c73726dfd Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin03.hostedemail.com (Postfix) with ESMTP id 3EFED28A26C for ; Tue, 16 Jun 2020 07:39:24 +0000 (UTC) X-HE-Tag: tramp48_5c0c73726dfd X-Filterd-Recvd-Size: 10916 Received: from smtp-fw-6001.amazon.com (smtp-fw-6001.amazon.com [52.95.48.154]) by imf04.hostedemail.com (Postfix) with ESMTP for ; Tue, 16 Jun 2020 07:39:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1592293163; x=1623829163; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ilTa35w3nYRqNuCqUjaoGWBZdGeyxteYiG74oO+q4mc=; b=Lvx2fP3I+h0OVlfE+kFBMm1gwQwglQTRLFIc5OZe17kZeGo4whisg707 ZxhCXFXr5xcteorXTdkP9dNo4zbEwEoag0KaxikhZcfgTUJDExpWuXDXa jHcJsWOD+QKhs60PJtQALt5PQAYYDPdQHjP5i6K/2Xj027EL56hDMyHks s=; IronPort-SDR: MbKL3Asaee6b/iTwb/DWNKNmWDZ1PLZCCGdiBaFzv1uOxyEtnwGqoiitYynsVye+KgavQJq+Pl qaFjtDREcDjg== X-IronPort-AV: E=Sophos;i="5.73,518,1583193600"; d="scan'208";a="37852701" Received: from iad12-co-svc-p1-lb1-vlan3.amazon.com (HELO email-inbound-relay-2b-c300ac87.us-west-2.amazon.com) ([10.43.8.6]) by smtp-border-fw-out-6001.iad6.amazon.com with ESMTP; 16 Jun 2020 07:39:18 +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 D441BA2702; Tue, 16 Jun 2020 07:39:15 +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 07:39:15 +0000 Received: from u886c93fd17d25d.ant.amazon.com (10.43.162.248) by EX13D31EUA001.ant.amazon.com (10.43.165.15) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 16 Jun 2020 07:38:54 +0000 From: SeongJae Park To: CC: SeongJae Park , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , Subject: [RFC v12 0/8] Implement Data Access Monitoring-based Memory Operation Schemes Date: Tue, 16 Jun 2020 09:38:20 +0200 Message-ID: <20200616073828.16509-1-sjpark@amazon.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" X-Originating-IP: [10.43.162.248] X-ClientProxiedBy: EX13D22UWC004.ant.amazon.com (10.43.162.198) To EX13D31EUA001.ant.amazon.com (10.43.165.15) X-Rspamd-Queue-Id: 3EFED28A26C X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam04 Content-Transfer-Encoding: quoted-printable 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 DAMON[1] can be used as a primitive for data access awared memory managem= ent optimizations. For that, users who want such optimizations should run DA= MON, read the monitoring results, analyze it, plan a new memory management sch= eme, and apply the new scheme by themselves. Such efforts will be inevitable = for some complicated optimizations. However, in many other cases, the users would simply want the system to a= pply a memory management action to a memory region of a specific size having a specific access frequency for a specific time. For example, "page out a = memory region larger than 100 MiB keeping only rare accesses more than 2 minutes= ", or "Do not use THP for a memory region larger than 2 MiB rarely accessed for= more than 1 seconds". This RFC patchset makes DAMON to handle such data access monitoring-based operation schemes. With this change, users can do the data access aware optimizations by simply specifying their schemes to DAMON. [1] https://lore.kernel.org/linux-mm/20200608114047.26589-1-sjpark@amazon= .com/ Evaluations =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D We evaluated DAMON's overhead, monitoring quality and usefulness using 25 realistic workloads on my QEMU/KVM based virtual machine running a kernel= that this patchset is applied. DAMON is lightweight. It increases system memory usage by only -0.25% and consumes less than 1% CPU time in most case. It slows target workloads do= wn by only 0.94%. DAMON is accurate and useful for memory management optimizations. An experimental DAMON-based operation scheme for THP, =E2=80=98ethp=E2=80=99= , removes 31.29% of THP memory overheads while preserving 60.64% of THP speedup. Another experimental DAMON-based =E2=80=98proactive reclamation=E2=80=99 implemen= tation, =E2=80=98prcl=E2=80=99, reduces 87.95% of residential sets and 29.52% of system memory footprint = while incurring only 2.15% runtime overhead in the best case (parsec3/freqmine)= . NOTE that the experimentail THP optimization and proactive reclamation ar= e not for production, just only for proof of concepts. Please refer to the official document[1] or "Documentation/admin-guide/mm= : Add a document for DAMON" patch in the latest DAMON patchset for detailed evaluation setup and results. [1] https://damonitor.github.io/doc/html/latest-damos More Information =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D We prepared a showcase web site[1] that you can get more information. Th= ere are - the official documentations[2], - the heatmap format dynamic access pattern of various realistic workload= s 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/_index [2] https://damonitor.github.io/doc/html/latest-damos [3] https://damonitor.github.io/test/result/visual/latest/rec.heatmap.0.h= tml [4] https://damonitor.github.io/test/result/visual/latest/rec.heatmap.1.h= tml [5] https://damonitor.github.io/test/result/visual/latest/rec.heatmap.2.h= tml [6] https://damonitor.github.io/test/result/visual/latest/rec.wss_sz.html [7] https://damonitor.github.io/test/result/visual/latest/rec.wss_time.ht= ml [8] https://damonitor.github.io/test/result/perf/latest/html/index.html Baseline and Complete Git Tree =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D The patches are based on the v5.7 plus v16 DAMON patchset[1] and Minchan'= s ``do_madvise()`` patch[2], which retrieved from linux-next/master and sli= ghtly modified for backporting on v5.7. You can also clone the complete git tr= ee: $ git clone git://github.com/sjp38/linux -b damos/rfc/v12 The web is also available: https://github.com/sjp38/linux/releases/tag/damos/rfc/v12 There are a couple of trees for entire DAMON patchset series that future features are included. The first one[3] contains the changes for latest release, while the other one[4] contains the changes for next release. [1] https://lore.kernel.org/linux-mm/20200615161927.12637-1-sjpark@amazon= .com/ [2] https://lore.kernel.org/linux-mm/20200302193630.68771-2-minchan@kerne= l.org/ [3] https://github.com/sjp38/linux/tree/damon/master [4] https://github.com/sjp38/linux/tree/damon/next Sequence Of Patches =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D The 1st patch allows DAMON to reuse ``madvise()`` code for the actions. = The 2nd patch accounts age of each region. The 3rd patch implements the hand= ling of the schemes in DAMON and exports a kernel space programming interface = for it. The 4th patch implements a debugfs interface for the privileged peop= le and user programs. The 5th patch implements schemes statistics feature for e= asier tuning of the schemes and runtime access pattern analysis. The 6th patch= e adds selftests for these changes, and the 7th patch adds human friendly scheme= s support to the user space tool for DAMON. Finally, the 8th patch documen= ts this new feature in the document. Patch History =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D Changes from RFC v11 (https://lore.kernel.org/linux-mm/20200609065320.12941-1-sjpark@amazon.co= m/) - Refine the commit messages (David Hildenbrand) - Clean up debugfs code Changes from RFC v10 (https://lore.kernel.org/linux-mm/20200603071138.8152-1-sjpark@amazon.com= /) - Fix the wrong error handling for schemes debugfs file - Handle the schemes stats from the user space tool - Remove the schemes implementation plan from the document Changes from RFC v9 (https://lore.kernel.org/linux-mm/20200526075702.27339-1-sjpark@amazon.co= m/) - Rebase on v5.7 - Fix wrong comments and documents for schemes apply conditions Changes from RFC v8 (https://lore.kernel.org/linux-mm/20200512115343.27699-1-sjpark@amazon.co= m/) - Rewrite the document (Stefan Nuernberger) - Make 'damon_for_each_*' argument order consistent (Leonard Foerster) - Implement statistics for schemes - Avoid races between debugfs readers and writers - Reset age for only significant access frequency changes - Add kernel-doc comments in damon.h Changes from RFC v7 (https://lore.kernel.org/linux-mm/20200429124540.32232-1-sjpark@amazon.co= m/) - Rebase on DAMON v11 patchset - Add documentation Please refer to RFC v7 for previous history SeongJae Park (8): mm/madvise: Export do_madvise() to external GPL modules mm/damon: Account age of target regions mm/damon: Implement data access monitoring-based operation schemes mm/damon/schemes: Implement a debugfs interface mm/damon/schemes: Implement statistics feature mm/damon/selftests: Add 'schemes' debugfs tests damon/tools: Support more human friendly 'schemes' control Documentation/admin-guide/mm: Document DAMON-based operation schemes Documentation/admin-guide/mm/damon/guide.rst | 35 ++ Documentation/admin-guide/mm/damon/plans.rst | 23 +- Documentation/admin-guide/mm/damon/usage.rst | 127 ++++++- include/linux/damon.h | 66 ++++ mm/damon.c | 347 +++++++++++++++++- mm/madvise.c | 1 + tools/damon/_convert_damos.py | 128 +++++++ tools/damon/_damon.py | 146 ++++++++ tools/damon/damo | 7 + tools/damon/record.py | 139 +------ tools/damon/schemes.py | 109 ++++++ .../testing/selftests/damon/debugfs_attrs.sh | 29 ++ 12 files changed, 995 insertions(+), 162 deletions(-) create mode 100755 tools/damon/_convert_damos.py create mode 100644 tools/damon/_damon.py create mode 100644 tools/damon/schemes.py --=20 2.17.1