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: 13453381 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1591CC4167D for ; Sun, 12 Nov 2023 19:46:21 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F368E8D001B; Sun, 12 Nov 2023 14:46:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E4C8C8D001E; Sun, 12 Nov 2023 14:46:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BE37A8D001D; Sun, 12 Nov 2023 14:46:18 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 9E8838D001B for ; Sun, 12 Nov 2023 14:46:18 -0500 (EST) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay05.hostedemail.com (Postfix) with ESMTP id 72678401DB for ; Sun, 12 Nov 2023 19:46:18 +0000 (UTC) X-FDA: 81450333636.18.B28A50C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf28.hostedemail.com (Postfix) with ESMTP id E14ADC000C for ; Sun, 12 Nov 2023 19:46:15 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SlZGuL1E; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699818376; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=yR1/7b/G3LTh7tOKOMEn39ajY24nD3UeQCXv5aDwCmA=; b=Hbht0ow2cN8H8U/EwtRLFL7LL8gI5FfQOqVprHEEyNrzAai8roTkggEMPS3JrqpMCKBjT2 /Wsr+Aw/WloNx+WzcPpjMyQU8t+ETRMdTk+uFBfufOodRCLg5SYN/LY+6LhjjrqiBd7l/3 naPSrpdtMLki8a9AqGSAC1u8Qqzs6Sw= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=SlZGuL1E; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf28.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699818376; a=rsa-sha256; cv=none; b=6vEaFvOlNpOucUxt4VKywYXuwR38Qqr5KGKq613000RLuEno2517BDRW4RmSxLNdq3P1e3 JbAgkJpEOK/tVSygygv9JjVmfZQPcrc0qra/rk1ZA7ynwHFsPR0EA5oUo5bi+psS3nz203 NCNPyi3e1yiIt5vIo0cE9ejXvwo8zds= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6CD2360C36; Sun, 12 Nov 2023 19:46:13 +0000 (UTC) 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 To: 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-Rspamd-Queue-Id: E14ADC000C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 33hkumfsftaasawtsoqkngmygqsxxcye X-HE-Tag: 1699818375-581388 X-HE-Meta: U2FsdGVkX18daWZPShpuPg1Z+3voF7IDM/CiSDCCaBRh4+qYd07gHk5eas5rXd1+dycACHo7PArY6ccM/sAl5Ckfqi9M35gsvorq2RZSRmB/E5cK/5JGYPm3NYw7WjKWIeeyWJXXubDsbMFia4ve61T65XgeOvYLbU3CP1pdJNMpRmRQeGJyapZQjPDgVgwSy9gGHHZXrcGQuS3iSo4qm1k5ucFx2FYS41jpcRL9NeenixgTdwAn66Tn0sZOxn0AZW/IbLZ1dWfRVLDfoqrPXIEzbDPIY0GxuzcRVa6/VRo5CBr+Cd8ay22tmKeVrMEVjFeK248veSZnyxm89pRDKGvrH2he/2IAA+HxwTRq2hC6rv1bUwQz3hPoCaGCA9/fJfJv+5DHsArCml+vj8rG76hHUCXb4BfCA3nwemxXI3yD7zzr6AE+msWAhfndggco5G6fobHX3iCKEfIy6Jfg14N87R8IZDUHqKKkYwKwB1Q0TN7KaNHvwnJecp1OlEDjzw12EEP3y5D3UF34hT87FVGkyG5TN8Htbp96dWugGBMIbKczZ1ViVpFZhYMV1o9V/IE83zJv4JBRm8hqZc6Ct9EQkLxqowKGjjtQ4bC9xB3RrfzQBvMDZPzxto2jWkEMFLCP5hb+rSB9hvftrmfpl+ItannjVRJhBB70+Se/JwvPBlczvxsxsB53nIf5Elfanolcuxstw3CWmJHCqQUuRuHgFHGdujAvyq50FoFNhxYmYcRVN+csdVUq+iYkDNo9rKsNGVUgaeHilDHrWwl+f2ec9jyHrfhL/wl9wog2VXxQgXt6y09l5SzDis8RGkcrIJg3bYZVU/PT2YlUeo0D2AJVlPmkhTOEsE8mSqHES979HLMR9DoxZeIt1YPuqQwZ+BPH1u4JxwVIg6DNqJAtJ3PrcT9XmgAlGTfFJfC5Mak92XSNoZtcdMDM+wMJhrlJl6b0b4aVkhABnFqwA3u 8maEopVO GHACqiEx+tuwre6vd/3xtPXTL1rai5ImEa4g+4WXXvwtv/wh1JjBLJ9ig3bu3KRAtS+m2pWvF/9JgDo5zn4TKwq6zCmpuSisxDK/2JoWxfm+08C3dMCSPfsguPhBH06aCX5caCBA4N7VuHO8VWqcmB6dp1JzhD0kpG7rOlZuP9gbGd1Xr4hBPwh9eiAurrP+neHVGwhFvMbEbRnUjzl+g2Vh+sFx5KzbkArOpx5gqcGZznvWOep5yrAPEJYMAWVOIe0b10aK4tuWTFr6M44uq1KspmhTjYBofxBiq X-Bogosity: Ham, tests=bogofilter, spamicity=0.001320, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: 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