From patchwork Sun Nov 12 19:45:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 16487 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp840665vqg; Sun, 12 Nov 2023 11:47:06 -0800 (PST) X-Google-Smtp-Source: AGHT+IGdUR/l9cAyZuD5g4qkLCXov6wXiefkeMzyQxUwGEf6Zoy3TrzNzkFwHCOep77TV3WY3ySV X-Received: by 2002:a05:6358:9986:b0:168:de6a:d653 with SMTP id j6-20020a056358998600b00168de6ad653mr4915037rwb.21.1699818426346; Sun, 12 Nov 2023 11:47:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699818426; cv=none; d=google.com; s=arc-20160816; b=xlPULscYYr3uPjt3hShRrxPTIgA9oetT8qyAQ1z4uq2VObFlbBudOxV2yDYHCSBTFu YxXu5QXu58SE4M7AQbSnf3GRDBhFLC5KtBIji5HUcjkzgUt4WFmyW9QXfYUvBg+RA/qw QqrEBdT868ZfBCN+N4193HWEXcLBxfGEXwCHtDza7GhrBQHNwywgloQs0oUaxsIdbVLw LcyHrrGWjrP9SSveAAvCOZ0/Mfkc1DPxrVnY5DGt3T9w7WS2Us0fJ75ihJ5+PZhny3Y7 RAI5LjO/FMRLrUyWMJ2DcQ/RwAx/OYagxBr5IiqO/BITXiqPOsgyYbxJ8dKo4D9z4cKT Y6Vg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :message-id:date:subject:cc:from:dkim-signature; bh=yR1/7b/G3LTh7tOKOMEn39ajY24nD3UeQCXv5aDwCmA=; fh=RLBxSvnw24YnX0i5LkO6SJS1TUicnhVSym8puwwtr5M=; b=a3UDfP3o77VNvFwg2+/9dYAPbCQLzmOIga0XiuRNqyHtknfM88YmdhO1OazHtkF/eh +R9x0F4I3KtdKcujaZer9QDPw/BLWfliqxoe7OzBWIB9kyB+2cA5R6Xcn9qKHaaEiy38 JZJdYNMcQV14Z4DMGwlSVHA00RHrN6ak7RfbGXOzLGll1ohGYD3pEv7NOoqwf2Py9viI FtBUATockK8U7TFSA2AvwPGkGPn+QYdA5+Gb3p1D5IWFxmj8NOZNzH+dzCc6t3NoKiK2 LqYG+1CAXsYaFneTEwqVzE5PzrBION8zsbzVzrvWTUsCuXRVa1Adebgazq0jP2eP3asl a1qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=SlZGuL1E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id u190-20020a6385c7000000b005641315d956si4261725pgd.147.2023.11.12.11.47.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 11:47:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b=SlZGuL1E; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 4DAD880658C0; Sun, 12 Nov 2023 11:46:21 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232157AbjKLTqS (ORCPT + 30 others); Sun, 12 Nov 2023 14:46:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41302 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229886AbjKLTqR (ORCPT ); Sun, 12 Nov 2023 14:46:17 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 880D01BFF for ; Sun, 12 Nov 2023 11:46:13 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4CA4CC433C8; Sun, 12 Nov 2023 19:46:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699818373; bh=MaALdKM6CkRciDDOKQFdOFbCFn9uUlJOWClVU8b34tU=; h=From:To:Cc:Subject:Date:From; b=SlZGuL1E4T3k46McUNsHAf1w2NuqPphfcHyZcICORU0yuRPWSemZxbxascnJEM4wO RGqzaYcCZwNc+hn+tWm1S1rg4ApB0FK+txAtSBRj88bPz3KUp1YmgrU3mqneE/WQcQ LRgOIygyg6GiR1u0UPKj92CP9Tdtpb1PRH9r1LNpaqAfPR82U92kkYKhr9mJuIPHKw mNv4tk7df0CvkpvYf/ccAWDqGNUqntwiHu537rFik2Qun1QdCwd+uZU52uP49w90oJ FjqEAQwnVGcI2+vci38RO6C4TlriKg9GeNRv8iftoLU5nESSXp+US/N05doraV0GvC ANjnFjTnid49A== From: SeongJae Park Cc: SeongJae Park , Andrew Morton , Jonathan Corbet , Shuah Khan , Brendan Higgins , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 0/8] DAMOS: Introduce Aim-oriented Feedback-driven Aggressiveness Auto Tuning Date: Sun, 12 Nov 2023 19:45:59 +0000 Message-Id: <20231112194607.61399-1-sj@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Sun, 12 Nov 2023 11:46:21 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782388805907214892 X-GMAIL-MSGID: 1782388805907214892 Another candidate of the subject was "Let users feed and tame DAMOS". DAMOS Control Difficulty ======================== DAMOS helps users easily implementing effective access pattern aware system operations. However, controlling DAMOS in wild is not that easy. The basic way to control DAMON is specifying the target access pattern. Hence, the user is assumed to know the access pattern of the system and the workloads well. Though some good tools including DAMON can help that, it requires time and resource, and the cost depends on the complexity and the dynamicity of the system and workloads. After all, the access pattern consist of three ranges, namely ranges of access rate, age, and size of the regions. Tuning six parameters is already complex. It is not doable for everyone. To ease the control, DAMOS allows users to set the upper-limit of the schemes's aggressiveness, namely DAMOS quota. Then DAMOS prioritizes regions to apply the action under the limit based on the action and the access pattern of the regions. For example, use can ask DAMOS to page out up to 100 MiB of memory regions per second. Then DAMOS pages out regions that not accessed for longer time first under the limit. This allows users to set access pattern bit more naively, and focus on only the one parameter, the quota. That is, the number of parameters to tune with special care can be reduced from six to one. Still, however, the optimal value for the quota depends on the system and the workloads' characteristics, so not that simple. The number of parameters to tune can also increase again if the user needs to run multiple schemes, e.g., collapsing hot pages into THP while splitting cold pages into regular pages. In short, the existing approach asks users to find the perfect or adapted tuning and instruct DAMOS how to work. It requires users to be deligent. That's not a virtue of human, but the machine. Aim-oriented Feedback-driven DAMOS Quota Auto Tuning ==================================================== Most users would start using DAMOS since there is something they want to achieve with DAMOS. Having such goal metrics like SLO is common. Hence, a better approach would be letting users inform DAMOS what they aim to achieve, and how well DAMOS is doing that. Then DAMOS can somehow make it. In detail, users provide feedback for each DAMOS scheme. DAMOS then tune the quota of each scheme based on the users' feedback and the current quota values. This patchset implements the idea. Implementation -------------- The core logic implementation is in the first patch. In short, it uses below simple feedback loop algorithm to get next aggressiveness from the current aggressiveness and the feedback (target_core and current_score) for the current aggressiveness. f(n, target_score, current_score) = max(f(n - 1) * ((target_score - current_score) / target_score + 1), 1) Note that this algorithm assumes the aggressiveness and the score are positively proportional. Making it true is the feedback provider's responsibility. Test Results ------------ To show if this provides the expected benefit, we extend the performance tests of damon-tests suite to support virtual address space-based proactive reclamation scheme that aims 0.5% last 10 seconds some memory PSI. The test suite runs PARSEC3 and SPLASH-2X workloads with the scheme and measure the runtime, the RSS, and the PSI for memory (some). We do same with the same scheme but not having the goal, and yet another variant of it that the target access patterns of the scheme is tuned for each workload, in a offline-tuning approach named DAMOOS[1]. The results that normalized to the output that made without any scheme are as below. The PSI for original run (without any scheme) was zero. To avoid divide-by-zero, we normalize the value to that of Not-tuned scheme's result. xx Not-tuned Offline-tuned Online-tuned RSS 0.622688178226118 0.787950678944904 0.740093483278979 runtime 1.11767826657912 1.0564674983585 1.0910833880499 PSI 1 0.727521443794069 0.308498846350299 The not-tuned scheme acheives about 38.7% memory saving but incur about 11.7% runtime slowdown. The offline-tuned scheme achieves about 22.2% memory saving with about 5.5% runtiem slowdown. It also achieves about 28.2% PSI saving. The online-tuned scheme achieves about 26% memory saving with about 9.1% runtime slowdown. It also achieves about 69.1% PSI saving. Given the online-tuned version is using this RFC level implementation and the goal (0.5% last-10 secs memory PSI) was made after only a few experiments within a day, I think this results show some potential of this feedback-driven auto tuning approach. The test code is available[2], so you can reproduce on your system. [1] https://www.amazon.science/publications/daos-data-access-aware-operating-system [2] https://github.com/damonitor/damon-tests/commit/3f884e61193f0166b8724554b6d06b0c449a712d Patches Sequence ================ The first four patches implement the core logic and user interfaces for the auto tuning. The first patch implements the core logic for the auto tuning, and the API for DAMOS users in the kernel space. The second patch implements basic file operations of DAMON sysfs directories and files that will be used for setting the goals and providing the feedback. The third patch connects the quota goals files inputs to the DAMOS core logic. Finally the fourth patch implements a dedicated DAMOS sysfs command for efficiently committing the quota goals feedback. Two patches for simple test of the logic and interfaces follow. The fifth patch implements the core logic unit test. The sixth patch implements a selftest for the DAMON Sysfs interface for the goals. Finally, two patches for documentation follows. The seventh patch documents the design of the feature. The final eighth patch updates the usage document for the features. SeongJae Park (8): mm/damon/core: implement goal-oriented feedback-driven quota auto-tuning mm/damon/sysfs-schemes: implement scheme quota goals directory mm/damon/sysfs-schemes: commit damos quota goals user input to DAMOS quota auto-tuning mm/damon/sysfs-schemes: implement a command for scheme quota goals only commit mm/damon/core-test: add a unit test for the feedback loop algorithm selftests/damon: test quota goals directory Docs/mm/damon/design: Document DAMOS quota auto tuning Docs/admin-guide/mm/damon/usage: update for quota goals Documentation/admin-guide/mm/damon/usage.rst | 25 +- Documentation/mm/damon/design.rst | 11 + include/linux/damon.h | 19 ++ mm/damon/core-test.h | 32 +++ mm/damon/core.c | 65 ++++- mm/damon/sysfs-common.h | 3 + mm/damon/sysfs-schemes.c | 272 ++++++++++++++++++- mm/damon/sysfs.c | 27 ++ tools/testing/selftests/damon/sysfs.sh | 27 ++ 9 files changed, 463 insertions(+), 18 deletions(-) base-commit: 4f26b84c39fbc6b03208674681bfde06e0bce25a