From patchwork Thu Nov 30 02:36:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13473980 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 0DC25C4167B for ; Thu, 30 Nov 2023 02:37:17 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D47766B040F; Wed, 29 Nov 2023 21:37:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C3CB46B03F3; Wed, 29 Nov 2023 21:37:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9C1436B03F3; Wed, 29 Nov 2023 21:37:07 -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 86BD86B03DE for ; Wed, 29 Nov 2023 21:37:07 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 67CD21406CE for ; Thu, 30 Nov 2023 02:37:07 +0000 (UTC) X-FDA: 81513058494.12.A743819 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf14.hostedemail.com (Postfix) with ESMTP id 25F83100009 for ; Thu, 30 Nov 2023 02:37:04 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="lydNSbh/"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.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=1701311825; a=rsa-sha256; cv=none; b=k5W3XCLrOP2VpnhmtmJARXDgfWLparJRHoBHozjt7Y4Ibzmy1DvyU+CoahU4CuC5fR495q 76m82caNO5zqqhLtTWVyhlUcL/gwLiUJxU1Nra2zgir4rwEuj7N3svieLvWTtCHG9/uF5+ diwn0hDdZkIz2dTmvFl87W1CVbohk1M= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="lydNSbh/"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf14.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=1701311825; 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=v/Rkh+PhwbnDO/pkwEGQDX87Y34a+REUKohEtpFfiho=; b=B5vcwgLHICWkAb5g1PfcDu4eQQoJ+wKd12FVqG8ciIcci5xoW+cVNMV9Aio9GUaJ4zJmP8 8ekxzH4dwrO+o9JiEC6/try323h78+ZH9KdMiVUo6D+pgaEWPkVQAAa7aaP13s7/ucnvUj VKtpLIFo8vhAW2C+xoKSfg7eSkI+oss= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sin.source.kernel.org (Postfix) with ESMTP id DB183CE2028; Thu, 30 Nov 2023 02:37:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B97F4C433C7; Thu, 30 Nov 2023 02:36:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701311820; bh=jwBIjpGZD3rM6rB5XeAwkaAzirgaxde9QsDx+o7twAk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lydNSbh/PCoA8/EI4ar2Ec+gdsQ/sP8wLwSz7QdbaVARbRFmcMt8GRGPi/IP/KKVJ jgEkE4yB4hZMmj74cPK9catW2EE5pihwR0ajHW6VG4oQM6RTKDLnssb6Cp6sM0JDX4 9hi7WxvY9TJyOCa3tpN4mLR+KATBlBpWQyW6yYm+m01i7SbgfkVi86kuYRAP8y2zi4 4l28vUQEjqnORCskD00MmdIHGPUEhUTInZkSQDht7SE5qp+2E0vLb5114Vt2IGJL3+ bGhmN7UA4j0SgjgVWK9WoBAhPdJOL4XuBBy9eQ2EZc2ahFIUIsQsOtFTFhRKlvy1Es EeZW9IhKznzYw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/9] mm/damon/core: implement goal-oriented feedback-driven quota auto-tuning Date: Thu, 30 Nov 2023 02:36:44 +0000 Message-Id: <20231130023652.50284-2-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130023652.50284-1-sj@kernel.org> References: <20231130023652.50284-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 25F83100009 X-Stat-Signature: jwjwcjogsc4jg1krgh9qtmaxbdsrgjy5 X-HE-Tag: 1701311824-369507 X-HE-Meta: U2FsdGVkX186wQ+dBPrlskfy4EZQ1jeaXwFxLsUvJvfGgP0UX6HI5qaYp1s4BMSf3xMOMKEsHByIxj5VRep4ot3oO/95FLxZRHeJfAySUFCaZw8cS496vL7sr6gNQDOmcQg+0/EA08QKAfNmzxvUCAs40RlCG2qgO6tsck1lCibqEOBfxo0GIRzcPBgqZsoPngCn46+OEzMhiOo594qUZQOHesxxJZ9vxWMy3PqSCv8ynaGR/sJSOQUig53RzRIyPnhE5HA8JrtjNKFj2toFNLwa7fEjPLLfMbmBk8MiaEFZjGhLXhwl7vqnEDq0sUxwHr7fHXCH+pLbjBW6zhyzuKvguMoTymjmrwoNmU7QyG/TNY/HOXoi4KlZbgsOsQmlmn1ZHlmecBrudCLF8wukkYbIMfIjpIVCbzGdwgi+XxkpnNjKk+LoDprwvd/Ppe60dBVzDitHwwsmEx/GDN+7tBpq4iu3hdFmnlXONXKQJ44nL5eGLGhOBi8LaL+66lAZ/dyoSsHvCUsCcSThJCyRmXO6XBVUqGqF+BjFaN+YlvsmRs84VQSlwsm8QOb/a2otOzJt2ljCMj0jP7xet60Q4WZBt5e7brFA9ilcHki4nTM8QDLMgVH00n+KpcdJ2zUEejazXEw98qb+KNTgbt/AN8wl2dmn0oCtKnRKheyiLveWOUVgJSEZq3KAcayR3seS0eERoLJVjgyUZMz4dtd/ppx2ATxEwZXPwGbqSa1oIwd34E5jDtTCnk9pRMSNGRGj1XYrN+VOAR0Sz+zA+RB0TuVLwkZ/FIYTTOBka+KP7jvYCwhiuwy0s/0Ej2llXPFMTwJ/vy6/w8abjqR+KMZLzL0sCaLnWGmeuLnr+5vfPTWDmCZEpfHV7TwDlS9osGd+dF5IoBo0/QhE9Az1Kf7+PbxWV8y1I7O9z6pd4Vgwq8jAbg59GtscsVdpDb0cXd2q6YiJM1lxMXDOPkwU8KR FvtWJxms IO54A3yzrhli6KzefdCdOYo2h5cLdCy7YavyuFPXOLCD7ELdROa4/Btz3ZeuQxPfSoMEyAwQwIO2PjA8a0Kha7z+ZGskmIIkBlp4Ud8NheUubWD6CSb2QVvO2787jccFZTys/1sWoLci7sMcdBsZKVXu6f2Asmez/cAaYfdMiedDpQ199kWdHh8QXioVF8UXTwGDvbB198bboLzXB3GksNMo4gaB40sAEKBg1zJ01s0qrczM= 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-limit aggressiveness of DAMOS schemes using the quota feature. The quota provides best result under the limit by prioritizing regions based on the access pattern. That said, finding the best value, which could depend on dynamic characteristics of the system and the workloads, is still challenging. 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 calls the function back and adjusts the quota based on the return value of the callback and current quota value. Note that the absolute-value based time/size quotas still work as the maximum hard limits of the scheme's aggressiveness. The feedback-driven auto-tuned quota is applied only if it is not exceeding the manually set maximum limits. 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 | 68 +++++++++++++++++++++++++++++++++++++------ 2 files changed, 78 insertions(+), 9 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index ab2f17d9926b..508a262418a2 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 ce1562783e7e..f91715a58dc7 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -1038,26 +1038,76 @@ 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; + if (quota->get_score) + esz = min(throughput * quota->ms, esz); + else + esz = throughput * quota->ms; + } if (quota->sz && quota->sz < esz) esz = quota->sz; + quota->esz = esz; } @@ -1069,7 +1119,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 Thu Nov 30 02:36:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13473975 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 9F9D1C10DAA for ; Thu, 30 Nov 2023 02:37:04 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E2F546B0396; Wed, 29 Nov 2023 21:37:03 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D1B1C8D0001; Wed, 29 Nov 2023 21:37:03 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BBAF26B039E; Wed, 29 Nov 2023 21:37:03 -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 AFD6B6B0396 for ; Wed, 29 Nov 2023 21:37:03 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 7DDE3A0822 for ; Thu, 30 Nov 2023 02:37:03 +0000 (UTC) X-FDA: 81513058326.01.FEC0568 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf02.hostedemail.com (Postfix) with ESMTP id D399E8000D for ; Thu, 30 Nov 2023 02:37:01 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lRgRzxND; spf=pass (imf02.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=1701311821; 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=VCtYpXCf0WeiwSqGgN3z88f6mgIHVeVdM3LPnGeS/IA=; b=hzhpocMiff8ijf7vuBmfr7rBiMkFCmS94s+1C03qE7rLMcOAA5u8jipQQwHuulDVOKsYcw UJr4m35QkhGAdh8iERJ8vTJz1QpF/002sa5cTT4+qUixqaeQSWXZcQM/uLy0AHEzGNNQAs 6PhEvWNCumTr6QT34vHzSGyKEID7z6U= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701311821; a=rsa-sha256; cv=none; b=MX6NexUjQDXwe9H3AIKyRW+gcNFRZ0ZjnHNw0n5hiTyLO8NvSZXDXo5MPBfWONOPKoZuyI eUUDN5sFmDpxyy+lvQFDyCdvtBKxYDY05Md6m5od0zwbpB87qNqnfVeOavicS/6Xmnl3lM NZTbjkKWx7YjbUwU7pZsb2qpLaI6818= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=lRgRzxND; spf=pass (imf02.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 0821661917; Thu, 30 Nov 2023 02:37:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5BD35C433CD; Thu, 30 Nov 2023 02:37:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701311820; bh=Zui/g7KxP982XBB/gWdJuIQ1teaLDQkwAJtBsHfxVTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lRgRzxNDNbm7lr2q7Y53CCXTaCb86uIcOob1lUwGtAF+twP1nzW6iYAepQ1c4Onj9 IS893QvCkslgxKA29cJnnoDFseUyk6dq8zTOFttcFjff9ootD9pK5R6Yl4pNUluDTK T2EpO72ELMrqrEgXJHAuaN5peRey2z3VXHOOhl6LNi0XqzV9RcQ5SHjxcopPexngIB KTHq1eQ9BuXqK7CqmbuDzYmPW97jbwMhc0hoQiHkEVwL5OxIaHKBsaKv8vb2qQh+yx xIoLY5MyFIkGdP8MEgLBpHIfYlTV8Py37fUUhPnX0ahYWFLEgVYsKmxTjn13jga9Td IfYb2F89T94gA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/9] mm/damon/sysfs-schemes: implement files for scheme quota goals setup Date: Thu, 30 Nov 2023 02:36:45 +0000 Message-Id: <20231130023652.50284-3-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130023652.50284-1-sj@kernel.org> References: <20231130023652.50284-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: D399E8000D X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 5ekom3x5qt1w455jr5fexhz84fiz9gxn X-HE-Tag: 1701311821-656175 X-HE-Meta: U2FsdGVkX18K/AkXb/Jcu3BsCk+vlVyXx3lEDqWkTf3XsQ0yAO7ibaUN8uZq/YGK8hP93ZBgyPyS/WieGMpbBfzutBChJ/OiJWmH0MNu3a9m8ON/uSTVUXFbC8oc2+O5M2pPNZqJE9S7pKEaY5cJ0NC3mRs90Z/Cq0GClbACH9kmHj4rGv7Qy1AGd8zWfw3vYJmllnmlpFz7zqMUEUULE2reYmsW72zMFm1gSZiMJMhp5WMowHTKSz4GqPhSyaXeR3V710G5Og4jkb+Jw7obP19dUY32UoXbuvKTYM7rug2RjyTv5+ucYkrdbZhzNWEbHvCb3vyotdReJaCX5ADirW7URYIc6puy6cCDhejCenRWvn2rxoaqGL5gt3i8RyEZMgUdWxbSIDyZB24ccoz4uJv2xm4PogHDWxKIWzuDKY9kp8hP8rVb6IHzTFAT35dah/evuNWRR2Nj+01he12rEPJpaulOUxrBbMihG9x841obw9VXs2aQoqyE5pDwyeKKKNGu8ec1zAX5ykuC5HWjpDLXNrQA3BczX8jgmPBw8b8od9IAt0UHTvujv0x9Xw12xZdKierNQYZdVi/I2KaqSMb0MgEuHBtGNXhkPRju1Ws8h8VZ9ZFQ48wF1JVg9pC27Z37k8EWBjOkFXOB503lIR5xTLWg09NMVnMkw35IW7Izb7JLKmTVlJr1CLTtKd7fd0vvCxEy++7uEbqY+OoI67xpn2mkvtnO1WGlfD04PM9Oj0mvJq6JraMT+1CwGCKDKFx6dyVtQb9yhXFeo3eeUmrFXghOmIS7ZzmCt4wBVnrQLtANohEecwh4yCFsBowEfeEkhVje6zyV+dWNLdM0yDS3MxxkTg+ykgNNjC+bpNBkWFzQtHfU/k+LlaRDBdgLJuwp82RHddBYj3Z2j2ZvOni872ZTYqOc/tigAeGIQq6XIrLrMbE+b3s5Rk8+Ii58sc+P7iQD6vKEt6n5ldE rmHZMKyT hDS8Cywg4EpEwqvlesTnILWfqLAmPAbUA6pGaSta6NqgfkhHC2GPiJv+SNnLAzyTULZYioVG58JpG6M9dBQAiHNK6jlaBdXltm42pR6P4LJNMplUpp4rEnecZ3rrp+81B3PcfkIbsDKn1YDf2H2HQEa3SMOJgXZxMt9jigpwpUsD2Xq+LK+XT8OALCcAk7yYmquaZnqR88jKj3o9ZddTRGJ2SR8xNs055TD48IBZVU/l57H0= 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. Those allow users set multiple goals for their aim, with target values. Users can further enter the current score value for each goal as feedback for DAMOS. Note that this commit is implementing only the basic file operations, and not connecting the files with the DAMOS core logic. Hence writing something to the files makes no real effect. The following commit will connect the file operations and the core logic. 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 fe0fe2562000..e5531dbd4cf1 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -820,6 +820,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 */ @@ -938,6 +1135,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; @@ -951,6 +1149,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); @@ -959,16 +1158,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 Thu Nov 30 02:36:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13473976 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 F03EDC4167B for ; Thu, 30 Nov 2023 02:37:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 640766B039C; Wed, 29 Nov 2023 21:37:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5F06E6B039E; Wed, 29 Nov 2023 21:37:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4B7A16B03AD; Wed, 29 Nov 2023 21:37:04 -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 3D63D6B039C for ; Wed, 29 Nov 2023 21:37:04 -0500 (EST) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 13F9612027D for ; Thu, 30 Nov 2023 02:37:04 +0000 (UTC) X-FDA: 81513058368.01.8772D83 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 7306D1C0019 for ; Thu, 30 Nov 2023 02:37:02 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TcLL9P8+; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.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=1701311822; 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=+y0XdEoH84SRvPQ31esO2pBGQn0+moIZB0kK+H5kX9A=; b=XGjOdj0KcmGx5w6bXEmxZ/mPiITNx9vkX05pxrrbxR8HfQGIoR4oiKDTY0VoTJ2W/df8y3 zoWiZterOYNFllZYdDAQfutJ8B/K0tsfXMZNaNL4XayjVkK9ku5ZOg8jvTLfl/2yi77+tT QiRpBdD+CD+xNCAcHlbnSzX4isHVdXw= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=TcLL9P8+; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.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=1701311822; a=rsa-sha256; cv=none; b=gib6HcllvKh85Z9wxVgEv3OV0zgO1JkgMAA6R0Nsg77vKVFPjg2K1UUic0cSgHjbIwLJ1a F9hsTzoeCOsK80aV28pgge4ewnt2fZeOb5HYZu9s7dwEhaGZ+/sZHozeIBscxiDNaQ8wa5 JNgs88507hvDNv2JrjwRKxGv/yE7nEs= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 80B9461920; Thu, 30 Nov 2023 02:37:01 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id F1D64C433D9; Thu, 30 Nov 2023 02:37:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701311821; bh=FMojcAP5QPRX+4T1uzEuLlR/gen6p9qPd+B5RLedtWg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TcLL9P8+Oy7ltVM5DiR3gFU7QyJ4fcHcQUswFA5l9LkcNpPDLaI9QY14RyNitoWB1 AteHwdn9YvdZ3w6aJFgIy5DjiYi/B2H31eUsy/Gx1qdvsRKrF9qTYj/yLx5IUHKFjz ajMFnvqGe1TlsBdByvYwU2OHu8YSc0XRyCV0IoDpkGiY8KEdMRVVMzf+65jIALOfcJ XeHnYD6l5pqPhPA1It6KvoYEilCMZ9ixhpVE2VS+POXVvhPTdYGBTWkDQgdVkXk4w8 ZkJuTZNLXXSx7dJyny7Jrr0324rZWw/DA1/74PZpGrXp85Et4yYCRJLm3rIBo/pSOs G3u542rHiHFWg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/9] mm/damon/sysfs-schemes: commit damos quota goals user input to DAMOS Date: Thu, 30 Nov 2023 02:36:46 +0000 Message-Id: <20231130023652.50284-4-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130023652.50284-1-sj@kernel.org> References: <20231130023652.50284-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: 3dsrszipbgdfrmme4x4obbs49yryjs6x X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: 7306D1C0019 X-HE-Tag: 1701311822-982898 X-HE-Meta: U2FsdGVkX1+CGpMsAr/6esPXodNs9b97QBNC4zQqd6pCchFt6MC9Mkik5n4Z4ejPpilX3pE5fS2jPr3nImklC9Cu1wcu0+IAtcb6e0RRfzQSyHUBe/fEzZmkNQf99R77HK2Y9HUWsr8JidfdT12csvTPs/+noQsFHZ6Y7BL252iAoYM8zZZn1ivsrsjx9Faros7eMqAlfykK27u8uVGchIyVsViVfoCEmIOXLPSrVEoyd2aT5ZYqXyQIUS2GUABH+F5QAXkkIMn7YoGjccp1egKiolTMy3Do9vhmtFM5h4a92fuVwt2o9JXVJ2T5wYB8Y8Khu/BWJIIDlYzqZEWjJZzCoUvtZiei1Pvg6wr8H1kozYKF4maSnrdiv26MWeB+rNTHA4bLRysWBB57S6j5TGsQZkC4Ytcopt44jrY2hYqXFSvEmhIg/hngHydjyc57/AFtRLmV/Glf7h9OSVTyCjixtGvPF+Vo/0ULmCDUec9V9Qf7jvf8poEzS+y94vD73dPA1k76+skOM4oLNuFxErXVLVBm/Ba+FeKV0z5a0/JVTp1ysf4bvJypyruti4Tb/TxsegJxXBjKm9v6xLH1QRkfZXtdS11nebFBA6JNkmBNRXuBwpRKaL0sx9MFe6YZoQrBD2OhnLBxvpP7Ek9GDmtvSZ9BsJeZLKYltfbj0Jha0i9mVayTaB2AHSoCNeBFXRy7eEpaNBvmPBTgFfkZdAm/jEH8g5q+O9ezQRBPZ6dmbakvbZswfmw4uY7TrWHmGq5INhQe8TbqSt3muAFc5miX9teOvZrxgRx0gPiOJvZDxOZrcAG6Mvks1vsAKOm7GQpTE5gvZBQJHQKOxjDqQdJHlQjip1cDfLKIVS76NKhd+m2yU5Um2eqTNc600Yvo07ZlQb6r3HlkEdRhRl+4m79euRdt1YrYzKEJvOqogpi0HBzrN6TnGL7Bhvz6/ELLxtClx9tNgWyD1T5eqaV QDQzthlM gC94NNL8H4J67HpMKW8I2RoLkJ1+nDhCvxRAj2Pj0qKYUUGbmF2x4FvKj63nK4exM4OYa44knfZKWYTRTK2hQPoUCGPee4cnT087SQYL56yrxj7j7hEAdsa7EqCiGiw2hoh/5yhcPgZuTdB5KdQLgazS49d7YBib8U16qrmgxpCDMM63UsqEHoRirEeCiL0bif8Pj1zr+UU8IZjaMJ5jm4mG/ZzG3b/Rn96jgnwLrGliQMuc= 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 user inputs for DAMOS quota goals and pass those to DAMOS, so that the users can use the quota auto-tuning feature. It uses the DAMON sysfs interface's user input commit mechanism, which applies all user inputs for initial starting of DAMON and online input updates, which can be done by writing 'on' and 'commit' to the kdamond's 'state' file, respectively. In other words, the user should periodically write appropriate value to 'current_value' files and 'commit' command to the 'state' file. 'target_value' files could also be similarly updated at any time. 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 e5531dbd4cf1..a7917534ca19 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1868,6 +1868,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) { @@ -1905,6 +1933,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) @@ -1945,6 +1975,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 Thu Nov 30 02:36:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13473977 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 F2802C07E97 for ; Thu, 30 Nov 2023 02:37:08 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D49376B039E; Wed, 29 Nov 2023 21:37:04 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id CF3D56B03AD; Wed, 29 Nov 2023 21:37:04 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B94676B03AE; Wed, 29 Nov 2023 21:37:04 -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 ABC3F6B039E for ; Wed, 29 Nov 2023 21:37:04 -0500 (EST) Received: from smtpin24.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 8E0F6160680 for ; Thu, 30 Nov 2023 02:37:04 +0000 (UTC) X-FDA: 81513058368.24.A27750F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf04.hostedemail.com (Postfix) with ESMTP id E31E64001F for ; Thu, 30 Nov 2023 02:37:02 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LBI5+n2+; spf=pass (imf04.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=1701311823; 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=RWxJmVCUjuGymk8ZXTQSqzcRQhY6Zmmd8YT9lOas1Vk=; b=DpcpD5SMa/Xr3sz3pufDDdw/wyJcGCJ3jUFyXzhVTTMSyczKLFHoe85lE0UihBNbY5YTia +6eYVd4Bg3jhUfWL+PEAko9X0WXgHxTPDfyyVragOu8OJ4yU1UJCYkxCbJjBdUvKdAOM5+ q5bmQn5mazfxfgTbQ1xI10vdUIWTA/E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701311823; a=rsa-sha256; cv=none; b=qHBfFH442m4hJFajJK6JcPYspAGpHpbuhkhFw9jmbW8TE+jeVk4+0AATgdd4W7wM8ttOmm ETw9XfCpHG/T5Kpx/redxNFFj1GEK1WgwujP7P9J85Hdnk/QcNcsvSiik1c8KwpXi77C2j sPFLkUt3uPOIegW/W6szHt1eM1dRTrE= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LBI5+n2+; spf=pass (imf04.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 34B4B6190D; Thu, 30 Nov 2023 02:37:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85DC3C433CA; Thu, 30 Nov 2023 02:37:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701311821; bh=tJsPu7JQL87ujr48iV6g/qqgx0+zpDp/3dR6mROKAm4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LBI5+n2+V0t7rY8iy3M9ZVdx0RLjzFwHuSY3nqWmWEr0rvrsO6aGZV+nYSuouZPVz mwb6Br2qeEj8e9VML8YdE7tUypRSZH1kRBXFlfZs3zLt6mmdm1Dbh+Zwi2b2f77t4K yvPJ5JXkTrmDH1EzY65pLmcf8nf9IGVJgfJN24PQjv55KlGlu0jn+zPa90Z2EjCSn8 bSvLyjqGIYbJB9IT9Dgh5sKsYCmtgdyEVhFp9fU64Ef8/BDhMxtg3sK6ru3Bp3enRI qhoetCAmq/iA9ycYb35mK/9bd5aCVgiFQWvWXVlfPvwlpm0b5x0ElXLFovDZXzZ32p qhhOB4SsqbO7Q== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/9] mm/damon/sysfs-schemes: implement a command for scheme quota goals only commit Date: Thu, 30 Nov 2023 02:36:47 +0000 Message-Id: <20231130023652.50284-5-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130023652.50284-1-sj@kernel.org> References: <20231130023652.50284-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: E31E64001F X-Rspam-User: X-Stat-Signature: xqufx1cpybmc7zb9zzz7zi9137nfs1yj X-Rspamd-Server: rspam03 X-HE-Tag: 1701311822-804962 X-HE-Meta: U2FsdGVkX1+x/LJWitW1x4uBmCMIyxkNb+iGhwZ66PowqYNbPzSKSo1WaV2CIwO/VCY+t1vJQU3T1n+Kl4zNGN/spYNiGJTUngoKDDk+9OFdH5C3bJ+ONJj6HYhzc+D27e05+HNCWvICCp02bOjv3Qcpbv7ShAkxizpPYwzO1PuhLtJIT8/XngPBmTP7EOp0ofgmyyhGH2C2OSu6izqt9WTZUO9md++aOF9+tQq89IMR02Hx8gUlUOfkmdMlGDGpdV7O7r2UOQUlp0vb/SdlgJmp7aqXHgsg3axyqhQlPbj4arxYPHxc3FSjTRXcw/1yCVlt4FML+IJUOa5B7IymzWrJf0q/ATP1EJrYeTeGZsw77BX5yGczD5L5Qb/iAHr0VagsQoQtjJbRSMqDeLP7w2ItdvIXsPsFLk4c3aX3ihu+eO8U3CKvt1Lk0A3TdpAkH6TsQUHIzhylCrZHh4/3o0KcEVKZQCa+WMOnZetGR0IKfxj6W3F4gnFHv7htXjjsosy3jNHU2A6pryG8BNYDXNSJqXWO8gN5QYqI7gHqq7GUA0GQrpHqNFdtw4y7ehlrPu4zYDSu7YxN2saJ1bgAoAGAv6JL7SbDweyyPrB0byHNM9rOgTvAImUDkJ5Po6j8wn6ek/Vzw3I9ryikJGdtNdyrQ0U22OjUHZ1p8H2bz8uSl7DfdcTNZYRmwkt3PwWcpWjTJ7XqUETXYSLIdI5pX4A8IE5P2VG9yvgk+wfiUFa3wBDglKqB7z4ucxafGVK/9B+vZvMGtH7zAuPdW5c+lbTyTswbmQAX2QYAKBsP0I2PRQG+Hy2UzM5ASp568xrxn7pL71i9qZSJaLGcO4d8wT67lnrZyNsmRoA0lblFn32epbNXZafQ2kpUGjCpzgfDHkYeTrWaJzdYEoe5QLRDthnyvNp1q28J3Nn4W+nlzoA74h8ZRIAC3Pybbm5L4yt4dOReFP4e4ElC8vFpf3O 7G6leFOf ohuDizE9lMTap27qB60TbYGVwOSvYrBszb2e8yO4qtpjSl+iSKS/ydG4x4eDwD5/CWZnWPFc612AGEvkecb3a2g5cK3BWdMuG03E3LAG09slviXV+Vpin6NfjDHbSHqrGKfhqBnb15rFZqNeiH8GdPzxpJfvVBfGbW9uhFirzQfeWHmzm3AlRFHATCqUfAVhuCN3O48LhDODtuOUp1WIbl5GPxL0o8O/JZmvtb+UpsaMFDEY= 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 applies 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 a7917534ca19..8dbaac6e5c2d 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1896,6 +1896,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 7472404456aa..1f891e18b4ee 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 Thu Nov 30 02:36:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13473978 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 72473C4167B for ; Thu, 30 Nov 2023 02:37:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CD0506B03AD; Wed, 29 Nov 2023 21:37:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C7E756B03AE; Wed, 29 Nov 2023 21:37:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B46C06B03DE; Wed, 29 Nov 2023 21:37:05 -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 A04176B03AD for ; Wed, 29 Nov 2023 21:37:05 -0500 (EST) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 69F7AA06EC for ; Thu, 30 Nov 2023 02:37:05 +0000 (UTC) X-FDA: 81513058410.23.F72367C Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf07.hostedemail.com (Postfix) with ESMTP id B56FE40003 for ; Thu, 30 Nov 2023 02:37:03 +0000 (UTC) Authentication-Results: imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Z6+6tCLI; spf=pass (imf07.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=1701311823; 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=SV91sbKHpchOuwEkTdeSfSLk3e2/GvbItb+/LWvupeM=; b=f1tewJL0eTrHevfWAHiAb/g0CvBxCLHntzBNAeUDH7KEfxZ7EcBIl5VmCr3lg1AuPxsdfM AALEP8sk+rpyrgnf0rbRSFSe6qrgRjN8D/8IAU7p11xnR+s8YXgG+COfbnHKa47NWOElNg Ux1WnxCEva4PVeo96j7XXADAO2cEkV8= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701311823; a=rsa-sha256; cv=none; b=mFAK2VF5vB3glIiouNhNtDHLf00PEznv7UMGJ3Q8CB9TX/lc6lQJ5iUHGeSR29fe81rSt6 nb2BfhKbD8gyyjH0S8gg0oSbeD3vj10BNPosQVkZnZCclptC+/OARgPw/NkwhV2d+mp/sx 9pTDbhj887y/SK6+ZS8GTeUUw2BKMUY= ARC-Authentication-Results: i=1; imf07.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=Z6+6tCLI; spf=pass (imf07.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 04A876190B; Thu, 30 Nov 2023 02:37:03 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1AC1AC433CC; Thu, 30 Nov 2023 02:37:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701311822; bh=EtcCE3aKL92GHTdnkP2hxrtGMR/ShXKbIT2mRyd4U4A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Z6+6tCLIAdAhswg3GRnBOLmuTKm3/4K740cV/qZXqJeePCyk2PGDIM6hlz0JUF59h CwnfWJGwv/ma6uevYQizY7w2KoKUhBrqhYWeTl81RNPi8QNGZA710/IYqgNHFbpUFW jJ+B1MncEdyn4JY3Jr0tTxCUn4DI6onqGmUXvzSH9tCs5RBeYcbVXy2FIVA1Bx5Wx5 perHVTael5dUoP8C/cTLFdstUUTFfXURD7Yc5WTb/uyFBVMRv/1jHhviCMBe00BkaS hfRoAuBG2WvyMptpLHFtLh1Hly+Atkns970LzE3OI3+Bb6MT12dFC25mvAtidZSgUH qwYEgT3+dO6Xg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Brendan Higgins , David Gow , damon@lists.linux.dev, linux-mm@kvack.org, kunit-dev@googlegroups.com, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/9] mm/damon/core-test: add a unit test for the feedback loop algorithm Date: Thu, 30 Nov 2023 02:36:48 +0000 Message-Id: <20231130023652.50284-6-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130023652.50284-1-sj@kernel.org> References: <20231130023652.50284-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: B56FE40003 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: jzh8o6hwga31rsj6wrn7ztgn8h8e68jf X-HE-Tag: 1701311823-964953 X-HE-Meta: U2FsdGVkX18ZpPGWlzLtWDLueznxF5BT8g3qAXexD7HfNi0+gCsoLiR86QDvPWx+XIFMLIEu0s0Nmwa6FCuDLxhWc5E+tg3NpiYIL4/S9bvBqU/rPX6ScktFyjTFJJJ5m41PDQFKiE7+lh8qtMXUU6BRr+GBgDtJX5AoWuzcvFtSrr9YHuHooUQ9L5k3X0XP9bEGkzXDSqyHSKwJbEx1+2Sozyv6qlzpd5lH/SXDAxHLxaKXzbFwsQKJRKOylflSgiyi8+C439GQY9wRHeDDmE5G3lNYgUGebJDPuvrKvarUSXrYrpjL3605X9PHi530F6orRVEdnOO3FfeCHqR+JzeK2H7EUpUjp78HHJcYmeeRfPqV1rlDvZOk4hcL0ozh/2dqfuNIvjmTbFM/EoQKFr3lDn+gt0Lo39Di9dPTewjHRrbM+mN2Y8AEBQKAFIWjz+WabZo90/bxBx5+nIR+DccEydbtUKSEY41dVmfEgpx4+U+TWryhruptrH6BNbQIsX8wgXc5ZOkApppeQRXITYZobnIDdtLLkrbPme9q064ztuZHRzvgQZd4pVAQZ7TUQzTdmgfRDOl0I1FpEoXlCm22noyVdfha+20iZk9kmydi64VjtuXKwUR5uNQTHLzWLC8iK6YdxipfqAfa96NdljL0nlRN9ufly6ZTiqWhhEsaOs2RpWdfwkQzf2cPeKbRMXJtDC7R0rC1gbe44UURa4Fxkc7b9zAxSt/UYhxL4hVOhQsj4iY75rzO9lGqupepLqDvM9RbFfkqtneO/fk1oXi2uP4FuZZ0yUIVAnIUoYxMHBWv41/WSKqO7ufGGrJDR636Ql3uiGfswvzpRtR4WFDVwn+GNVqz6qMrYdkw1QK35xIOtEvEmigZW3uD7NArO4lZcjo4y8u8/vjaJp5jPv1GfPEMPn2l68ALyaMd5amPJXkoKdbUBjuojhg59X5xKSyvoo+phpJD+jwP9CD 2Av2uZsO aHZ1NYVrY7YqVWA7zZDHK8+sEmuWhnfnnsS8kxBmbQLcgBtLUkn3P2KJtvQmTzdgXJk8fcYEJ1shS7B/DsElA9bupBB1KodT3jrIKOjaoBbCaCb1/ppSkM+j7WOrkAxMIL6WnU2KpvwchqwV9fEche0wEk4WxkqIqd0ovloIeQWB7sPbS52k4NdDwYqccEI8om3Mh+YpbGbdZUA3vg3JxcFpSz8ktakVCCyIScgUlQBDEbxdVrFOLXn0zcg== 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 feedback loop algorithm for the aim-oriented feedback-friven DAMOS aggressiveness 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 e6a01ea2ec54..6e5e9502d648 100644 --- a/mm/damon/core-test.h +++ b/mm/damon/core-test.h @@ -446,6 +446,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), @@ -461,6 +492,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 Thu Nov 30 02:36:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13473979 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 69A1AC4167B for ; Thu, 30 Nov 2023 02:37:14 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D2306B03F7; Wed, 29 Nov 2023 21:37:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 97E456B03FB; Wed, 29 Nov 2023 21:37:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 813326B03F7; Wed, 29 Nov 2023 21:37:07 -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 686436B03DE for ; Wed, 29 Nov 2023 21:37:07 -0500 (EST) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3E041140540 for ; Thu, 30 Nov 2023 02:37:07 +0000 (UTC) X-FDA: 81513058494.13.E8457D7 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf19.hostedemail.com (Postfix) with ESMTP id 8741E1A000E for ; Thu, 30 Nov 2023 02:37:05 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mF2NM7qE; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 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=1701311825; 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=Ci1gxBZngxXIjLSOe9PSBUL+wa0760wbp8Ih0BpTE9gXUQkTf/+J+hRL6N5d4JusNgKTFm 6868its2tm9tHFkP1DrC7VJ6MTNj0c/NfgIHPzNQzTP3v3Zci0rC8w9kTVZB4cLdGQTeWa ZHomiPh2dDWELfr6Ixe4nSGx1r4eDf4= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mF2NM7qE; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf19.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701311825; a=rsa-sha256; cv=none; b=fWGeavBl0MKEN9hnmYwSKzEXPHID07HL8tMLv/r07vVNFS5axRHFuvp3UUQbzoG/GM56lW K3RqbldGJt22WN33yZTNtokgkxyVmv9S/0V1c2Eg6Bqv8HADVQcu5HIsANADBxfVmotdpk xRtAF/nszGSpHA92jDZC46Fsp3PRJWc= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 074F6B84103; Thu, 30 Nov 2023 02:37:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id E14DAC433C9; Thu, 30 Nov 2023 02:37:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701311823; bh=tm53i8GhYDRGpRCnZgtLIn7P8jIf3OMjFqv6O/swkJU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mF2NM7qEDR2eJeiTCxOHD0A+5NunTLYKc63iE0l9/ywqjnaj6xo8D0yGnT6Gmvw/A xD91IpuQUYOBVVCxDiJe4H16CJesJnVJ21lgmggfbUD5S3QxJiJkLZszoLmYDHMXxz PEj1zqFucaACRUuOXA3oPuDzdJy8kYEUBSv5OE8pBMbxrZHe2uJjsTidqJEOFmS8eR 0AGIKl4PgJVr/z5eQ3zv6EABddpoQCRpnRrDVKwL/lnsjlaZ0+Ma9teMxzaf/ccZz7 fo0/hMTsCfM4rXGNO0cNf6rXSkHmTF7AkE30ORjDwm4TF23bo0hVD688vrMHNQ/Vku s9Kd4TI4Fn6xQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/9] selftests/damon: test quota goals directory Date: Thu, 30 Nov 2023 02:36:49 +0000 Message-Id: <20231130023652.50284-7-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130023652.50284-1-sj@kernel.org> References: <20231130023652.50284-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 8741E1A000E X-Stat-Signature: we5uf8tjtooide66buanab5ss33pz66d X-HE-Tag: 1701311825-260328 X-HE-Meta: U2FsdGVkX18nNhkGq7unTJDqUvtWreIx8BJvmc3qCFDvNkHoYZi/lkPoHlTgLZID6SIyN/X7LTyyRfGFa7/tOL//hh+5ipel0KBWNRwyk/dQvtiJS8sOVVDmACyC+XcXQcZ88O1N/JOemAEbZoY8WCkTtv6PNEY1GruiHq1uZtGndDXrDhGWSzK2DR1Ga992FHcdDeYM0lsDs6OHNVG7mY+0RBtGJz7iBC5of7vJyDPyRz5IdLbsdTC7OsakMAKsagBiniKn3QhSFO5nDJPs4514n+T+zkOb9QvmfC3yLdS+kvvk1y/+nM+5xGKj14wa+B9ZqvN7rnaA54kUt3peiiaDz9EblDxfkfHhI1dHNOvBT6LhaqzJ3q76Dhc+4vPV/zygY3v6GIVRZNsdXc862QREXEcS5x8vB8HX/aXBofHwmNfuXGJRmwnynXNJP5GerxLpImQpfY2kBUSPsB0YFBWQrcKZbxx2mvXq9JPmX5F5oGDXRSCtRwbCOcZYD2+faQEmObEHS6bTdQR1uDNN0Jo2lCrkJNyo3wCu8W1uc6BW0Px5aOfRoBWY4t8gOsjFzON1AjxUJiuZjW0ueOeYswnjTUfE6jvFEeRy0J3dkAqTW4uIS7K0wj+V8ckixdLY/C83FVaoTSeIZ0Ba+m37jZJgjrei/UdwzXlU+ljESEEyqSnQHN2pa0qG2w4Mnm+PB0KQ701FlmEona8YwVTcbrBVBOoBKsL/oxg9VXfdGY8b9y8E4+7xwN/5nw7It4Hhn4V13q3EspkhaNMSEfAX85kraFVx6oub3QIvOKR1N59scAypGu11lyPDLjoZXnUT4zKDgrNQ7mxPes0decbkkGsLCNP/Qx0OuamCiI3d+ljfq7uwKlZJNlMW8l3p1ctjNxp5jyagj8LSYKxwp91DSyDXp12j1vF/CMGZKQvLGCIJZhFh01GYpcBYX2HUHhO2mLkd0pvuvm60Njr0s1B MW+vgBja auWHoslgR14On2s+ndNjPkpdtfGqOOJX5QUitPORGcvViiQJUb9nApF1dhKWiE/m8fB0sbgsFJPzohWtTI/tYvxBNWYAhnkk+8mMtCL73Sc0NSTMVRKr0mdoczWIokLmUcsjzegT0USBKNCGBFUzTy1HXb7bqklleKFLp0Dn44Hsai9bwGpukrHSxOflew0vcxWrx52lJ1KLPdW52mlMYXwwHOM652qYyQDcbOxDUjQ5NPIbWdevYLYHHuTl7ta/ibTvh 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 Thu Nov 30 02:36:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13473981 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 E72A4C4167B for ; Thu, 30 Nov 2023 02:37:19 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1FAB56B03DE; Wed, 29 Nov 2023 21:37:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1AA666B03F3; Wed, 29 Nov 2023 21:37:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D43CB6B03F9; Wed, 29 Nov 2023 21:37:07 -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 A7A476B03DE for ; Wed, 29 Nov 2023 21:37:07 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 7BF0F1606B2 for ; Thu, 30 Nov 2023 02:37:07 +0000 (UTC) X-FDA: 81513058494.10.8893825 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf29.hostedemail.com (Postfix) with ESMTP id C4D7F12000A for ; Thu, 30 Nov 2023 02:37:05 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ab3KL1CA; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 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=1701311825; 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=podQ7MdCYMOQEFat7IduJyxXomRDnVDa8W1EdQ9KzZg=; b=2hqN2qdAzoOnMpVCAVLjR2AN8wL9AarLa8+hOdfMWdFRmcqYxxZ0d+5fx07oAzOLVDpwp/ h6KtHLu7mS77qhE8hr35fqqn8Bs08h7ZO5TZfCX7Gt91Rlh8u5qnxHUeMeZ6kQVw2MPypJ Cl5wElZWNhMzggB79P5bA/8uqrYPJHI= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701311825; a=rsa-sha256; cv=none; b=53Hq7WrSe+O1e50GWas6n4JUc1x0t8IgD6cQZqzpEFcoVebN0HruphamCkNsZ+UReT16Pj hN5Q1XeBFHnmq1eQJ7qKmlMOPI7kWGRkQBz0jp5te8XqAM5DMzEO8bppVCUlAByd/1kv4f kL5oJMFcEG4DNo2Ur3jPaD96kP3LjcE= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ab3KL1CA; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 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 ams.source.kernel.org (Postfix) with ESMTP id 63986B8414B; Thu, 30 Nov 2023 02:37:04 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 95400C433CB; Thu, 30 Nov 2023 02:37:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701311824; bh=aVQYYR7Wa2j5FcEbEqZY4GpoX0ij3ZW/t2YkLOpkPDs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ab3KL1CA/Q1LdHqbROyoGrBYbAzm+vS90RXg2E8BXqXKEg5WEjZojHnxDn9nYqvD3 F1f4Im4M6vU9+o7l3V1SvkvjkldXXrKbk03T1no8M0JuRDCfSx/Iy8YOPKdDINT6FS ISWn3NNg2kx3/5L0ud8yO5DiDbbsFVb4sZYKvK+PPVjRqXcqDYrl9PDurGehZAeban sPc/85by17P4PosFwLVgg3428nwiR3rQRMv29Ggy/BIrzH3ZwJinZk99qOHsE3XUAg eXbFr3YYNbMNjrS+iX50I9+vg6aZId9yd3e0qppFUtYx8tISAFwq9gnrCu7zl70r82 fbwlXVVYwoYjg== 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 7/9] Docs/mm/damon/design: document DAMOS quota auto tuning Date: Thu, 30 Nov 2023 02:36:50 +0000 Message-Id: <20231130023652.50284-8-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130023652.50284-1-sj@kernel.org> References: <20231130023652.50284-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: C4D7F12000A X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: bo5caiakqtbcszpa5q5deg4j5osx5e71 X-HE-Tag: 1701311825-274686 X-HE-Meta: U2FsdGVkX18JSqUrbRAO/BTGkPgjZureOKPT+wMv5N9cuhfqmmOgWy4w0ayATuV21/3HZFVXB2dK3wv1YhYjF54zEMEx97J8Yteo4/OHeJ7eWXE8gPzTLoISF/74cXKfkPLgFajbVTrI/M8iocR4qpt8Y1nOugXrwZYU+F8AM7BPc55sg/HOnTSyPZlbTShhlpZqsGCofuYn+B19Pzvg7+YB+/4PoFF1cPuL6blsGdhWFaa+jSYXX6QFabbbOxDUJuxpe5daJenW5bgPv7NJFuvGqprbkU0Wp/4EFiDj2SlHA4IjHRRfAtxf5+kv7cWBATFqj77b30fSwTheoF9up0ZF2ySEHmbSnDiwt7/sW/1mVsougpNZp76o/j/xKki+ZHLZ/75fPybf6g6HJWHzU1++9Dbyc/iUtzbGVrPUJbcsH3moNb8V+sm4KbNly01RJf+xzYtW7TcQtylqSjgq66DhSkKvuX3OGnsl6AM4X96ia1iMpIp/8+9Cz8tupSkLWrbQP+N+io/37G/Qj5N754xvodMO0TvTnDO6rgDpuYwnfqklZTaPHKOaFIpL9Kd4rNhR2Ulqd+/LbSKxL/GMpN0zb74OKLHC2k91RwYNlbvFRonw78dT4SdAVpiHAgHqZXYquFeSFSAohsOgW/B0D2l4vDRAGVTKtC3IK+vXsYmDGc0ONLXxXqKrZVBod8tSfJ9phV9g8qbYKsCMJkedcrV4TmtXiBS3rqHEgDVeoNb0xec812lHjlCHf70RCGYlmHZ7LztU8Y1XY/WTc9xuu4oGe40RTPLfYMBVqVn79CZ8dSHpRCCMhFdrxbaHJwknLRDnDxct50NeVghW3VQKlVF9TlnCMdbkQSJ1eAvnmBkEPxzH3QNT5FqhS401RFG0M1wZJ1gJLKYLQcsWWhTNc0oQRiF/Zlie8oDEcuaEIQchQrpNFI8TD+lfUEmU8IE4kcpe/Azig7xbyksJduG rJwTQIeb UnhyXow6GoR2oJh8aRiK4TqMCbeHjDOCIUQru9hniiGT3lP+uvCfbF42LWvXc8p75d5q6s8GMS4UGjgG1KZUGNrNrfL8h2nBBs3Ac0zQoEfKCyR4hLEQ8zUCWCx7vSWJXstUJge4SpvPbq7nZasL54muylpTZJqyhZ6qZJvVlI7g7fgmAz3uIwHPrniYzh1VSgPIqDxNWZcSxaRcONSdAVkKSdaZMXUQWVTNDtfPHm2bzpvU= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000224, 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..947c9df6cd33 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. +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 +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. + + .. _damon_design_damos_watermarks: Watermarks From patchwork Thu Nov 30 02:36:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13473982 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 61614C4167B for ; Thu, 30 Nov 2023 02:37:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 976226B03F3; Wed, 29 Nov 2023 21:37:08 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8D6076B03F9; Wed, 29 Nov 2023 21:37:08 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 68B6C6B03FB; Wed, 29 Nov 2023 21:37:08 -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 58DA26B03F3 for ; Wed, 29 Nov 2023 21:37:08 -0500 (EST) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3C21B12027D for ; Thu, 30 Nov 2023 02:37:08 +0000 (UTC) X-FDA: 81513058536.08.86D90D4 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf09.hostedemail.com (Postfix) with ESMTP id 66D46140008 for ; Thu, 30 Nov 2023 02:37:06 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=V1SVwMeW; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 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=1701311826; 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=lUIbfuFQ5f07c6eQ5WlZXiGCDTA/MO9hOvBwdWAwWe4=; b=ztIKqqvU9CmGj9itG1cMW9cPoSUmcZX9GKTcAHq9QOV6FMyOMhOYrHZcjVxjFddmgq6c3V F8lgu8NJCZldevbcmUttCwNq3rtDB02TkuqN10W0QxJWV/ijM9v6Xny1E3B4803cm9XwQ+ qN6dIwMDLD+QsUrtE7NDr2tdyMTqDEg= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=V1SVwMeW; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf09.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701311826; a=rsa-sha256; cv=none; b=eEdHM7fjbVSPeaMIsvq1XJDo29J/ZhUK/W6XTZ89R11GM9pB9BAhn5lyP5+XlmlTqlKG3j csS6L6BDwmhAWqr7STKy6QRItvikf++VdwiR7sfOxOPn8RoBAfPrPHQl+P8UTya+7mFP3R pqpudYWRSRE6BWiJG6WFVE7YdiDc3ok= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 15F30B83E27; Thu, 30 Nov 2023 02:37:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 47FE1C433AB; Thu, 30 Nov 2023 02:37:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701311824; bh=qpI3K6y2bl+C+kintuKgeKanPx5i37W/Tszsh9HeKhU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V1SVwMeWHdgYs4jpDF4orbpSyyG9vn4bRy/aHf+eo+IYlxietj5xvUrwU3gyuZ5+z xnnF2z93D6mPI/Lt4SlB61ZQiwhKBCaZlB7hU7KRqBb99I3x+7LkkAmPf0Kjl0tCoV /vfxe11hgxWaDQyYVe0dbo7OI+UcvT+lMZnvRYriRdlVhcxNl5bUpy/PkR5jF+T1Da 8JP1CDG7KORBs+HtA1lqd9Pn3PpEFPsF2RxmLGVxYCJRYLFegvQuOG1wHynnOyL8rC z+KA0A+0ceyaDTHwqCUEu6ndT7H5VQ1Zqo/uRUI18+GIGDlbgChie1A30qmUbewyAG edOnU4tXWPoxg== 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 8/9] Docs/ABI/damon: document DAMOS quota goals Date: Thu, 30 Nov 2023 02:36:51 +0000 Message-Id: <20231130023652.50284-9-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130023652.50284-1-sj@kernel.org> References: <20231130023652.50284-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 66D46140008 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: kep71jphcaf75741rsoi91n1ge9disep X-HE-Tag: 1701311826-30601 X-HE-Meta: U2FsdGVkX195a6bsrFul6sBl6bHzE6ZT3u+x7qbXvMO6SwluFiBKO4wCqS50g9S9g21wx6+9xGiTh0y9lcj2Uks0n+VylykhQdYq0ogkNS8KpouqZRj7zMiolaLm/gBGfrSE+M/IlSjFXnBDhcTaRmkTyyG47E/F+gVAsCOSTbbmGG2LUHNF10OgcGLL5HhPbNkBMpEHJpPwxcLwO8QnkFmTzE16Dfshn9k5dcEfgCG37CQq7lN/20SNOr0iKs0C1I4d3F4nizZLUYQfA3oNjUsbKm3jxU7PJnQ4wMiPv/2tjAHd7QscG1l90jSP1eoySRuIx0NOhV1k3d4VPi/ilFAHhmPjOokIJ63TQ4VL4xIOczyARTnx4FQhKby/l+cepZIP0MBt6B0N9SzZ9D5gmF0h19GyYHBP6RhKRFDQyadgaK7Oa2oIzba8FSpNKNhm/j/kAIIHtN5unUPVh1+vGADc+MdjEp6LOHB73RxwP2h7Lr1EQPgDqeNRBV8mwEHYsTj1HemS/k77MklUuVgSA7RUga6/ZLpDOxD9sGedHkKYLXuOHR1ARwsQqPz99hsqBinARSgnvY673EPLwCb37Pq+t/nbhlfAHKLtHUjzmIXewPaOyrrJ5kCPy3T3XVTRct6AEyurAiu3RlT904QLliZoTDqA4zAJf/+s1vZth4f7g9GUUmiNVWTzjaSwreH7dwbvHt2XV0opu+NPjEUTLC0HGgZowb+T4TsjF14f35Ke7VyiFnaGkc/PgGnmnDmxqQJfBgLUBLqPXiXnIMQPcsnB4s5QHrKfr54XEmcUBjtec8FuwpNT1pxh8JE6XIYgr17IOqwGumNAhEiWGyTNWgQSi1q1yfoXm2DNbAu6BO22U4dMS52wSMErf6dArXw7hJ+RtFBxr9IgydHF7F4A2Z+7pHA16zvVZmPHeP2JjGSCX8+dYGJEDm+Wf/nAh5zmDume/lC/hBwncW2WMTC XKzHMCbP tV4En0wAAgaUFdWi5XwHqcU5qm+fl2nmTVK4GGczl+3g0Kw/wce6Dw365gTil5qRBHmAkazlfsIaaAthpcH/+UTrQp9/tRorTHSmSHP6YoNbkLWx2K2JU8vk2wqIl+hM+h4Tn6X77rLHgko4fm71z8dtTV2n1nBeajzvnJ+V/m4CcTlvBj+ucsjRP6Dqyfhwz9EH5HzadTltzIlIZSUOS69no/C8m3E63gVlm74Lry7E4nE+jySp4WoTX6V1sfvyDdI4LmfKprYYjcPIdgOrQ5SNPFHSPDYILvu2cRzyyS7aezyU= 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 ABI document for the newly added DAMON sysfs files and inputs for DAMOS quota goals. Signed-off-by: SeongJae Park --- .../ABI/testing/sysfs-kernel-mm-damon | 33 +++++++++++++++---- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon index b35649a46a2f..bfa5b8288d8d 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -25,12 +25,14 @@ Description: Writing 'on' or 'off' to this file makes the kdamond starts or stops, respectively. Reading the file returns the keywords based on the current status. Writing 'commit' to this file makes the kdamond reads the user inputs in the sysfs files - except 'state' again. Writing 'update_schemes_stats' to the - file updates contents of schemes stats files of the kdamond. - Writing 'update_schemes_tried_regions' to the file updates - contents of 'tried_regions' directory of every scheme directory - of this kdamond. Writing 'update_schemes_tried_bytes' to the - file updates only '.../tried_regions/total_bytes' files of this + except 'state' again. Writing 'commit_schemes_quota_goals' to + this file makes the kdamond reads the quota goal files again. + Writing 'update_schemes_stats' to the file updates contents of + schemes stats files of the kdamond. Writing + 'update_schemes_tried_regions' to the file updates contents of + 'tried_regions' directory of every scheme directory of this + 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. @@ -212,6 +214,25 @@ Contact: SeongJae Park Description: Writing to and reading from this file sets and gets the quotas charge reset interval of the scheme in milliseconds. +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//quotas/goals/nr_goals +Date: Nov 2023 +Contact: SeongJae Park +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_value +Date: Nov 2023 +Contact: SeongJae Park +Description: Writing to and reading from this file sets and gets the target + value of the goal metric. + +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//quotas/goals//current_value +Date: Nov 2023 +Contact: SeongJae Park +Description: Writing to and reading from this file sets and gets the current + value of the goal metric. + What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//quotas/weights/sz_permil Date: Mar 2022 Contact: SeongJae Park From patchwork Thu Nov 30 02:36:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13473983 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 1602EC4167B for ; Thu, 30 Nov 2023 02:37:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 41D9B6B03FB; Wed, 29 Nov 2023 21:37:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CC246B0410; Wed, 29 Nov 2023 21:37:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2469E6B0411; Wed, 29 Nov 2023 21:37:09 -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 10B156B03FB for ; Wed, 29 Nov 2023 21:37:09 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E3F021206DD for ; Thu, 30 Nov 2023 02:37:08 +0000 (UTC) X-FDA: 81513058536.04.616B538 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf12.hostedemail.com (Postfix) with ESMTP id 1D5B140009 for ; Thu, 30 Nov 2023 02:37:06 +0000 (UTC) Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dvVUGnsU; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 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=1701311827; 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=S7OvprRVzCQVTy9nlCCqrmLv57KjBqPf/71FHcnZ2wQ=; b=3hj9eGY3TQpoJ6IlveyNt6mU0NoZrqqWfhsHzLARXFDAX37IUufi3HCWczW8CANDKrDig/ Y6ZfCRKuFSV5ZQGp+vSe0d0AnzurKg4nG7ElYzY8zPHN+L0Nt984trLkDmmH2mbUQh58uz D+bPKhZcMvHpCBjLKx+4CninN/qwCkM= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1701311827; a=rsa-sha256; cv=none; b=uc3LFyVDTSBFvIK6kVQ1QCcQqZw9JtydLpghKcsIasDkVhqvUB5jFMv/Vpx8Blhsr60lbR 6fFmVMhQJ6eb/O91fVHseJMk1DR00kJJGtY00lJIy+pNqmMb3HWCgwb3kQgRXQ/2qT1AX3 MOb6OtTzS4V0LIyc97n8RASEi1xHa+A= ARC-Authentication-Results: i=1; imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=dvVUGnsU; spf=pass (imf12.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 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 ams.source.kernel.org (Postfix) with ESMTP id BDB5DB84147; Thu, 30 Nov 2023 02:37:05 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EEC48C43397; Thu, 30 Nov 2023 02:37:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701311825; bh=hrTz5NA/0bpRG+IM7KT93kpboj36cTnKZu8N5QKEqUA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dvVUGnsUsiWCKqpDlmOX2XKk6UqdaHKsZaVRWF91tLjhwdxfdUtr9Yomb5BxOaIqJ FBXVuQfdLlmiSoWtD+ymomcu7SR+EVWV5O37jMU2y3G9C7TwprdJZb2uRZ0h/dLDVt pEkCA+vn2BnVIMRYYOiCLX46TP/NmsVyzhueBhNVLK2Y3iiLwzsiY2sS+RJ8AVbAkW l9gL7SBopuNkfmne+dJdUmCFE4I/1ZjVxk+CNKdEzM0fdaEU2Pnyz2z7t1263Ab6LJ IhBMQSbOi7qkVCFuIAe7E5otrcTrE5vJM6ctuRQXsR+QSb9ASNSWzaooKDvNJ7m8Dy mXxIO/shZsVIA== 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 9/9] Docs/admin-guide/mm/damon/usage: document for quota goals Date: Thu, 30 Nov 2023 02:36:52 +0000 Message-Id: <20231130023652.50284-10-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231130023652.50284-1-sj@kernel.org> References: <20231130023652.50284-1-sj@kernel.org> MIME-Version: 1.0 X-Stat-Signature: qnbt4p5h3rbsa84ua9gzwkm9kfyqzaaf X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 1D5B140009 X-Rspam-User: X-HE-Tag: 1701311826-640354 X-HE-Meta: U2FsdGVkX18hP2pzL3ipZlPqTi1yal2HXmUHF2MQM4pe3ktKyoCjMFHQLvoQz59oboEASMI+JqQ8etLzFQ8pRpJDrKj5adIRRegRmsCqzd8dUY5iobJb0k7hJyesDOUPHEbTsT7YwiMJU4GU5o4+CNvKXchLYsBP+hBeGXFUd3JLyoGpK7hvKJk9bwgA99KAWdm2AuFxfKRUeOmoAmVMAzu2KVS3Cx8ttWQCT9yA12jk3DVDGtWb/g2rwFA/iPpG8ZBAnoj16EiV5voqNFKvrO2NO1dkbm721T4VWB9MwRZD/yAJDorqvGsxkXN65WXdxaCjsqm+y1nBPS+xY38KbFOTzCsiWGzX/O6VUnd/W+niYBwBeZoqtiHuzXFVAP8V0Rc+Zz+uztnTlB67vz4QND/kLDZWQy5n5FA6NhXKqgsmorB8DUCraL8r8WchJEYXuDOXhhC94+jQoqu1mcfvkfQbx9p5a/LYvhBz9Ci74WKx5sdbvg4ACJOxfnTv2lBH76Sgi4UM13f4a/34aF7i8nF3quGVHgE4hoKzNAAxreCEBZieifV4LIuHGj2aJ6Dfeo/k2XnwLvjrzYc+GaAE8gDPDCr1LbG1o0A6Td0IPU+FVpjuWpUqiD0ti1elcO5pwy0DDosJTw55iFRXFlYAz8gDxQ2z8Iq4VCKQiUzTIzoLmlIdMOutzX7quGoVQyvP/dqpmt56sITwo/O2efoJH4AaVGrnWmBWsknuvg3rrMt0/mwjbC4w6P7LgWXt5G9pS1K4OhTBhdEGBamX2grFRLZuGkhxF4HGUcaVLji9OSRAcDZS21AkalklgDw77pzwEII9xZhIYiE3qMVlEhZiImfV+o5Gqf3qjVJsCimqXNqxc/OzHEU0SJkgEbVymdz1+9uEHynd1wXrrQtVOBp4pd/RSt65WvAAd3MJ072S5TLK+DuJWv0UUrxQVHBWRWNSEMaEHeRZLJuiCaf42dj 3k3nycJP MPU37zh7DhXmRaD2MXuAxMoiGY6EgPS4fuEr18hThmqoKLETG0vL+V1QLAuaRS3O8m01e7OINk2dCkFlaf5eNy0OETkF8T9ZYccZPbgkeRtD+p0jXM0blNKHvniqCCGAe9EA3c5nDQQvYCdy1JLS8pQ5301fSwjRFraihLg5SFPkY2UkLKUlhpoz2Er/ZjYiPvI00lpdL8xna7OXlXWMbQTY94IysVhbi9x9tjkQv2dLwhfEloJBydKL3MDL0IDnEvLYe1G15F+ptpcGPDAu/IuCp+1owwC0yVpny 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 | 48 +++++++++++++++++--- Documentation/mm/damon/design.rst | 2 + 2 files changed, 43 insertions(+), 7 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index da94feb97ed1..ff9f62e65722 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 @@ -113,6 +115,8 @@ details) exists. In the beginning, this directory has only one file, child directories named ``0`` to ``N-1``. Each directory represents each kdamond. +.. _sysfs_kdamond: + kdamonds// ------------- @@ -121,11 +125,18 @@ In each kdamond directory, two files (``state`` and ``pid``) and one directory 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 +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 +330,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 +340,35 @@ 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 :ref:`automatic quota tuning goals +` of the given DAMON-based operation +scheme. + +In the beginning, this directory has only one file, ``nr_goals``. Writing a +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 +``commit_schemes_quota_goals`` to the ``state`` file of the :ref:`kdamond +directory ` to pass the feedback to DAMON. + schemes//watermarks/ ----------------------- diff --git a/Documentation/mm/damon/design.rst b/Documentation/mm/damon/design.rst index 947c9df6cd33..8b4a49ac057d 100644 --- a/Documentation/mm/damon/design.rst +++ b/Documentation/mm/damon/design.rst @@ -346,6 +346,8 @@ the weight will be respected are up to the underlying prioritization mechanism implementation. +.. _damon_design_damos_quotas_auto_tuning: + Aim-oriented Feedback-driven Auto-tuning ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^