From patchwork Sun Nov 12 19:46:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13453384 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 4168BC4167B for ; Sun, 12 Nov 2023 19:46:28 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B16A58D001F; Sun, 12 Nov 2023 14:46:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id AC6368D001D; Sun, 12 Nov 2023 14:46:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 918328D0020; Sun, 12 Nov 2023 14:46:21 -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 5ABC28D001D for ; Sun, 12 Nov 2023 14:46:21 -0500 (EST) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 2EB33120445 for ; Sun, 12 Nov 2023 19:46:21 +0000 (UTC) X-FDA: 81450333762.27.07D3DBC Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf17.hostedemail.com (Postfix) with ESMTP id CD73840007 for ; Sun, 12 Nov 2023 19:46:18 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XkjUxCxf; spf=pass (imf17.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=1699818379; a=rsa-sha256; cv=none; b=zHRV3jGZreU/Jo3vYc/sUMbi8arxcuGXMPvqWReSZkYbYWnptLqsnwooAhq1545hBS9gYL SUb9qdLObw7L8ORCgtanNujS9hFfLb2UAeQILiWRsNNRtstS4R9HRoCgnWBJJHABNST3m+ zAvivXnuFiSYl1LVT2KG9Jv34rcH1hA= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XkjUxCxf; spf=pass (imf17.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=1699818379; 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=gxGV2K3I6gjEYhXMANRPr9ZZAD0VMOdDCMI2p6R70Mg=; b=OJDxCiL2S+XPAuiU+9Tx1OjZYktrWHl3VfJ1E6KQAQK5yML0qA01ezDFVoN6IoZ7zXs2z/ RlEMUJRSZEohJMseNsw1wd7l/iuItJyxNXiAFkRYWAdcteQuvrj1j4Yl3rUhohCkCLn9Y+ ONaP95HHlBHpGNgkV/ar6Teg8doGCIA= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 9D624CE0F1C; Sun, 12 Nov 2023 19:46:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 51465C433CB; Sun, 12 Nov 2023 19:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699818373; bh=KH5zwAcadi379iK70CZqM3VL8+sPUwrVnpfkvLQxuio=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XkjUxCxfX1eDI7+ZUfgU0fc8n+Jbbw4SnAXuDwRc0gK2X9MJSQ/Im4hUdsXf8ulo1 kWBRMqtgQ7mu/hCku3ihWgdbs9bRZ30guaTnrITIWYBeVXdhn3cXqcBZSX15bmxyoH kZx70B5f6Wihw8EQUrGMeKL+8/OZLa/P2mdO7LyxR+hxkpW7dAqzS2x0wMNQHUsD+V vkYfSwqBIzDI90NSXv8G57GkDDvA/kKI18Wh2GuRYSi6dSIl7rS/X1aIZzaRu61F4o 3NpMhRv3qxln2doao3lETfko0/RzXJVEi2a08qylRuH1pAmVvXB8CVyZXk20qiarmm 8SIzWD3FOpPCw== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/8] mm/damon/core: implement goal-oriented feedback-driven quota auto-tuning Date: Sun, 12 Nov 2023 19:46:00 +0000 Message-Id: <20231112194607.61399-2-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231112194607.61399-1-sj@kernel.org> References: <20231112194607.61399-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: CD73840007 X-Stat-Signature: ohqqrjde4cga87wdkpb9t8hng996fms7 X-Rspam-User: X-HE-Tag: 1699818378-907108 X-HE-Meta: U2FsdGVkX19oT8iBLBWyP9b2Q/uSe/7DUM/2SR7DEr9twCf8L5ZpPizUipT2pMpgK+1XZah7aRVjhWsyoepzUboHhEtrg5HJMQdwowqF+kepW2anaAST5rByDJPgnRGjWPuc6c0Sb28FUbzsMnjvwadhw/dxyOkiYFgb/1LLUsMqAK8HmPw8KoMKsL769cO8bzJ9B0QwnJ0yGYBcmR1Qp/ZyP8sQz51S5hTHuGV/3gP6onvrU93gu0JMHczoq6AZ/ORjjsyX/K5qsCY6imQbhcqIhbk4n1xFsHi0a8U+b+imdxtrb1W9GGSA4sGFK0fvew16frovynZVGR9lMtb8smcKYmTQrn6KJs4Z/nEhpwtQPROs3rMNLsaIAK4dWnGG2SXhLH43LPMxs7NFjvvCbDXXMPTSbajmHX96M5LaFWa3VNJvspqUHl0Nq2NGDwPuU/IuQj4GSAHNKFfiXjZ+y3+qAi4c/k1VFvmXFZuSImBwk4JSpqB7gqn+idCXEGj3nfNlNcnbSTZk3QEnBJUaMP53rl8nSS+v9zGJ1DugInw8eix+x/0RTcVaZW7uXwZ7O2bJVenKNilLmuBcBhojgRNHWyV5LrGpZNgypf3hMCaSQofLWUwZflZJKTM+hSolzYlNJZPeDQOE2bDEZvmtnb9iamodPHbgs3Uv+cF8msJ05K/ASvtrX0VDC3SNPi00UnRf8qeNAKV8e2r+utZsgC8OXl3zcnCTt5mH7A6+gXCdqQ0sfS2RtQrHXzEqSUGN0irDOFmrlO81dHYDAhNrKGAMK56XLn9woANXz0VE0xdjmVCXGKwaSpn+KX6iRFfpyhD9m67AK9A/KvkRxSIZHvrKHfvQYHC5BDA4rcYm7q3AaD70bbbNs4DXPH5Xy6Jcxeq/THjmqSOpQkquR8K/jCCJNQmu4cksEiZ8QUv7NEFtAUfKrSQmGECDoLU1oGZKg9vzs/ppoVRAn19+YZ0 jTRwqSwE /Aao+S6ZOSdrwIZYdBMT7pcOE931/sWA6JIA2Gnt7xRCf7S1lIxC/bo7l7CWBgWbWY4UB/PFHUI+dMFBb/ly8Maa/Cw2oF3XOOjwi8dpatzYNCXqHkRcbkrTMUYMIO58+J6Eqk+2Wi4dY2u2fUzgLc/n5/4t/jEB+ljfpN8vVyN7usroUWNCKw/OFCTt1Mc3w3w+as08SJT9XmZJyhia6oLH7vU8+ilwKJBh2Az86+SKSap4= 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: Users can effectively control the upper-most aggressiveness of DAMOS schemes using the quota feature. The quota provides best result under the aggressiveness limit since it prioritizes regions based on the access pattern. Finding the best value, which could depend on dynamic characteristics of the system and the workloads, is still challenging, though. Implement a simple feedback-driven tuning mechanism and use it for automatic tuning of DAMOS quota. The implementation allows users to provide the feedback by setting a feedback score returning callback function. Then DAMOS periodically adjusts the quota based on the return value of the function calls. Note that the absolute-value based time/size quotas still work as the maximum hard limit of the scheme's aggressiveness. The feedback-driven auto-tuned quota is applied only if it is not exceeding the manually set maximum limit. Same for the scheme-target access pattern and filters like other features. Signed-off-by: SeongJae Park --- include/linux/damon.h | 19 +++++++++++++ mm/damon/core.c | 65 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 75 insertions(+), 9 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 89f5ca041848..9d46e0b39456 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -136,6 +136,8 @@ enum damos_action { * @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. + * * 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 @@ -153,6 +155,17 @@ enum damos_action { * 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 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. */ struct damos_quota { unsigned long ms; @@ -163,6 +176,9 @@ struct damos_quota { unsigned int weight_nr_accesses; unsigned int weight_age; + unsigned long (*get_score)(void *arg); + void *get_score_arg; + /* private: */ /* For throughput estimation */ unsigned long total_charged_sz; @@ -179,6 +195,9 @@ struct damos_quota { /* For prioritization */ unsigned long histogram[DAMOS_MAX_SCORE + 1]; unsigned int min_score; + + /* For feedback loop */ + unsigned long esz_bp; }; /** diff --git a/mm/damon/core.c b/mm/damon/core.c index c451e7dfcd64..4d4e4ebbbb2a 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1086,26 +1086,73 @@ static void damon_do_apply_schemes(struct damon_ctx *c, } } -/* Shouldn't be called if quota->ms and quota->sz are zero */ +/* + * damon_feed_loop_next_input() - get next input to achieve a target score. + * @last_input The last input. + * @score Current score that made with @last_input. + * + * Calculate next input to achieve the target score, based on the last input + * and current score. Assuming the input and the score are positively + * proportional, calculate how much compensation should be added to or + * subtracted from the last input as a proportion of the last input. Avoid + * next input always being zero by setting it non-zero always. In short form + * (assuming support of float and signed calculations), the algorithm is as + * below. + * + * next_input = max(last_input * ((goal - current) / goal + 1), 1) + * + * For simple implementation, we assume the target score is always 10,000. The + * caller should adjust @score for this. + * + * Returns next input that assumed to achieve the target score. + */ +static unsigned long damon_feed_loop_next_input(unsigned long last_input, + unsigned long score) +{ + const unsigned long goal = 10000; + unsigned long score_goal_diff = max(goal, score) - min(goal, score); + unsigned long score_goal_diff_bp = score_goal_diff * 10000 / goal; + unsigned long compensation = last_input * score_goal_diff_bp / 10000; + /* Set minimum input as 10000 to avoid compensation be zero */ + const unsigned long min_input = 10000; + + if (goal > score) + return last_input + compensation; + if (last_input > compensation + min_input) + return last_input - compensation; + return min_input; +} + +/* Shouldn't be called if quota->ms, quota->sz, and quota->get_score unset */ static void damos_set_effective_quota(struct damos_quota *quota) { unsigned long throughput; unsigned long esz; - if (!quota->ms) { + if (!quota->ms && !quota->get_score) { quota->esz = quota->sz; return; } - if (quota->total_charged_ns) - throughput = quota->total_charged_sz * 1000000 / - quota->total_charged_ns; - else - throughput = PAGE_SIZE * 1024; - esz = throughput * quota->ms; + if (quota->get_score) { + quota->esz_bp = damon_feed_loop_next_input( + max(quota->esz_bp, 10000UL), + quota->get_score(quota->get_score_arg)); + esz = quota->esz_bp / 10000; + } + + if (quota->ms) { + if (quota->total_charged_ns) + throughput = quota->total_charged_sz * 1000000 / + quota->total_charged_ns; + else + throughput = PAGE_SIZE * 1024; + esz = min(throughput * quota->ms, esz); + } if (quota->sz && quota->sz < esz) esz = quota->sz; + quota->esz = esz; } @@ -1117,7 +1164,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) + if (!quota->ms && !quota->sz && !quota->get_score) return; /* New charge window starts */ From patchwork Sun Nov 12 19:46:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13453382 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 EA82FC4332F for ; Sun, 12 Nov 2023 19:46:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 34D988D0002; Sun, 12 Nov 2023 14:46:19 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 265468D001D; Sun, 12 Nov 2023 14:46:19 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F330D8D0002; Sun, 12 Nov 2023 14:46:18 -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 BA6218D0002 for ; Sun, 12 Nov 2023 14:46:18 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 7ED06806D7 for ; Sun, 12 Nov 2023 19:46:18 +0000 (UTC) X-FDA: 81450333636.13.0411145 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf21.hostedemail.com (Postfix) with ESMTP id D04341C0007 for ; Sun, 12 Nov 2023 19:46:16 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MIh9ucCT; spf=pass (imf21.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=1699818376; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=245TcY1/4hwVjJLNcDhHKPMaQGy/jXqRs0r2aKC+E6g=; b=f8LrESllY+iE48a8eWW8RmeZxhYpjzu2Sl/W67UT64ypzPYEuFUQTFRPYnPxijrmfu00w0 Evw8wxPH4qm1YrNKHn/MMWOgTRvLTO9yt2K6TOPwcreHxQp7Wv0cjUK6l+ZTPazaDOQqFx b5DCxVJhpUu3Chgfmj9MJhX67h7efh8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699818376; a=rsa-sha256; cv=none; b=QB2d34fzlbniLqlBYwzhn0cI8ymTzkza5R5VpjcUksmddLsn20ndHnMbkI/CPfuOcjlJzJ GH+ieyYQReC0aIHzU5us0FxwVdfCjr8T7D6IgtwAKeynESJsjoPnZPXr1btssfVpBytXvs vrSmpYbndiY7BDj/Cn81T4p6Nqc2cT4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=MIh9ucCT; spf=pass (imf21.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 8C22760C68; Sun, 12 Nov 2023 19:46:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EA98DC433CA; Sun, 12 Nov 2023 19:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699818374; bh=8h4xcSrlngKXz6YrUu+DyY/DYWtQeX+QuoziQCKM6Qo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MIh9ucCTepKRwsUBhaeQTqSbnm6Ezok1Z01it4NK1/7eOF+AvLvl6S3L6KK2DYzVH n7S/Ax4akpIniSkGmPWk5EotaJGJRKGD0wb4v2jqu4rBew/mk+/s3xUP1hbXrajNhl hKnWmdQ6ytt9PQA2R8X7/YeiL6Cf4w+xiRQDnt4+ZChxDQ1slQLhoHdNxXMPoOzQRH u/ooQB77RM6qCtHj/YNpr02MYV3BB+ChlSlFYUWRBUy/x0RPqP5okkEfKNS9VNVd6X 8GqIg/MdrDblrjoPI2J08jhGzzseTnJqWhcufBWbXAqcpC7XrxmfPVHY/JRftmpWmP Rowj0FpL6fkQA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/8] mm/damon/sysfs-schemes: implement scheme quota goals directory Date: Sun, 12 Nov 2023 19:46:01 +0000 Message-Id: <20231112194607.61399-3-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231112194607.61399-1-sj@kernel.org> References: <20231112194607.61399-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: D04341C0007 X-Rspam-User: X-Stat-Signature: wy7ubu4ga3uh56bfs7orfhzeiyjffeot X-Rspamd-Server: rspam03 X-HE-Tag: 1699818376-305681 X-HE-Meta: U2FsdGVkX1/PdRJkUptuIXLLKymXfwpQBa8UmR9V6p3aUmYvgMrt9Svw+EIfjChKD+baQWyuV30qMXnM6z5LJRKfCRmEVApcZkjv1NBBtutcwPzQaUcf1Cw6tE6f0avB38nDGtGXE6JMwPiHPWeOrF8JD71F60zZkIlOoYErGt9jx8XfCyCv11w56muDQzLwUVGuW6ilq4uZGSZkWQsU3bP3+ldsRXV7tzCQuOOg3GA/p51JXzb2BxJ+jxwwzdMeZZYFDkAlaxEtRZxJ4edztQ1ywaVkMfQykcXFSN0yxemS27SwjkW9fE5k9g75GKMjJwmG3zM0TZ7/r50llonh2sgGwkkEaWyopK52Ic6lCgvn/t4VnCOjehOrGIO5OCFXpczKtvWORpCvW4NfCf6zAUXuhZI4rzWOBOVAdqkXdbSFyOAaWAYeqf/e5M0Iq5unH/zrnIukMZ+kDU71TfpDSKGFOpSbvvG+Bw4bx24wdbAWBeaERg7CISf+gJmRZtCesfsK2xqn0rKYZmZgWFl5y0GXNA47N+aZbwnfVvx10R2qRBwAHNu+4h6uC/htkszm9Io9Qls3kzy1YxmyTvDxNzbLxT9RuWXytiY512AqLf0mnS79FOopdlt4HvAaa5h/gQKiAyuZ/4b3BelDgCVuA4nN3z5TJq6/YZx0CD33Z1RQSKGYckmLrv7XxA6tRHjaWKukbNj5mlUM3HEy4/nqFQ2QejCIP4GInmluxSCMOrbMlQqjU2BQUQ/mAtJgeq/tEOXYNTlRysBer5VgA+ulIHFIZHZFWC8Zwvza9a1oIjIPdmLbW513ujo+o3P0tKuiJm/1wV9YkNH1P7B7LC2XpPmt27vErIkmLYSZfE4wCjeCilbOWe7Tgmj0iUj4UKZiGaI3BInfGt3agquTB0SVTPy7K5NCDOvfVlNrtDp138VnZUAFHOCiHS3+n6Q6DI3KX39Jj894HZ9MVCEaqK7 Rl7vvsh8 71d8NYnyQXRvUf/c7lS5dp712VtabRIYOcvWVacqFc1XZZHHsk5manV2Yp0+nZg9V0+eA1UF7VmdM0QrfJKlzB9YkxTNBy9WDu/+RV+Y/y9CVRXVBwP7W5m4raK7+bGi8wN+g8OLpcgISRtFkPcZrb7EYXNMiGnfQ99AqkKiXJA7BIwydAhXcjtkkSWTsmObaFfiRRL0TnqQaJEQBjizVHisKfgTsT+/Wu7qqhnyDxdUqlko= 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 DAMON sysfs directories and files for the goals of DAMOS quota. It allows users set multiple goals for their aim, with target values. It further allows users to enter the current score value as a feedback for DAMOS. Following commit will connect the user inputs to DAMOS quota auto-tuning. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 224 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 221 insertions(+), 3 deletions(-) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index be667236b8e6..d3b57348f07b 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -812,6 +812,203 @@ static const struct kobj_type damon_sysfs_watermarks_ktype = { .default_groups = damon_sysfs_watermarks_groups, }; +/* + * quota goal directory + */ + +struct damos_sysfs_quota_goal { + struct kobject kobj; + unsigned long target_value; + unsigned long current_value; +}; + +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_value_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, "%lu\n", goal->target_value); +} + +static ssize_t target_value_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); + int err = kstrtoul(buf, 0, &goal->target_value); + + return err ? err : count; +} + +static ssize_t current_value_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, "%lu\n", goal->current_value); +} + +static ssize_t current_value_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); + int err = kstrtoul(buf, 0, &goal->current_value); + + /* feed callback should check existence of this file and read value */ + return err ? err : count; +} + +static void damos_sysfs_quota_goal_release(struct kobject *kobj) +{ + /* or, notify this release to the feed callback */ + kfree(container_of(kobj, struct damos_sysfs_quota_goal, kobj)); +} + +static struct kobj_attribute damos_sysfs_quota_goal_target_value_attr = + __ATTR_RW_MODE(target_value, 0600); + +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_value_attr.attr, + &damos_sysfs_quota_goal_current_value_attr.attr, + NULL, +}; +ATTRIBUTE_GROUPS(damos_sysfs_quota_goal); + +static const struct kobj_type damos_sysfs_quota_goal_ktype = { + .release = damos_sysfs_quota_goal_release, + .sysfs_ops = &kobj_sysfs_ops, + .default_groups = damos_sysfs_quota_goal_groups, +}; + +/* + * quota goals directory + */ + +struct damos_sysfs_quota_goals { + struct kobject kobj; + struct damos_sysfs_quota_goal **goals_arr; /* counted by nr */ + int nr; +}; + +static struct damos_sysfs_quota_goals *damos_sysfs_quota_goals_alloc(void) +{ + return kzalloc(sizeof(struct damos_sysfs_quota_goals), GFP_KERNEL); +} + +static void damos_sysfs_quota_goals_rm_dirs( + struct damos_sysfs_quota_goals *goals) +{ + struct damos_sysfs_quota_goal **goals_arr = goals->goals_arr; + int i; + + for (i = 0; i < goals->nr; i++) + kobject_put(&goals_arr[i]->kobj); + goals->nr = 0; + kfree(goals_arr); + goals->goals_arr = NULL; +} + +static int damos_sysfs_quota_goals_add_dirs( + struct damos_sysfs_quota_goals *goals, int nr_goals) +{ + struct damos_sysfs_quota_goal **goals_arr, *goal; + int err, i; + + damos_sysfs_quota_goals_rm_dirs(goals); + if (!nr_goals) + return 0; + + goals_arr = kmalloc_array(nr_goals, sizeof(*goals_arr), + GFP_KERNEL | __GFP_NOWARN); + if (!goals_arr) + return -ENOMEM; + goals->goals_arr = goals_arr; + + for (i = 0; i < nr_goals; i++) { + goal = damos_sysfs_quota_goal_alloc(); + if (!goal) { + damos_sysfs_quota_goals_rm_dirs(goals); + return -ENOMEM; + } + + err = kobject_init_and_add(&goal->kobj, + &damos_sysfs_quota_goal_ktype, &goals->kobj, + "%d", i); + if (err) { + kobject_put(&goal->kobj); + damos_sysfs_quota_goals_rm_dirs(goals); + return err; + } + + goals_arr[i] = goal; + goals->nr++; + } + return 0; +} + +static ssize_t nr_goals_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damos_sysfs_quota_goals *goals = container_of(kobj, + struct damos_sysfs_quota_goals, kobj); + + return sysfs_emit(buf, "%d\n", goals->nr); +} + +static ssize_t nr_goals_store(struct kobject *kobj, + struct kobj_attribute *attr, const char *buf, size_t count) +{ + struct damos_sysfs_quota_goals *goals; + int nr, err = kstrtoint(buf, 0, &nr); + + if (err) + return err; + if (nr < 0) + return -EINVAL; + + goals = container_of(kobj, struct damos_sysfs_quota_goals, kobj); + + if (!mutex_trylock(&damon_sysfs_lock)) + return -EBUSY; + err = damos_sysfs_quota_goals_add_dirs(goals, nr); + mutex_unlock(&damon_sysfs_lock); + if (err) + return err; + + return count; +} + +static void damos_sysfs_quota_goals_release(struct kobject *kobj) +{ + kfree(container_of(kobj, struct damos_sysfs_quota_goals, kobj)); +} + +static struct kobj_attribute damos_sysfs_quota_goals_nr_attr = + __ATTR_RW_MODE(nr_goals, 0600); + +static struct attribute *damos_sysfs_quota_goals_attrs[] = { + &damos_sysfs_quota_goals_nr_attr.attr, + NULL, +}; +ATTRIBUTE_GROUPS(damos_sysfs_quota_goals); + +static const struct kobj_type damos_sysfs_quota_goals_ktype = { + .release = damos_sysfs_quota_goals_release, + .sysfs_ops = &kobj_sysfs_ops, + .default_groups = damos_sysfs_quota_goals_groups, +}; + /* * scheme/weights directory */ @@ -930,6 +1127,7 @@ static const struct kobj_type damon_sysfs_weights_ktype = { struct damon_sysfs_quotas { struct kobject kobj; struct damon_sysfs_weights *weights; + struct damos_sysfs_quota_goals *goals; unsigned long ms; unsigned long sz; unsigned long reset_interval_ms; @@ -943,6 +1141,7 @@ static struct damon_sysfs_quotas *damon_sysfs_quotas_alloc(void) static int damon_sysfs_quotas_add_dirs(struct damon_sysfs_quotas *quotas) { struct damon_sysfs_weights *weights; + struct damos_sysfs_quota_goals *goals; int err; weights = damon_sysfs_weights_alloc(0, 0, 0); @@ -951,16 +1150,35 @@ static int damon_sysfs_quotas_add_dirs(struct damon_sysfs_quotas *quotas) err = kobject_init_and_add(&weights->kobj, &damon_sysfs_weights_ktype, "as->kobj, "weights"); - if (err) + if (err) { kobject_put(&weights->kobj); - else - quotas->weights = weights; + return err; + } + quotas->weights = weights; + + goals = damos_sysfs_quota_goals_alloc(); + if (!goals) { + kobject_put(&weights->kobj); + return -ENOMEM; + } + err = kobject_init_and_add(&goals->kobj, + &damos_sysfs_quota_goals_ktype, "as->kobj, + "goals"); + if (err) { + kobject_put(&weights->kobj); + kobject_put(&goals->kobj); + } else { + quotas->goals = goals; + } + return err; } static void damon_sysfs_quotas_rm_dirs(struct damon_sysfs_quotas *quotas) { kobject_put("as->weights->kobj); + damos_sysfs_quota_goals_rm_dirs(quotas->goals); + kobject_put("as->goals->kobj); } static ssize_t ms_show(struct kobject *kobj, struct kobj_attribute *attr, From patchwork Sun Nov 12 19:46:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13453380 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 AAE88C4167B for ; Sun, 12 Nov 2023 19:46:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C827B8D001C; Sun, 12 Nov 2023 14:46:18 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C4C2E8D001B; Sun, 12 Nov 2023 14:46:18 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A9FCE8D001C; Sun, 12 Nov 2023 14:46:18 -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 8F8E48D0002 for ; Sun, 12 Nov 2023 14:46:18 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 8E9CF802F8 for ; Sun, 12 Nov 2023 19:46:17 +0000 (UTC) X-FDA: 81450333594.24.0B7AE74 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf10.hostedemail.com (Postfix) with ESMTP id E519AC0006 for ; Sun, 12 Nov 2023 19:46:15 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ElglL7CM; spf=pass (imf10.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=1699818376; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=c8RBfebLYj/irJ50NtFuHKb77zJqGsqkj803DZDYu+M=; b=ESt8j+zCJklqYNKPPdx5h49TjJ5HIO2JsDGHmliuiqbOg3kND/qeaF+54glljO9vWzMIeG 04ZiGOOTQMyQuMxn4BVY0Wzc7LXeAqfB0WOnF3nG0OsPu8lvOY75L72dvf78LHDsLxPu9y q+l11Kl5yl7cYu5kqLARht4Mzc3e14A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699818376; a=rsa-sha256; cv=none; b=C3Oxp6ZMzVOpetwFVjIhG5xF0MUkOIP5dbVWnApQEQ8KNINh6ZjM9Tfz3EKz9lX4WKhiaN bfkbSC0JtxpmS0F6irP/Ibt6uh4QJsUZrh5xB2U/I3jK4ggtY932DdKAlAwBZazx87AJzf JjUNf8rKVC+yM4ZsKKY9JDdIUt/AfOo= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ElglL7CM; spf=pass (imf10.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 246BA60C6C; Sun, 12 Nov 2023 19:46:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91F23C43391; Sun, 12 Nov 2023 19:46:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699818374; bh=MxtUx51tOzqutV8xiuFATacKMvsWPmbxLxD9xhq6D0U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ElglL7CM8DTNUMvs6zpbU98dLV/xAZSfMCOCe74EzCDQx13WqQ2sun5Eop+Vu1JlN 5aqCvIxzUfxRmaWDjsoSi05967P4ozWuGPaX8Yt6ko7ElRPUiyRe5gRfJekha2/nU+ FQIp8l43A/Mbx0w9H9Mc31haTzjOTEEl9q7T7+lryokZBn92fl6IFKRpaGZC38znwQ cW/R7dvdzCCnxPfKmKDMIQvdnOEshOxgT9y29zMJqwpAu4PVZfc01AkZ9a11sAmllC p7YuBzxb9uPB6URkcXhop5z84lhTVq7K7IepbaqAEBSB/Usb0KHEsYkG41nfXAXCKa dlPydUs9fyzOg== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/8] mm/damon/sysfs-schemes: commit damos quota goals user input to DAMOS quota auto-tuning Date: Sun, 12 Nov 2023 19:46:02 +0000 Message-Id: <20231112194607.61399-4-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231112194607.61399-1-sj@kernel.org> References: <20231112194607.61399-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E519AC0006 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: phehzoasi3ku7ihmx666fanmd8q4a14s X-HE-Tag: 1699818375-518780 X-HE-Meta: U2FsdGVkX1/KqgVTPEN7vB1mGs4KkOHETYNMJ5E1nze0LauNNKMxZ4WoTOxa83wnJ4dYAeJ2qwo9VDPxfs9vpaoh86NBM/sgZgby8J1rUUPVoUeHLwkr8Ml/urJpUUa8TyBzsDyDWamADNbj+tWe0HYMvchMxIwBG0zmYq42Vu97nmEIZ9fZIy3r7CxrN+XpsSTF6A9rOevWO8TcASIxid1Z2dKE0jybyEA9N1Eeu85APEqpAePEYTynnGYQNqoMITCCwrI2IQjrVGp4MijNc2fpzRzpBLW6oGfpNnrSrChfAKWc/UqkYYDNDEW/5KIrllsKtF6bBrOE+eqxj2HMN1eUSE16FU0lpW9Y+j8/s4YjASqZH6qUhxyIrvtyu+6ti4SqpMwbHktzRrK1lQ51oPTWwdzxYd+TQayR5JoajjmlLmuFGJ0nwHpnM3ibWSDnh82lxPwqDgzZ9xd+4eGsN52ocKHwRNf03RV7uKQUVJODh2BCs59K6odPoZim27h3Q3znjh/tj5K2KGuuUNHz6Y9cRrXuH3vsnVXPdjQfU4vXwLYYGi2h91NAZ8OkNYg1LLpUWz5HYmNbJcWd4eMqae5FtztXL4fF4yl9/mSBo1Ip5q3Cvdj7G9Ug9Wr3sRlVAHfP8XXAYf7B0wMHOz3ScX64+rriYFOwEJ1V8eLKvuVbBV4aokRGpwepFPXzKtqHsq76SvUlqo2RNsb+OSYUwyenCI4uOoNNItazBExHtbYysZqednwypWR81lGLhMni4GSt5T7gaUoEAFScXZEGuicLd7GNX60R5TbZU6HF1nhzAPbQC3pxWs6R8RJCiS4t2uOC98LauwOYaDMIMPiopQ10uX0iPhh1lSAgrnP7JtCLHxciqYlgJH8pJkUiVf8LUfTskTr5W2rLPqB18x+QK6BHGrcASs0GMUIVua09naSuf1Kz/0MBS6nMQXLUcHtFZ6RiaMwTzd/eqqokGvL oXFlaJzT 9zsCwh5HKqELUna/6KWXZdLXQ46RFWBoWO1FoGHxLqyYzcuNkkSlyh2fwY6fWvPZ8LjtB5cYSQRRorxija7ZiBUl91g8+zujY7mR/ViQAUs20SvLeQEvWuQCESzW0FdUJHcnCQW1haIcJzSNYAGqcZzMVfk85gXkgNmx127p4I3+7hDaAWvXmPf1Lya0NfCDPIHHopge2ivspxJWiSt3+ciCGI9vt6IR+AXGC3RIEV+tIAZE= 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: Make DAMON sysfs interface to read the DAMOS quota goals user input and pass it to DAMOS so that the input can be used for the quota auto-tuning. The committing is made for initial starting of DAMON, and online input updates that can be done via 'commit' input to the kdamond's 'state' file. That is, the user should periodically write 'current_value' files under goal directories and write 'commit' command to the 'state' file. Note that the interface is supporting multiple goals while the core logic supports only one goal. DAMON sysfs interface passes only best feedback among the given inputs, to avoid making DAMOS too aggressive. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index d3b57348f07b..10d8678e48ea 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1860,6 +1860,34 @@ 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 void damos_sysfs_set_quota_score( + struct damos_sysfs_quota_goals *sysfs_goals, + struct damos_quota *quota) +{ + struct damos_sysfs_quota_goal *sysfs_goal; + int i; + + quota->get_score = NULL; + quota->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, + sysfs_goal->current_value * 10000 / + sysfs_goal->target_value); + quota->get_score = damos_sysfs_get_quota_score; + } +} + static struct damos *damon_sysfs_mk_scheme( struct damon_sysfs_scheme *sysfs_scheme) { @@ -1897,6 +1925,8 @@ 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) @@ -1937,6 +1967,8 @@ 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); + scheme->wmarks.metric = sysfs_wmarks->metric; scheme->wmarks.interval = sysfs_wmarks->interval_us; scheme->wmarks.high = sysfs_wmarks->high; From patchwork Sun Nov 12 19:46:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13453383 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 ADAE8C4332F for ; Sun, 12 Nov 2023 19:46:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6F7AD8D001E; Sun, 12 Nov 2023 14:46:21 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 65A5D8D001F; Sun, 12 Nov 2023 14:46:21 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 3C5978D001E; Sun, 12 Nov 2023 14:46:21 -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 1CB398D001D for ; Sun, 12 Nov 2023 14:46:21 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id EBBA480191 for ; Sun, 12 Nov 2023 19:46:20 +0000 (UTC) X-FDA: 81450333720.03.0C04A52 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf19.hostedemail.com (Postfix) with ESMTP id BA0351A000E for ; Sun, 12 Nov 2023 19:46:18 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="ilsJm/vr"; spf=pass (imf19.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=1699818379; 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=8jJDnazw4CPbQhsvvDn1i0KylqzCFjmFWUxf5kvsA0k=; b=Jj4mMOFOu6NxusspZSk6WB9YH5Zvef0b7LfMzxYBqoyHqfZkOXv0jt/88lfjxT/P60BdQC GU9bdyFeaClMNzrAQgN1YJu2XaUh9WxvJk7t7pJvvZW0UCMlkli/XHg3rOiDoMeoe4Rj8h p6ip/KGcda3NUwLeBFWwCGNIc05sWpo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699818379; a=rsa-sha256; cv=none; b=OE8GMEkIsnNz2j2iEn7h6GZV/nNhXAGZw7V8Pa2hmSabVjYkIufErarLbE0T38kazs23Pg QCK7oHC7ox2nINur69fPXGQgEpVJpPIpht9s81zKXEjhTwsm3xviatPLi4fgRNsXNnEIPN 3SP6SPAIhgaqGZaFO9QdQ7G+Z/k28ow= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="ilsJm/vr"; spf=pass (imf19.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 DB14ACE0F24; Sun, 12 Nov 2023 19:46:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2906DC433C7; Sun, 12 Nov 2023 19:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699818375; bh=3hLtCq4IeSzVAzt9xwdt8SFMTkOmxWIve71ZhjNphZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ilsJm/vrsBo6Yu1ARBJXfw+m015LoFYGrGhL/3VpYDAsxMUdX9vYwdMYJDtgee/3r 2BobP/nc2JGuXBqoYQqTNwcHNW5Ul9h5jQBXL8J9jNE/kU9f+YyP4IB3ucA1GKwMF/ aVX7CwYjHhsScSiQ6bEPXWZXfsqDaxSSXIIamlhSeqRsvgt7urc/TcfeDoBssuSlIs 5nsUjlIN3IEX+FEQIB4x0276ygds0KDvX8pHGguetiHuUDPLdMrlnI0JiCa8UY/bm7 Hd5jdrzrPWfkBHm2Us92VOCJDsEJu9z7ez2YSTrZ29EZEOa9USrpWHji/+z1pjDsqj yaPQldDJREiJg== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 4/8] mm/damon/sysfs-schemes: implement a command for scheme quota goals only commit Date: Sun, 12 Nov 2023 19:46:03 +0000 Message-Id: <20231112194607.61399-5-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231112194607.61399-1-sj@kernel.org> References: <20231112194607.61399-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: BA0351A000E X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: thadgfghbue89fng9pdr5mfad6rctc4e X-HE-Tag: 1699818378-313616 X-HE-Meta: U2FsdGVkX1/7/OsKKwXlv6up+Ir9t8JeFiMibefENasui8EaHmtiY+18Pw/otp/QuoaJbWIwnme0+RRC8QVhBup5r7QE8RvOIrFOOw43MDC2R941itoNK2xRY3Oo/0s/hJ7BI21TqRN/weJ5ILxa1aVm0crLZFhOT+XbwLaJXGy67Ne5bRqmmyFjDerARyi0iE39cyVgJ9ZWwtYMR4VKnIQsV56h3R1ltXsK/+FkwKuRHAD8dSkogxPSSDNgsXElOdv5ljqbjpGQn6vdPnHW7o0ujl6dz+6fJCOzzrqqON9X+kFEqhDODCIFgqJvVTLU0O4rEN42QIF98VhW5DPXo5uPCVpALcLXYVhwO2DZ/a0LcGrcZ+Hzx2gktfw5e+Kk+/cDKxvoLKbFaaFIwY1fnEaTj7kMyoyOt3KaPIllW8T1i/1HgkPaO9+2kh8aF/UcoJZgC2/KaBMFjIDTFgi0N7WYFP+KLwCkrZ43yNpHEshB83s6fPivpD7a9ETDGlnPk2RlFuhV7sSJSssA94iJWYRb/k/3jjR7qDdqW8m8w1xSNC2p+3nHxfvDRa8iEUVj4W/m2VQOvHbS/0I+qNMl70K0Xij5ZbTKVsZxlGMrScOLYyRqrFpbLQv3X3j6pcRiox9EHJlQQVYJkopEismMLiRN0qFP/ZQeXXIRr0chEK0Zy/8LdAs1a7vVV3Co1TLOtm0fp/p26G3l3VYMk3HtHMKDkjyZE+r46epEbOGOyDmfDesUrMoAgTaNGd20XYGonomx1GL09+Ra7/XFtczoMDktV8DHYhEiq6liZkwfom11zxsum+YpSfeZF2GbM37/PUhjG+6zeOJDmX4/WdldAlWllaJUB6NMSmtXeS0bEaJ7e3ARfjoJtPh7uN7zYt9qGLdmpswMVc8ywqC2VSLKFP2tgq/w9Cl//Y3HcaBVTuZhUgVN+xI5JyUvqxbDghQQVMFGy1JevROb5iXXyac bHYzGspM pt8glHW2bRz/V4nA5n6/DA9Zlqw1j3Ol+CFg69wrLe0uK+BL7G6Fxk82CvvOXnW48jlz1acA/I7RoiHiQTy8mHONejiUaJogmV7M/OTuIpDVFJFFgl2udXZW5dUWNKxssscNiU4VyNo2VsHfLks06A3L0+kcFBblFoQWBx1cH30+sd4yMj8L9a8zuFdRivrOXVld8SlZ3FbBEhntpNZ0UIZkY3g2XTv/Bah733w1d+V9guyM= 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: To update DAMOS quota goals, users need to enter 'commit' command to the 'state' file of the kdamond, which reads and commits not only the goals but entire inputs. It is inefficient. Implement yet another 'state' file input command for reading and committing only the scheme quota goals, namely 'commit_schemes_quota_goals'. Signed-off-by: SeongJae Park --- mm/damon/sysfs-common.h | 3 +++ mm/damon/sysfs-schemes.c | 16 ++++++++++++++++ mm/damon/sysfs.c | 27 +++++++++++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h index 5ff081226e28..4c37a166eb81 100644 --- a/mm/damon/sysfs-common.h +++ b/mm/damon/sysfs-common.h @@ -56,3 +56,6 @@ int damon_sysfs_schemes_update_regions_stop(struct damon_ctx *ctx); 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, + struct damon_ctx *ctx); diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 10d8678e48ea..273fb7862fce 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1888,6 +1888,22 @@ static void damos_sysfs_set_quota_score( } } +void damos_sysfs_set_quota_scores(struct damon_sysfs_schemes *sysfs_schemes, + struct damon_ctx *ctx) +{ + struct damos *scheme; + int i = 0; + + damon_for_each_scheme(scheme, ctx) { + struct damon_sysfs_scheme *sysfs_scheme; + + sysfs_scheme = sysfs_schemes->schemes_arr[i]; + damos_sysfs_set_quota_score(sysfs_scheme->quotas->goals, + &scheme->quota); + i++; + } +} + 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 2d31390edfc0..f6952cec9f19 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -994,6 +994,11 @@ enum damon_sysfs_cmd { DAMON_SYSFS_CMD_OFF, /* @DAMON_SYSFS_CMD_COMMIT: Update kdamond inputs. */ DAMON_SYSFS_CMD_COMMIT, + /* + * @DAMON_SYSFS_CMD_COMMIT_SCHEMES_QUOTA_GOALS: Commit the quota goals + * to DAMON. + */ + DAMON_SYSFS_CMD_COMMIT_SCHEMES_QUOTA_GOALS, /* * @DAMON_SYSFS_CMD_UPDATE_SCHEMES_STATS: Update scheme stats sysfs * files. @@ -1025,6 +1030,7 @@ static const char * const damon_sysfs_cmd_strs[] = { "on", "off", "commit", + "commit_schemes_quota_goals", "update_schemes_stats", "update_schemes_tried_bytes", "update_schemes_tried_regions", @@ -1351,6 +1357,24 @@ static int damon_sysfs_commit_input(struct damon_sysfs_kdamond *kdamond) kdamond->contexts->contexts_arr[0]); } +static int damon_sysfs_commit_schemes_quota_goals( + struct damon_sysfs_kdamond *sysfs_kdamond) +{ + struct damon_ctx *ctx; + struct damon_sysfs_context *sysfs_ctx; + + if (!damon_sysfs_kdamond_running(sysfs_kdamond)) + return -EINVAL; + /* TODO: Support multiple contexts per kdamond */ + if (sysfs_kdamond->contexts->nr != 1) + return -EINVAL; + + ctx = sysfs_kdamond->damon_ctx; + sysfs_ctx = sysfs_kdamond->contexts->contexts_arr[0]; + damos_sysfs_set_quota_scores(sysfs_ctx->schemes, ctx); + return 0; +} + /* * damon_sysfs_cmd_request_callback() - DAMON callback for handling requests. * @c: The DAMON context of the callback. @@ -1379,6 +1403,9 @@ static int damon_sysfs_cmd_request_callback(struct damon_ctx *c, bool active) case DAMON_SYSFS_CMD_COMMIT: err = damon_sysfs_commit_input(kdamond); break; + case DAMON_SYSFS_CMD_COMMIT_SCHEMES_QUOTA_GOALS: + err = damon_sysfs_commit_schemes_quota_goals(kdamond); + break; case DAMON_SYSFS_CMD_UPDATE_SCHEMES_TRIED_BYTES: total_bytes_only = true; fallthrough; From patchwork Sun Nov 12 19:46:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13453385 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 9A9BAC4332F for ; Sun, 12 Nov 2023 19:46:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4ACE38D0020; Sun, 12 Nov 2023 14:46:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4374B8D001D; Sun, 12 Nov 2023 14:46:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2893B8D0020; Sun, 12 Nov 2023 14:46:22 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 0EB378D001D for ; Sun, 12 Nov 2023 14:46:22 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id DC6AF160115 for ; Sun, 12 Nov 2023 19:46:21 +0000 (UTC) X-FDA: 81450333762.24.ABD2FAE Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf15.hostedemail.com (Postfix) with ESMTP id D14A5A000C for ; Sun, 12 Nov 2023 19:46:19 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IZqjkc6F; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.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=1699818380; 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=8360v2be9T2lgyjq9aBm32O9Ko2A7dDB6T7+GQjYV0Q=; b=fhm18RwAZKT6VxyMC9Yxk5Lm7YlovFWNbJuTZhIpohmNqSTnYCaMprMJYyCK/3s/buyX0M GS88YzifpygbFQyz6dQRMKvinTLIS6oHqlSmg/grDYg0NrxkzVxXZrlayf0Kvjh30ee1P0 Au4zijhoU41x4q80GzLN2+v17GGnF/g= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=IZqjkc6F; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.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=1699818380; a=rsa-sha256; cv=none; b=zHkaneE/mPHbC6QuxBK11nV3YSKt25l3JXUDHKxX7wguGuu/Nnd21Mi7MxcTfVcHOvT8zB f17VWlgVrWjfprA5uyeVfnEjPFc52yfO84fFPqYh56izZafXYUy6ZrlmwoEn+i40LFk8iQ bq9l7qQApO2Ch2O4qdsHSh9pRUP2Q/w= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id 0BFD6CE0EB3; Sun, 12 Nov 2023 19:46:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B47C7C433C9; Sun, 12 Nov 2023 19:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699818376; bh=aHVFSWkLgL3DSZk4BMjseldmOMFwERpUZXKvLSdezzE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IZqjkc6FTf18ZhcDORKrMuhByH+hD2Ss0jubtVf43EF5ai/X82RLUEbaKYzgzrYU9 z6lLO2EUuHLi77rriepOZl7QKtaMC8Lnri0kYl1PYU209QyxwYWYWi9JCcsCDjorSY nX7TWmp0x/LbG5ORpd0gvkGY5iZ3V4vgnl0FRXB+P9gnFbOn20pXo3jAaOlyD6rwT3 EMOH773xXOzjDJZwTk0G2KvHE4Vh6Lo3Loq7gL6WzItm5OgzbL5eYpkwesgfSh4aAc tfP0sImuju4Qi3qfRbyvnT60OF/mRJz+vhHo9fpIDgD5AGwY3tf9vxowqQUza3+BJo jkDyFPFq0/qnA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Brendan Higgins , damon@lists.linux.dev, linux-mm@kvack.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 5/8] mm/damon/core-test: add a unit test for the feedback loop algorithm Date: Sun, 12 Nov 2023 19:46:04 +0000 Message-Id: <20231112194607.61399-6-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231112194607.61399-1-sj@kernel.org> References: <20231112194607.61399-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: D14A5A000C X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: kgsns5maywr196nwaoybgfgyn5juased X-HE-Tag: 1699818379-205244 X-HE-Meta: U2FsdGVkX1/O0MGBC78eN0cEi9eqvhIUlX9YvntX9UuCjCsJ3z+RA8sMGYBLwNXwqCQ2sW3Aij/r6j9EWMb1rYcRsGvTz9mfXOn3NmUnAsh75AI0Uy/AcaOhzjayf9mZDNhxJw6Oewka/IoRmzIY/4QfghmGWzkXGF4zXHmzw+8Qz2+PDwfb6B3sJM4SVf2iomidaXZLYTfYHFZ9LROcr3GbWqIc2DlNKhTliSwVDJx8KyS/DVJhkNMUfX1PlIgTw+hCa2he2Ve0ZDvezJfPfmgl0EolRi7AjxxlP7PbkJnD4wUQlhRxjtz9q8gt53Rtl+3Q93sdbojNCnfxbIbqEIsUWgr1DhIbcv7lkUJ7iTZGdELPHSEkHi0ubQwS40yTSo6tM5v3wJichgoEHbBi77mhPuW1Oegt5yA+XlZzJ0gH9/79R30comNZjaXLY7+3zPT7j6VpAASoHpyYdStDmiR8VpQKC4HLjZa65wOes63f0BTMgA241G2N7bwRXT2TNi9Cms3fBzM5jJtZiPgsHBebGi/0NYxSQUTIaOW/B13pXtfjlgL25uHCVbRNH36rtpf68LYjqKreRTunl7hLSaEm9fSvku4w9Ske8b39g8/tmwO7D2KOkouoEV3HJ7n+uW82vzZsvRbe5Mvzq0r1Ijw77cEfnA09W55TyVbmSpDWgNS4j/EH13PwG3Qm9InG0GY6izcEiPmvmE+IAn3lUoS0J7mzA61qk5g5XYsgsoqADkwKwqkIk2EIV2YpSDsSSi4ASYkX47nV/0gBbErtgecbH36rW16Ri3gyf8ff4X1QE641vGmbIeIRt8jllAVIbDRnRYEi8AZxVxYhvs2iMiMw5QPtP9ffBSGDVIwMa3KsQEOD2z3huADNMMX1BSg2J7WmlK+zzHeW/Jf2HYA3qUbOHMPJMQreUo/Lqwi/krNGKwR8CSe2lhvkmHYDcm/SmQPPo7mjYjh9Gh22ddK x0fBTFgy RHR2LfmOPtjxOJjglZgkGpXFw+8LYIJYU5pc7R/5XGuQh2XuqbxSMhjI9xGzgIQamrHmTBdViU++BtZ2ljGCopMTd1sMwQt233jasyAPvaTeBHSqyj1lscQSSghoU7jAk1sh/+d6lc3o9yocm+4yKKgjnv+/3KIDv9IDsqhWYb4IVzciPfhrbw1raKSRgSqQAElr/zJD1qc63Jbf/ttDdvnsDwkoEiCKPLmlyS55xybPUTPc= 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 a simple kunit test for testing the behavior of the core logic of the goal-oriented feedback-driven DAMOS quota auto-tuning. Signed-off-by: SeongJae Park --- mm/damon/core-test.h | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/mm/damon/core-test.h b/mm/damon/core-test.h index f405d79dc623..c2b8cb25a195 100644 --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -447,6 +447,37 @@ static void damos_test_filter_out(struct kunit *test) damos_free_filter(f); } +static void damon_test_feed_loop_next_input(struct kunit *test) +{ + unsigned long last_input = 900000, current_score = 200; + + /* + * If current score is lower than the goal, which is always 10,000 + * (read the comment on damon_feed_loop_next_input()'s comment), next + * input should be higher than the last input. + */ + KUNIT_EXPECT_GT(test, + damon_feed_loop_next_input(last_input, current_score), + last_input); + + /* + * If current score is higher than the goal, next input should be lower + * than the last input. + */ + current_score = 250000000; + KUNIT_EXPECT_LT(test, + damon_feed_loop_next_input(last_input, current_score), + last_input); + + /* + * The next input depends on the distance between the current score and + * the goal + */ + KUNIT_EXPECT_GT(test, + damon_feed_loop_next_input(last_input, 200), + damon_feed_loop_next_input(last_input, 2000)); +} + static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_target), KUNIT_CASE(damon_test_regions), @@ -463,6 +494,7 @@ static struct kunit_case damon_test_cases[] = { KUNIT_CASE(damon_test_moving_sum), KUNIT_CASE(damos_test_new_filter), KUNIT_CASE(damos_test_filter_out), + KUNIT_CASE(damon_test_feed_loop_next_input), {}, }; From patchwork Sun Nov 12 19:46:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13453387 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 9EFE6C072AB for ; Sun, 12 Nov 2023 19:46:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1277C8D001D; Sun, 12 Nov 2023 14:46:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 0975A8D0023; Sun, 12 Nov 2023 14:46:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5F7F8D001D; Sun, 12 Nov 2023 14:46:22 -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 B295B8D0021 for ; Sun, 12 Nov 2023 14:46:22 -0500 (EST) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 82B4414068B for ; Sun, 12 Nov 2023 19:46:22 +0000 (UTC) X-FDA: 81450333804.19.C0EBA4B Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf04.hostedemail.com (Postfix) with ESMTP id 85E0440009 for ; Sun, 12 Nov 2023 19:46:20 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XXNBzq2z; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf04.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=1699818381; a=rsa-sha256; cv=none; b=N9aCJ27XQ0Se4aGzDb479m4J1dNwiNB8vVSrFT8g26F9BQ0fQfuCa67jmRD/1LlQa8Qo9Y GElt3xx6zjIlumle3vWDk3olEoG6J2KL2Vn9XvjsJ3YgKfyZQ5hH0t+u8QPnrfEnd7haI5 xWpjt8K8NvjrOZr9n5Ieil/tX8q7eaE= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=XXNBzq2z; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf04.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=1699818381; 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=smsCDfkqa8LsuAqRj5y7TvHYHkhdv6jMiB4jYS248x8=; b=6p2cT4EVZ0CLl4p+umtGC5dxbNei3VTbrCr38lgY6hmpSKK/vQitN9sg9NPBXlnrrxsYlS pbc3U1FKE9cWmqOopNDEtnTzeFZ48LSNn6YFMqxKMqPg8xbnPGZIn2phCcR8ilSa4Yg81T ST1239HtKJWCuhHzVnMnySiQTs3a420= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id C4AB9CE0EC1; Sun, 12 Nov 2023 19:46:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79A10C433C8; Sun, 12 Nov 2023 19:46:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699818377; bh=tm53i8GhYDRGpRCnZgtLIn7P8jIf3OMjFqv6O/swkJU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XXNBzq2zCZgn2UYIGKvFcCBBjZM3OsXnwYAYjfdnuvAc7vizTJiNCl+uyVVJ6WyIm Cfgcc3kzBfeZ3Jb5Tckg+aiaCEnG/DcKQxoVCzBEwRPhaIgEZYt1XfmOrheu95cfLH OGw+GOLfmabiO+SZ/+OReGQK7XVM2GUG8Q0FZEyEtHLjcauH9QISo0m2+uBSHkttxd t7TGcn79ZD6lqANkN6R6bAfwexg2lNxX+DqYtmWqIygswnmKYtfczhmiNjZBWJyY/h 99/hFUjkYThSkmQk2NsHbl+q8HGW8K0e1YEk7+QzlP5FY4ocV5B+Q/nD9Me0FxYIvI X9b4MAHnJ6GjA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 6/8] selftests/damon: test quota goals directory Date: Sun, 12 Nov 2023 19:46:05 +0000 Message-Id: <20231112194607.61399-7-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231112194607.61399-1-sj@kernel.org> References: <20231112194607.61399-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 85E0440009 X-Stat-Signature: 3w41jyhjnq4nn98zonkckd3yztw3o4y6 X-HE-Tag: 1699818380-158726 X-HE-Meta: U2FsdGVkX1+ITZHL/L8yNynYm0EwIcF6BJxk2uy0+xx2kMeBQxUX8Ea/3nVa5bvCstm5T3lN15fET6fhjMZIE4y70tNg8tr8eaQW3g9Kff0BB0alZsvhYgp6lyVyNApkYkm7/fE9Fb7sOYXcvengFZl/HaXcZvwnvjBrDFAJPMaENAHu/wJr2MILkLgH7D7DJ8kPYvYUbjB6IUj0H1G3s1/rgp3zz3hWVoBXbNdgCxeeqW24NdJSM/w1Xswah01ez0BD9Vh/uPFpBVLALkUr19oe7lqYz1qY6gNtu09Nk60yU0cQoeIH7svd7V4YN6XKpjbwO9MBvKh2ikuKSCSXuuCTJn2ytOTTv7aBdRSGwTiYb9TewYrWcwLu6bkr2jIzrm0kbAoiyaHRJc/5G25PZKCcAFcLelmy9AUimrj2H2xr8pjW0Zt7+9Cv2uP3TQLqhxQ3h6XVU28zOBm3ThmqO0IL5jKfO07wlRb6e4wmpwsDnQgM5aXZ/9pfYWb8NTJfViRML4IQ6prK4KG55sEKVZQcI3tcuSG0v1f2RDl1EQUTT2oHYBp7gfYVorbKzNQmNyFcq3huvqyiJr82ZYcURmln3Ng0kF3hDZ/mgPFOMnszgn2EfWN6/jyDhvWsqOL3ZRdnfcmCBCwfInpSjSvG2T1e4f5fzreimBD9hKCV/2bcCPOJWZD1nWtJn/5JBEvoP8RUMi7JukuKuT0HRXGI0bI1idiUXO71KCrXo0rlE1zt1yxPlFpx+xKfNcK/qeuWwBVfeEEnSFHhiL2IqjTZVm09zGUGyJ3dVl2ldTjplLxnVeAtqOLlVCqBR7GYFANpI+zbCjWlxaFc8xdYvaEPrHI6l4PchU86zq70ME08EXvnpDHZ8XJ0dfNNbqEvH0vAl4k8XbCrUDcdZ1hcZWsut9UbLtRB2w/IwSOy5P6gHxGeGdhRrYYoPKz8QRYB9EnR7hRbqaKlqBEA+uGmqwD k+f5R8Dr 4QWkYVj2qE1zRcs5b3vlToiTuqZOrqSnoEQaQCbwk9bERVZWYYKGX8sO9rTruZGNHhWuLoiOKnEaFOl9c7K2uFRmPrnZ1vJSf35FpACDWs83NueeuTAWCtAY0jmfRFCGdmjYx6Nw9fj7j/ER1w4KEyhvypgXwYMWAlsXdf4nV2LVbS3Qzjvpsms/RDqHaiW+vITOXgkwBT6K4QvOUgauKa14AZ74BjJ0CmYxWIa80444qWRgSqTOXb2hEc00HTGmaso9O 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: Add DAMON selftests for testing creation/existence of quota goals directories and files, and simple valid input writes. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/sysfs.sh | 27 ++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh index 56f0230a8b92..e9a976d296e2 100755 --- a/tools/testing/selftests/damon/sysfs.sh +++ b/tools/testing/selftests/damon/sysfs.sh @@ -150,6 +150,32 @@ test_weights() ensure_file "$weights_dir/age_permil" "exist" "600" } +test_goal() +{ + goal_dir=$1 + ensure_dir "$goal_dir" "exist" + ensure_file "$goal_dir/target_value" "exist" "600" + ensure_file "$goal_dir/current_value" "exist" "600" +} + +test_goals() +{ + goals_dir=$1 + ensure_dir "$goals_dir" "exist" + ensure_file "$goals_dir/nr_goals" "exist" "600" + + ensure_write_succ "$goals_dir/nr_goals" "1" "valid input" + test_goal "$goals_dir/0" + + ensure_write_succ "$goals_dir/nr_goals" "2" "valid input" + test_goal "$goals_dir/0" + test_goal "$goals_dir/1" + + ensure_write_succ "$goals_dir/nr_goals" "0" "valid input" + ensure_dir "$goals_dir/0" "not_exist" + ensure_dir "$goals_dir/1" "not_exist" +} + test_quotas() { quotas_dir=$1 @@ -158,6 +184,7 @@ test_quotas() ensure_file "$quotas_dir/bytes" "exist" 600 ensure_file "$quotas_dir/reset_interval_ms" "exist" 600 test_weights "$quotas_dir/weights" + test_goals "$quotas_dir/goals" } test_access_pattern() From patchwork Sun Nov 12 19:46:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13453386 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 333FDC4167B for ; Sun, 12 Nov 2023 19:46:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E74348D0022; Sun, 12 Nov 2023 14:46:22 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DD3BA8D0021; Sun, 12 Nov 2023 14:46:22 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BFFB68D0022; Sun, 12 Nov 2023 14:46:22 -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 A4D408D001D for ; Sun, 12 Nov 2023 14:46:22 -0500 (EST) Received: from smtpin22.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 89F84160115 for ; Sun, 12 Nov 2023 19:46:22 +0000 (UTC) X-FDA: 81450333804.22.A86B2CE Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf27.hostedemail.com (Postfix) with ESMTP id 872144001A for ; Sun, 12 Nov 2023 19:46:20 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nYH0rlFs; spf=pass (imf27.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=1699818381; 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=SbRxX6GgJlF/ky6HC8gP0ElvVJnEMn6CvNUwYygBucU=; b=lEwHYFRFZ0QVJF+ZB4l3PT523WEuMpTkUoayZ+Tvw/fAn+4dUi3YBKOhzmglZU4LgLwzsM HYAmv5de+R0Faog6pRw0HQMfWV6Y452Wq/71OTxr8sjt6G0E6ugX9nmadHJ/CZ3WW0U4iG zTIqA+LoIpvYyIfphxjz2bqSE055Cgs= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699818381; a=rsa-sha256; cv=none; b=Sx7agubaFwiw7cc57fq3rblEMmjkI4iI6VLCXLM7uLnKl7AFBbronbbQG165tRKRNFT5pr xDdWbkstuFnxRK7BUNhKD230yS1hLJSb5zSQu1yYB+RfnVa3VyiUG1iGRZhanJydO9bDPl wfVyWi9h1LYMKe6PZn3jZgGo/l3zLYU= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=nYH0rlFs; spf=pass (imf27.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 0995ECE0F28; Sun, 12 Nov 2023 19:46:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2FC19C433C7; Sun, 12 Nov 2023 19:46:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699818377; bh=eYWOuBaRm7gUBwsw8MKJnCTGV0ZszqASzlgqM1IUQmE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nYH0rlFsJBrDrANNHDdlzS61wIc8bZdp2hUgWOgsXWFKJCZ3KnMObjtCni4f0diDU g2Z4RT4NsvLxJILjF6kRSpebeBN+wmwGsk58Lo7CXP1WrEiSR2/Dq7VqVB6IBgpJGb F3Bj+xKTXSGqZK3VdTW/ILQW9PbdUvedatn13RqucpgrvVjXD6L+LPlOl1yyR9bBpW N3JNbYtPri7PhmBeUfaRkXqN1HPMpZVTSY4rrXAW/LFEJjVpkDBvYOXg1dTYa48TfP D5vOtEL2SFxCEtfCEhA1zNN/2mlo4BWYjCz8S2hcrEyCty/qC9MOg8mCmaFsRwY3qG TPdccTEqa+wWA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 7/8] Docs/mm/damon/design: Document DAMOS quota auto tuning Date: Sun, 12 Nov 2023 19:46:06 +0000 Message-Id: <20231112194607.61399-8-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231112194607.61399-1-sj@kernel.org> References: <20231112194607.61399-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 872144001A X-Rspam-User: X-Stat-Signature: 5ojxjmu59wapxfn8fucohijnmtn87e59 X-Rspamd-Server: rspam03 X-HE-Tag: 1699818380-311913 X-HE-Meta: U2FsdGVkX1+M9g5m1PzKw8wAg51yuqviNPrgXMn7YU2sZxNtZvB2OUZnR7mFl59bXJ4bWZ58ndhH3BaUCXCxEfV8WphQZBteTBMv3R1pT2yNc/eZXQsyFhS71V0xRJknWf3efys58jl8m7+/tSogd9wYwXPhUBnaTSDfhpZuWcVrNZ4qk3GGhLoIslaDypMCkVi7cDbEFW2k3bk5stnIdjepKSAgr89C82JS4o73mgQfj3NpEreZjxJoZGtzVZN5AjXWM3qkp3KnEVYGJVrBOJ5al1OlfZpBos3rZ05sYEcxrH8IsvvSx/kZrQOcVanfFMYwhBK8qINWR98Tt/Po6l7D9XKQ8jL3YfLXh83UYWXnLIiwJnfzg7GMb21PO/D2iQxCi7P5Kdjeib7i5K5Iqk/z47hKgqVyA0tk69JFMK4BcZSs9w7nq4leQ412WP9siOJrRn+J6a0hmY5kmBxjJANOaBvAL2tDbXwhSKidaTalJj+0RNOS3y1Fb0O6cbzy/nnlV9SLur9xmC97aIPdGH+sBFLgBU17NTIpydq9+4GGABa1xjJJTsOdbIhmQK5nwlxBMygRAN2jHnKlewen7Kj17wOlUBVFowlkpcmwt+Z6YlGwQdqJX0qihFp9jpXjG/sffmoI067lqY60StiagNxOfrwFAvyxc6bCDV7Ajv/TmGfusQOe8A12dCbmARN8DvyqJm8IK2zymzA5p2uAVdPnt2uJ8GqQF6Q8fYnLU42IM/+b2cRxf7EmG9mSdqrEZsBZVuZgverm0tbV6LwTMuQEPaixVzGofYJjeI6dnlPiAcRBllR5TEJ1BKNyUdCwkd4mE2ZS3ExG0i6mxZMdRwQFZd209+7LR+xwP6dsX/vIarL8hKBuryxaJA7lul3idCN2NvWzITROB5L9r/USrMiNl7iOvXpgfBvSY++he8MQVWb2JhMs0cBvc1n7zTmamZn/Y7klFmmYuqWWc7T kc7lOXzl HWqa91iMf+3QY+FAlh08PP3u6GB+o3DPCTq7CdQ4hs/f6N2hK3j+Cg8v2OqBktEoXvpccDGQMWkZhGhxlUbSymcIbDQAEgSKz8JuctuxIkbU19GtUifS9WkZDuLo0nwz9afYxs9inVEzth8zBX4cW9V9M93Ld/z10XrskLYwV7EUmyj1Bj4vebEoN0zFf6HaVdJc/yUpsnu46IcTAEIGFhnYY0tiCPw+2nHUyB5AFsbnx08k= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000114, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Document the DAMOS quota auto tuning feature on the design document. Signed-off-by: SeongJae Park --- Documentation/mm/damon/design.rst | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst index 1f7e0586b5fa..3e1b34f55bb8 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -346,6 +346,17 @@ the weight will be respected are up to the underlying prioritization mechanism implementation. +.. _damon_design_damos_quotas_auto_tuning: + +Aim-oriented Feedback-driven Quotas Auto-tuning +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Automatic feedback-driven quota tuning. Instead of setting the absolute quota +value, users can provide feedback about how well DAMOS is achieving their goal. +If the feedback says DAMOS is still not achieving the goal, DAMOS increases the +quota. If DAMOS is over-achieving the goal, DAMOS decreases the quota. + + .. _damon_design_damos_watermarks: Watermarks From patchwork Sun Nov 12 19:46:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13453388 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 E60BDC4167D for ; Sun, 12 Nov 2023 19:46:38 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id DB0BA8D0023; Sun, 12 Nov 2023 14:46:25 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CEAE48D0021; Sun, 12 Nov 2023 14:46:25 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B3E488D0023; Sun, 12 Nov 2023 14:46:25 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 9D33E8D0021 for ; Sun, 12 Nov 2023 14:46:25 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 7F640120273 for ; Sun, 12 Nov 2023 19:46:25 +0000 (UTC) X-FDA: 81450333930.28.9723F0E Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf20.hostedemail.com (Postfix) with ESMTP id 449C21C000F for ; Sun, 12 Nov 2023 19:46:22 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=m6SJsMg5; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.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=1699818383; 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=XS3UL1qnVy5BbCEeiz3ohjPhuQAd1jZWYS8apOgyf0A=; b=XUkUwoxoKX1j+7omJSaC4OISn/aKWBOkW51XtLLslRbIvrrPG+a0+GYbnX8R2Q4LLNlx+Y cBzuTkxHy3fpMvHJ2mvkm6TcyxltEImrvKJKR80qa+NBHdZOZa4QMOc6C8qbyddz6907Nz HOXOAt2T8DUX4jbbynZs7tYSoleaCNo= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=m6SJsMg5; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.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=1699818384; a=rsa-sha256; cv=none; b=oELRdBGm+NGhs3OpwQFTyk4UuDjOVu+h4fvRumfh7fVdHjsw/LGgvhUBlLl6RblJ63az/I Nu5CNHK5TNtIjYQkXxPAQC48QT0mhIcTrOAzSaTMkFHdY842Nw83QkATdg/7RMiy6yiNsJ YeJLUDXVuk87mMUl3cTXs93z5AdWNww= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id B5BA4CE0F30; Sun, 12 Nov 2023 19:46:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D91CFC433CD; Sun, 12 Nov 2023 19:46:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699818378; bh=fBe7fu6fdhvjb2Vl3O+hHCTrOe9yrQAdsDE2H6K6JUw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m6SJsMg5KavzlrZgEup4w6srQLVMAzL1OT3+mkIGn838VdebxO4YPThMRTBxbHVjW arJxb9kZ9SKHg0X2BJUxftHNHaTNPpPTXR8N974jOsMd+MJc2mvO6cCvMf5pMKR2NX lHbrm8j2ERD7CrCkcHxTVFX+jc0PdTLZ8B+CmqEXc2xjnLcOghjG8oRZpNLFiTBHFr LZm9mfo7sUjlJu8DyHzMB55sUkkjMsO/+XXGDDSeH5GvHbyL2WuuXhy5UwbvB+LrGD eBq+cYwgAFEVvUJR5V+BJ+pMei61W+C9LpZYo+csOCuMf/OiQ/LPjZppZRFO6smDq2 23aDyqdfNzXhA== From: SeongJae Park To: Cc: SeongJae Park , Andrew Morton , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 8/8] Docs/admin-guide/mm/damon/usage: update for quota goals Date: Sun, 12 Nov 2023 19:46:07 +0000 Message-Id: <20231112194607.61399-9-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231112194607.61399-1-sj@kernel.org> References: <20231112194607.61399-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 449C21C000F X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 4nwjj1fmw7krgpyqeaaz7bqnk5botpj3 X-HE-Tag: 1699818382-371690 X-HE-Meta: U2FsdGVkX19zxCL4kvuOCT4QrBNbZnNNMNhb13U4T85uhYUiyvhRXtrbMYEzLH65qMUxOqiuP7qkJVIx/4x/bKW9oejBNgh1AUzQwbdNlQZvAcbiAxJH81my5rouR0sk5NtcmV/Ozd+end33E45z0yUc7KMrCeO99zVYRePB7vnK8unoA1RNJqnE9yKy6NwhrgVaS12cibj/pBI2x2zx6NqrHoO2qIfniU9K5aC1ycFdJEAtL72KwHmYgT5krPPXt8fevcrD3Zs70YRgbahyoCN2RI863TMeMvBLlLaU3lzy5uLU1UYeT3RU+w/2yNe5tUe3OhSUbcy8EFpxr328E2XJRCNWzyswMozpUX+DICBoOHN4m0kAtUvIHu63dkmq0vIp2EpTwAJfs8tcJrY1m9puVkJs/KQ2vJUyNVqrp2um8y96Wi5rK0VftqmXJHE+uoNHSgyIkCx16KqfiKjWAj0KjRyyXqKCX3ihs8EfexOzRe2/dan562Eec3LhzcmhRGeR7Z41c1ECXiABzp//p2H8Hf2NMiw3wVsYUk59cyxHzukeiYhF6k4te6GzzTjYCHFygW2EcXL0QsPYR7JSRsGLcTDni4iMmqt5OeWWuA4vH8N3VmDTwBArCPE/Q72GXzLgcFue+6XQdz6Nyok2c1cFK+NBjcymvpwRXCwBQ1eBP9ebkm4uMv8FQnu5At7PF3duhsz1cFB0jI/6QW9Fk0/18FfNsNX+3tgg3JKpXi0qpnB5IogFS/NTE53yUGAGYrDoIlOUs8G5wRDVDvby4Irw6scq4HKWkdJOAItYtgc/368cIj8HnGij5ABJ0pClNNkNpfHNUNy2YIZeazTT26q+RHBkWvT2LbSWhdKfsUUAl3osQcAK+M+6V8tkuNiSwyIqCdn1r8Xtw8S/L2j9qOO2bviiYqL6vGAria4+QmdAu7Doym5kl4pktMu5IQjmBTaBwAKi5jxmfAB31JI ilwePTuY dKVtUbp+qIw3raeKvbxbadPm3DuyGN52iwIu+gzYwZonb6fFqyA6DopoCwCSueKrE5m7C7nBaBvuz77s3L9go/68CJoTm1CDEhB9msYMfgTJtBF4UAHKILyo+wKhIzwceYAYAhQec2q3DgSCA4C4V+UTjI+t8NunJnJZfxYJiex77E4qpLYDpl600XXkxi6jMZu+4YZjw6Ytmb8/7nj+u6sUWzvEfV4wDM7pGVox+AmQFaw0FBYNVfyWxtCeUkrF+RiYUe1FP2qSMsiEva0flOoxyzp43V00FebPt 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 sysfs usage for newly added DAMOS quota goals interface. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 25 +++++++++++++++----- 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index da94feb97ed1..3a2d308ca1e1 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -83,6 +83,8 @@ comma (","). :: │ │ │ │ │ │ │ │ age/min,max │ │ │ │ │ │ │ quotas/ms,bytes,reset_interval_ms │ │ │ │ │ │ │ │ weights/sz_permil,nr_accesses_permil,age_permil + │ │ │ │ │ │ │ │ goals/nr_goals + │ │ │ │ │ │ │ │ │ 0/target_value,current_value │ │ │ │ │ │ │ watermarks/metric,interval_us,high,mid,low │ │ │ │ │ │ │ filters/nr_filters │ │ │ │ │ │ │ │ 0/type,matching,memcg_id @@ -123,9 +125,12 @@ Reading ``state`` returns ``on`` if the kdamond is currently running, or ``off`` if it is not running. Writing ``on`` or ``off`` makes the kdamond be in the state. Writing ``commit`` to the ``state`` file makes kdamond reads the user inputs in the sysfs files except ``state`` file again. Writing -``update_schemes_stats`` to ``state`` file updates the contents of stats files -for each DAMON-based operation scheme of the kdamond. For details of the -stats, please refer to :ref:`stats section `. +``commit_schemes_quota_goals`` to the ``state`` file makes kdamond reads the +DAMON-based operation schemes' :ref:`quota goals ` +of the kdamond. Writing ``update_schemes_stats`` to ``state`` file updates the +contents of stats files for each DAMON-based operation scheme of the kdamond. +For details of the stats, please refer to :ref:`stats section +`. Writing ``update_schemes_tried_regions`` to ``state`` file updates the DAMON-based operation scheme action tried regions directory for each @@ -319,8 +324,7 @@ The directory for the :ref:`quotas ` of the given DAMON-based operation scheme. Under ``quotas`` directory, three files (``ms``, ``bytes``, -``reset_interval_ms``) and one directory (``weights``) having three files -(``sz_permil``, ``nr_accesses_permil``, and ``age_permil``) in it exist. +``reset_interval_ms``) 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, @@ -330,11 +334,20 @@ apply the action to only up to ``bytes`` bytes of memory regions within the ``reset_interval_ms``. Setting both ``ms`` and ``bytes`` zero disables the quota limits. -You can also set the :ref:`prioritization weights +Under ``weights`` directory, three files (``sz_permil``, +``nr_accesses_permil``, and ``age_permil``) exist. +You can set the :ref:`prioritization weights ` for size, access frequency, and age in per-thousand unit by writing the values to the three files under the ``weights`` directory. +.. sysfs_schemes_quota_goals + +schemes//quotas/goals/ +------------------------- + +The directory for the DAMOS goals. + schemes//watermarks/ -----------------------