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=-10.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING, SPF_HELO_NONE,SPF_PASS,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 8D72CC4708C for ; Fri, 28 May 2021 12:42:02 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 20029611BD for ; Fri, 28 May 2021 12:42:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 20029611BD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id A49AF6B0036; Fri, 28 May 2021 08:42:01 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9FAB46B006E; Fri, 28 May 2021 08:42:01 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8743A6B0070; Fri, 28 May 2021 08:42:01 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0091.hostedemail.com [216.40.44.91]) by kanga.kvack.org (Postfix) with ESMTP id 3A8576B0036 for ; Fri, 28 May 2021 08:42:01 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id C50A3181AF5D0 for ; Fri, 28 May 2021 12:42:00 +0000 (UTC) X-FDA: 78190602000.31.647C1DE Received: from mail-qt1-f169.google.com (mail-qt1-f169.google.com [209.85.160.169]) by imf27.hostedemail.com (Postfix) with ESMTP id AC2508019706 for ; Fri, 28 May 2021 12:41:51 +0000 (UTC) Received: by mail-qt1-f169.google.com with SMTP id k19so2575434qta.2 for ; Fri, 28 May 2021 05:42:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=38syo+ldw1QudlXVlbps0ms54ePB01IrTOpMTCdiin4=; b=ooF8ERF7a6r8xrauEEaMoj9ZArPxs7jrtDMzGogESnc6KzPvWLjnBC9jgTJwLBUQD1 aNE2iNZk/Chaw98DRWKEdePQJjP/Ivx3zY012Uum3Yhb/wB8Uq0QTR4jLQZp1gN3NyP9 ++fTyQp/S+1xDCAiqMxSCWCEpis+FxB+OWQ2C6fQIwpczi94QMxIlwBcfmBOiwypkM0W Pyv1gXsOR2r2LhJCWb+UHhYX10JuBloy857iZzB94ofuZSGXss0S1tND0AqzpftWef8J 40Q6gvrX/T/0QHvz9OUFpjHSEgd01GqomC5vy33/7M+LtsNfvhQljuc0KFiYOhYHsdFF q30w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=38syo+ldw1QudlXVlbps0ms54ePB01IrTOpMTCdiin4=; b=Q6MGR+M6AkfPhOJh6hXt9p7pFlHAP5LweCsp3yXUu7dIVWla9yb6TcjepNtqUswWwL dBpChsu3XnqbgNuCP/TgcMmCDKN+q66SStiBLWrdaLe8AYF77u6S6tW9pvQ3syIODfWe CvkXqH5i8yHWWUwWB0OZ5p4r68lmWeZg0f3PuTMd/YiO5CheCwJFyYGlctxmKh+nGsjJ UFxmhVSiSOM0F2CJpsPO2x+Zf4LXxWePfzpAo7g5zeqIiUIW0sYu6Urdbon7znNclKlD xT834EGk7pi5DnzWxsRW/PnymU3NuO7H642UfbJZe403upVlp/SxbdRAPIlaVDz0/Obo uQtw== X-Gm-Message-State: AOAM530RscOT64vq7HmZehZBbNbWph9rinqSwqJxd8GHrTpqxtzPFX30 UNngxEl0tQLRAhJMDUhbhBI= X-Google-Smtp-Source: ABdhPJx0XdIKvgVkkQdcEeX3hjpMCqmMQ8Ir8T1hCTh8diPdnphWR3PsUsIgV6qkehzFoZMWRUdLow== X-Received: by 2002:aed:210f:: with SMTP id 15mr3247806qtc.149.1622205719777; Fri, 28 May 2021 05:41:59 -0700 (PDT) Received: from localhost.localdomain (ec2-35-169-212-159.compute-1.amazonaws.com. [35.169.212.159]) by smtp.gmail.com with ESMTPSA id v8sm3319707qkg.102.2021.05.28.05.41.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 May 2021 05:41:59 -0700 (PDT) From: SeongJae Park X-Google-Original-From: SeongJae Park To: ksummit-discuss@lists.linux.dev Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [TECH TOPIC] Writing a fine-grained access pattern oriented lightweight kernel module using DAMON/DAMOS in 10 minutes Date: Fri, 28 May 2021 12:41:25 +0000 Message-Id: <20210528124125.9051-1-sjpark@amazon.de> X-Mailer: git-send-email 2.17.1 Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=gmail.com header.s=20161025 header.b=ooF8ERF7; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf27.hostedemail.com: domain of sj38park@gmail.com designates 209.85.160.169 as permitted sender) smtp.mailfrom=sj38park@gmail.com X-Stat-Signature: b7dtqu3ne8r5ydsjz5srginnc7j53gah X-Rspamd-Queue-Id: AC2508019706 X-Rspamd-Server: rspam02 X-HE-Tag: 1622205711-601261 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000917, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: SeongJae Park DAMON and DAMOS --------------- DAMON[1] is a framework for general data access monitoring of kernel subsystems. It provides best-effort high quality monitoring results while incurring only minimal and upper-bounded overhead, due to its practical overhead-accuracy tradeoff mechanism. On a production machine utilizing 70 GB memory, it can repeatedly scan accesses to the whole memory for every 5ms, while consuming only 1% single CPU time. On top of it, a data access pattern-oriented memory management engine called DAMON-based Operation Schemes (DAMOS) is implemented. It allows clients to implement their access pattern oriented memory management logic with very simple scheme descriptions. We implemented fine-grained access-aware THP and proactive reclamation using this engine in three lines of scheme and achieved remarkable improvements[2]. As of this writing (2021-05-28), the code is not in the mainline but available at its development tree[3], and regularly posted to LKML as patchsets[4,5,6]. Nevertheless, the code has already merged in the public Amazon Linux kernel trees[7,8], and all Amazon Linux users can use DAMON/DAMOS off the box. We are also supporting the two latest upstream LTS stable kernels[9,10]. Agenda ------ In this talk, I will briefly introduce DAMON/DAMOS and present how you can write a fine-grained data access pattern oriented lightweight kernel module on top of DAMON/DAMOS. With the talk, I will write an example module and evaluate its performance on live. A data access-aware proactive reclamation kernel module for production use will also introduced as a use case. After that, I will discuss my future plans for improving DAMON and improving other kernel subsystems using DAMON/DAMOS. [1] https://damonitor.github.io (https://damonitor.github.io/) [2] https://damonitor.github.io/doc/html/latest/vm/damon/eval.html [3] https://https://github.com/sjp38/linux/tree/damon/master (https://https//github.com/sjp38/linux/tree/damon/master) [4] https://lore.kernel.org/linux-mm/20210520075629.4332-1-sj38.park@gmail.com/ [5] https://lore.kernel.org/linux-mm/20201216084404.23183-1-sjpark@amazon.com/ [6] https://lore.kernel.org/linux-mm/20201216094221.11898-1-sjpark@amazon.com/ [7] https://github.com/amazonlinux/linux/tree/amazon-5.4.y/master/mm/damon [8] https://github.com/amazonlinux/linux/tree/amazon-5.10.y/master/mm/damon [9] https://github.com/sjp38/linux/tree/damon/for-v5.4.y [10] https://github.com/sjp38/linux/tree/damon/for-v5.10.y