From patchwork Mon Feb 19 19:44:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563012 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 9B1E0C48BC3 for ; Mon, 19 Feb 2024 19:45:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9A67F6B008A; Mon, 19 Feb 2024 14:44:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 95A136B0095; Mon, 19 Feb 2024 14:44:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 647FA6B0092; Mon, 19 Feb 2024 14:44:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 49E0D6B008A for ; Mon, 19 Feb 2024 14:44:47 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 16718A03FA for ; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) X-FDA: 81809581014.23.BB7DC51 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf06.hostedemail.com (Postfix) with ESMTP id C7756180012 for ; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lX9paEie; spf=pass (imf06.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708371885; 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:in-reply-to:references:references:dkim-signature; bh=/ZWqB51uiSLVGsyFb3R7KQTuo8SuEk6lmuqlWRgYzFg=; b=lMCz9IrxAUMalMsM9NnAi5l4jGtrrM5zY+rKXFASwptInj+CgA4HB8pOZoGZgjLFQT+3yq ZTy8WoY67EZMmUXD+qKHc2CK3RpYF701iuYq2oVgK9XrH0zTC2JLc9mcDcFjj9dhccYf5C x9RNo4Vq0rtA3QBwHqzXr2+xASZpMTA= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lX9paEie; spf=pass (imf06.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708371885; a=rsa-sha256; cv=none; b=3m+ZZJC9rCAtuq62NlcNanUwGWRcmwLDFmjFGZ8PAGcfmrj1CEz6p/iSCMuZ2TFL5jnAep n2uCjpx72IqP+zLow1pgJ31MX65qPv/hDnr0vSQq6lc5GQqYqDG5lTQaLQvgA8XKVIKC5h kshHBlNYFR7ftRzQ+JxprjBIHatLmvA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 342D0CE13D9; Mon, 19 Feb 2024 19:44:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 13681C433B1; Mon, 19 Feb 2024 19:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371879; bh=d9LlALHiCfhiFh3lfhrepX1jc1b9cJAF+/9AGNt4qgM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lX9paEieqsiLEM6ItX40DG83FoS+BVepX8gzH32254OLWTtBWI+pg31scSWLMWDJO GGNt/pSlFCUeH11AZGf9BctaR37ARnCtn1SfAL6koonIlexRk8n/9D1FEWg1OBmnx5 V7Q0BaN7U19dLpeuk5L6/UvDx081fJVf8OqUjh9pXyVbMmtNhAs1Y5TG4esBp/TLF2 gNWo+SwxA8YPMogR5Z6XEx7SBxZryYYfep794y3jfF2rm4/1enu3XGHv3IiXiN4v4M 476v8cI23J4qe7PzLEf+xrPgVXo1lMqliX1rPD09v612FyMdnJBq75Xj9faG5232RG Jnre6Sp+zmveQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/20] mm/damon/core: Set damos_quota->esz as public field and document Date: Mon, 19 Feb 2024 11:44:12 -0800 Message-Id: <20240219194431.159606-2-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: C7756180012 X-Rspam-User: X-Stat-Signature: o4natx8a9jdin35nxa8u17ojsacg7536 X-Rspamd-Server: rspam01 X-HE-Tag: 1708371884-339687 X-HE-Meta: U2FsdGVkX18g1Og/o0co8Jx09EBD8/sndPqsBcOtcZXiwXfmHZ8OcRZ4ZhhKWUfFt+6YYXGndkzqWlDifjb+KqBtWnOV+58CPBZ4qAVP8BzTVAX9/h/JgwZ3IP3eSxEw6l10M3ST6uB0FP4oAvU35Vr8G/tuGcO71Jx3XrgdWwiGrVaMJTazmRWlBaAsRiWRafIv1MmiXs6bleKrBhSdNloNtA4BK7Xi80tuhRyW1346PWXvWAt4nURnHbzKSqgTbDZrPXx110VRoz7pJWCGrylCjzryrkxcEQbuWYZaQXQVDvjJfdFN0LdiodyyvL47yBMFYJDgyOifa9Nq2DByGVrLSRwlReiP/U4LF1WO6ENuLalyLWg/SzzQemUGqTE+T5R0eKrAxSgFV2lX5nOZm7Wzpk4UMEKL8YTxOteL8MtkR3TrLepQZpTNNjp50uGDaPX/BsLoE6wtkwY/wV6WKLEjJbWY1QhrPeNrx3kX/UjqDwaNmUOxxpJGQI78sgo0S3iZd1zalRQmxTqDMabeqZBllBIKIEJJUEm0fL/5RXET5qNpda8L2KW7xftmhGlJ+MfpihahURpG6CXSHjDQmELYMM8KlYHhabI+T4c5OYu8aj4QBankW/B06zZ7jtz3aLmYjfreIs9AzjiIbXkUuv/0QIT71Reoqj9uJXPLYkkEWWS7x3FuLb09XQSda/vp1JkgxoCr1iK8C1yT+ciVH9p5wR9rY/xn0WxED6kTloBCw+cbmoqDbgbBcayiXA4GgT3Vot3AHCKm7O1J8KW44OpHUCyvNnAYoIjRFt2YZ/DadT/ulfJ44feXhd1ejlITh4uV/paZcqtFOcp7eDwzcieLpoljHBEegxdOcFNP+md3HprPLX8k/GcX2R8hbMqgSOPYF7pylIiRpHXr2inKDsOTB+F+yPJJtpFs4st5ZwfcJj7jJyIjFxhTsG6/6S4jegi8YP2UL8+oWUH0oJt K61QWg1V y6s+kTOqh4s6bMFhfX6zDJ0Ai33xDiky0ikn1uqOb8J5apYLJLJb+oxi2P/TP+k1vegjGpEA+4vviQz/j7f2v7oPkP2n/P+VI4BOF4LCR6nRf+jf2oeI4yTNQmr17uhMvmUpbdM+WBlZh/LeDvqGDQLilAYa2JIl+MLLeiUjQrESSItbLQLPRNWToX6vsTc9XXEphNqtH1kJN5tnrztYi/bMn/l1+SRbdSsDWhDtEcjCPcphGXSvkirpuQXglgqkMVLLuHpqiv7KhmTj8bYKkLy864ZW5mCxsHbEb 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: List-Subscribe: List-Unsubscribe: DAMOS allow users to specify the quota as they want in multiple ways including time quota, size quota, and feedback-based auto-tuning. DAMOS makes one effective quota out of the inputs and use it at the end. Knowing the current effective quota helps understanding DAMOS' internal mechanism and fine-tuning quotas. DAMON kernel API users can get the information from ->esz field of damos_quota struct, but the field is marked as private purpose, and not kernel-doc documented. Make it public and document. Signed-off-by: SeongJae Park --- include/linux/damon.h | 6 ++++-- mm/damon/core.c | 8 ++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 5881e4ac30be..93ef45b87b9c 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -138,6 +138,7 @@ enum damos_action { * * @get_score: Feedback function for self-tuning quota. * @get_score_arg: Parameter for @get_score + * @esz: Effective size quota in bytes. * * To avoid consuming too much CPU time or IO resources for applying the * &struct damos->action to large memory, DAMON allows users to set time and/or @@ -167,6 +168,8 @@ enum damos_action { * tuning is getting the feedback screo value of 10,000. If @ms and/or @sz are * set together, those work as a hard limit quota. If neither @ms nor @sz are * set, the mechanism starts from the quota of one byte. + * + * The resulting effective size quota in bytes is set to @esz. */ struct damos_quota { unsigned long ms; @@ -179,14 +182,13 @@ struct damos_quota { unsigned long (*get_score)(void *arg); void *get_score_arg; + unsigned long esz; /* private: */ /* For throughput estimation */ unsigned long total_charged_sz; unsigned long total_charged_ns; - unsigned long esz; /* Effective size quota in bytes */ - /* For charging the quota */ unsigned long charged_sz; unsigned long charged_from; diff --git a/mm/damon/core.c b/mm/damon/core.c index 5b325749fc12..0656966a6fc4 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -299,12 +299,12 @@ void damos_destroy_filter(struct damos_filter *f) damos_free_filter(f); } -/* initialize private fields of damos_quota and return the pointer */ -static struct damos_quota *damos_quota_init_priv(struct damos_quota *quota) +/* initialize fields of @quota that normally API users wouldn't set */ +static struct damos_quota *damos_quota_init(struct damos_quota *quota) { + quota->esz = 0; quota->total_charged_sz = 0; quota->total_charged_ns = 0; - quota->esz = 0; quota->charged_sz = 0; quota->charged_from = 0; quota->charge_target_from = NULL; @@ -336,7 +336,7 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern, scheme->stat = (struct damos_stat){}; INIT_LIST_HEAD(&scheme->list); - scheme->quota = *(damos_quota_init_priv(quota)); + scheme->quota = *(damos_quota_init(quota)); scheme->wmarks = *wmarks; scheme->wmarks.activated = true; From patchwork Mon Feb 19 19:44:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563003 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 E2B14C48BC3 for ; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3DA636B007D; Mon, 19 Feb 2024 14:44:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 229AD6B0080; Mon, 19 Feb 2024 14:44:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0F0B56B0082; Mon, 19 Feb 2024 14:44:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 02A586B007D for ; Mon, 19 Feb 2024 14:44:43 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id CE435A0421 for ; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) X-FDA: 81809580804.23.680BCA0 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf17.hostedemail.com (Postfix) with ESMTP id 2A4B440010 for ; Mon, 19 Feb 2024 19:44:40 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Jw6EhW1Z; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.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=1708371881; 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:in-reply-to:references:references:dkim-signature; bh=R/p8IGr4o4yj1mgg6arIdwYYqkZ5HnQP0B/yd4p0fUE=; b=mDltfjX49qQtsjNoyWtf9EENPjgsYXvAyTfFQ213yK5tF0mhP1Svq8+/5mrPcIQC5WKowp JurQPmhz1sl6G3RAS1CXHrrRr4toVcruE933ltfwMIGPtDVhslUOTjULZcgWswEUfyZ2Rd Dh4fpXN7IzTGj3snvODZ0vxgPcJb51s= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Jw6EhW1Z; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.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=1708371881; a=rsa-sha256; cv=none; b=KmShi6nUBQCD69Qb3TIHO4fgnUczzb5Swiuku2Lzg1FAGOkhIUlxdXdpbWPLD+fbfYHGif ima1XuelGAqsdswaUFM9s2WwnWaTTakgwilyKbpYARawgUMx/6wqEEjnOwro5YzZUu5YyC KCsftR3njuGKTkxYlu6Gfx9MR7ZHQeM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 3DA3160F7D; Mon, 19 Feb 2024 19:44:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AB99DC43330; Mon, 19 Feb 2024 19:44:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371880; bh=D150sO/L6KppSwNTajXy1QJufbQ+UvH1B/ezhNJc/3s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Jw6EhW1ZSt+p4B9o5bnE7L9Um41kTj5LlJ11v+SKB5Ded8ERmyZ6Uj6cNq6Pz24hc SSVGzfI+ODvl/iDjlDOa1b4q1K0xicVWz05XrBawu3mwE0yXj6ou25f7N3ILpAP6Dm P1dGWjAGGJXayQ0NbhOx6KJKELZjE/o1FfJduSffxHkiwCDPacNfPB4nORfSoODhNu p05pXuGzzwnuBHRXipFZXIfQ2nsJ208W4Jw+XfWueks3Es1fa2QlK9qHfGTLIEwhm4 iEafNu024SYNb9Lh7hz5l/4pa1BFxHUiyHicSjgD9rdIpsoB8/hWvwrcRhGXsXse17 ENhkkrCF6yh9A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/20] mm/damon/sysfs-schemes: implement quota effective_bytes file Date: Mon, 19 Feb 2024 11:44:13 -0800 Message-Id: <20240219194431.159606-3-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: g4u4nmskxeib9chp8po1fgfn47ga6gn1 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 2A4B440010 X-HE-Tag: 1708371880-639385 X-HE-Meta: U2FsdGVkX18YeDOWuEV5xpABrC1m/cSkgGmAjHLwyVSLKgVNNBzQxVPmQerzFcrgFOcPqB5aYcBwyMkhFCHssWiTq1ZaB/zlp3ZLXejBT4HwiO7LX7w0oboNDzrcIuNWxbpA0KmHL8pyRgAgCPTdVs64Tme3OdJf7h41IjNo7MiB3jpLvfioFSantK4c+x890N/MclM/tOSCVH3L0901PEvg0gN8lDmr6/vAmxe5+DJfALYvjj0mD6ozir8L5xQFxG1LOVKgteWAPZzaHDOPOWs2k+13nu/PrrXmAB7sqKqDJL4ycPgpimmNSzn4pa4dRpTFEv6z8eqJFpXn+9nbN7sXpck3K/8tYhx3vEM0ZV+N/Azbbs+uuvkjGXiszGAVBBrKJBUpIrWBLDcK6lDglhrXDCyv/194nwfljMEYdPkDTyV3btfg9uV4dyt/0hgEawv03K3AO1Po0bHfx8YUZxEZ5D65FJqhuUgTxZsyw7px0HL4lS6jpUzIgJjwHpk2eQANyIFqI35GA5O70UvXPvs3KGyLwIVFloHVwMlCrFTftkqeA6ujLn4sNDB0Mm8qxwKsJOLPk6cgzLNbSV3dQeLsVHjKmvQd/mHZeJtQTtjp8AXzt4xmyB/uP2nTf00ubAo9BFVTDL2f7HPFNfupuYzaoNLcxmZLGJpFChpI23Cbg9sZKcQXcuPGgZqjpsNO05qCNOwgH0+WrxYoXM2rS4HztPuNdOt5KbYFdqeM+P7WjSEObm/+iNDo1QfY+xFwoxRytvH7w6BdR7TaOu67DWeBRG4YCxZpCU8/IeH0gRNS5ZUWAoL0aHI3pbnxjaw/Z+7a8cYYWaSHI/zJj8YwhxFdTvb2FQogYtL42jF0UP/lOkwJmctbDi+eYon9oqgxviTcysufNXP7Iz0kDIn9/654ZVjXpmVpUz6+pX6ZFgcn16MiqPQwrJRKXLMR8yiJnJvJWhG6sHhYvDrkkkR Jr33aNCQ zILrTkqz01wDGmmcQMCBHgdW4H3CvbPewCQs9It2xQBX2L4e0UklmxsO5FMksPdPH5sbSAyDS1kbPK8kLGso+tf73v+06z/KG34dyXctF5AVVhYoiv1CtAnyghVGexSVlW3UCYEVx/7jIaL9AXw4ZZjVIO5tBVcy/XZbDGOwAKdGGeTlqH5lGkOsv7uKw/UGkSwFNG+b24myQiWKaD/rJVh3jgNm/0jflpt8Fb5S42WCEGQ1hrd+m/La3s5BgjKdJmkuOyIrnFgENqT132nh5Bvk94JVCvBXDmifp 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: List-Subscribe: List-Unsubscribe: DAMON sysfs interface allows users to set two types of quotas, namely time quota and size quota. DAMOS converts time quota to a size quota and use smaller one among the resulting two size quotas. The resulting effective size quota can be helpful for debugging and analysis, but not exposed to the user. The recently added feedback-driven quota auto-tuning is making it even more mysterious. Implement a DAMON sysfs interface read-only empty file, namely 'effective_bytes', under the quota goal DAMON sysfs directory. It will be extended to expose the effective quota to the end user. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index f6c7f43f06cc..dd46b2db5455 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1139,6 +1139,7 @@ struct damon_sysfs_quotas { unsigned long ms; unsigned long sz; unsigned long reset_interval_ms; + unsigned long effective_sz; /* Effective size quota in bytes */ }; static struct damon_sysfs_quotas *damon_sysfs_quotas_alloc(void) @@ -1252,6 +1253,15 @@ static ssize_t reset_interval_ms_store(struct kobject *kobj, return count; } +static ssize_t effective_bytes_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damon_sysfs_quotas *quotas = container_of(kobj, + struct damon_sysfs_quotas, kobj); + + return sysfs_emit(buf, "%lu\n", quotas->effective_sz); +} + static void damon_sysfs_quotas_release(struct kobject *kobj) { kfree(container_of(kobj, struct damon_sysfs_quotas, kobj)); @@ -1266,10 +1276,14 @@ static struct kobj_attribute damon_sysfs_quotas_sz_attr = static struct kobj_attribute damon_sysfs_quotas_reset_interval_ms_attr = __ATTR_RW_MODE(reset_interval_ms, 0600); +static struct kobj_attribute damon_sysfs_quotas_effective_bytes_attr = + __ATTR_RO_MODE(effective_bytes, 0400); + static struct attribute *damon_sysfs_quotas_attrs[] = { &damon_sysfs_quotas_ms_attr.attr, &damon_sysfs_quotas_sz_attr.attr, &damon_sysfs_quotas_reset_interval_ms_attr.attr, + &damon_sysfs_quotas_effective_bytes_attr.attr, NULL, }; ATTRIBUTE_GROUPS(damon_sysfs_quotas); From patchwork Mon Feb 19 19:44:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563004 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 C1569C54764 for ; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C16B46B0083; Mon, 19 Feb 2024 14:44:43 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id BC5DF6B0082; Mon, 19 Feb 2024 14:44:43 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A189F6B0083; Mon, 19 Feb 2024 14:44:43 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 8D09C6B0080 for ; Mon, 19 Feb 2024 14:44:43 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2AAB5120427 for ; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) X-FDA: 81809580846.22.995DBE1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf14.hostedemail.com (Postfix) with ESMTP id A33D9100013 for ; Mon, 19 Feb 2024 19:44:41 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JmCv8hem; spf=pass (imf14.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708371881; a=rsa-sha256; cv=none; b=xMpZvbPmAEntEUlrH4Ni0t7pU6vh6D0AvbB8HTaN8vjOuhi+Z4+QHJyDCQiFzEertcN2W3 arqj/FlntDg8abgSzK9GVU8irNM58nPJHZdP+IeKBAf964dMj6LurDGs1OdP/S7Y1Cq11V /BJovdhMGvnqinWXpHCgDBZ3tmjTYDs= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=JmCv8hem; spf=pass (imf14.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708371881; 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:in-reply-to:references:references:dkim-signature; bh=ZUy4XggBW2XMmQvOyA0+ZUcd0/YU5UEv8j/aEi35guo=; b=uKZqo5zMlMjbmuQqeH5p1C6xozin9Bz2WNobtyx1EcFGOvZvzNusuE1u9q8e4tGW5HZLJo 3JlOUF7lZy8uC09iVE/oumYhLsgy4U2OHJrO7+kpUto1gENgn1dpk2qWvnt0ByTVEK6lxp NtrhBOpx1tVhgoy3XSTTfYucvxb49oM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D3FB660F88; Mon, 19 Feb 2024 19:44:40 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 41180C433B2; Mon, 19 Feb 2024 19:44:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371880; bh=rzYXRY+0g/n7Kn4lIsgWKL7FZXy8S0J6qwcWKx/b2nA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JmCv8hemCSNgYrpk0Ff5mzvIxAHJ3jIHrdLuTVvCYP2smFXiNdJFrxas2R7s6aMTD VXDPpBUJN1p9KGnKN2lVRQ/qZxTQqQbnmdTl45LhAcXXZnWRkT/PWxRl/Rn7EXbTlx tQg8ZSSuCxUKk8kMw17YYl0Tey2AkJGW2D6FtYmyx2TkXUvbs87nrMyKTfgLAUTq3m HJcMUTNmM7XsPbJ5dVn9ZbBde4zoPcfekCrT886UNpCuAjstpOzlo8qqbu1WS0bXmF Ho0ojO1mPVMNxv90T0GcCt6rjzs1y3XRdPEdSztpAHgGZ0bLTYY3rbpscgrkFAR+zj D+AhW7SDqDk2A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/20] mm/damon/sysfs: implement a kdamond command for updating schemes' effective quotas Date: Mon, 19 Feb 2024 11:44:14 -0800 Message-Id: <20240219194431.159606-4-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: A33D9100013 X-Stat-Signature: ddfb6huo1wmgdouiee5n3koixrf76yyz X-Rspam-User: X-HE-Tag: 1708371881-326054 X-HE-Meta: U2FsdGVkX1++mI+6IU8PN+2Yr238L1741SdmfQ5z7pe/k+Tu/n8xF/J2+EmziN9vIOCtjSzWG8kIP5HgFq1l9raidig5UZ/X7D8gMxErhE74gAEvpj8M6geQ9Z+CGIIjGE2Y732ROOb9CovB3E9HQM+SwCSE6kPAvEv7MVEVZ/dMgjPsHA1IPBM7T7pf3lpx//9IjiuvSsAQtClV71HP73Ry52VUEZNh6qxoQFH7G+u1fR60rfM60r5tKK1qdwpRMZNtIG5MF6tFbJ0IB6BG4EXMUspxKMY8tM4HVUphGY6ZvIZS5xKTlhNFYeXHnRbtOujMPnOXiW9TBQ8j/wMXgROm3WwnCUBW9e8QYm4Xy19vwL210CdMT7mke/uP33LdFi0XOUBNg5ug2GNFIe8P2Pt/vVJpa2b/HI+LVTgbxbsrViSbutmiQeYFXjkxCnLaQn86mh7PFCkjaU8mGgoIu6i3f4Lj1Pwwh7btkEM2OjUpnnfiEL3bcos4qnJ7BxO2FiToOurd0hPX4smq6uEZhd3igTamw8FiwH2/m5RuVtAyTflZ8JKxoLqa6YippEDulBgWZIoWDsS4u/3Y2YqTU20gqgIXURDV7VszJSULQ9j+vwO30glzhARnZH6YEmsIAUdFe/ePxVatmI0I0k6wB51ec2PFmFT0dlO8jKxEBCsagQuH9Dvxj5JV+Zl4xVznsXukm/1wJge3tKar+Eh0Nlo84EQeW2n+rjBMz1hiK26bQBB+ElwLJctzyiGFOWdOnQPCBzvjILZfDMJwR50lcKYsliKfaWZV/NpSoiIPWr14/rBJ999aXyQxLD3Aa+HWHEufaFpK2rYib3s/iJzikfpKBOf8SUWSlUkdfef/Coi/It9YCqV07K5OcVxugJj9Jn3Bc9Zzx9YwnB5+nBPmqccs9C7ZvaKjMFRKCtyewk8= 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: List-Subscribe: List-Unsubscribe: Implement yet another kdamond 'state' file input command, namely 'update_schemes_effective_quotas'. If it is written, the 'effective_bytes' files of the kdamond will be updated to provide the current effective size quota of each scheme in bytes. Signed-off-by: SeongJae Park --- mm/damon/sysfs-common.h | 4 ++++ mm/damon/sysfs-schemes.c | 20 ++++++++++++++++++++ mm/damon/sysfs.c | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+) diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h index ec0703e1e90b..5a1ac15fb2f8 100644 --- a/mm/damon/sysfs-common.h +++ b/mm/damon/sysfs-common.h @@ -61,3 +61,7 @@ int damon_sysfs_schemes_clear_regions( void damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx); + +void damos_sysfs_update_effective_quotas( + struct damon_sysfs_schemes *sysfs_schemes, + struct damon_ctx *ctx); diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index dd46b2db5455..9d90e7b757b7 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1930,6 +1930,26 @@ void damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, } } +void damos_sysfs_update_effective_quotas( + struct damon_sysfs_schemes *sysfs_schemes, + struct damon_ctx *ctx) +{ + struct damos *scheme; + int schemes_idx = 0; + + damon_for_each_scheme(scheme, ctx) { + struct damon_sysfs_quotas *sysfs_quotas; + + /* user could have removed the scheme sysfs dir */ + if (schemes_idx >= sysfs_schemes->nr) + break; + + sysfs_quotas = + sysfs_schemes->schemes_arr[schemes_idx++]->quotas; + sysfs_quotas->effective_sz = scheme->quota.esz; + } +} + static struct damos *damon_sysfs_mk_scheme( struct damon_sysfs_scheme *sysfs_scheme) { diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 678de97fcc88..cc2d88a901f4 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1019,6 +1019,11 @@ enum damon_sysfs_cmd { * regions */ DAMON_SYSFS_CMD_CLEAR_SCHEMES_TRIED_REGIONS, + /* + * @DAMON_SYSFS_CMD_UPDATE_SCHEMES_EFFECTIVE_QUOTAS: Update the + * effective size quota of the scheme in bytes. + */ + DAMON_SYSFS_CMD_UPDATE_SCHEMES_EFFECTIVE_QUOTAS, /* * @NR_DAMON_SYSFS_CMDS: Total number of DAMON sysfs commands. */ @@ -1035,6 +1040,7 @@ static const char * const damon_sysfs_cmd_strs[] = { "update_schemes_tried_bytes", "update_schemes_tried_regions", "clear_schemes_tried_regions", + "update_schemes_effective_quotas", }; /* @@ -1375,6 +1381,29 @@ static int damon_sysfs_commit_schemes_quota_goals( return 0; } +/* + * damon_sysfs_upd_schemes_effective_quotas() - Update schemes effective quotas + * sysfs files. + * @kdamond: The kobject wrapper that associated to the kdamond thread. + * + * This function reads the schemes' effective quotas of specific kdamond and + * update the related values for sysfs files. This function should be called + * from DAMON callbacks while holding ``damon_syfs_lock``, to safely access the + * DAMON contexts-internal data and DAMON sysfs variables. + */ +static int damon_sysfs_upd_schemes_effective_quotas( + struct damon_sysfs_kdamond *kdamond) +{ + struct damon_ctx *ctx = kdamond->damon_ctx; + + if (!ctx) + return -EINVAL; + damos_sysfs_update_effective_quotas( + kdamond->contexts->contexts_arr[0]->schemes, ctx); + return 0; +} + + /* * damon_sysfs_cmd_request_callback() - DAMON callback for handling requests. * @c: The DAMON context of the callback. @@ -1437,6 +1466,9 @@ static int damon_sysfs_cmd_request_callback(struct damon_ctx *c, bool active, case DAMON_SYSFS_CMD_CLEAR_SCHEMES_TRIED_REGIONS: err = damon_sysfs_clear_schemes_regions(kdamond); break; + case DAMON_SYSFS_CMD_UPDATE_SCHEMES_EFFECTIVE_QUOTAS: + err = damon_sysfs_upd_schemes_effective_quotas(kdamond); + break; default: break; } From patchwork Mon Feb 19 19:44:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563005 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 6CA0CC48BC3 for ; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6731B6B0080; Mon, 19 Feb 2024 14:44:44 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5FAFD6B0082; Mon, 19 Feb 2024 14:44:44 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 473C66B0085; Mon, 19 Feb 2024 14:44:44 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2A8DE6B0080 for ; Mon, 19 Feb 2024 14:44:44 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id C13AD160131 for ; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) X-FDA: 81809580846.16.1A408E5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf26.hostedemail.com (Postfix) with ESMTP id 4BDEB14000E for ; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bGNlhels; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708371882; 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:in-reply-to:references:references:dkim-signature; bh=mx822/uT9dCM9whfDewBfHDOKnSk4kYdQB/NEXJRAIY=; b=rmOWDaJNJbI0OutU2JBJdFm/SKHhrcFWzZXgdH82EOSuI32k74DlM0h//uGM7kCWG9jDaQ gZin724HgDy43nJkWwOB4ioxZRziSm74llJJQ01H6W3yCn/ioMn5jsLi8D6YKPp4Zo2KYb z3mluNBChI44UH6Rd1TMgn4xo4MqPCU= ARC-Authentication-Results: i=1; imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=bGNlhels; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708371882; a=rsa-sha256; cv=none; b=8qwQ/BGS8ksTNVfiP8wyNGJmVqSI49p0YErZmzG8aHX82tHEFXu9MZYATCDD2K16SAdj0+ yXQMftv0CjGL5RPlw7amuIwzmUcMM/UC51x4xaYW6IoOp7BGYE6M+SVq8YBDd6P1+tQO1o iaPcILO2sfHhYIqu8AIDDxW14t3cVXc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6EB2960F77; Mon, 19 Feb 2024 19:44:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D968FC43601; Mon, 19 Feb 2024 19:44:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371881; bh=zs+kw6wIVyudOx0IbIQ/KacaL4dSPBoyKxbciIuGSqk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bGNlhelsuaOaVxbpRiKvqbRC14Uit74+279k9YL6Eqrf/mCSZmQo5fNZC2Zn6ZDKj fOuHIHYPsbeH88zPeYuccArNi0m1YJ0i/565Ne57yKMD7zC9YblLyXJDvea9GrJE9O zarsCYLN1OJhuIAnD3y1Wdk3AH+hplMwdJZdNHr6z1HoCozoX1hXubFTIulZFy8K67 WoP3gxY4HmUpWAuqB7ShV6n116XZy2e+77MmGhGjyuu8r6sBQi6zh3VQ855a9VHTe6 L9fLcKFksI1kXy2qX+E6FftgAS1BP3hRJ8lpic3LqDJCpyKQz4yUpfjsvf6A3u7g6a NggL4U2/GvAuw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/20] Docs/ABI/damon: document effective_bytes sysfs file Date: Mon, 19 Feb 2024 11:44:15 -0800 Message-Id: <20240219194431.159606-5-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 4BDEB14000E X-Rspam-User: X-Stat-Signature: n6gq5jahpt6855juisgdgaj9qyz39ei1 X-Rspamd-Server: rspam01 X-HE-Tag: 1708371882-359127 X-HE-Meta: U2FsdGVkX1+GqT8+Wemttmpm1wHgjo7TZ5/3G0km6sF9kmqNqPZhgtYkpR4mvcpRO3fv2VvSg+dp2aqFlrftjCoChIHYGApGNhy5/OMshk3Oi5a9aO4bLnZ3QL8RIcTnBtXKUOiWjuEJ/s6EE7CTLURJF5ri0pp6SLBEC4CGZGUuzovifewlFj2ELknvR1XOn687fXaItOM9iF4dNxxzZfsfvAoZQBwOvE3X5C3MwQB2Neg9upzuVJIqoIS45vlnwG7JmoGPkfbl4dKpYOl+C9dKUO8bL4U2nGPPvhQA2S1srkY6EXgorYlxhbbtIQspo1UwcB6XOBMEu0wNsY1qVeQxTQO2x+n9pZrPIMIeO7bx4v37uSUAbuXgDKh2Bv6Kig72MXO57vXX0Dj5l2kEI42H76Gcdou6/QSUFfurNQvHyzZm8DDYnuGL0bWTM6nOgOkuKWIc2XX9WGtrgz/NdqTuo+uOmeK7GyLM6gZEK6KkGi90o1cRf94aWadRh0fcgFykqwIjWxJcjwz5bC/xKQO0+CodsejHOBilw75L/qZEiE7h2ZF/GmlyZdC8SevOh0Mxt8Kqp73T3DQd5Ug7zNdJONCqWZxY+b0SdAfdTf5RQB7X8FZYXpxPV6TGnLwxRFap+C7WlHVPwaeJq642NRxc+2ATVbcA6v0sNVOWoAgxco14THQ38RBJGM6a0AoSk1gczeLyKwlm3AB5HlZdxs5crlZkB2hwRgF9qLWchRQ5H8ghksZ77muFCkaPF1/XnJL2lK4A2fVGyUWvXyHcqkKVS572/sz+CM6IK8L+x12v/iCqvtpCyQqFC1QItCzWpPtSJeLlo//AjrgOY+I/PDotNDfrshsO/VpQa625L7WLDlX9mmgQieBx0glMWiuFNAGkApcuXxxH/jC5sVFA7yFtuske9xI7byLkXytlWPiW3HTkSGacJHVOKeXeb47SRErBE8SfM8InFqQWH3X fBwLw8Hr 0SNYj 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: List-Subscribe: List-Unsubscribe: Update the DAMON ABI doc for the effective_bytes sysfs file and the kdamond state file input command for updating the content of the file. Signed-off-by: SeongJae Park --- Documentation/ABI/testing/sysfs-kernel-mm-damon | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon index bfa5b8288d8d..a1e4fdb04f95 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -34,7 +34,9 @@ Description: Writing 'on' or 'off' to this file makes the kdamond starts or kdamond. Writing 'update_schemes_tried_bytes' to the file updates only '.../tried_regions/total_bytes' files of this kdamond. Writing 'clear_schemes_tried_regions' to the file - removes contents of the 'tried_regions' directory. + removes contents of the 'tried_regions' directory. Writing + 'update_schemes_effective_quotas' to the file updates + '.../quotas/effective_bytes' files of this kdamond. What: /sys/kernel/mm/damon/admin/kdamonds//pid Date: Mar 2022 @@ -208,6 +210,12 @@ Contact: SeongJae Park Description: Writing to and reading from this file sets and gets the size quota of the scheme in bytes. +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//quotas/effective_bytes +Date: Feb 2024 +Contact: SeongJae Park +Description: Reading from this file gets the effective size quota of the + scheme in bytes, which adjusted for the time quota and goals. + What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//quotas/reset_interval_ms Date: Mar 2022 Contact: SeongJae Park From patchwork Mon Feb 19 19:44:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563007 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 F04AAC48BC3 for ; Mon, 19 Feb 2024 19:44:51 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B7B9A6B0082; Mon, 19 Feb 2024 14:44:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A69876B0088; Mon, 19 Feb 2024 14:44:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8C2BB6B008A; Mon, 19 Feb 2024 14:44:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 5CC736B0082 for ; Mon, 19 Feb 2024 14:44:45 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id BABA01403C2 for ; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) X-FDA: 81809580888.06.A494614 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 0A65D18001C for ; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=q3JlR1TM; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1708371883; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=SRDCctGY6qtGU8lGbKUE5wni1l67EM3vmJhAhZajsSA=; b=tDKhhhEzBhIXeZY6kpurHDFH1oetRFvpnOgpUHfBmIS9qQUt9Ug5t54BVJ1klol062X6AX huK36v6a+pkfBmBXgtEnoR9rRT/qVWBMjXmc+7ZV/LSnS9tY34FQy62zBvd8Sq/UU26Avb lpB3Fhp4CWTIen1D+irA4QvbKjWKx+c= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=q3JlR1TM; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1708371883; a=rsa-sha256; cv=none; b=aoWJeUHJ37/oP8+Q+xObr1QPg1H55be/hzc4j3c1ggH3s47A8ygu9u6ukL8fDaymarDeUh VNqyEAsKYu0U7aws8DpDp7Xp3VsK1YxST+GkdBD3ctakDxJ85oqE+/ygMW61WnrSTt+hRY u8xfKVyx2MJhiJu0DLzZc8Jr1xzNSyA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 209ED60F7C; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6E787C43390; Mon, 19 Feb 2024 19:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371881; bh=Kc80eiLjIjFfjUUzf1ec4uqhs3PwKD70+PMFGRlYm9w=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=q3JlR1TMBd4SZipJkxguG3s3i9iwsqiUwe8NWYu9g5VarCQPcboEKYUol/8Ltw02/ 7lVy4f/dwVLcQIzZq2RwxsBGYZPGlnDwh/ncGthYhY+xGOxovBI2rk5qA8CmR4V3P3 rOgyHFgBbl7gBF7thKUeezEPey8JCAxfIjN1twH61U5pqFdIxT4PvAa4FHXrrhIGiu SUCph24Jhh8qdoNRJzRpTQnRUE1/Y3Xx91lMc263hFrZIgsAzmpfyQ+84r5OHWFwKQ cJ7bWU4XUwCN1ukCpTJBEgtQk1D5I6a6/1+YdOXyMFDGXpSrXK3/fhvNVVsDoZ+ZTV f7hbn9PJKUiPg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/20] Docs/admin-guide/mm/damon/usage: document effective_bytes file Date: Mon, 19 Feb 2024 11:44:16 -0800 Message-Id: <20240219194431.159606-6-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0A65D18001C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: fhejpwp1s6ksu8unii96qzw1ro1g9gtq X-HE-Tag: 1708371882-484456 X-HE-Meta: U2FsdGVkX18sgsNZSRLB+wnUDFk0C7+jRpYFXsPYqllCRT4AZUJtdLyW6X3J5kEteGibL4eqO11OGdap4nCTHBofLMZwhXxJKZuET2GiYRg5OnAA/cEwpURqEpX9tbreReNk4NTZx95zXDFoZZPuo4cXQm3yQkrTRHrGMY2ubG4qZqpOXx3V4QfuMgCIkj9amPBbhURWRxJZzMnrp39PG2zkfn9gs0zzDMWUo2eO1c/d1KJ0PT0C23ehOvdw0lrXzrSgfQzsVUe3bVDRVuxyEtvqnIApdT8P4YSvuem8ySuCeddioXuxyq4UdydgbxGVy/MPrq4d/YVFwfcZFOika9PsnVQluo0NoPip85G/2S8+zs/uei5jJyyIPbG7HNJB4os0TKuE5YF7gKX5kBUQZs9iKAF/f2Vt2AuFX2u4Z78lriGxBI8CsIe4ffGFHmrh8+NrmYYBTmTeN9DkeSJBtvyOi86iKGKKYxmgg6fyRSeMtmKzLeIJETyIFIX0ZYcdwbAOiUFw0c+iLeczqm1Q0IzoTSqM4FJPCV7gr+y+YUbQ5JoRnEUaowajOKGTVVhfrWDdpX+vlCzWOBsNMpD9UPo+wZDCDvfeMMFJ/zLicUZOPkJ8C0au+IsDR55e/Smt2909Fjlqt9EPqVNrS7ja1lsZTpc8f6SN81dYaSRAofqB9JDYJ3QLUbsFLvgL+BBighh9YESYIGnFAuv8xrjAyT/vlqsVCJM/DXQoPcyn562q7QzMWnirD04qnvf7bYBP/n4tahjrtdBWfTgShVMUWRWd2atEY9XsOalKBmevnvblhSQ57+qpNo/QbFPio51jriJ3RkKv/+8jiUYGf5AFd4V37ZASwsVGFDCkYqz3tLkoh3ayeToI6p9XuINX3pDJljUuNZWPOkVbaTzfL+HVB6CRPie2VRph1De7stJqP0w+DzdIwnuPVAcppARL/wDjJ7jrbH+uuxfeGPQ8Qb7 qP4iwZNy KVxwP7T/mmxAtQ/2egCVv8GOgQDcXlmQ9u+T0Wm0YwCaiAj1r5WzKZ7v8L4W0o3bh36NN8JKLGukyKH9ftC89oyx9GPetwJgbrGPz4UsbVOI9j/cC3tHLsnokqxd9c7bnaXhWtmzUsADGrVsUQOyZE2PnkosLWduI39QiMlbMNuG5iM/qhGtYRksCRd88xZmkTXwJJleC/qD4edsYY5TewTA4BF02WIGJw9rj/xHEZgGt1htLc6Hn+Hz70le/0WnU93nVhhwe9Mu25ShYwQWUIqQ6fd2Wa1YcSNQ4Y24XDwPN1DlPWxv2tCT/qIxhmoJiaDU9jYsq5de2mMJkbGc0iDPhWQ== 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: List-Subscribe: List-Unsubscribe: Update DAMON usage document for the effective quota file of the DAMON sysfs interface. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index db6620b5bc0a..220ebbde7324 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -83,7 +83,7 @@ comma (","). │ │ │ │ │ │ │ │ sz/min,max │ │ │ │ │ │ │ │ nr_accesses/min,max │ │ │ │ │ │ │ │ age/min,max - │ │ │ │ │ │ │ :ref:`quotas `/ms,bytes,reset_interval_ms + │ │ │ │ │ │ │ :ref:`quotas `/ms,bytes,reset_interval_ms,effective_bytes │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil │ │ │ │ │ │ │ │ :ref:`goals `/nr_goals │ │ │ │ │ │ │ │ │ 0/target_value,current_value @@ -153,6 +153,9 @@ Users can write below commands for the kdamond to the ``state`` file. - ``clear_schemes_tried_regions``: Clear the DAMON-based operating scheme action tried regions directory for each DAMON-based operation scheme of the kdamond. +- ``update_schemes_effective_bytes``: Update the contents of + ``effective_bytes`` files for each DAMON-based operation scheme of the + kdamond. For more details, refer to :ref:`quotas directory `. If the state is ``on``, reading ``pid`` shows the pid of the kdamond thread. @@ -320,8 +323,9 @@ schemes//quotas/ The directory for the :ref:`quotas ` of the given DAMON-based operation scheme. -Under ``quotas`` directory, three files (``ms``, ``bytes``, -``reset_interval_ms``) and two directores (``weights`` and ``goals``) exist. +Under ``quotas`` directory, four files (``ms``, ``bytes``, +``reset_interval_ms``, ``effective_bytes``) and two directores (``weights`` and +``goals``) exist. You can set the ``time quota`` in milliseconds, ``size quota`` in bytes, and ``reset interval`` in milliseconds by writing the values to the three files, @@ -332,6 +336,15 @@ apply the action to only up to ``bytes`` bytes of memory regions within the quota limits unless at least one :ref:`goal ` is set. +The time quota is internally transformed to a size quota. Between the +transformed size quota and user-specified size quota, smaller one is applied. +Based on the user-specified :ref:`goal `, the +effective size quota is further adjusted. Reading ``effective_bytes`` returns +the current effective size quota. The file is not updated in real time, so +users should ask DAMON sysfs interface to update the content of the file for +the stats by writing a special keyword, ``update_schemes_effective_bytes`` to +the relevant ``kdamonds//state`` file. + Under ``weights`` directory, three files (``sz_permil``, ``nr_accesses_permil``, and ``age_permil``) exist. You can set the :ref:`prioritization weights From patchwork Mon Feb 19 19:44:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563006 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 84124C48BF8 for ; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C0E96B0087; Mon, 19 Feb 2024 14:44:45 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 670C16B0089; Mon, 19 Feb 2024 14:44:45 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 49AE46B0088; Mon, 19 Feb 2024 14:44:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 369E56B0082 for ; Mon, 19 Feb 2024 14:44:45 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 07650A0391 for ; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) X-FDA: 81809580930.04.8E9C6C1 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id 762BBA001D for ; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NgOgZmiU; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.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=1708371883; 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:in-reply-to:references:references:dkim-signature; bh=1PRKGkczrSCC9U0WyWDOfOusUernchL4EBxBtw24NII=; b=4uBphnZHkn10wsrZH/bongNwHz8XhVLX2j7NHjg2LC5yy3QY4ezUXr1IZyZu5jTPZBpFO4 r6WvhTYnv/yk2NTp9VMkuFzpBWNnXb8b3u9cCL/s+9vlCnxmT77r3UkUXLgvm6CqyKfMLc ZaNGA8vbMtNudtrHrGZSAZRWGHwFp28= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=NgOgZmiU; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.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=1708371883; a=rsa-sha256; cv=none; b=VIDgv44/jUguUrAfChQ4bwxjJeHvk5cehU/ZyLbCOad6o7/jyhdO+dqzOjAKpMh9VbGoZd wgDB9lD0zIrwAGFPfvAw+taGjTNEe+GkE6PXnvRXdqo19n3ma59tck3xKbSv3vye/Q7Y0m cNmZ/FPsHPjUsFllFOmk7/dk0tlETK0= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AC87960F63; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 257E6C433A6; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371882; bh=Qrt8JsNV5WkN+0gJ5TqfdjaJcuo1NKzpe3AmVI9CrWY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NgOgZmiUq1dFACJWkzSo40xUY0CWmo3HkcrEs3Qntc04KmTD4ie048M4w7bSaDvGe X3uAWqEpQJnp5rIcb9NO63LE6exscXEK2a7FrdEhAnUsYNjMOXHS9hx7vrtqgAa8Ww N9eKU4ocm7Y6VVhmKolxeOUC69Ksq6HGnop1dAPJ6Sr4ZYdu/KVTVcVAzkQ9fUJfu4 Dtl+wq7VEg/lbpHNeevT31JTyjyQb9n9Iajdj6MHNetRMx95jh+nQSuTKvJDznV4hn JqBZMBaAYQyzGoXXA/SPyGlrDPXu66aXtoxujWaavGaBVXHfobr5Er2PGN5moe/tt5 B8X6f3vRLzZag== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/20] mm/damon: move comments and fields for damos-quota-prioritization to the end Date: Mon, 19 Feb 2024 11:44:17 -0800 Message-Id: <20240219194431.159606-7-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 762BBA001D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: pdmm9m336yx3hg4ah9s5u5kh586cz6b3 X-HE-Tag: 1708371883-381427 X-HE-Meta: U2FsdGVkX1+0NmYnaxUe4Uin/yqDRCYgjEQFQCdNlTGd9fCmm3XdzX5mZUDAU1T74wu/3tQ0JZampI6/zkVMad5UB1VNUKt6f6+2f8Ws4K+Y47zTnivNHwXGDhsUAL76cz+Sd3apkFXzvyue5M63APiQ/5qvgFJuBDJ8OyyFBEyhQym2n/m1+IrYEHNYuubZ3MJspGPKgvoSENHDKt59t/zaKvUiS2SKygSCyifJp6C+NCoOog5y/037O5WwP1tlCWmpGvK4hnH8xc5tup2HLi4SW//M9LLn6C3Le4gf4jNXHSpjwQ3E0NFhgBXwmAcHP0fuyiKwnzq5gPpCBXt0LwnftVImQmYdintEi58GCQT3RsootG9xHUG6Sodf5Q1kCZhuzjd5k6MlB22rrJpOUr6iluLMQK1WUmnJuEb4vf8Q6A6VJqhBUia43GzIdhFdRY38Ktdp6tKxnLnK6DJ1NyjO+QDpTDEvvjlQR7cfq6ohJojyXqOPThaPRvJDwykFnAtPf1tMEF7naZ2XsRa/nWQzdUYL0wHd+p5bqkq83WHgb6mym1+msQ+S/KR3C3yVySOtZPerrSHzcYeQIMohIxgytzv0P5CblIn3iQsQKp96T9Jvx3pOoE4OMzCy1r39ZDz40Y6wrYTi19sbEOxQ0vFDLZhOhiOkDxLVhge1xW1m8TH91J0kQVKGE8FwI59nGZ64csHjR+qHyDoSh47haWVEFMfaISAj+5xBKXuJNSeb3KewaUIIggwIpOmMyd2doE/7ZSFnEeM/NMTvs0891trLesShl2Y3ikVgqwTcvz9EGa0pBfXylKDyzDPu3Qyw9sqdqsR3tiNSEtUwOjXypx9zKXki0RbsvG7jVY9WkSue9C0VJZzxxuNLA3wvEEl9gMlA8Iyp20QS4+DzmfXm12jjdk3zLR7r9VdGxlgl8IOjTs1KTfudlA== 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: List-Subscribe: List-Unsubscribe: The comments and definition of 'struct damos_quota' lists a few fields for effective quota generation first, fields for regions prioritization under the quota, and then remaining fields for effective quota generation. Readers' should unnecesssarily switch their context in the middle. List all the fields for the effective quota first, and then fields for the prioritization for making it easier to read. Signed-off-by: SeongJae Park --- include/linux/damon.h | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 93ef45b87b9c..bd17b14828bc 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -128,18 +128,17 @@ enum damos_action { /** * struct damos_quota - Controls the aggressiveness of the given scheme. + * @reset_interval: Charge reset interval in milliseconds. * @ms: Maximum milliseconds that the scheme can use. * @sz: Maximum bytes of memory that the action can be applied. - * @reset_interval: Charge reset interval in milliseconds. + * @get_score: Feedback function for self-tuning quota. + * @get_score_arg: Parameter for @get_score + * @esz: Effective size quota in bytes. * * @weight_sz: Weight of the region's size for prioritization. * @weight_nr_accesses: Weight of the region's nr_accesses for prioritization. * @weight_age: Weight of the region's age for prioritization. * - * @get_score: Feedback function for self-tuning quota. - * @get_score_arg: Parameter for @get_score - * @esz: Effective size quota in bytes. - * * To avoid consuming too much CPU time or IO resources for applying the * &struct damos->action to large memory, DAMON allows users to set time and/or * size quotas. The quotas can be set by writing non-zero values to &ms and @@ -152,12 +151,6 @@ enum damos_action { * throughput of the scheme's action. DAMON then compares it against &sz and * uses smaller one as the effective quota. * - * For selecting regions within the quota, DAMON prioritizes current scheme's - * target memory regions using the &struct damon_operations->get_scheme_score. - * You could customize the prioritization logic by setting &weight_sz, - * &weight_nr_accesses, and &weight_age, because monitoring operations are - * encouraged to respect those. - * * If @get_score function pointer is set, DAMON calls it back with * @get_score_arg and get the return value of it for every @reset_interval. * Then, DAMON adjusts the effective quota using the return value as a feedback @@ -170,20 +163,25 @@ enum damos_action { * set, the mechanism starts from the quota of one byte. * * The resulting effective size quota in bytes is set to @esz. + * + * For selecting regions within the quota, DAMON prioritizes current scheme's + * target memory regions using the &struct damon_operations->get_scheme_score. + * You could customize the prioritization logic by setting &weight_sz, + * &weight_nr_accesses, and &weight_age, because monitoring operations are + * encouraged to respect those. */ struct damos_quota { + unsigned long reset_interval; unsigned long ms; unsigned long sz; - unsigned long reset_interval; + unsigned long (*get_score)(void *arg); + void *get_score_arg; + unsigned long esz; unsigned int weight_sz; unsigned int weight_nr_accesses; unsigned int weight_age; - unsigned long (*get_score)(void *arg); - void *get_score_arg; - unsigned long esz; - /* private: */ /* For throughput estimation */ unsigned long total_charged_sz; From patchwork Mon Feb 19 19:44:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563008 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 48F75C54764 for ; Mon, 19 Feb 2024 19:44:54 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2CA4C6B0088; Mon, 19 Feb 2024 14:44:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 119466B0089; Mon, 19 Feb 2024 14:44:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F211A6B008A; Mon, 19 Feb 2024 14:44:45 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id E0D886B0088 for ; Mon, 19 Feb 2024 14:44:45 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BB8C7A03DE for ; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) X-FDA: 81809580930.30.3A1CF29 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 29D5240011 for ; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gphxwb2u; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708371884; 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:in-reply-to:references:references:dkim-signature; bh=lV3L6p79knSzLtiMqkJs5JForDRjkSbvrgJLfK73hi4=; b=506Ems5P6lsSBZDRSA6bocdJYMPpPUsmxEIsspU669vOSjgabS2JJ+dXd7NV7QPe1Y24CO zrIHgLvp4JmfJmiLTr+/Vlx2DkL/GMZX6Fprd7tc7vp5UaXKSQy8bo/UATGi2Us6mjScPr PyJzKK17r4pon4JEXJAJMUJT+bj5M1s= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708371884; a=rsa-sha256; cv=none; b=U+Riradl1i+6lud1QG+dKzlI+0tZQg2sZoccKbBgwPoo0ZkXokIypxtqdUs/fYVq5v1OM3 O2Fc3AA6/lYTTo41qbXenBjzZa7CVpD8cIKix9ptClIgSgBD70cV+OYwmCg2cqADZIiz30 1wGFfRdSnLNIjXSm8Pkrn5QF9xmzgdI= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gphxwb2u; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 4661360F95; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B00EEC433C7; Mon, 19 Feb 2024 19:44:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371883; bh=BGP026mJwlW/eKHVIUjB0WBT8A8x06Px6FbED6keS6Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gphxwb2udN9PVME6d5bTuNTiFXFuKfFFZHlFeju9dUGTOajLOpZfQKlxikbafpC1b eEvBQusALO514a+hnWtLbkRylZihVkHFaBU73bpN1uOTk2yJ5wuad9zjPoiAlWKwwy aHvHZpGgauHziCU2VPTn+9bCIlwJdfOkNXogRBWYlf6amibtzPfFnZ7ivWjohRhnve GG2RB+HJfAVJ8Jzg9La/euCL2mC734M7jNPrgJZtX0nn5kfRomW0rMKXBDk1kIVpsg CkiuMvITGMdr0Nd0JkiiOu1GdmKPOcVLa3tWSascMIF5SlZZ/qjx7qOq8ilDWpkQrn ySNK1Fyi883oQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/20] mm/damon/core: split out quota goal related fields to a struct Date: Mon, 19 Feb 2024 11:44:18 -0800 Message-Id: <20240219194431.159606-8-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: aq4kd8rf4he6g7h3aj5urijg6ub6sss5 X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 29D5240011 X-Rspam-User: X-HE-Tag: 1708371883-738098 X-HE-Meta: U2FsdGVkX19FJLUAZR/1tkxnt3dD7JJ5NIH/gJhNOZrkkCSOcnSAfnBBkBgWp2n//lmhVI3l0A5fnNQXy/tK529gQcNnfzNMkLEAVTY5XXKUZHY5Go0JvQsN6kkfhZM5t3OiHRtuCp/9Ym8l2eWxUOWYOOPnKpMnRI3hrLXgXiogCm+m5oGnQVd6Z3fzMM+PJtrj5nR40RUecFqMNsz8GEz4rUMezF5n5Gsw40SMO45kAYv9hQ1jStI4R3+LWPSblWTnfKgSIZlWlOW7nsY2Il2prBPbrg23d4Ux5yPubChmsRDdtaR8z6xz9ICzsNFH3aPqr7DmTUFoPzPinfPRfBlXWSnmHMjwQ9F3Qy0qZB4zN7Kd9ieVCUQNMvkTKGx81MFuo8T012IfojMk2DsTCYJKVPYWgcDmiyBpoBni1k45X+lGB3Be8H8J3ng3CnfkSfPvAlVwAK8OD1Hj5SH3q7NE0Ml+ZfNNarTCMdNSy0NXycQjnD/azZu3hsxUCHgq5eRXMjCKjyPXYP0lNt7IgYosfvG40IHFyFefC+ZMqQgpETsxO1TuVCL/OmWVr7rc51s17HVnsqeI79g/HQSnZ4Kr3NLz85jxk9AzcjOLU7dOlCVHGZNcML3BlIjrmpa7BmGdpsYO/8DcS/eCaPohXlGaJOm6VSCwpbNKkOWNIlJgf0WfXx3o/geDKgIJ/DlvtZ0KBfPN80RbB36if3jHm3bnWS2AUjghX7jhVHTxKg3QLEb22tMt2xjuZZY3vxmlYuJTmVEoz3RaboFEuVRQsRLoFL6TIum6MOA30okT2bQuCJvZb7prbodbn4BReDFN7cEvGzRcFlyv/OjABchoYxQLwh3KH/lCmcDaAEkV/mkZAVitbo04tGrncsg6yDGctLhMajGvBCeLdeYSN75Hnq5sIEK8xUtNLBJr+stJthUIAKPeQ0dqLkKY9xkAlfPdADO4s1YO3xjouLSTNIS cMtyVpwQ OLTpSU6EZ62ePfK+40zr8kYEMLAcd8qBH0wuy2rnZuvMr5+u4FT8YxB4O3bd+/cgHCPshMXIiaAtT8rorMmWTk7cKaQMUwEMHmu1HpAkLM/jzjeK8Mz9fllhZrd1ylL5pdnkHeKUjJq0+cAdG4junyOYje0HkD6CATfPxWtBihm+pYu6237yzfJXcub9pc5WegAdSJK70CU3CmFkZ5zaORmqdFA81PZlg+gPXpRdJ5Z6vYps= 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: List-Subscribe: List-Unsubscribe: 'struct damos_quota' is not small now. Split out fields for quota goal to a separate struct for easier reading. Signed-off-by: SeongJae Park --- include/linux/damon.h | 36 ++++++++++++++++++++++-------------- mm/damon/core.c | 13 +++++++------ mm/damon/sysfs-schemes.c | 10 +++++----- 3 files changed, 34 insertions(+), 25 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index bd17b14828bc..2fe345adf6b2 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -126,13 +126,28 @@ enum damos_action { NR_DAMOS_ACTIONS, }; +/** + * struct damos_quota_goal - DAMOS scheme quota auto-tuning goal. + * @get_score: Function for getting current score of the goal. + * @get_score_arg: Parameter for @get_score + * + * Data structure for getting the current score of the quota tuning goal. + * Calling @get_score with @get_score_arg as the parameter should return the + * current score. Then the score is entered to DAMON's internal feedback loop + * mechanism to get the auto-tuned quota. The goal of the tuning is getting + * the feedback score value of 10,000. + */ +struct damos_quota_goal { + unsigned long (*get_score)(void *arg); + void *get_score_arg; +}; + /** * struct damos_quota - Controls the aggressiveness of the given scheme. * @reset_interval: Charge reset interval in milliseconds. * @ms: Maximum milliseconds that the scheme can use. * @sz: Maximum bytes of memory that the action can be applied. - * @get_score: Feedback function for self-tuning quota. - * @get_score_arg: Parameter for @get_score + * @goal: Quota auto-tuning goal. * @esz: Effective size quota in bytes. * * @weight_sz: Weight of the region's size for prioritization. @@ -151,16 +166,10 @@ enum damos_action { * throughput of the scheme's action. DAMON then compares it against &sz and * uses smaller one as the effective quota. * - * If @get_score function pointer is set, DAMON calls it back with - * @get_score_arg and get the return value of it for every @reset_interval. - * Then, DAMON adjusts the effective quota using the return value as a feedback - * score to the current quota, using its internal feedback loop algorithm. - * - * The feedback loop algorithem assumes the quota input and the feedback score - * output are in a positive proportional relationship, and the goal of the - * tuning is getting the feedback screo value of 10,000. If @ms and/or @sz are - * set together, those work as a hard limit quota. If neither @ms nor @sz are - * set, the mechanism starts from the quota of one byte. + * If ->get_score field of @goal is set, DAMON calculates yet another size + * quota based on the goal using its internal feedback loop algorithm, for + * every @reset_interval. Then, if the new size quota is smaller than the + * effective quota, it uses the new size quota as the effective quota. * * The resulting effective size quota in bytes is set to @esz. * @@ -174,8 +183,7 @@ struct damos_quota { unsigned long reset_interval; unsigned long ms; unsigned long sz; - unsigned long (*get_score)(void *arg); - void *get_score_arg; + struct damos_quota_goal goal; unsigned long esz; unsigned int weight_sz; diff --git a/mm/damon/core.c b/mm/damon/core.c index 0656966a6fc4..fe4209672121 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1083,21 +1083,22 @@ static unsigned long damon_feed_loop_next_input(unsigned long last_input, return min_input; } -/* Shouldn't be called if quota->ms, quota->sz, and quota->get_score unset */ +/* Called only if quota->ms, quota->sz, or quota->goal.get_score are set */ static void damos_set_effective_quota(struct damos_quota *quota) { unsigned long throughput; unsigned long esz; - if (!quota->ms && !quota->get_score) { + if (!quota->ms && !quota->goal.get_score) { quota->esz = quota->sz; return; } - if (quota->get_score) { + if (quota->goal.get_score) { quota->esz_bp = damon_feed_loop_next_input( max(quota->esz_bp, 10000UL), - quota->get_score(quota->get_score_arg)); + quota->goal.get_score( + quota->goal.get_score_arg)); esz = quota->esz_bp / 10000; } @@ -1107,7 +1108,7 @@ static void damos_set_effective_quota(struct damos_quota *quota) quota->total_charged_ns; else throughput = PAGE_SIZE * 1024; - if (quota->get_score) + if (quota->goal.get_score) esz = min(throughput * quota->ms, esz); else esz = throughput * quota->ms; @@ -1127,7 +1128,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) unsigned long cumulated_sz; unsigned int score, max_score = 0; - if (!quota->ms && !quota->sz && !quota->get_score) + if (!quota->ms && !quota->sz && !quota->goal.get_score) return; /* New charge window starts */ diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 9d90e7b757b7..85ef58f98a87 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1894,19 +1894,19 @@ static void damos_sysfs_set_quota_score( struct damos_sysfs_quota_goal *sysfs_goal; int i; - quota->get_score = NULL; - quota->get_score_arg = (void *)0; + quota->goal.get_score = NULL; + quota->goal.get_score_arg = (void *)0; for (i = 0; i < sysfs_goals->nr; i++) { sysfs_goal = sysfs_goals->goals_arr[i]; if (!sysfs_goal->target_value) continue; /* Higher score makes scheme less aggressive */ - quota->get_score_arg = (void *)max( - (unsigned long)quota->get_score_arg, + quota->goal.get_score_arg = (void *)max( + (unsigned long)quota->goal.get_score_arg, sysfs_goal->current_value * 10000 / sysfs_goal->target_value); - quota->get_score = damos_sysfs_get_quota_score; + quota->goal.get_score = damos_sysfs_get_quota_score; } } From patchwork Mon Feb 19 19:44:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563009 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 CC8B4C48BC3 for ; Mon, 19 Feb 2024 19:44:56 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E12916B008C; Mon, 19 Feb 2024 14:44:46 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D9A956B0093; Mon, 19 Feb 2024 14:44:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C15926B0092; Mon, 19 Feb 2024 14:44:46 -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 A62486B0089 for ; Mon, 19 Feb 2024 14:44:46 -0500 (EST) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 548BE12038D for ; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) X-FDA: 81809580972.26.BB19D8D Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 9A8AD4000F for ; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Z7CKpYy3; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.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=1708371884; 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:in-reply-to:references:references:dkim-signature; bh=vwLHs0PKGhGSIgKerYJ521PT+13VxaMIHLgN3P/NRzk=; b=4giMN5MsWHXTtNafKTs9Poq6xxuLyasYgHK7kzP4F2ZlHlvu/+vHJipG1dAguvg5HYSARK +pKLGP8yhWDjmbJTppgnl+CxfDOX9SAPIytJMWlZx5E/42jd+XN8Jvl0q3Gx7LjmzZS75U qv1HAquQv5MZLHoRLUDmEknNcIC7AMI= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Z7CKpYy3; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.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=1708371884; a=rsa-sha256; cv=none; b=xm8+wJJuEV7E3S0GsijIpCMMIv03yMw4x9KBef+/9rx+U5qYsn6Tj9hM3qeQYAXvM1Ti1J wV7uIMfa+nOZQ/vPJoz87fg0onwHVWCzSpexTPwYAckSXgiIWUhlCRBJBZ16gBs5V/ouWj WR/Ra1FJWK8TAfhktb3l8JghQjrMIfM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id D0AA860F78; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 46B6EC433B2; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371883; bh=oql1XzmeT1+l2YfyGdM6ybnvM0NrgJg8QAeQ/QOsNwg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z7CKpYy3zZMnNZ2RLrlm/AhKAtiDKdltHNeltt9YG/c//avZ/C21btvKo+6IMHC96 LuwXn48YUa67+phLsPiSdim1cxKHYuV0Kb8Q9wGuJtXotzBoNuJ3dItv/tLRJeL+QQ d/ph0VDegeSUVff2L1TWYXgi8lgOT8AP06X9xZHbaMikLZS7a0IzQBAVQx/htTH6Vg WvzON9voOco8RI33NMG3fCC//hezOSpAo+mrz2fhCQP1CWpuofBL8v+QUxd6zewgej /QJNyZg1x6+1scwJCV3Ql/pIaF55xQUw6DDSxXLKge0+xX8eYYgdvgZ3QfHD/Dd+Z0 tBvtii6hP0Qew== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/20] mm/damon/core: add multiple goals per damos_quota and helpers for those Date: Mon, 19 Feb 2024 11:44:19 -0800 Message-Id: <20240219194431.159606-9-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9A8AD4000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: fzyeam5879mar5xe9139qicjanzkzgy3 X-HE-Tag: 1708371884-909591 X-HE-Meta: U2FsdGVkX198ntTBQhDa62emXbyolkxexuM+K7lWfj7AqgAbtzuI63sPrl3FT8l1/NUMhFVlv7WSVdLZOQkKs3y3EcaQpRXkpHlRE1n4dVBoWPtqczCC6LicKSm90NQ83tPopmgnRBWMLj/l8si9YHyVh+iczvHnubHuIo8sgXQ2NJEnJLsRh9tzBahaJ/11YzEPVcrvjAXtyZzOYpYKRV3GS+8fhyNCh901NLX+PuHudg4Gt1iPmfr6kx7F7VnllsVZAV50VfvNHVbVmjU40qA5Yks9F5BzPtfyBsgD2TxEqCbJ2Iy0NX5gzQeGHTaxM7tTngUN+T0WYSgDyxAnjFRrALrDUt9awF1qqBfMq04NDvR6CkKWGeIpdRhVP6DqaiVn2q31gahR2L/PvjrB3BTfLYa6XK07XgaS+iNwfaLoB/kI1bkMyPHDGcMqXFHkbTI2Hu/REZvHdcJdzMlkCU+IOTyv0Vvxm5xVmaLxjk4tsaXnDQxHDwFiCQCE4DbRlquxkWNwtLskE+Yzi83kF5EqqjIkxa0ocAsrEf9Yk0UKJUcVOJGiy2n81nQuDl9i5nSf7Y29Phw0FO4yFMNkVXwpn8IjmwWBgDAhHvB1ynt/Dm55z0czsV4XocKaFewpQ079GnV+eegRjZDL6VuA2A2+7kcaMSHeEAORLdKbWfrTfS1W9MFYjp5SL3TNaX7S4N30N9pSWUa3NAEwTQC7JERFNXHbvFYovuUgTf5McRhuVyA81DhhXc9gxUyTQP1mP2xOOC5NS4dBt5o8yfFXCqWvDGWCSbIDhlBDwl2vKKTtPMS2AD7j8mZeaHmJnlHI6r+7JBgVxBUFIflw7RIJXHehBqicq3GzOILPyLDzhDWOGGpFyDgYrMGvHeI3AOJ90dmCKpj2iQeuuJsQ1lv8DI2sRg8/59ub2qYzRANqdgKFCpaXsD4k9D/gAf8MBLn6BSfFqOKyMtQXKvT3gKN hZxoA4MQ 2+lA3//aOlCZA2SDHXg6X7TbkOjkksjGyGW9jhVMUWlHxK9YMNjPTCq3D5g76SVCdqwM+5WNCu8i1uG6hjEhoZVqUA7zq6krPsWE1WN/EyHnnbRDpxj8BFQJlv4nm/Nl/x9BtRVICgOaz8QxVcWaBb75vErNI701sHPtzwYzjwxNO8QULg7jPOSlaeScpPdQ4RFt0OnobxUkZ/J79rInARUfvXwnrpxWADynpF1Lett1k536gyIcwmGFEOOnetsBdMeAHQ1Y/C976vJmeS4NxYDgXp8WHSd53TwbX 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: List-Subscribe: List-Unsubscribe: The feedback-driven DAMOS quota auto-tuning feature allows only single goal to the DAMON kernel API users. The API users could implement multiple goals for the end-users on their level, and that's what DAMON sysfs interface is doing. More DAMON kernel API users such as DAMON_RECLAIM would need to do similar work. To reduce unnecessary future duplciated efforts, support multiple goals from DAMOS core layer. To make the support in minimum non-destructive change, keep the old single goal setup interface, and add multiple goals setup. The single goal will treated as one of the multiple goals, so old API users are not required to make any change. Signed-off-by: SeongJae Park --- include/linux/damon.h | 17 ++++++++++ mm/damon/core.c | 78 +++++++++++++++++++++++++++++++++++++++---- 2 files changed, 88 insertions(+), 7 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 2fe345adf6b2..4bd898eaf80e 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -130,6 +130,7 @@ enum damos_action { * struct damos_quota_goal - DAMOS scheme quota auto-tuning goal. * @get_score: Function for getting current score of the goal. * @get_score_arg: Parameter for @get_score + * @list: List head for siblings. * * Data structure for getting the current score of the quota tuning goal. * Calling @get_score with @get_score_arg as the parameter should return the @@ -140,6 +141,7 @@ enum damos_action { struct damos_quota_goal { unsigned long (*get_score)(void *arg); void *get_score_arg; + struct list_head list; }; /** @@ -148,6 +150,7 @@ struct damos_quota_goal { * @ms: Maximum milliseconds that the scheme can use. * @sz: Maximum bytes of memory that the action can be applied. * @goal: Quota auto-tuning goal. + * @goals: Head of quota tuning goals (&damos_quota_goal) list. * @esz: Effective size quota in bytes. * * @weight_sz: Weight of the region's size for prioritization. @@ -171,6 +174,8 @@ struct damos_quota_goal { * every @reset_interval. Then, if the new size quota is smaller than the * effective quota, it uses the new size quota as the effective quota. * + * If @goals is not empty, same action is taken for each goal of the list. + * * The resulting effective size quota in bytes is set to @esz. * * For selecting regions within the quota, DAMON prioritizes current scheme's @@ -184,6 +189,7 @@ struct damos_quota { unsigned long ms; unsigned long sz; struct damos_quota_goal goal; + struct list_head goals; unsigned long esz; unsigned int weight_sz; @@ -648,6 +654,12 @@ static inline unsigned long damon_sz_region(struct damon_region *r) #define damon_for_each_scheme_safe(s, next, ctx) \ list_for_each_entry_safe(s, next, &(ctx)->schemes, list) +#define damos_for_each_quota_goal(goal, quota) \ + list_for_each_entry(goal, "a->goals, list) + +#define damos_for_each_quota_goal_safe(goal, next, quota) \ + list_for_each_entry_safe(goal, next, &(quota)->goals, list) + #define damos_for_each_filter(f, scheme) \ list_for_each_entry(f, &(scheme)->filters, list) @@ -681,6 +693,11 @@ struct damos_filter *damos_new_filter(enum damos_filter_type type, void damos_add_filter(struct damos *s, struct damos_filter *f); void damos_destroy_filter(struct damos_filter *f); +struct damos_quota_goal *damos_new_quota_goal( + unsigned long (*get_score)(void *), void *get_score_arg); +void damos_add_quota_goal(struct damos_quota *q, struct damos_quota_goal *g); +void damos_destroy_quota_goal(struct damos_quota_goal *goal); + struct damos *damon_new_scheme(struct damos_access_pattern *pattern, enum damos_action action, unsigned long apply_interval_us, diff --git a/mm/damon/core.c b/mm/damon/core.c index fe4209672121..b6cd99b64e85 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -299,6 +299,41 @@ void damos_destroy_filter(struct damos_filter *f) damos_free_filter(f); } +struct damos_quota_goal *damos_new_quota_goal( + unsigned long (*get_score)(void *), void *get_score_arg) +{ + struct damos_quota_goal *goal; + + goal = kmalloc(sizeof(*goal), GFP_KERNEL); + if (!goal) + return NULL; + goal->get_score = get_score; + goal->get_score_arg = get_score_arg; + INIT_LIST_HEAD(&goal->list); + return goal; +} + +void damos_add_quota_goal(struct damos_quota *q, struct damos_quota_goal *g) +{ + list_add_tail(&g->list, &q->goals); +} + +static void damos_del_quota_goal(struct damos_quota_goal *g) +{ + list_del(&g->list); +} + +static void damos_free_quota_goal(struct damos_quota_goal *g) +{ + kfree(g); +} + +void damos_destroy_quota_goal(struct damos_quota_goal *g) +{ + damos_del_quota_goal(g); + damos_free_quota_goal(g); +} + /* initialize fields of @quota that normally API users wouldn't set */ static struct damos_quota *damos_quota_init(struct damos_quota *quota) { @@ -337,6 +372,8 @@ struct damos *damon_new_scheme(struct damos_access_pattern *pattern, INIT_LIST_HEAD(&scheme->list); scheme->quota = *(damos_quota_init(quota)); + /* quota.goals should be separately set by caller */ + INIT_LIST_HEAD(&scheme->quota.goals); scheme->wmarks = *wmarks; scheme->wmarks.activated = true; @@ -373,8 +410,12 @@ static void damon_free_scheme(struct damos *s) void damon_destroy_scheme(struct damos *s) { + struct damos_quota_goal *g, *g_next; struct damos_filter *f, *next; + damos_for_each_quota_goal_safe(g, g_next, &s->quota) + damos_destroy_quota_goal(g); + damos_for_each_filter_safe(f, next, s) damos_destroy_filter(f); damon_del_scheme(s); @@ -1083,22 +1124,44 @@ static unsigned long damon_feed_loop_next_input(unsigned long last_input, return min_input; } -/* Called only if quota->ms, quota->sz, or quota->goal.get_score are set */ +/* Return the highest score since it makes schemes least aggressive */ +static unsigned long damos_quota_score(struct damos_quota *quota) +{ + struct damos_quota_goal *goal; + unsigned long highest_score = 0; + + if (quota->goal.get_score) + highest_score = quota->goal.get_score( + quota->goal.get_score_arg); + + damos_for_each_quota_goal(goal, quota) + highest_score = max(highest_score, + goal->get_score(goal->get_score_arg)); + + return highest_score; +} + +/* + * Called only if quota->ms, quota->sz, or quota->goal.get_score are set, or + * quota->goals is not empty + */ static void damos_set_effective_quota(struct damos_quota *quota) { unsigned long throughput; unsigned long esz; - if (!quota->ms && !quota->goal.get_score) { + if (!quota->ms && !quota->goal.get_score && + list_empty("a->goals)) { quota->esz = quota->sz; return; } - if (quota->goal.get_score) { + if (quota->goal.get_score || !list_empty("a->goals)) { + unsigned long score = damos_quota_score(quota); + quota->esz_bp = damon_feed_loop_next_input( max(quota->esz_bp, 10000UL), - quota->goal.get_score( - quota->goal.get_score_arg)); + score); esz = quota->esz_bp / 10000; } @@ -1108,7 +1171,7 @@ static void damos_set_effective_quota(struct damos_quota *quota) quota->total_charged_ns; else throughput = PAGE_SIZE * 1024; - if (quota->goal.get_score) + if (quota->goal.get_score || !list_empty("a->goals)) esz = min(throughput * quota->ms, esz); else esz = throughput * quota->ms; @@ -1128,7 +1191,8 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) unsigned long cumulated_sz; unsigned int score, max_score = 0; - if (!quota->ms && !quota->sz && !quota->goal.get_score) + if (!quota->ms && !quota->sz && !quota->goal.get_score && + list_empty("a->goals)) return; /* New charge window starts */ From patchwork Mon Feb 19 19:44:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563010 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 A7201C48BC3 for ; Mon, 19 Feb 2024 19:44:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1574C6B0093; Mon, 19 Feb 2024 14:44:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0523E6B0095; Mon, 19 Feb 2024 14:44:46 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E13826B008A; Mon, 19 Feb 2024 14:44:46 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id B63D06B008C for ; Mon, 19 Feb 2024 14:44:46 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 7C617C025E for ; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) X-FDA: 81809580972.27.B82E26A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id CC72118001C for ; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VMJk4oti; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1708371884; 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:in-reply-to:references:references:dkim-signature; bh=mVAfZuCBWhLF2qymxTW+slKPvr24mSdNV8P6Wan9dLc=; b=M6Ya0PSehdchbbLLodBPRq8t2WEuu5U1EJkefn4JpSURpwK6k4Msi2kvujb0MAzmUpMdBP N7H3j67dGsb/EUEM7p5FhLSeqLhzMDZxAY6vLzel9bobs0901+A1gxkFK6XZlMFnzgTU1Y joaOVLamRBPZVopkTQsAHoIU4/cWNZ8= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=VMJk4oti; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1708371884; a=rsa-sha256; cv=none; b=ulJvrnD4koO4pa3pMLqBcrRqWc7W42q7nUgfpZvKlzhtYq1pvFFSPMykbTgWZEtVRwgpwU zzPjppumDGUORvqSj9aCSRuVxXRLhFj0Dc9+VAHq8yp8PgSMC6awVVGT0eSJCNsogwZL7L ErImMLNR+1YqSfnJTHbrl7UpqmSuzAM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6A43C60F9B; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D37B9C43390; Mon, 19 Feb 2024 19:44:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371884; bh=Y86PEzdDsloDNtE2rhRk0igx3/ADGu50K3PYFIjUmww=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VMJk4otiuaR09DUh0+iezb8GZovrgKQlfCvrQ1tTjXsAlaxptT+OfVNaBmfkIbFrW CI4FSuRWy5qz0EKsYf3eEMo6zk3Zzi/Al2auGEqa/LLZKRcQkPQoZP1hos61FPiNL2 vmEX1DzJ9t4QhST25LMDbcl3LncVzCNUJfrrRwOqMnU5OvkRHLOH71Oi5dc1JKyjyu x5EHaMvyUIkvAuov3A9Qf4lqMmG5NdF9QZOYZYQdEmUZOt0dgra/nCF6MAbbX/hgUF 4kRTvUeVZHjdlNPLNnOCC2xg1aUGBPNDiBaxwrQG3uN5cvGnGDZ8a9mWrp7sunheBU 9LxMizAj+NVLg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/20] mm/damon/sysfs: use only quota->goals Date: Mon, 19 Feb 2024 11:44:20 -0800 Message-Id: <20240219194431.159606-10-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: CC72118001C X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: mbwzb8gth6mn4gcfbzrmcmnr974okz6p X-HE-Tag: 1708371884-847230 X-HE-Meta: U2FsdGVkX1+HFYo4eoH8meCYV0sYIXtQw1TGcHNx89ay051Ary/26bNC7Q3vaIhgIzc/Kb6J6XXj3gy9qELP7zfylsIHEYbpkEWockpv1/qSglLh5kB6LPzJNJia4vcLPmEYyTs43vQ3cCpbSe+PtrlMX0Pfu6pt7iTOZwGIFKchRjpQJEnKWtWoOFhatVr+IW8QuDIIUmiwNutaGQ6mFoUjzM+44ORGv7QQDoqXRtk4aQp2z7L+IDuvXV5vpOKBAmyZDMxKGoRD4NWbC06pnmrc/FRfUgr2Lta2Q/kpq/UtLoFZYd8FFAhYCdFy48za3dtsqfGY3quUrtlb2fqZXbO+dxVG7uaYbcxKGQCPglzTwkg0mORS+rDyRHvq3CQzDt0VwfZlA7sPCKabWE/rBEcnDxbhNNicIHoy5tZxmvplJo26NyJUkiIi/2oOuHSAQvGyiiii620DHZZJp0sj4gBg5CT8wTHYT9DUcRxvp7hBxDzWYg6ORWtFycnVCnOAuBknGJexNHKooS8pZrL/x+4nUI9v5kPzs5HZE46CIfhP64JzpnieOtFYvNsY60PRsLlqeNHapusnSqgCqCX9iX9qQr2ccWAxwb9jeE6ifMrEwcvP3KZPvu/wZ91aJ1w+/e09dtPvpX4HKDZAWUhKo6eUHYTW9xahnrqoV8SAUKpv7uTyZG8D4RMV8peDd+fDUhUaWor1IqlH8qE4Rizu1HfylJPGXmAyeQzfhvYDhRdjWIXQXf6KWvAt3ZF6QIvUeDMhj5mt2TKbT5UshSOiwA4omd6yQ4mi3v/U+uvbtOdlFlEtGVSqhcldJSPTZqZO3S5Fj3yOmoGPZn/csVgpR8xe3Kl5WmUvFxuff2wxSFU84lrS09w0uz9XpFrylaG7pck6DbtcewS08XGbPIz9vuzmfcs+4hx6NhO51jW7cImBL7CptwWQlRsJJjEAVR56vkoGBqbM28NVJ1PtZBc FAySZxpv TW8FP0DqpxxGZHCOdmfXNbKbv38pLMIxcvYnoeu3VdDyLof9aDznf2z8m34jpmQBIupNhnOHuEn8qxccF+xu5/i2afsYvXmm70nfOXxKEAVsj0ljBudV0cu6LfE+gZ3zeBWVQcdpxruYcwK8Tr9P4E5nCORtzW7e/khQTFRE57syd3XfYB8Eh9LHfoHN9khV8gEL7u8AvazFJrRo2moR4T4XpwdTKBYiMPPkHbTp3FPZtZkhc44buQ03jn3zL6U1LFn1BgiRga8oa4ksfvWAbjEiaTw== 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: List-Subscribe: List-Unsubscribe: DAMON sysfs interface implements multiple quota auto-tuning goals on its level since the DAMOS core logic was supporting only single goal. Now the core logic supports multiple goals on its level. Update DAMON sysfs interface to reuse the core logic and drop unnecessary duplicated multiple goals implementation. Signed-off-by: SeongJae Park --- mm/damon/sysfs-common.h | 2 +- mm/damon/sysfs-schemes.c | 49 +++++++++++++++++++++++++++------------- mm/damon/sysfs.c | 3 +-- 3 files changed, 35 insertions(+), 19 deletions(-) diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h index 5a1ac15fb2f8..a63f51577cff 100644 --- a/mm/damon/sysfs-common.h +++ b/mm/damon/sysfs-common.h @@ -59,7 +59,7 @@ int damon_sysfs_schemes_clear_regions( struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx); -void damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, +int damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx); void damos_sysfs_update_effective_quotas( diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 85ef58f98a87..7bf94b1ed6f7 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1887,30 +1887,34 @@ static unsigned long damos_sysfs_get_quota_score(void *arg) return (unsigned long)arg; } -static void damos_sysfs_set_quota_score( +static int damos_sysfs_set_quota_score( struct damos_sysfs_quota_goals *sysfs_goals, struct damos_quota *quota) { - struct damos_sysfs_quota_goal *sysfs_goal; + struct damos_quota_goal *goal, *next; int i; - quota->goal.get_score = NULL; - quota->goal.get_score_arg = (void *)0; + damos_for_each_quota_goal_safe(goal, next, quota) + damos_destroy_quota_goal(goal); + for (i = 0; i < sysfs_goals->nr; i++) { - sysfs_goal = sysfs_goals->goals_arr[i]; + struct damos_sysfs_quota_goal *sysfs_goal = + sysfs_goals->goals_arr[i]; + if (!sysfs_goal->target_value) continue; - /* Higher score makes scheme less aggressive */ - quota->goal.get_score_arg = (void *)max( - (unsigned long)quota->goal.get_score_arg, - sysfs_goal->current_value * 10000 / - sysfs_goal->target_value); - quota->goal.get_score = damos_sysfs_get_quota_score; + goal = damos_new_quota_goal(damos_sysfs_get_quota_score, + (void *)(sysfs_goal->current_value * 10000 / + sysfs_goal->target_value)); + if (!goal) + return -ENOMEM; + damos_add_quota_goal(quota, goal); } + return 0; } -void damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, +int damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, struct damon_ctx *ctx) { struct damos *scheme; @@ -1918,16 +1922,21 @@ void damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, damon_for_each_scheme(scheme, ctx) { struct damon_sysfs_scheme *sysfs_scheme; + int err; /* user could have removed the scheme sysfs dir */ if (i >= sysfs_schemes->nr) break; sysfs_scheme = sysfs_schemes->schemes_arr[i]; - damos_sysfs_set_quota_score(sysfs_scheme->quotas->goals, + err = damos_sysfs_set_quota_score(sysfs_scheme->quotas->goals, &scheme->quota); + if (err) + /* kdamond will clean up schemes and terminated */ + return err; i++; } + return 0; } void damos_sysfs_update_effective_quotas( @@ -1987,13 +1996,17 @@ static struct damos *damon_sysfs_mk_scheme( .low = sysfs_wmarks->low, }; - damos_sysfs_set_quota_score(sysfs_quotas->goals, "a); - scheme = damon_new_scheme(&pattern, sysfs_scheme->action, sysfs_scheme->apply_interval_us, "a, &wmarks); if (!scheme) return NULL; + err = damos_sysfs_set_quota_score(sysfs_quotas->goals, &scheme->quota); + if (err) { + damon_destroy_scheme(scheme); + return NULL; + } + err = damon_sysfs_set_scheme_filters(scheme, sysfs_filters); if (err) { damon_destroy_scheme(scheme); @@ -2029,7 +2042,11 @@ static void damon_sysfs_update_scheme(struct damos *scheme, scheme->quota.weight_nr_accesses = sysfs_weights->nr_accesses; scheme->quota.weight_age = sysfs_weights->age; - damos_sysfs_set_quota_score(sysfs_quotas->goals, &scheme->quota); + err = damos_sysfs_set_quota_score(sysfs_quotas->goals, &scheme->quota); + if (err) { + damon_destroy_scheme(scheme); + return; + } scheme->wmarks.metric = sysfs_wmarks->metric; scheme->wmarks.interval = sysfs_wmarks->interval_us; diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index cc2d88a901f4..6fee383bc0c5 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -1377,8 +1377,7 @@ static int damon_sysfs_commit_schemes_quota_goals( ctx = sysfs_kdamond->damon_ctx; sysfs_ctx = sysfs_kdamond->contexts->contexts_arr[0]; - damos_sysfs_set_quota_scores(sysfs_ctx->schemes, ctx); - return 0; + return damos_sysfs_set_quota_scores(sysfs_ctx->schemes, ctx); } /* From patchwork Mon Feb 19 19:44:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563011 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 68CC0C54766 for ; Mon, 19 Feb 2024 19:45:02 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 64AE96B0098; Mon, 19 Feb 2024 14:44:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 58B1E6B0095; Mon, 19 Feb 2024 14:44:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 367F16B0096; Mon, 19 Feb 2024 14:44:47 -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 E30526B0092 for ; Mon, 19 Feb 2024 14:44:46 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id BB1D4A03B3 for ; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) X-FDA: 81809580972.22.18BD01A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id 41293A001E for ; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ab+A5Sfs; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.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=1708371885; 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:in-reply-to:references:references:dkim-signature; bh=Ik7g0pmo/rQPmaWjcBRzeMKt20ZGklsmFHY/Az/CDHo=; b=FI32iCFg2QLPLJ2aYryi8MHilQJO3EaNDEbyJP/p9SDQ0NkDr8NVdWjCY46SEd+5c5eBVk rRPw+Y6JDFSGpMF88LWhjs5ZUrPkaA5lwEJAXk8FktQGgxvSarho6YAzgmx3+l8iv9t8b0 Z2xcPN2YCaqhRnToNLS2mB70idIweNE= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ab+A5Sfs; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.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=1708371885; a=rsa-sha256; cv=none; b=SZBhmmWJK5k1n0WmatpEkpsKMuHfLqYPJgzlUiZ4DRXfNTZBS9Nm9GYS+amsZlg8v/ELaH FQA9Zc7JYBsRfxqbpg0JrZCv/HMV/DS5Yt0+oAhno0GY7L3wOgrW1REMqwJ1SY6uM0GIgo SM8886WKK0/B0+HlZTXRaFeqBmC1jZM= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0658660F56; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CDE9C43142; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371884; bh=QeU5c/dwATJidBlGHBdNGbMWliRdhvFFFKPfbT81FqU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ab+A5SfsaBxGqQ9J4X3fZQnWF7spadZC+lmESnnYLCSADToO6/m5SSUsThlK0cWsb Ub9tDmvaeUhGcdOx4/HVC+x3lj3WvVEXvZcMfjNG9q2vVe7KwHvZDofEd9umrUN7aC o6LYXNdE07D+b5Lnsb72tj2JsQkbSo9wWxPnHnmIO7oQpjBZX4WJx1cj7gcFqevQg7 EiXZMnxtLt+M94kbNS1Biw/13mEtXV8JpNz5EXGh14tD4Z8im3Lom2Y/QZXI0KbVG6 rleAwT/68jIKL4wV544A45Cehx5TLoPG8K0zYPQQtut1lypcWsN40nynj7IHzPZU8/ pNYJL4G6rXXXA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/20] mm/damon/core: remove ->goal field of damos_quota Date: Mon, 19 Feb 2024 11:44:21 -0800 Message-Id: <20240219194431.159606-11-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 41293A001E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cgtf1ww1n7epr7sye7c8ypnueyskc9b9 X-HE-Tag: 1708371885-309267 X-HE-Meta: U2FsdGVkX19eZ2KJAW0sfiezhmgb0/gzbCVens50mwAY5D/Xj1/X4re6UKh6iaOwZ/dDjIWaiS10j5EvkJ3k/fPNzG+/zFNWRa4JbAVHm3v9rHBIhnGh0VmgoCbUrhxsGRMzS+gyOyce/mDDCoHVw29qTjkEFnSS8NbF1xHYAtcUJJ5DbfvFksphTlg4UHPeepeGct+9FXk40CRUmHyGGUG4LHu6nyULRC79Hw2anf3MOblxMP5L2PYGT1qpaxtg5i0EAFkBAHlX72MOtOtDyIGaWhZJqIniG5dVopXl7E/g8zQfQDDTvTcE/oZlpRltSAIiIYi0BG1wobE+DOcOV81guQWD0X75bQX8dHXce5jR9XNWAORksqq40oNLdxsDEOLbdFKdA2ppn+MULjvLqf1el5/wLmzrwebqxLLERDjLGmWfGYInXg1NBNKRPhfdK/p/rmzZGlVE5ONbiB4p8l35bg+pyGi9tIdhh6isdvSSxmuHm0APN5O4HFdbRpBb16ZML6ZGij3DsQ7DTE8MdthyHQSOFnY/ShwFrOz2idRFVoyKDtWUr+/dGilAYqzQD8H7mJ61o+SQzZEM1Bk+5OvoV43YLWGbaTjqwUe0KcYZeYK0WRX19jpERK6jnTPXBss6E5n06If7tU/aX9DLlO5CX8vxyyx0cHnOZCwRIDLn/yad3Bk5mUnbSMRU5h9kXODIEclPy7Reyz+m9kCykSRKzHZGdDbppumCk4fUyfNLRrw2KwfN3ROmYbQ7jx8xvLKu2EUymh28jUSUm+yPa5vgAN7U9DECZeDtkd6XvbJNPHWLPSf7CWmgXGLqbrzMmUwInJIR6kRRNCwI1BGj/8bV/mIB8CUDwcmqceJc7QqPAZ3DjtsRnY/6b26tmrJyU5pdChNwNJj35ZLuFz/rZ9M0riwpQioHQJjd/iH5/5uAX49XAmNwbVpj3i3hD7Ugk8ijAgK1cyLhjH9UuUB 5gb6mVIX xddHS 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: List-Subscribe: List-Unsubscribe: DAMOS quota auto-tuning feature supports static signle goal and dynamic multiple goals via DAMON kernel API, specifically via ->goal and ->goals fields of damos_quota struct, respectively. All in-tree DAMOS kernel API users are using only the dynamic multiple goals now. Remove the unsued static single goal interface. Signed-off-by: SeongJae Park --- include/linux/damon.h | 12 ++++-------- mm/damon/core.c | 17 +++++------------ 2 files changed, 9 insertions(+), 20 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 4bd898eaf80e..76c965c1eea3 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -149,7 +149,6 @@ struct damos_quota_goal { * @reset_interval: Charge reset interval in milliseconds. * @ms: Maximum milliseconds that the scheme can use. * @sz: Maximum bytes of memory that the action can be applied. - * @goal: Quota auto-tuning goal. * @goals: Head of quota tuning goals (&damos_quota_goal) list. * @esz: Effective size quota in bytes. * @@ -169,12 +168,10 @@ struct damos_quota_goal { * throughput of the scheme's action. DAMON then compares it against &sz and * uses smaller one as the effective quota. * - * If ->get_score field of @goal is set, DAMON calculates yet another size - * quota based on the goal using its internal feedback loop algorithm, for - * every @reset_interval. Then, if the new size quota is smaller than the - * effective quota, it uses the new size quota as the effective quota. - * - * If @goals is not empty, same action is taken for each goal of the list. + * If @goals is not empt, DAMON calculates yet another size quota based on the + * goals using its internal feedback loop algorithm, for every @reset_interval. + * Then, if the new size quota is smaller than the effective quota, it uses the + * new size quota as the effective quota. * * The resulting effective size quota in bytes is set to @esz. * @@ -188,7 +185,6 @@ struct damos_quota { unsigned long reset_interval; unsigned long ms; unsigned long sz; - struct damos_quota_goal goal; struct list_head goals; unsigned long esz; diff --git a/mm/damon/core.c b/mm/damon/core.c index b6cd99b64e85..7b06d926c552 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1130,10 +1130,6 @@ static unsigned long damos_quota_score(struct damos_quota *quota) struct damos_quota_goal *goal; unsigned long highest_score = 0; - if (quota->goal.get_score) - highest_score = quota->goal.get_score( - quota->goal.get_score_arg); - damos_for_each_quota_goal(goal, quota) highest_score = max(highest_score, goal->get_score(goal->get_score_arg)); @@ -1142,21 +1138,19 @@ static unsigned long damos_quota_score(struct damos_quota *quota) } /* - * Called only if quota->ms, quota->sz, or quota->goal.get_score are set, or - * quota->goals is not empty + * Called only if quota->ms, or quota->sz are set, or quota->goals is not empty */ static void damos_set_effective_quota(struct damos_quota *quota) { unsigned long throughput; unsigned long esz; - if (!quota->ms && !quota->goal.get_score && - list_empty("a->goals)) { + if (!quota->ms && list_empty("a->goals)) { quota->esz = quota->sz; return; } - if (quota->goal.get_score || !list_empty("a->goals)) { + if (!list_empty("a->goals)) { unsigned long score = damos_quota_score(quota); quota->esz_bp = damon_feed_loop_next_input( @@ -1171,7 +1165,7 @@ static void damos_set_effective_quota(struct damos_quota *quota) quota->total_charged_ns; else throughput = PAGE_SIZE * 1024; - if (quota->goal.get_score || !list_empty("a->goals)) + if (!list_empty("a->goals)) esz = min(throughput * quota->ms, esz); else esz = throughput * quota->ms; @@ -1191,8 +1185,7 @@ static void damos_adjust_quota(struct damon_ctx *c, struct damos *s) unsigned long cumulated_sz; unsigned int score, max_score = 0; - if (!quota->ms && !quota->sz && !quota->goal.get_score && - list_empty("a->goals)) + if (!quota->ms && !quota->sz && list_empty("a->goals)) return; /* New charge window starts */ From patchwork Mon Feb 19 19:44:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563013 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 1E5EEC48BC3 for ; Mon, 19 Feb 2024 19:45:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2EF986B006E; Mon, 19 Feb 2024 14:44:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1DCAF6B0078; Mon, 19 Feb 2024 14:44:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 01A366B0096; Mon, 19 Feb 2024 14:44:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E0F406B0092 for ; Mon, 19 Feb 2024 14:44:47 -0500 (EST) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id B1A51A05B5 for ; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) X-FDA: 81809581014.15.19A6F8C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 08CA04000D for ; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OlEYB5tC; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708371886; 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:in-reply-to:references:references:dkim-signature; bh=BPtcDrW6smk42ob/SAFc/GI98wGX/lFjOHolWe6AUqg=; b=OAzeK3t1jPSZkZ6IfOK3KHtFFKhTN/cTMHFFQz+IaZgv76CGPeGtSYqxCu1oTBSPOrv901 RCqd+X4HXKKuShVE26nNkd0oYVhg4X/4/Bli0RIU+zfLM2Fuv6W6dTFsD9Tn1Pzp456BLr /bLenEHeyTv721InHgCFp9MNbLeYevY= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708371886; a=rsa-sha256; cv=none; b=gRXo4INqRJwie7TiuF3efBed1paVFQxwQCWZSkvoRQdOlqY3AZKB/YAjZvmifp/nYPIG8b PAqxVdRFBMipl5oUavPS0krbglMIsLEPU5DQcIAlcorqBWUHH3x5PSZG1lgO7cEO0Mdm1l 1zZI6v1MUmDwJ1HwKuye7865NpbLXTo= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=OlEYB5tC; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AD72360F6A; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 03D0CC43394; Mon, 19 Feb 2024 19:44:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371885; bh=R3dxTppsO4aJJFug6nWMDIsYsBasUQvKpFzDWX0osTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OlEYB5tC4/VXhLLWfLhPwyH9Tzvh/9R0vhtcqhC+OvyZXwKASESgHHIjXyOQTm9fD tM1wtoxgijVyLP2EumAzUce+yvGmcGMEolxhZkNjwobgwRfeBEMN+ZYH2F1EwcBTTw Zklz3HDqD4mx/QWmPq6+0qpQWu/tPAaTa9OOdfUCxr/0VQ6iQa/gNvsPsFqsCgoYyW +NKW/JwAn8XxwOUbHwBxZ8qQQ8jIWBn6qk2ZwU06pG1Q3HDZ6qC27mv4F1XC+FfQGT 2aq8jhUFVJfdXLig4ZB9Q+4aQzEv09sXFcKMyciaKHTbOz28r9voYDgQn55ZTjpgx7 1rAXIxYu/wSzA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 11/20] mm/damon/core: let goal specified with only target and current values Date: Mon, 19 Feb 2024 11:44:22 -0800 Message-Id: <20240219194431.159606-12-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: rdd9e49ywfsmkokzy1yy7w1ebpp9udei X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 08CA04000D X-Rspam-User: X-HE-Tag: 1708371885-448235 X-HE-Meta: U2FsdGVkX19tyk4IsGp2L+9jYxGRfu0JyE7KnTRX80tBEiWFYeQ+i/W8JR7GJe4IuDMGGQaHoOJSN4A/39ZPV/mlUYfYLox7p0ccFI9NgTMr7LTziivSkLX4HCiogQNVts1Y3u8B7porivJ6QgxQUzyLawbAancwyn3nsOQu/TwSNDoEGZtBDHdZKG4cJuWkWMITvgHdvuiNm8+gMN4irNzWrQA96G131xpucpmxhA3COj34d1D1nyCV9Zu+bb/9rzJfKXTe6na2kd7EbqDsGi2Vh70TJKg2mu22hVdohDT2sClBDQqVNxJEe6yuMCBB1BbeY1vl/HRRf+7Q/vZDIboe/+C0t1Pl7jJYW4KePXslLEyNrUCIeyx3ACRr8mOsmuNtCKh2S/TtREDgTffZC5qQZ79Fsa/Yiq39SKeQ8G9gNU6/5rSCDqunV/0QQMbLSCszBTvDITUEUz3UbRHMnpIItPOCVefj3usroNnztwb2rKr/OeoV2nVyY8obcl3JAHYCEYjcsgEtwdhx1OPDR9mklXDnrBkpfXn2+Tyezz2FTQFT7D7DNIQ7gkVDIN5qVkr5C0lSBYqnrtXYCcDheDpM9XbLczBMUxA5KQT1iWYhMIRhDJk/pehgrGTB6GrXeVRUYhmn0YJBoVBUCPUXAEqfcP6YOkIRTC8RrRFPOfWXrkClnd+ZNqrVHLlnnCvz7UDCrvpgruioDYC8tDUlPCO6DGIgPWsxFLGzike9JFWHqVGGyh5TGriigKOhCQuBPsGDgdHmmRZx86susJzhR63+nxrQ+WXgBEAslSsMsYMAYWK+utRUbUq2byXLVENVTRCddiLWBWzd08EK9oqoB41IOOW5qil/7lCTaQGOO6PLlWO4qgA5Sq6VL9QMhOh9LfdZDwN0XRzwn9QLrmn56oNRxodYNPCEM/3xXdbyRlCalPrtIilR7y2oBCyoaIdse2tliZvVQDzJUqPqow0 gkbwDNYc arw1jASNfFGWkUZCHUWIJi/7b3VON9ljfWws52pHNxHS/L4bYQsnmL5FtLsNI6/LE4gHbWQSRy27w8rsDXXUuwWgQJVRv0H41e+E6c6FFpAhgbsZjqJh//0FQ5VswruPfnOxgTiV+vFlePxR1whFsH+ZXruff7bMMFP3frrc0y6+k/4JaaxNKl17YmIIbxyEVjQQA8IqHxR3UP/XMgAIt0p39pbJA1BF3/aFZ1+fttlISe+nkLn/C0nQJEA== 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: List-Subscribe: List-Unsubscribe: DAMOS quota auto-tuning feature let users to set the goal by providing a function for getting the current score of the tuned quota. It allows flexible goal setup, but only simple user-set quota is currently being used. As a result, the only user of the DAMOS quota auto-tuning is using a silly void pointer casting based score value passing function. Simplify the interface and the user code by letting user directly set the target and the current value. Signed-off-by: SeongJae Park --- include/linux/damon.h | 19 +++++++++---------- mm/damon/core.c | 9 +++++---- mm/damon/sysfs-schemes.c | 10 ++-------- 3 files changed, 16 insertions(+), 22 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 76c965c1eea3..de0cdc7f96d2 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -128,19 +128,18 @@ enum damos_action { /** * struct damos_quota_goal - DAMOS scheme quota auto-tuning goal. - * @get_score: Function for getting current score of the goal. - * @get_score_arg: Parameter for @get_score + * @target_value: Target value to achieve with the tuning. + * @current_value: Current value that achieving with the tuning. * @list: List head for siblings. * - * Data structure for getting the current score of the quota tuning goal. - * Calling @get_score with @get_score_arg as the parameter should return the - * current score. Then the score is entered to DAMON's internal feedback loop - * mechanism to get the auto-tuned quota. The goal of the tuning is getting - * the feedback score value of 10,000. + * Data structure for getting the current score of the quota tuning goal. The + * score is calculated by how close @current_value and @target_value are. Then + * the score is entered to DAMON's internal feedback loop mechanism to get the + * auto-tuned quota. */ struct damos_quota_goal { - unsigned long (*get_score)(void *arg); - void *get_score_arg; + unsigned long target_value; + unsigned long current_value; struct list_head list; }; @@ -690,7 +689,7 @@ void damos_add_filter(struct damos *s, struct damos_filter *f); void damos_destroy_filter(struct damos_filter *f); struct damos_quota_goal *damos_new_quota_goal( - unsigned long (*get_score)(void *), void *get_score_arg); + unsigned long target_value, unsigned long current_value); void damos_add_quota_goal(struct damos_quota *q, struct damos_quota_goal *g); void damos_destroy_quota_goal(struct damos_quota_goal *goal); diff --git a/mm/damon/core.c b/mm/damon/core.c index 7b06d926c552..907f467fc8c0 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -300,15 +300,15 @@ void damos_destroy_filter(struct damos_filter *f) } struct damos_quota_goal *damos_new_quota_goal( - unsigned long (*get_score)(void *), void *get_score_arg) + unsigned long target_value, unsigned long current_value) { struct damos_quota_goal *goal; goal = kmalloc(sizeof(*goal), GFP_KERNEL); if (!goal) return NULL; - goal->get_score = get_score; - goal->get_score_arg = get_score_arg; + goal->target_value = target_value; + goal->current_value = current_value; INIT_LIST_HEAD(&goal->list); return goal; } @@ -1132,7 +1132,8 @@ static unsigned long damos_quota_score(struct damos_quota *quota) damos_for_each_quota_goal(goal, quota) highest_score = max(highest_score, - goal->get_score(goal->get_score_arg)); + goal->current_value * 10000 / + goal->target_value); return highest_score; } diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 7bf94b1ed6f7..50218a7bfa0a 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1882,11 +1882,6 @@ static int damon_sysfs_set_scheme_filters(struct damos *scheme, return 0; } -static unsigned long damos_sysfs_get_quota_score(void *arg) -{ - return (unsigned long)arg; -} - static int damos_sysfs_set_quota_score( struct damos_sysfs_quota_goals *sysfs_goals, struct damos_quota *quota) @@ -1904,9 +1899,8 @@ static int damos_sysfs_set_quota_score( if (!sysfs_goal->target_value) continue; - goal = damos_new_quota_goal(damos_sysfs_get_quota_score, - (void *)(sysfs_goal->current_value * 10000 / - sysfs_goal->target_value)); + goal = damos_new_quota_goal(sysfs_goal->target_value, + sysfs_goal->current_value); if (!goal) return -ENOMEM; damos_add_quota_goal(quota, goal); From patchwork Mon Feb 19 19:44:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563014 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 288CEC48BF8 for ; Mon, 19 Feb 2024 19:45:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 86C596B0078; Mon, 19 Feb 2024 14:44:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 81BF16B0092; Mon, 19 Feb 2024 14:44:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6E6716B0095; Mon, 19 Feb 2024 14:44:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 5C2656B0078 for ; Mon, 19 Feb 2024 14:44:48 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 1F52D1A014D for ; Mon, 19 Feb 2024 19:44:48 +0000 (UTC) X-FDA: 81809581056.11.FFC9297 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf11.hostedemail.com (Postfix) with ESMTP id 76BB24000F for ; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) Authentication-Results: imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sBawmmXP; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.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=1708371886; 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:in-reply-to:references:references:dkim-signature; bh=Y3OhFaB2k7Pb8ZijHspmx/eNWjFg+R6JWIL6cDH0GjY=; b=fln3UWUt2D9ujguRXzce/vCaW69a37pmjKnCodW1LKgCvReVEG1JniLr9PSE8aVJ3YbKl/ hulB1MaOvnez+Ym8E3Ad9dVOsi96XOIO6f5xQ9QKYBSBtlyqUzwoTfa++XpAamICEdKMTx dUriTRjdrO5BWySxHfmNPxjubuDqtZY= ARC-Authentication-Results: i=1; imf11.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=sBawmmXP; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf11.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=1708371886; a=rsa-sha256; cv=none; b=RFi+bbLm/CH6/W5/qZAASHA6b+bPl+c7CnqeyF2kNrs3qm7uHN8auRct0lASYZnxEZmm0X VPOWZsw452vk6lJXRUWKojQIUIrJbWvU71AUpyEhD83iFXt55znMPNTxdT0gRmMe15KK0v tZW39FRKDnNhIeCi7bzzDB7FitPPdJI= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 22A3460F75; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 90AD9C43390; Mon, 19 Feb 2024 19:44:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371885; bh=k0sVHhoP1l10FZGLvNv2ZQk6SLTzHmp1jaim+1skQqQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sBawmmXP4SAQih4l7kjcCb8kPPaiAeqHNjh3ek/vrXAWbguNYIFOsl0zi2ZwrqbCC X0NDppc10tKHbCZa4jaj5XsyGU2kuRfex+PUO+GvBmfE2APRTp2+5d5WTg1jJDfocC Ic8+M+Z4BEtesgKhqejnoPQkfOkygCr5dExvWF31KCTseZ7tNM9+cMOZEAxbhmUybf MV+TOQ2et5Y909rkNOhJyMziq4sxd+CHWHrdE4WFtzZnYPed8ICfs2Rk91lJTc03Ay NDNEr5LK3SGUD126pw+2744vsjBc6fgNPOWMvPA9V4RDvrkueerTpw7PDEXJP5Z8wW H4skvQs+UcbcQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 12/20] mm/damon/core: support multiple metrics for quota goal Date: Mon, 19 Feb 2024 11:44:23 -0800 Message-Id: <20240219194431.159606-13-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 76BB24000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: wxp55mn7abzrjwntfgskrbpneub9pied X-HE-Tag: 1708371886-135164 X-HE-Meta: U2FsdGVkX19uCfGNPidXGeFc8RzbDLrMFbKtE01XCh8RJtVlBoj/hFf3h2lkoSDV/SuMrJzLbFYt8Rq/gRXlvtWyncAmVSPOM7bepXF9HgGQMcxBGJM4ka5zU4MN8NAt+frerao8ZXA7Xg0Ii08o4mwPcOfxKVeCbVeIgWW8Pntaqojh6dADQpZUjBAomQIgf9bjXCzQZyp0UOKr0QgADeZ5aapVEfYI1ADovEU6p32/sJbNlIH4amXs2dLRHA2hhz9BTj+cB0vTrqKAocm3905eZN2fv+8C5rJmlYp9mYDrqNaSI8WSC5L+VnUfoDKcRRuE1geTJV+XZx1lm6MfJR2mYP7u0ZtN3Haui2QoaTCE+Q5EVZ1NCwocsGEkJ6yXc01KhSLOUI+k4KmRchOD4ckKMCs8bN1MZ3rOgufB3UcAy/zySLVrjAxMkY1icx0Q95TGhfUnge5nIi5ROZZC5X0A41uDFB1rhjFWr56ya+We7Cwrt2rhRWVfA+dwY6IpOTH0nGzliaMRuCYisqPGaVptwsEF8KUxnZxmyPT2WhrOeluUgBL7bd49fb6XwF3W/N/FKSdCC1TGpkIntPvPUi3bm759nVbxxr2fIQ6vIj0TxZxuARpKxDR7U24i00UQgxEO8jVqsGvqjF50DUrZgcLtVqO51K8oz6CKInxCUvNjIOQ6x+BNkCIN0GGCgrneDMebrB/O1EnzSs4jLJ2F23BU5zJD0SnP2gukXT35j3rdnFQLT50OOxaNjzESWWiCghI//ZhwEqfc5cot7IjReUY7yLBBasnmIb2ajKyXu81iRBF0uOW4JH2LEKy9pLTadhFZ/+H66EU0Re/vyL3pQOwPNeVeWy2Ek+FGM/4DlAmgXWipxjaPyJznBuW295ES/+jVmwTIbnTsamfrXDqmpFlhUT8JVnfmv+ONggHSYxvBYH1tFA+Ay+oLI0JbN7+CnrAA01qw4S9LmmRZGWH T61Y1IpC 8AFyLeWzshW+oOdNTcdXYYSQQp+mzK8rADhIT9gNZBSmR4B/6QLM4yFVa8RWvElni3Rz6cqB1TQGVHOXVLuCoXNugqB2xWqCF+3bcDG8EO2CvLwPvsKbl36WAHAoMM7gQeEN77hMcngOK4sMqGEMy5rT+PsFc+iUqM/WnqAVZhgnnYyFi0GndeUF1DDs8HazheDDG4qHpZJtnDukvPPMzRw+iTuyRFiQtqTw/a6fKmtw7Exr2acbx5Z6yPA== 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: List-Subscribe: List-Unsubscribe: DAMOS quota auto-tuning asks users to assess the current tuned quota and provide the feedback in a manual and repeated way. It allows users generate the feedback from a source that the kernel cannot access, and writing a script or a function for doing the manual and repeated feeding is not a big deal. However, additional works are additional works, and it could be more efficient if DAMOS could do the fetch itself, especially in case of DAMON sysfs interface use case, since it can avoid the context switches between the user-space and the kernel-space, though the overhead would be only trivial in most cases. Also in many cases, feedbacks could be made from kernel-accessible sources, such as PSI, CPU usage, etc. Make the quota goal to support multiple types of metrics including such ones. Signed-off-by: SeongJae Park --- include/linux/damon.h | 26 +++++++++++++++++++++++--- mm/damon/core.c | 22 +++++++++++++++++++--- mm/damon/sysfs-schemes.c | 5 +++-- 3 files changed, 45 insertions(+), 8 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index de0cdc7f96d2..5a06993d8479 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -126,18 +126,37 @@ enum damos_action { NR_DAMOS_ACTIONS, }; +/** + * enum damos_quota_goal_metric - Represents the metric to be used as the goal + * + * @DAMOS_QUOTA_USER_INPUT: User-input value. + * @NR_DAMOS_QUOTA_GOAL_METRICS: Number of DAMOS quota goal metrics. + * + * Metrics equal to larger than @NR_DAMOS_QUOTA_GOAL_METRICS are unsupported. + */ +enum damos_quota_goal_metric { + DAMOS_QUOTA_USER_INPUT, + NR_DAMOS_QUOTA_GOAL_METRICS, +}; + /** * struct damos_quota_goal - DAMOS scheme quota auto-tuning goal. - * @target_value: Target value to achieve with the tuning. - * @current_value: Current value that achieving with the tuning. + * @metric: Metric to be used for representing the goal. + * @target_value: Target value of @metric to achieve with the tuning. + * @current_value: Current value of @metric. * @list: List head for siblings. * * Data structure for getting the current score of the quota tuning goal. The * score is calculated by how close @current_value and @target_value are. Then * the score is entered to DAMON's internal feedback loop mechanism to get the * auto-tuned quota. + * + * If @metric is DAMOS_QUOTA_USER_INPUT, @current_value should be manually + * entered by the user, probably inside the kdamond callbacks. Otherwise, + * DAMON sets @current_value with self-measured value of @metric. */ struct damos_quota_goal { + enum damos_quota_goal_metric metric; unsigned long target_value; unsigned long current_value; struct list_head list; @@ -689,7 +708,8 @@ void damos_add_filter(struct damos *s, struct damos_filter *f); void damos_destroy_filter(struct damos_filter *f); struct damos_quota_goal *damos_new_quota_goal( - unsigned long target_value, unsigned long current_value); + enum damos_quota_goal_metric metric, + unsigned long target_value); void damos_add_quota_goal(struct damos_quota *q, struct damos_quota_goal *g); void damos_destroy_quota_goal(struct damos_quota_goal *goal); diff --git a/mm/damon/core.c b/mm/damon/core.c index 907f467fc8c0..973423166ee2 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -300,15 +300,16 @@ void damos_destroy_filter(struct damos_filter *f) } struct damos_quota_goal *damos_new_quota_goal( - unsigned long target_value, unsigned long current_value) + enum damos_quota_goal_metric metric, + unsigned long target_value) { struct damos_quota_goal *goal; goal = kmalloc(sizeof(*goal), GFP_KERNEL); if (!goal) return NULL; + goal->metric = metric; goal->target_value = target_value; - goal->current_value = current_value; INIT_LIST_HEAD(&goal->list); return goal; } @@ -1124,16 +1125,31 @@ static unsigned long damon_feed_loop_next_input(unsigned long last_input, return min_input; } +static void damos_set_quota_goal_current_value(struct damos_quota_goal *goal) +{ + u64 now_psi_total; + + switch (goal->metric) { + case DAMOS_QUOTA_USER_INPUT: + /* User should already set goal->current_value */ + break; + default: + break; + } +} + /* Return the highest score since it makes schemes least aggressive */ static unsigned long damos_quota_score(struct damos_quota *quota) { struct damos_quota_goal *goal; unsigned long highest_score = 0; - damos_for_each_quota_goal(goal, quota) + damos_for_each_quota_goal(goal, quota) { + damos_set_quota_goal_current_value(goal); highest_score = max(highest_score, goal->current_value * 10000 / goal->target_value); + } return highest_score; } diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 50218a7bfa0a..7a8a39f2679b 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1899,10 +1899,11 @@ static int damos_sysfs_set_quota_score( if (!sysfs_goal->target_value) continue; - goal = damos_new_quota_goal(sysfs_goal->target_value, - sysfs_goal->current_value); + goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, + sysfs_goal->target_value); if (!goal) return -ENOMEM; + goal->current_value = sysfs_goal->current_value; damos_add_quota_goal(quota, goal); } return 0; From patchwork Mon Feb 19 19:44:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563015 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 09CE2C48BF8 for ; Mon, 19 Feb 2024 19:45:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1685D6B0095; Mon, 19 Feb 2024 14:44:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0F3E36B0099; Mon, 19 Feb 2024 14:44:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EAD0A6B0096; Mon, 19 Feb 2024 14:44:48 -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 D7A016B0092 for ; Mon, 19 Feb 2024 14:44:48 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A9A27120383 for ; Mon, 19 Feb 2024 19:44:48 +0000 (UTC) X-FDA: 81809581056.06.5D67386 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 014DB180025 for ; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TdWxaHKc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1708371887; 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:in-reply-to:references:references:dkim-signature; bh=2IPFCHuVQYIU935uM08rqgUJZWzciquZX/wAtiLCpQc=; b=X0IAs+ozPUZAYTpovZqFSa2hKeuOFAlVCy1RS77NTzVh3Ln+2MNYw2P3L7Dw8y8FbeJ5/c eRy2Txax3+9C7wgiN3CpqvlyN0JP7S/12e8a+hLXTjwDLBoeAueBPPhcIWe4JzcgQOv2Xn wASVRz+AF3+wcA6oLxGna2WGrITKT7o= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TdWxaHKc; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1708371887; a=rsa-sha256; cv=none; b=PPHMXwR4jxUo6+frCjAgZhPk0PDFK7yV2RcgdsI0RTdWGlo+h4M/7uzBte7zGk3waeWFZL gNdlslUJwRhvooyH0y7cshSeqa8bIU4mxcs9VfAwDmoBYlqe06yRMHIKcoFAtg1dwoUd93 thWYJiWMt/j3DAUZpptviw3fm5JNiOY= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id AE8B460F56; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 29130C43142; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371886; bh=+x9YEwq0wFUN061d3yOJa9HVAX8E/VoU7wyTTkm6mIw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TdWxaHKcnSEnWZqTNxUepviJgGCPR1bk6d5g+2L1cVg1/eGNxrn5SkWPrUnaK7JQO Vuk7vnYM1Uyb590YgKH6608jYA3nygvM6QZFCbklC41SZDPa1t+ounHmjZEt3oMH0y PMS26IDxgZF5792MlVW3661l3tMRtrU640g13+hslj96jsyC9AraLApqoZ7CKh1ys4 0xGiJfqM41TDv+KREnlPoh8PTfFBxKLQAQloBLwOAfGKGKjqF+CTHBjvGiORIcX8pW eSn7zriouYN9nH/T2G4lv45dJoL7vY0B0Sa6QCi1HrGxLw4YzYVogR6lVo0QFWSQJf MwsQeCfDxr3iQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 13/20] mm/damon/core: implement PSI metric DAMOS quota goal Date: Mon, 19 Feb 2024 11:44:24 -0800 Message-Id: <20240219194431.159606-14-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 014DB180025 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: sa9s9cdz7ip49psbf51gxe93ck9hpgy3 X-HE-Tag: 1708371886-960409 X-HE-Meta: U2FsdGVkX1+XAw3RYZ/6v9Q90+owpMmKcXc7MOSzaW7wxFYGzGf8xBQxaXiM36heb3/bMJZpSw6rsoSsXtYmJEhGThSrSrJLYdbIKZkNEGennIgCid4qzxRPi/DZYsREOi6pz1Oa1sPPu9/5AazFznZNm4W2Vnv7mk237/qkos0KUq5nyo973VY1WZzFErgcSg+QzlIxI+I3tC9jcKxu2bjLQQafkaPG61R6DKKxDvmp+OBHr6onHk02cI1kHwBNdDBBpnCxjijkggjexV2/YbmOcdrqPAW2sx/LYkebwCtDddum83ZrsYifHChX+VnIBzESmZKI42WJkkCb0uHUNSauSB2xvzlMKKuE/Pn6W1adiJGpJ+NTsvm8z6giXBCNJQqLeJZiC+VkOR+saE+Zg6TqBtpoS3YlCrjBOpAVnEUKiV/TzPiEYhURMykXcHWb8hMFWxIfAG4BbtFrMQIv97he26zhjCd9Aa1OwQQWE6SZ69b1hvixfeG0OWWv7nD6/UPFdCJgTNNqPx67sjt7N7x6MbkyqachW3zV2glMi5kRmapDi3cfoLsMZu/x2MYhZNbRRHrF2jXjNnSSn3xGm2FHFm+SeZynoTMIlNdGHxP68ke9UeRBrNMPwdtV2Qe+7HY+rF5JFBsw0rtYrmk8gClZUSYmXA0AqF3sDZMMsTz4oHHfmsoogCKVTrqqRpDNHVdFhMeqZ6ixmRPVW5q9IESQB48oJ5VnOUPCjJEKUNs4GQiBPVBe+Q4C1f6Rpo/bKuMt9favxstH/JGRZO3PK2INc7u2k+P/0WbR9Nf9E32rN5CCEFx/xADFBfwUQf57oKnh28pM9uuyS9v5LmiUHVvCqh8TP9D3hk/Znnt9q2OKfe7OrbGipieioclNXF0yIF3ated2+5PUxViaiJ1gSOTTmbjL2IDlM4zx1iQhst4+fVZG9w1MZtt+y4WSJ0ow9gDJtQqE7AnhY5gsAJ0 61pJkhWf dWnSoGdxcMuHfvr4hp7gdWURwUfeVL2w7cVW3Nn2wcPekZnk8RPoBp1h0tS3b62ABmtItJOf1KQmNyKqyeSJNT84F+/y7v25K8MSq4ICHwhspuj2WVO/p3Jyc8UWwxfXzAbk3Akqmj5DtzelKYCoGCIf0xq2fVEzGmeblTeY8KR0uxyOkAq/ktpnlsWVL8mYitLuAm854vc05IX2w/juvoaAhYx27qiJJztp1f1VAv/ApKKCxQ0SkF/tH4RXnPuyUkoanXMV23cFORfoSmfhrfxgTPw== 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: List-Subscribe: List-Unsubscribe: Extend DAMOS quota goal metric with system wide memory pressure stall time. Specifically, the system level 'some' PSI for memory is used. The target value can be set in microseconds. DAMOS measures the increased amount of the PSI metric in last quota_reset_interval and use the ratio of it versus the user-specified target PSI value as the score for the auto-tuning feedback loop. Signed-off-by: SeongJae Park --- include/linux/damon.h | 7 +++++++ mm/damon/core.c | 25 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/include/linux/damon.h b/include/linux/damon.h index 5a06993d8479..886d07294f4e 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -130,12 +130,14 @@ enum damos_action { * enum damos_quota_goal_metric - Represents the metric to be used as the goal * * @DAMOS_QUOTA_USER_INPUT: User-input value. + * @DAMOS_QUOTA_SOME_MEM_PSI_US: System level some memory PSI in us. * @NR_DAMOS_QUOTA_GOAL_METRICS: Number of DAMOS quota goal metrics. * * Metrics equal to larger than @NR_DAMOS_QUOTA_GOAL_METRICS are unsupported. */ enum damos_quota_goal_metric { DAMOS_QUOTA_USER_INPUT, + DAMOS_QUOTA_SOME_MEM_PSI_US, NR_DAMOS_QUOTA_GOAL_METRICS, }; @@ -144,6 +146,7 @@ enum damos_quota_goal_metric { * @metric: Metric to be used for representing the goal. * @target_value: Target value of @metric to achieve with the tuning. * @current_value: Current value of @metric. + * @last_psi_total: Last measured total PSI * @list: List head for siblings. * * Data structure for getting the current score of the quota tuning goal. The @@ -159,6 +162,10 @@ struct damos_quota_goal { enum damos_quota_goal_metric metric; unsigned long target_value; unsigned long current_value; + /* metric-dependent fields */ + union { + u64 last_psi_total; + }; struct list_head list; }; diff --git a/mm/damon/core.c b/mm/damon/core.c index 973423166ee2..6d503c1c125e 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -1125,6 +1126,25 @@ static unsigned long damon_feed_loop_next_input(unsigned long last_input, return min_input; } +#ifdef CONFIG_PSI + +static u64 damos_get_some_mem_psi_total(void) +{ + if (static_branch_likely(&psi_disabled)) + return 0; + return div_u64(psi_system.total[PSI_AVGS][PSI_MEM * 2], + NSEC_PER_USEC); +} + +#else /* CONFIG_PSI */ + +static inline u64 damos_get_some_mem_psi_total(void) +{ + return 0; +}; + +#endif /* CONFIG_PSI */ + static void damos_set_quota_goal_current_value(struct damos_quota_goal *goal) { u64 now_psi_total; @@ -1133,6 +1153,11 @@ static void damos_set_quota_goal_current_value(struct damos_quota_goal *goal) case DAMOS_QUOTA_USER_INPUT: /* User should already set goal->current_value */ break; + case DAMOS_QUOTA_SOME_MEM_PSI_US: + now_psi_total = damos_get_some_mem_psi_total(); + goal->current_value = now_psi_total - goal->last_psi_total; + goal->last_psi_total = now_psi_total; + break; default: break; } From patchwork Mon Feb 19 19:44:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563016 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 9D85BC48BF8 for ; Mon, 19 Feb 2024 19:45:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9B4086B0096; Mon, 19 Feb 2024 14:44:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 92DC96B0099; Mon, 19 Feb 2024 14:44:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7A89C6B009A; Mon, 19 Feb 2024 14:44:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 65F3D6B0096 for ; Mon, 19 Feb 2024 14:44:49 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 40CEF12047E for ; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) X-FDA: 81809581098.02.B47B846 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id AF75FA0018 for ; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KOTw5DPt; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.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=1708371887; 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:in-reply-to:references:references:dkim-signature; bh=h6jlea1Ny+YARehAvjsycPDwPQ3WBJoq0Zz+xFE6jbg=; b=ecwaLlf+GFb+WiN74qydURBmNAjJDr0oZdANvtd2P+Enj/BM3Yw6+y154FZmiDzcukttuX yKSsp0kC+bfTy1WABmK2DoNe/O8UKg0/CZkcDugwSDHUZcXxprJWJiMeiQ96jT25mXTeeG g7ZeS/lpujVgJsWIFG/Sh2xvxYB1fSc= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KOTw5DPt; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.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=1708371887; a=rsa-sha256; cv=none; b=GB0DnAIoLvJ3woygzoRX/xYzDDYVc+J7iI6pFciUfsK3c54PAL0E4T1LVD8Dr4jYNrF+mP S1ZB+4khS/oM3DyPeUg97OPVIdKHNm1MPT9TTVxzegp/IbCJmS7imO/JcxSL0S+jW1/Zxa qh+A4AX+QQjBLvRsXx5gY7K7J4p6RaE= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 6D71A60F6E; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B3ADEC43394; Mon, 19 Feb 2024 19:44:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371887; bh=CUFUQFRYuN+1nr4LagyWWgpSfoijjUeoeRxWSSISzx0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KOTw5DPtqz7EDT+Ul/z9K5LjGneHPwrOsY/SajlL5Bl2oLIl1awpnenXU//722LAQ 8JExaw7jR+vC9TyifyBA/ng8sJ87t7b37ykCu8xFWt24f0okGZcQbo2GFB8QAWcRXb hysuM2OlpQhwbWAQEH9GUDz/8v1fcgJ51HkbcvsA7C47wkJcaqIZutS2Nu9WPxI0Kj aI43L5ZT+zyPVvcx6ufR2x75e3X0TwFz52dWy9kjcozyTPg7XCbl7QazgclVpk6rRu MQL0doHMyussoB9I/RFG9LiYx5NoGiggqQ3nc542MghmJl7kUZ2K90wbKZqTjJpRHa zSlnawmoY8v3Q== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 14/20] mm/damon/sysfs-schemes: support PSI-based quota auto-tune Date: Mon, 19 Feb 2024 11:44:25 -0800 Message-Id: <20240219194431.159606-15-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: AF75FA0018 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 3w9x69ubibmmehcwqjtcsga7chg68sgx X-HE-Tag: 1708371887-477968 X-HE-Meta: U2FsdGVkX19NWpYMV9kbkdRSE6yfQe4SDJ6W5xLaHGUvgGSHlWnJxmi9FKP9c1yvBNTodqe291amXSc1/obvIm9bYBl/7vVr2ixxLnU2ACPE+R3UfDXVl2ZLoOi93J4dgdACxoAYJF21DzNYXg0Wm0/0xPQEQKj+B32fqt/6mFzJxpalwXr0lHtpUNTSsKumsCsyhNW/vq4GNAIvhlsjzMtRG0nrV5tqgSWeE46Pfq3sS7rG8cfaAiKzCDuqBbFiG+r57TfUV2cGMSNe0ZmO9AUXGC7vLdEKxT/qb2Z+/FWTNtUv4iS6EtjHSSegghJshbOMhfmEsEGdBGbKxjZCwiLmgsYaSVH9nwgkL1OqV0xuvGVIFny1YhJALluOQttRax6u60B4d13Xgm5XPY+eJVL/Uf9ccZGsssYDcmAmW92sZz1i0jsHKeAuA4SoX1M7jr6pr2uMp4iKaK2Abvx2h13tg0W7dmH7pjML/87sj1nCbeB41Y8UzFZ+ifZLa12HWP1FD/TyZ2HxD/HjkJe/jy15xxNVE8oglDcoIIwcjP9BdDnqBWQOSmAf2D3YhST4sxJ0gQ6X8mjRnUFCp9J4o4Ze5kKgtlctvFityyWNaE56TxTheBiKIZdjiNMZu+A+aA6EYmNf4HRYZxD5pGc7pOdzS1diATcyB/YrKv4rXHi/6NblA6ZVR5wxowqWC8WoFhoLpkcR1CSRt04lnlAnye1JjO17FCqpSD0eGz3aQ9TfC1XRyEuwiNALlPf4L5zA1c2lJHzCrjk9IuWV1thk+05/EmteJWWm10nWbdE5/aQBCjeODeZQVQyzg4ZDMyjZ+A4czQwVUTjtb2igUwFxEdIk9E9U1zzAcaoWgz8mk2LKqNARsxDvgsSp1raHA3w2qXTzDi68Z7P3P9Ltqny0NwO6xWasypLP6O2yf3jsbqLcMVMU/3loZw== 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: List-Subscribe: List-Unsubscribe: Extend DAMON sysfs interface to support the PSI-based quota auto-tuning by adding a new file, 'target_metric' under the quota goal directory. Old users don't get any behavioral changes since the default value of the metric is 'user input'. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 42 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 40 insertions(+), 2 deletions(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 7a8a39f2679b..53a90ac678fb 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -826,15 +826,48 @@ static const struct kobj_type damon_sysfs_watermarks_ktype = { struct damos_sysfs_quota_goal { struct kobject kobj; + enum damos_quota_goal_metric metric; unsigned long target_value; unsigned long current_value; }; +/* This should match with enum damos_action */ +static const char * const damos_sysfs_quota_goal_metric_strs[] = { + "user_input", + "some_mem_psi_us", +}; + static struct damos_sysfs_quota_goal *damos_sysfs_quota_goal_alloc(void) { return kzalloc(sizeof(struct damos_sysfs_quota_goal), GFP_KERNEL); } +static ssize_t target_metric_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damos_sysfs_quota_goal *goal = container_of(kobj, + struct damos_sysfs_quota_goal, kobj); + + return sysfs_emit(buf, "%s\n", + damos_sysfs_quota_goal_metric_strs[goal->metric]); +} + +static ssize_t target_metric_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + struct damos_sysfs_quota_goal *goal = container_of(kobj, + struct damos_sysfs_quota_goal, kobj); + enum damos_quota_goal_metric m; + + for (m = 0; m < NR_DAMOS_QUOTA_GOAL_METRICS; m++) { + if (sysfs_streq(buf, damos_sysfs_quota_goal_metric_strs[m])) { + goal->metric = m; + return count; + } + } + return -EINVAL; +} + static ssize_t target_value_show(struct kobject *kobj, struct kobj_attribute *attr, char *buf) { @@ -880,6 +913,9 @@ static void damos_sysfs_quota_goal_release(struct kobject *kobj) kfree(container_of(kobj, struct damos_sysfs_quota_goal, kobj)); } +static struct kobj_attribute damos_sysfs_quota_goal_target_metric_attr = + __ATTR_RW_MODE(target_metric, 0600); + static struct kobj_attribute damos_sysfs_quota_goal_target_value_attr = __ATTR_RW_MODE(target_value, 0600); @@ -887,6 +923,7 @@ static struct kobj_attribute damos_sysfs_quota_goal_current_value_attr = __ATTR_RW_MODE(current_value, 0600); static struct attribute *damos_sysfs_quota_goal_attrs[] = { + &damos_sysfs_quota_goal_target_metric_attr.attr, &damos_sysfs_quota_goal_target_value_attr.attr, &damos_sysfs_quota_goal_current_value_attr.attr, NULL, @@ -1899,11 +1936,12 @@ static int damos_sysfs_set_quota_score( if (!sysfs_goal->target_value) continue; - goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, + goal = damos_new_quota_goal(sysfs_goal->metric, sysfs_goal->target_value); if (!goal) return -ENOMEM; - goal->current_value = sysfs_goal->current_value; + if (sysfs_goal->metric == DAMOS_QUOTA_USER_INPUT) + goal->current_value = sysfs_goal->current_value; damos_add_quota_goal(quota, goal); } return 0; From patchwork Mon Feb 19 19:44:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563017 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 6084AC48BC3 for ; Mon, 19 Feb 2024 19:45:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 27AD16B0099; Mon, 19 Feb 2024 14:44:50 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 22A516B009A; Mon, 19 Feb 2024 14:44:50 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 053BB6B009B; Mon, 19 Feb 2024 14:44:50 -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 EC2D06B0099 for ; Mon, 19 Feb 2024 14:44:49 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id CEFD1A03FA for ; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) X-FDA: 81809581098.27.5805754 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 4212840011 for ; Mon, 19 Feb 2024 19:44:48 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rN+wAd4r; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708371888; 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:in-reply-to:references:references:dkim-signature; bh=AH50pB00vL1ssxOtJIF22yMyJ0UUCrycixUityu75ko=; b=YPVLIvjSejUSfq03Xe6a4vg7ypeCAHMnv4cEaFj7ckSYApRMbFUbGxhdcYRKCITOyu1o34 jJnRxPPL1qZ2bsENyH+x/jtKxa5PQeSkp/7EMlCtOH7bFdt+UaqkzRgiK+6IcVRpqcKVzF uEWM/NKB5MTiFfCTK8l6jEa2uxfk6WE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708371888; a=rsa-sha256; cv=none; b=cNFnTNsVp3uakAenvI+Hem1gMyOiyFJJSiOkaStnOE6mPLPtj8NtyssdupTWbjGGOP4IVi V7JByNgkSf6v31pG3PPMpNQjVZWgtLIjrrIlNT5GzPraJLvmyGPNIeWDXzWCZwEnRdClXa UALs7tK96Gx00JFoSwr70bmpzL46y00= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rN+wAd4r; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id EE03860F76; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A133C43399; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371887; bh=dE+jqLZYW9QB5NiFklbDnZHaYSFDuOnT6wibaYvQ7fQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rN+wAd4rUpHbmoSCSt+/pVijeH1M2J+z3ioq9IiqpMA7SQFSRjct47t4BrxCbYLzm g+NTWKrJdapNMH3m9ClPNCicsC8FXavIYUJ+PTZpM3XOUKOjufVIRPa+f6MVCL8FKx mnvvP4UR8ztDA3EZAIC758uAZSZn6xL0EAMZAUfFtGXapQSihyvtpmetzNaC/Kghcx UNloo8Ow4xzXJiJmt/6CbhAsy17pIVqzgkj0XUIKlijM/hF+Tkk2+/az2jLdwG67tG ZGw7C9Tdx2lPuF00Kfz/OfYDrG79xQFFIGBkn/Tpc1eB2mhLP1THJX3eXJLAQ/kPEA eQzcGIUVQS9rA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/20] Docs/mm/damon/design: document quota goal self-tuning Date: Mon, 19 Feb 2024 11:44:26 -0800 Message-Id: <20240219194431.159606-16-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: 6ypqxhy8nqy99dq1n9tnqdnubyz95zji X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 4212840011 X-Rspam-User: X-HE-Tag: 1708371888-942049 X-HE-Meta: U2FsdGVkX1/9e8qdwHCgGePRh+j2cZchUSVIsl8jkYeb0KCNg/l0S3Oh9/bHTSms9dvI//g8mk08CMRTSGXmgu+lImqnpHIMNDGldHgIgYhWlH2Ma82utXEa/G79Opfm6jHR7eOGpxJJ76krN7yNlupqV9Aqi6CpXBraxzdt7H8U6n90vxvc5t+pXk1V3z+KQFe2k5Z58gTQ4gsimxvDNufko6BCfhZ15TSf9BT47hwvmisl0PUnAmSBXZvIKbemFX1oDI4KXQZoakd0PAxh4W/n6+QlPYZDo2yljr6if6rCqlMjGZ9hgcN1AB35WxQNp8S7wGwKnoSbmXsNKRdgucOhLyg/XcKrQoK8eTVa1rR7aQ1RKTCUrlucOonSQlLsYT2MW1LCp2ub0d69IBNaDYR3oae64AMUqKPAvd8nnKB8hA6712Hzbo5vIbP9LkwffFkTaijYwLd4Wd1JUVGDdIPZ4fjz3hJLsZOPJQVDw/glK2v0HC4GaSkXJmOI518heqsoYF8XMSqvBGUTi3JzHsOJNEj9bIMAGEZ2DpUJNiBWEsUGBw/6xZZ2fg5dIRtL7S+oqSCX5qqwKl6vDW0jz+YhzePJo98hiWWl8NdqyUIvrfxIlpXfNBIEAgHiK85WRoLmEnG4IKpHpiV6d6W1Y3yE6Yj0rEHFMUNktOvzsNMplWCdAvq02bpqrV2mpu3c+UflfAezWlvdiWFaqBnWqEa7wfT2nuKDF66KhXVnZoiuESIbmscv1yWPvyivkPtcu3l+rSt0RLolYw3RZ4TG83yDJt4NzQOU82y01dDn1uhqNpkK3H/FGIMwjqxzOlTcezzvum1fWtuw64kn4QlIjPppk+GJfCL17/RyKVnJ1OrBedaRoVZjEeP7oP3TGqDRn+0Yi8PKKTLk/QxVTRVBxLogozthLb2/YXWOIVJDFJk5Wt+fbYuqyoNlpMDTL5KETRDUEG3sVPjDpAPOF8N w3I2H5X2 CXhRh1bhx98DOoMWd9gI7L4x5qfIhqJn40rEX6LaDo+UIvklUjMfgf/eOyCpHUFNHHzo6+zxWdAh1JTDF5JzR9LruZiJyoVlU7Q5+Hybtb0bR99/2X9FY2DZZuKk25t3ZuMOM9C7m+mOIxIapVuOYZf2WY7bqdpYnGtEIUrIOqbtIja8PAEX1QQx/XZdWy2LpIoHr/gvIPZ1nuspwpQYrpC9IvPiSliZwF3TOlw5s/MAUK43vGEKgpDFqKw== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000061, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: update DAMON design doc to explain the quota goal self-tuning, which can be used by setting the goal's metric to metrics that kernel can self-retrieve. Signed-off-by: SeongJae Park --- Documentation/mm/damon/design.rst | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst index 2bd0c203dcfb..8c89d26f0baa 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -398,12 +398,28 @@ Aim-oriented Feedback-driven Auto-tuning ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Automatic feedback-driven quota tuning. Instead of setting the absolute quota -value, users can repeatedly provide numbers representing how much of their goal -for the scheme is achieved as feedback. DAMOS then automatically tunes the +value, users can specify the metric of their interest, and what target value +they want the metric value to be. DAMOS then automatically tunes the aggressiveness (the quota) of the corresponding scheme. For example, if DAMOS is under achieving the goal, DAMOS automatically increases the quota. If DAMOS is over achieving the goal, it decreases the quota. +The goal can be specified with three parameters, namely ``target_metric``, +``target_value``, and ``current_value``. The auto-tuning mechanism tries to +make ``current_value`` of ``target_metric`` be same to ``target_value``. +Currently, two ``target_metric`` are provided. + +- ``user_input``: User-provided value. Users could use any metric that they + has interest in for the value. Use space main workload's latency or + throughput, system metrics like free memory ratio or memory pressure stall + time (PSI) could be examples. Note that users should explicitly set + ``current_value`` on their own in this case. In other words, users should + repeatedly provide the feedback. +- ``some_mem_psi_us``: System-wide ``some`` memory pressure stall information + in microseconds that measured from last quota reset to next quota reset. + DAMOS does the measurement on its own, so only ``target_value`` need to be + set by users at the initial time. In other words, DAMOS does self-feedback. + .. _damon_design_damos_watermarks: From patchwork Mon Feb 19 19:44:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563021 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 8C114C48BF8 for ; Mon, 19 Feb 2024 19:45:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 2A4078D0007; Mon, 19 Feb 2024 14:44:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 2045B8D0001; Mon, 19 Feb 2024 14:44:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 02D8B8D0007; Mon, 19 Feb 2024 14:44:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id E3D258D0001 for ; Mon, 19 Feb 2024 14:44:53 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id C3B9D12049E for ; Mon, 19 Feb 2024 19:44:53 +0000 (UTC) X-FDA: 81809581266.27.6F7CBB8 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf03.hostedemail.com (Postfix) with ESMTP id 0096420003 for ; Mon, 19 Feb 2024 19:44:51 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q8gTpAJD; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708371892; 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:in-reply-to:references:references:dkim-signature; bh=InfIGkqwLY1rjp/JcBV8FfHT13fDCnJZWmtQPVbvJvg=; b=IH7tsvGt2pJ8XOYVyKCfjqud60Z54rg+7xJulu5uf4PKVESOP+/IRwrd68O+eXmrOB5C9I X7o2uDVWqHawlaxMHG9EI7xKsEXTUDHsQehPimQJqc+cfwR+rzxpXVihgxNLfSg53DBvJv PBX+EViIjhWoDOo9zgE5wwV2jaMI1ao= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708371892; a=rsa-sha256; cv=none; b=vtPnJXwvQ7yuqdgcNkq/gXOHxJla9t9+r5VKjCIOLX9jFK9uOuZKroiM+36swcgaXfVIpu wmB7XRe8GcpzplXgN9jb1njyonFpoqPy/emSk8c/YKchIvLni7YWofZjlvt3idQAnebAEa dnjGsZ339WZcBJo13bPs5HxN7SVn12o= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Q8gTpAJD; spf=pass (imf03.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 10850CE13DB; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F302FC43601; Mon, 19 Feb 2024 19:44:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371888; bh=JKYORKiKp9fESKQKjIG1tUqNr+4IIyTYixshjOr7TsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q8gTpAJDSUzJv8SYnqnTE+B4iPJvIqmm7yTz4AgyCUn2q6YUpC/PRX2+d/wOAti1S YgtPp8CLq7n025xJ/5a7E8FrGh6nPgEzzziDF/GySMDgyJzDRX9qe9+GEIxn8frWWv vFkGXpDH3rBXUZzCeYvB5bhyfjtRAZODGi9WIx1Dqnh25o70cAIH/DiPCnjmB0C9hE e8zcW3eIeT4hAqhLacEzc6/J49hpuP9T1531pVqwKmDi3tv0q1ihiL/i+WIvv6LR7y Bkkc9Pm5IH7cnm1+YZN2RbaqMCGNqhltt4sznZ+sKGB+D2XikKVTeEVt+z46zXNubF 7cb1/2hWWXAuQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 16/20] Docs/ABI/damon: document quota goal metric file Date: Mon, 19 Feb 2024 11:44:27 -0800 Message-Id: <20240219194431.159606-17-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 0096420003 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ryqkwef4rdjjj8qhohddan7pon83bnbp X-HE-Tag: 1708371891-58108 X-HE-Meta: U2FsdGVkX1+M30R3KngmqVFwXyjTQErdGleKrJY2+N8ZuZAeD5Wleu9Le8bh6GU1PFiUoAggFNMejsM8GpAhbxciPkzMAkcAVONFv1foZNCVXzVihkg/q3Ozkrf8By0Lpz0TiebyK4pfFG/temlSANLLEz4YeWRVw7NYEwxWN+9jx4gWdugNzuKsmtY6GI8j5VN+QDO30HWCxtMG2YpSlkVbaNsg0XsAkIpj5vCkIW82d5FbHgJnQkrNR3fv4LwVMhevrScpCRc9V0l0QaqjSGWz8nmqYejDaDbFlaXYyT8LcKKn5w4n2xBVGr0cMhFQdpq3wDFu5plV+vzHjnmavQgBGXqy3VBABButN1mwHSTGW23OnAfTT9GG/p+40aZ2NU31MigHRt3+oI9bjRmDHfvntgAAmckzliTHBeVbHsz9H/pJ2jO3F3RTdcQoBLliI/6vQs0/JXwggtzzdpnOHMES0v2Qg9LBZ74RAri3VHiEA+GlQJQfnoBt/vU5/tqXw5WiAnGkZCHjcE9bdTp635tk0U7X97o5FU1rmEFXuaYiNbcdTpVaLW8Mc3Y4O60HWjdgHzFATDIteA96g1y0Oye7F+Vi/BOuxuqUYyyQhNnoQ1tERcDiNicUEX8rZ1qjuSujdBXPQyYUGeA9i/FCXzD4n45qfxlqlLm97AYEOS2oDOUwFIbpJy+KyB9GcJSgm9blQKfGJBVQbAmshaX55OQKf6p4vzXsQt98OvrtYrEJQNPp1RCHmPjANeq5HZkFZN5atW/pIxbijT72pIDrohi5t+3wO4Aphu+As//5u1i+hYrOGY+nh9CAEHOuv6igtn8qttqAHWd8azloGcLEW88IRIvJkUpakVA2J7eaNhrsoluxIrW4dNN4wyQFn5TF7sSAIBkn5X1EC3KIkJkIETlSwRqxUJZiEtQW+pc7WiA= X-Bogosity: Ham, tests=bogofilter, spamicity=0.014276, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Update DAMON ABI document for the quota goal target_metric file. Signed-off-by: SeongJae Park --- Documentation/ABI/testing/sysfs-kernel-mm-damon | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon index a1e4fdb04f95..dad4d5ffd786 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -229,6 +229,12 @@ Description: Writing a number 'N' to this file creates the number of directories for setting automatic tuning of the scheme's aggressiveness named '0' to 'N-1' under the goals/ directory. +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//quotas/goals//target_metric +Date: Feb 2024 +Contact: SeongJae Park +Description: Writing to and reading from this file sets and gets the quota + auto-tuning goal metric. + What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//quotas/goals//target_value Date: Nov 2023 Contact: SeongJae Park From patchwork Mon Feb 19 19:44:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563018 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 EA06CC54764 for ; Mon, 19 Feb 2024 19:45:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id AE32A8D0003; Mon, 19 Feb 2024 14:44:51 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id A1BCF8D0001; Mon, 19 Feb 2024 14:44:51 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 86DA18D0003; Mon, 19 Feb 2024 14:44:51 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 7455B8D0001 for ; Mon, 19 Feb 2024 14:44:51 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 45A92A0450 for ; Mon, 19 Feb 2024 19:44:51 +0000 (UTC) X-FDA: 81809581182.19.62363E8 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 83A9E18001E for ; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="aCReNk/o"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1708371889; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=EhCmKs8/QhIiXHvZ4tYCoFVORO+R9k7JihDJpv78Jwc=; b=TO5otTtqEAO0jf5zSY6YOvCq94/9YZkBIBh67UGEY/tABKQTMWAIvXQNLK3/LFsbMHG9EM jXgVplVv24K7m8f2b53lEFuBlcXkWhOeSTO2WGEL2CDtgwnR7i2x6CAyyOJHVBi0Z9t0jf P5HnIPLVltsdEtL9oApED8+sUqRrwys= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="aCReNk/o"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1708371889; a=rsa-sha256; cv=none; b=pWN9OjTH5uwyhhHXGhD/EsZoBMluF1WG/Fiud0JbuRy6tLObFS1stdXghgvV9k1b6mJdL1 ao1sCa8NqSOxYBmgI2qUEcryZBzJUBDR1YK7VCxnxEArgz8FRMvNQEM3YmlRekcwXHsvM5 c5+5Kss1Lzh4UGcOIORUwN0PZJ/Mf2c= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 41AA660F77; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 87A6DC433C7; Mon, 19 Feb 2024 19:44:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371889; bh=on8Lep3AS4Mtk6AjiPZh/C8TU3CHqMgnp8c3zsc3Iao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aCReNk/oosprUvxML+loGz5WEl3Ex0wq8loimKpYSK8vC0StgTzc6hzZtHhrVpWd+ me+a2u1A2eOPZrePsH9WPL1k2OS8p8XMl2saSj+BmYT3t6QBHa+T0pb7ZfAlzCvrk7 gA6aUzkKjMNrH76IFAPd0BaiuojxtgycMnw8vDjd8Vyj4MbrA1ejTXY7slYrRDLE8c MgPkImBcgWOtQ49mT8xulLK8eeMQ6OytjD582dPstYkeDyokYl/YmwJ0jIILgvYZwL DlFu3pE/pVPe/hLKevn9ubaCmAWtyDdVO+9RXbtJrdpoVlzCFwt9KG9NjcHwEW/F3b PuXS69mZlmmzg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/20] Docs/admin-guide/mm/damon/usage: document quota goal metric file Date: Mon, 19 Feb 2024 11:44:28 -0800 Message-Id: <20240219194431.159606-18-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 83A9E18001E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: ttppqkzfhxxmhnpe7xj3kjaf6d6y7fn5 X-HE-Tag: 1708371889-903601 X-HE-Meta: U2FsdGVkX19PFyF4wMgakvCN0d9iRxqQzEVx3fEodkYkwxGdliy4b5I5TctI0qvOpnUq3YbUFsLd/Si13ELhBFaj13C7XsSOQELT2RltJIywAsCWA11RNpMi4meoonnI8I351LVXIHPByrDrTL4X1D0/UjLIvF76/lc2ILwmvFAz7PttawbeKBVpSb/RYoF8ocmGj3WcEDR6IL1fKhWHFPLQTP8oAD92ih6VVp6kXCJ88VnXcOZZpgZA9aOBPUHGLNR1V7VEKGDeX6hrThou9mLgtbVfdnemRtIW3qLrSLsYpe6zghOwkYLaS8CMeLv4aLgRzWaxLLbCabgRj/a6ruWppK+aUPoTCzA+L/F7N9yXNvCHK5pAVcaNIvt8sIeeoBLs+WjR0PAL8yTIgJO7Gjf4S28pdGSNhiM5oQMqyt5T/4zuhWGCDbpOXkdLaZbJHz2uQa+qiXmIzL59a+jXJUBjEgQ0a7Of0jRCls8HTdth84VdLE6vC9NuoQt7JsLXj1T5JHUgr+N/k2pCyI6D0gEO2ecaeRhd60lsjdBnoLQaIKCO5GML75EwzUj3fanyCUGcZWd1dRp8cdnR9uQ1U9mSRw8E7WW/C+cML/TFEUzL1SfHKC+4z4hGcVoFlzmvsmSWlRsZPoibAZrR3wXXaQVznYLHAgImPckZ6OA+IRF4vcHi7ZjlKBjDvCja2dmFw7yp4XWD26SZ83QneAgbks5+P8HircEcGMDfU3XwUMAUlnMQ3/aBDx03NE3vAsSHANDiCAOEQFhcFVmtVuBhOrRauSBjUGN1XJlTKt4OR8KtyeM5bMLXHiwnzoRa1bTKthfjS7QngghKPjXKb7cEJR9GN2h72GwGVtTTAt1IpA10vImkf14hZjoxR0/o5NL/1TsT3Z59RNdt7/ce4ej3cZKgCbzI71YI1Wy9tPLWlH1gmq/wykOMgXHt7bVdMEukw+/0SWbHNS44tLd+CAu SBzIQJYy 0+tHJseHaQIedrsoRTdxMrOLs14smLFkSwvfOjfZ0iBsQeKtXETqk3u/Oq9OnGfPU3G0JhfbWuyNHEKb7AWLjEtjBSLJqtEBL38A7eVJ25UuuiiSN6jL3rzAJEcB7f2R9AhOII5V2iBKppDUbaKIkRh0bE8GimQFGDb5eYNkrnhCyeRUi1CH5Au3HLKyCRvjPOVLVwXclZijJxGdUCEpyVHAcNOOzi11W8n79OiPEVwegQvQY7Mg8g+q9zE5Rmu6WMm16REgpPRIM+mK7bTXDm0G9M/QvsgJlloG/ 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: List-Subscribe: List-Unsubscribe: Update DAMON usage document for the quota goal target_metric file. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index 220ebbde7324..b33eecfd0e90 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -86,7 +86,7 @@ comma (","). │ │ │ │ │ │ │ :ref:`quotas `/ms,bytes,reset_interval_ms,effective_bytes │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil │ │ │ │ │ │ │ │ :ref:`goals `/nr_goals - │ │ │ │ │ │ │ │ │ 0/target_value,current_value + │ │ │ │ │ │ │ │ │ 0/target_metric,target_value,current_value │ │ │ │ │ │ │ :ref:`watermarks `/metric,interval_us,high,mid,low │ │ │ │ │ │ │ :ref:`filters `/nr_filters │ │ │ │ │ │ │ │ 0/type,matching,memcg_id @@ -366,11 +366,11 @@ number (``N``) to the file creates the number of child directories named ``0`` to ``N-1``. Each directory represents each goal and current achievement. Among the multiple feedback, the best one is used. -Each goal directory contains two files, namely ``target_value`` and -``current_value``. Users can set and get any number to those files to set the -feedback. User space main workload's latency or throughput, system metrics -like free memory ratio or memory pressure stall time (PSI) could be example -metrics for the values. Note that users should write +Each goal directory contains three files, namely ``target_metric``, +``target_value`` and ``current_value``. Users can set and get the three +parameters for the quota auto-tuning goals that specified on the :ref:`design +doc ` by writing to and reading from each +of the files. Note that users should further write ``commit_schemes_quota_goals`` to the ``state`` file of the :ref:`kdamond directory ` to pass the feedback to DAMON. From patchwork Mon Feb 19 19:44:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563019 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 4682BC48BF8 for ; Mon, 19 Feb 2024 19:45:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C7728D0005; Mon, 19 Feb 2024 14:44:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FD228D0001; Mon, 19 Feb 2024 14:44:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 251028D0005; Mon, 19 Feb 2024 14:44:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 124D28D0001 for ; Mon, 19 Feb 2024 14:44:52 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E6938C025E for ; Mon, 19 Feb 2024 19:44:51 +0000 (UTC) X-FDA: 81809581182.11.60B7C5E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id 2EE2DA0002 for ; Mon, 19 Feb 2024 19:44:50 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rFJSr6uM; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.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=1708371890; 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:in-reply-to:references:references:dkim-signature; bh=riSQdEiVLB6Q12bND90ux+qR3YMcKh9xiFH3w7RB5OQ=; b=1IQFGzjeBDw3IM7OFpK1w98hdC0heigdwWxAsT77yDGAuA3OHykzOYjVXXQnMb2MT1iH/o 5us3ZU29VGkMbXYrSxgyh1ms8n0IEaFLk2pTGfzRQJ/HyaSh+nFOaQs8WUGuPGI3u4yjHm I9aTp1ob04FK5ON697v1skNWMJgWjOo= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rFJSr6uM; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.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=1708371890; a=rsa-sha256; cv=none; b=1gnlQJoaYlKar6KCS1KTTdBfZoYBExTem81wg3iWe+/uQcKpLu/CTnBBC3PJYu+WvPmlpV 2GBO9SmBPt4Odh82b7lURRq4NY7pvSUxD5bFXGn1ZMijVmcf5CWfGZpLkpKEBeUKrhotRa 1URUEZC0xP66NTJO2NWQ1k17k/NkDS4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E20A760F6B; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C0DAC433B2; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371889; bh=md7Aj2wC1qQQtLcqUJ8iiiADXUQCURmj3A5KbIYpZeI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rFJSr6uMfuHvK3mAQWBO/Kx6owcMmb7rsY4jYWRds3IthNLEW3TlfK7jgsRfr4CSM dN61MrBA2XaPqDMU1gaWjxDOp5uJue4FiXV7dyB9ih0d1yjDW8TJqFmyoJ/AprBXak +FjLU5myQyDjsWWNPpqZTo7WXY0W2RxROETQtMeADxrfSn5wvY7a6iFAWvj+4JDzLp O61GWEWp+dqyVwTmB+0q+9dX6dgijC15QKRxTU3XGe0mlKXQzQaYL3LVdw/xMeOVmQ bToBakwXJn07j5AZmC/mO61+fYpOd8aT2rRkCdhkI0gbIiIPbCe1sxCqAirQ894/Nl te5B+uRH2irWg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/20] mm/damon/reclaim: implement user-feedback driven quota auto-tuning Date: Mon, 19 Feb 2024 11:44:29 -0800 Message-Id: <20240219194431.159606-19-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2EE2DA0002 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cw1bo1oqoywgkr14aqewarcszsbr15ec X-HE-Tag: 1708371890-230611 X-HE-Meta: U2FsdGVkX19jumnMMo+yAjpXMwBX40QwdJrmD9S1h8UVYY7swpNi1n1CyMlSUXal87sWxukzRZhdyA9yAgwHzr1t4Yn1zL/1t0GLAeTsHdjf9K16T7zCGzUYrcJC4R4WRzvMGf1Z4eKpncUjaFPdQqDmkZjHZsHTZBQFzfGdSik6/c0jBEDpPXM4c7NXgIpjYZsrQI0vR8txy+WpLKuA2OPWGVTN1O+WnqIcF2fIlxfN67lZVZTB9oKp+ewymChmPtKhPtAvRVLwYzbt7fBdXhrMjN839dOvqAeFFPP50dNnxMjWLHsCvDRoVda30a+JL/i21reuRiLdPQIKzdO4xoBLHGMIifAdcljBLNU0DDhqp8es3WgNIJ9FKpqTrNgGxe91exEhyecA4Xe2DcSMlcMfR96UQ6kpUa8IE6a91G2Whp2VvIb9vv722D3gE1AUHLeo4gz2i/xS2xN57ammTHqe6sJC4uhMHRDxEVM9wO7jtn9RuqCCT02cUt5plkabQowigJIeCVoKUEDQZY8zTC5ZE8v57yb7f+6H+2lT47GhYYCNNy8NRuFgICDif9YQMlN3Ce7Df7uUDsDXuazICanst6rttt2Vfe66c9q8QwmXY/1aDxCfeez60a/g2XWseFowUoAWELzYFZ3y7oWFC26RuQdSuVT4P/IYlPH2Gx64K4Nxp1MiIjdvJnOfJZgpBJG9nb4QqM1zisMy3uAHpxvO5NZFXMzeTLTIXgcvBjb4kPq3gX6jw/M4S7uO/7Xv+dpldsuSOnrIDa+CVX4bhL1dp7e7GU4lS3fO/X6UfXhpLxCq8pgbEME8By//YCOzcZ4hLMT7UyOHUqIRxPKN/oQ8cgIf4AOeSMS3GWj62ZEoObBGJg1OU0qk0e5eu65Slsa6HnZRTNhLfjNK09dfCQ8bcoTOLgftiCWuJNQCF/JM1sMl4eBtWA== 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: List-Subscribe: List-Unsubscribe: DAMOS supports user-feedback driven quota auto-tuning, but only DAMON sysfs interface is using it. Add support of the feature on DAMON_RECLAIM by adding one more input parameter, namely 'quota_autotune_feedback', for providing the user feedback to DAMON_RECLAIM. It assumes the target value of the feedback is 10,000. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 66e190f0374a..9df6b8819998 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -62,6 +62,21 @@ static struct damos_quota damon_reclaim_quota = { }; DEFINE_DAMON_MODULES_DAMOS_QUOTAS(damon_reclaim_quota); +/* + * User-specifiable feedback for auto-tuning of the effective quota. + * + * While keeping the caps that set by other quotas, DAMON_RECLAIM automatically + * increases and decreases the effective level of the quota aiming receiving this + * feedback of value ``10,000`` from the user. DAMON_RECLAIM assumes the feedback + * value and the quota are positively proportional. Value zero means disabling + * this auto-tuning feature. + * + * Disabled by default. + * + */ +static unsigned long quota_autotune_feedback __read_mostly; +module_param(quota_autotune_feedback, ulong, 0600); + static struct damos_watermarks damon_reclaim_wmarks = { .metric = DAMOS_WMARK_FREE_MEM_RATE, .interval = 5000000, /* 5 seconds */ @@ -159,11 +174,13 @@ static void damon_reclaim_copy_quota_status(struct damos_quota *dst, dst->charged_from = src->charged_from; dst->charge_target_from = src->charge_target_from; dst->charge_addr_from = src->charge_addr_from; + dst->esz_bp = src->esz_bp; } static int damon_reclaim_apply_parameters(void) { struct damos *scheme, *old_scheme; + struct damos_quota_goal *goal; struct damos_filter *filter; int err = 0; @@ -180,6 +197,17 @@ static int damon_reclaim_apply_parameters(void) damon_reclaim_copy_quota_status(&scheme->quota, &old_scheme->quota); } + + if (quota_autotune_feedback) { + goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000); + if (!goal) { + damon_destroy_scheme(scheme); + return -ENOMEM; + } + goal->current_value = quota_autotune_feedback; + damos_add_quota_goal(&scheme->quota, goal); + } + if (skip_anon) { filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true); if (!filter) { From patchwork Mon Feb 19 19:44:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563022 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 A27B1C48BC3 for ; Mon, 19 Feb 2024 19:45:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 07F1A8D0008; Mon, 19 Feb 2024 14:44:56 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EFA1D8D0001; Mon, 19 Feb 2024 14:44:55 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D9AAA8D0008; Mon, 19 Feb 2024 14:44:55 -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 C52C48D0001 for ; Mon, 19 Feb 2024 14:44:55 -0500 (EST) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 81D6F1403BB for ; Mon, 19 Feb 2024 19:44:55 +0000 (UTC) X-FDA: 81809581350.14.CF0F59E Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf29.hostedemail.com (Postfix) with ESMTP id 8A43F120016 for ; Mon, 19 Feb 2024 19:44:53 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ml2xbaVH; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 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=1708371894; 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:in-reply-to:references:references:dkim-signature; bh=rwELeJCpNTigCYTVCX3u3te/203k+c65c/t/DHkAQWI=; b=yU01rQQSl80BgaD1w93rMBzUhZmQl1wp4cX1S+rT9NfDnnbbJJBqP69aoWV9pYrBKJkeXW K2Qw7pz8zwF3QN4X7EeDcyrnpFarXsRF0K6QuE/gC9wxTVpEZFb6L7KQeKVFvs8HZZQs7m qH54DVSsXpIudc0yv6dZ/foBf9By/yc= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Ml2xbaVH; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708371894; a=rsa-sha256; cv=none; b=irvCVXv0ZPZd6WtY7XuOLVoPGK+vgtu5ijHKNOg+4IxfKds0AnkHNMFNb+8QaahCH3FvvK DWGnCSlw89j5CdwB0LwCen+erWIiTEG2q+QiBfjz30GEJ/pSd3uOGLN+6omV0IRwHxSnuc fwNMXi7I6oFHtKPGY2YAphD99YOA3Dw= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id DAFB2CE13D5; Mon, 19 Feb 2024 19:44:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C78DEC43390; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371890; bh=tG3S12R9lWJQ+3nlob/l1OneJpRLcwIKt8aIF6Enn4k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ml2xbaVHRr850LD2Xo3UE5RqNzk6jup3abKGVZsJufjCxh4FJL1I8ZLvAZQoyItue HsySrTPrtzqdevNi77IFL3ZvmPJis7apE/tV6U6QtXX2SNDv5FT/sKqi2/hKWVjzoe gdoaRsNbvsNuyUEd4Lq3oJ5reSR7mh+S046aZHsPibxoaN4WpBJaxV5l/AHDuPka7n HQ2YIwBqI3s/axquI4sbDmMIpgQRcTMt9Ac6Ol1oXPTRv/6lWDDkUuFj/3whWZSJmf hHiEKQnRplZQhMflDZlQr8UmQs0rNWwf6LwEEx3x0UJg11hlIUZCbjrkPrqcf9wZES /bSAM8OTHrttw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 19/20] mm/damon/reclaim: implement memory PSI-driven quota self-tuning Date: Mon, 19 Feb 2024 11:44:30 -0800 Message-Id: <20240219194431.159606-20-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: cjjdgme1p6enr9ojq8h1sgwdr5t43phh X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 8A43F120016 X-HE-Tag: 1708371893-732975 X-HE-Meta: U2FsdGVkX18ORgs1bkWSiPpeMEL7cT+KcasNbSSrl5hrmLK7gyJ0/KoBWA7NjY8oAFKj3+f4ymD65unHl1/aPdHHQACuatCbHQhg1k9Clbd4mKWd3JebITwPmfVLYBXwV7levFwn7F/satBrgc9Psk/DlD/g/w1NsjMg8n9phatzCYNMpSiXKRxJQsg6qrPZMvyfF/eERBZPGDyL4ej+EKgJT8M6fmbQmfR6EY8q4WMlhmVzktPn4jsH7A+7LZPltM9rGRbOcIOHbIkXX74UZtHvViIDG3/VGe1d0hwfEiuUpPsZvpoyROKP+Bm2NN1QcimdfPDoDdBBvPA7fStY5532jWp/msZbsVFy0vGbX340i580jsXxXfT3NeBTtaYYj0B3Y+R+OMOLrooQZqonJb7aC3f6aRV92H2aR58Y4So7HsfNAwsSGZxakbix7T/6FAEU4f20a57ByQQNv0JqRq7FM396m8Uyj7Re+OEOSRJQj93p6RhkoL5LrmecmOOVD71e36afovUc7ah3FUhGSqYc345ZRjN3BlAaI1aczu/JkQIkAfNZQPpcipC5aEgbnhyRGwP8FTLDow9fQKkItxygHGoie6DHiezAn107OLsCFQJAI/2WEl6yjK/ikidyLJO118LrW2UU+sai0kza+mLE1M7gs+XJvq+1nDeFroYGrsIimUIXgC6NKHf4HN3e/ADzic9ZW8KU5KIXsFnvzTKjv28VhWZLbWP4C8EMKb0hxTjdaE374zVR2A+A94pUm7UwVOoDZZw00n/hDT1HQKhLq8z+3wqZzR7iRHBxheWQNoM/0tjAKO6sLfX9I/qhP13Q9KCCZuFewfVJemfiGJrkFQ+31gmYkOMvFSTuTCpdIn+h3S09JaM9VFSDUnx0WpNBY9/to/Tb8O7y/nE2t2NmlV7e68yU7TQYHi49Rmdy86QirE1RE8AlcbWwnseOpTI7eb9IaNmZDCPqrkv MR8oWdfc OUWHOZlVB7whfg8l8dqw/4+oJVZ5VI3EuyIXGT9LXaDPqtOoTAcNGb1yaRdsQ58WGFUeILofn5nk7cBUJRreP2mVv/u6R2CuueKqx8A4XxTsho2XDF2Wa88BtJ8ApkrA6aGQjlRa282wJooHrGHxcDs9HDmHj4d9YGSb2fUz6z9wTIwW1OyyMJMOPLZf2baOdlU/Vdp3/Yfh+nOHbsBR0VjQikX2dS8LuoM1q75VJf0bEqi8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Support the PSI-driven quota self-tuning from DAMON_RECLAIM by introducing yet another parameter, 'quota_mem_pressure_us'. Users can set the desired amount of memory pressure stall time per each quota reset interval using the parameter. Then DAMON_RECLAIM monitor the memory pressure stall time, specifically system-wide memory 'some' PSI value that increased during the given time interval, and self-tune the quota using the DAMOS core logic. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 9df6b8819998..9bd341d62b4c 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -62,6 +62,21 @@ static struct damos_quota damon_reclaim_quota = { }; DEFINE_DAMON_MODULES_DAMOS_QUOTAS(damon_reclaim_quota); +/* + * Desired level of memory pressure-stall time in microseconds. + * + * While keeping the caps that set by other quotas, DAMON_RECLAIM automatically + * increases and decreases the effective level of the quota aiming this level of + * memory pressure is incurred. System-wide ``some`` memory PSI in microseconds + * per quota reset interval (``quota_reset_interval_ms``) is collected and + * compared to this value to see if the aim is satisfied. Value zero means + * disabling this auto-tuning feature. + * + * Disabled by default. + */ +static unsigned long quota_mem_pressure_us __read_mostly; +module_param(quota_mem_pressure_us, ulong, 0600); + /* * User-specifiable feedback for auto-tuning of the effective quota. * @@ -198,6 +213,16 @@ static int damon_reclaim_apply_parameters(void) &old_scheme->quota); } + if (quota_mem_pressure_us) { + goal = damos_new_quota_goal(DAMOS_QUOTA_SOME_MEM_PSI_US, + quota_mem_pressure_us); + if (!goal) { + damon_destroy_scheme(scheme); + return -ENOMEM; + } + damos_add_quota_goal(&scheme->quota, goal); + } + if (quota_autotune_feedback) { goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000); if (!goal) { From patchwork Mon Feb 19 19:44:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563020 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 465CDC48BF8 for ; Mon, 19 Feb 2024 19:45:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 515148D0006; Mon, 19 Feb 2024 14:44:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 44C4A8D0001; Mon, 19 Feb 2024 14:44:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2EE0D8D0006; Mon, 19 Feb 2024 14:44:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 199BF8D0001 for ; Mon, 19 Feb 2024 14:44:53 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EAA5B80388 for ; Mon, 19 Feb 2024 19:44:52 +0000 (UTC) X-FDA: 81809581224.03.C00842A Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf06.hostedemail.com (Postfix) with ESMTP id 51EA218001E for ; Mon, 19 Feb 2024 19:44:51 +0000 (UTC) Authentication-Results: imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KqdSM2r2; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1708371891; 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:in-reply-to:references:references:dkim-signature; bh=Y/X+A7MxKLZzEOLxaIOzCd5+qV0ysfi1p0eFECsMYz0=; b=xul2/VENfqNhGSShiOYyX1KGnR37myrTP2btV5WurxIwaLm2BWivOVraF+Kv68V9PEWzV9 roxIG4JgEzqF4Hal4wJ2NNsohI9Cock0ezwi3j40/qKwJTQf6mUwZvovsxxiFnZuBA48lM Thdde795OwF0UuNs9SWhBgxyi+d/qdc= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KqdSM2r2; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf06.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=1708371891; a=rsa-sha256; cv=none; b=7nCrDYcwzF79ylTRvAas0nu205eThPVQVcdmb8lkhFHfBY75/83Aw0P++HZR117A6gECyP mA5c6r7lwVUF088RNSH/YO3bk54clMID38xtRVWnLn1EzxjMlz5jMMcha9q5q2H5P+Nv1x 1eFp5CZJ88YbDxUH1XekpAzPoBOfBCU= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 0E8D560F6F; Mon, 19 Feb 2024 19:44:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5D981C43394; Mon, 19 Feb 2024 19:44:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371890; bh=N9nR7nwUdsukBui32rCfnM5+OryMCusxZ8X3or6m4gs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KqdSM2r2arnrE2pBIUDFF7hZiMjke6At78DYHjdLpERwp7GzGMMfZrZD/XkvVsvoL iZ0gKt+cXZC2/Q6/wDxgAXwR2lScpDLfLDBK0fbWYh8QYEaBEUqQaD8GbSEYU19OnH U++3UpC6Jpa+GOpKK5QyaegBWlVfHsoysde0a5MGIv1cNeG+RjS1KFiSJb8z408nxj LTZLeZw/EPiwFOioMXDWha/73iN4Zoz2vCX2USa/2Djbqs9MMszoIsoedfNOl1FCfS 7RKT1NeXBEKPFeYON6dpCo1wCv301lTmRD+TNX3etwdGvFarVDTz+/bbCnHbR5kJo9 LiI+VOgnX3CPg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 20/20] Docs/admin-guide/mm/damon/reclaim: document auto-tuning parameters Date: Mon, 19 Feb 2024 11:44:31 -0800 Message-Id: <20240219194431.159606-21-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 51EA218001E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: p9ehb63w8atfxask9wriwneokkww41zf X-HE-Tag: 1708371891-351511 X-HE-Meta: U2FsdGVkX19vBSfTjaiPBuDQKEqhNLlkmEV//EVFsBeNSuRZsNBZK5+SZAbNC9wdu6WOZgGD4L1PogYtRPF8V8CSXgjOEM3pWc/rl/nDsKam5amYpMZ7ZDhmjHeCualHN6dIa7kdtPcEdiN4T9d5gRv3/+A5TX8N0hOzWgMp4VdU3KmRxf27a02YdplWPLSnk/BDQGxdPuQXVxcf9l+WIUOxsQfezvdFRjqM5BcrzillN6danzoPga/+bJIsbUt9pXKh8fdj0Dj4zbeuLpKi/sSGMWiwGtY+dAA1QDPedx4S6+lPexNnEHhA2oumyNk8AIeMdgQuW529UV+3hJTxdNiU7rzK9vw6dgCAq5aX3msoDauLDdqOj5/ZPcgh9ohH9/g//VjBDY8SZMvaowZE3poJLr9/XeKcZjUE9KPw2FpXVMN5il18As62I7FW6P1kvoPxJyO7ZwCgkKO9193hwFGUsR2LPgqrJJmdcF7ozfkDgWnRzJ7lsadEHvY/8t9ZnRyj+LYdrWegH0w1QDAV55q1FnUIfyUWrYAHXU/zkL6LNfLUEa68mgPyMssVHDwdubBUhbxvE6fN8JA16N+b7Bd8qDd38uXT6hMRYzdE9bC6fEjajO2ieqOqzqxeiHsnpOVjBNxspIu4PSVa7wkqReYYyIg5wqs2dy2LxFFtPDrxPnwrgt+wIVMRoQrABGjx9QKSo9qvYvrICojYhVGfknUKY8Ppmqs9IsiOeYuq5fyKoTdubOyIibry3B8aYhx66jeSI5/nGqkpTHDiUvUfCAyc6GQ2ERyycEj8gzuFirEFCX/40aCqf6MHuHw1eSdGybYZpBWhjrPSqSjtb2Af008jwUiUc+JW6qIyNTvczATuYk95J0ODV33dqWZCn54nnKyCpUci0VTeuduw7/vwTIk79UzDtZhUx3m3zG2dfKUlubN0qSNuomx/Bouw+bmGsah9ewLEFyrkaxejiq1 /rQf5WmH 1sXreJecWxr3s/mNb6CuVOQpYydjy2skVEQSi9Zm3ToskcPk8cZ83fYoSOSHyg9lBdNFk3cBR0n3Novd/mXsItQWbMqGr526erA4GEWwdUUndfvWASy1MvSZiVvk22pitMBC8uiiuzOb9MOf3PerL6cAIVUyAgzmMQxKgx1xKEzNedx0rlcMY9InTE5e8NBlvDPjhWH3RmCgUgze1zC4cPHJg/uQYioTFAZ36RR8wa6PaMTw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000100, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Update DAMON_RECLAIM usage document for the user/self feedback based auto-tuning of the quota. Signed-off-by: SeongJae Park --- .../admin-guide/mm/damon/reclaim.rst | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/Documentation/admin-guide/mm/damon/reclaim.rst b/Documentation/admin-guide/mm/damon/reclaim.rst index 343e25b252f4..af05ae617018 100644 --- a/Documentation/admin-guide/mm/damon/reclaim.rst +++ b/Documentation/admin-guide/mm/damon/reclaim.rst @@ -117,6 +117,33 @@ milliseconds. 1 second by default. +quota_mem_pressure_us +--------------------- + +Desired level of memory pressure-stall time in microseconds. + +While keeping the caps that set by other quotas, DAMON_RECLAIM automatically +increases and decreases the effective level of the quota aiming this level of +memory pressure is incurred. System-wide ``some`` memory PSI in microseconds +per quota reset interval (``quota_reset_interval_ms``) is collected and +compared to this value to see if the aim is satisfied. Value zero means +disabling this auto-tuning feature. + +Disabled by default. + +quota_autotune_feedback +----------------------- + +User-specifiable feedback for auto-tuning of the effective quota. + +While keeping the caps that set by other quotas, DAMON_RECLAIM automatically +increases and decreases the effective level of the quota aiming receiving this +feedback of value ``10,000`` from the user. DAMON_RECLAIM assumes the feedback +value and the quota are positively proportional. Value zero means disabling +this auto-tuning feature. + +Disabled by default. + wmarks_interval ---------------