From patchwork Mon Feb 19 19:44:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13563019 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4682BC48BF8 for ; Mon, 19 Feb 2024 19:45:25 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C7728D0005; Mon, 19 Feb 2024 14:44:52 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 3FD228D0001; Mon, 19 Feb 2024 14:44:52 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 251028D0005; Mon, 19 Feb 2024 14:44:52 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 124D28D0001 for ; Mon, 19 Feb 2024 14:44:52 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id E6938C025E for ; Mon, 19 Feb 2024 19:44:51 +0000 (UTC) X-FDA: 81809581182.11.60B7C5E Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id 2EE2DA0002 for ; Mon, 19 Feb 2024 19:44:50 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rFJSr6uM; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1708371890; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=riSQdEiVLB6Q12bND90ux+qR3YMcKh9xiFH3w7RB5OQ=; b=1IQFGzjeBDw3IM7OFpK1w98hdC0heigdwWxAsT77yDGAuA3OHykzOYjVXXQnMb2MT1iH/o 5us3ZU29VGkMbXYrSxgyh1ms8n0IEaFLk2pTGfzRQJ/HyaSh+nFOaQs8WUGuPGI3u4yjHm I9aTp1ob04FK5ON697v1skNWMJgWjOo= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rFJSr6uM; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf25.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1708371890; a=rsa-sha256; cv=none; b=1gnlQJoaYlKar6KCS1KTTdBfZoYBExTem81wg3iWe+/uQcKpLu/CTnBBC3PJYu+WvPmlpV 2GBO9SmBPt4Odh82b7lURRq4NY7pvSUxD5bFXGn1ZMijVmcf5CWfGZpLkpKEBeUKrhotRa 1URUEZC0xP66NTJO2NWQ1k17k/NkDS4= Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id E20A760F6B; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3C0DAC433B2; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708371889; bh=md7Aj2wC1qQQtLcqUJ8iiiADXUQCURmj3A5KbIYpZeI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rFJSr6uMfuHvK3mAQWBO/Kx6owcMmb7rsY4jYWRds3IthNLEW3TlfK7jgsRfr4CSM dN61MrBA2XaPqDMU1gaWjxDOp5uJue4FiXV7dyB9ih0d1yjDW8TJqFmyoJ/AprBXak +FjLU5myQyDjsWWNPpqZTo7WXY0W2RxROETQtMeADxrfSn5wvY7a6iFAWvj+4JDzLp O61GWEWp+dqyVwTmB+0q+9dX6dgijC15QKRxTU3XGe0mlKXQzQaYL3LVdw/xMeOVmQ bToBakwXJn07j5AZmC/mO61+fYpOd8aT2rRkCdhkI0gbIiIPbCe1sxCqAirQ894/Nl te5B+uRH2irWg== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 18/20] mm/damon/reclaim: implement user-feedback driven quota auto-tuning Date: Mon, 19 Feb 2024 11:44:29 -0800 Message-Id: <20240219194431.159606-19-sj@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240219194431.159606-1-sj@kernel.org> References: <20240219194431.159606-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 2EE2DA0002 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: cw1bo1oqoywgkr14aqewarcszsbr15ec X-HE-Tag: 1708371890-230611 X-HE-Meta: U2FsdGVkX19jumnMMo+yAjpXMwBX40QwdJrmD9S1h8UVYY7swpNi1n1CyMlSUXal87sWxukzRZhdyA9yAgwHzr1t4Yn1zL/1t0GLAeTsHdjf9K16T7zCGzUYrcJC4R4WRzvMGf1Z4eKpncUjaFPdQqDmkZjHZsHTZBQFzfGdSik6/c0jBEDpPXM4c7NXgIpjYZsrQI0vR8txy+WpLKuA2OPWGVTN1O+WnqIcF2fIlxfN67lZVZTB9oKp+ewymChmPtKhPtAvRVLwYzbt7fBdXhrMjN839dOvqAeFFPP50dNnxMjWLHsCvDRoVda30a+JL/i21reuRiLdPQIKzdO4xoBLHGMIifAdcljBLNU0DDhqp8es3WgNIJ9FKpqTrNgGxe91exEhyecA4Xe2DcSMlcMfR96UQ6kpUa8IE6a91G2Whp2VvIb9vv722D3gE1AUHLeo4gz2i/xS2xN57ammTHqe6sJC4uhMHRDxEVM9wO7jtn9RuqCCT02cUt5plkabQowigJIeCVoKUEDQZY8zTC5ZE8v57yb7f+6H+2lT47GhYYCNNy8NRuFgICDif9YQMlN3Ce7Df7uUDsDXuazICanst6rttt2Vfe66c9q8QwmXY/1aDxCfeez60a/g2XWseFowUoAWELzYFZ3y7oWFC26RuQdSuVT4P/IYlPH2Gx64K4Nxp1MiIjdvJnOfJZgpBJG9nb4QqM1zisMy3uAHpxvO5NZFXMzeTLTIXgcvBjb4kPq3gX6jw/M4S7uO/7Xv+dpldsuSOnrIDa+CVX4bhL1dp7e7GU4lS3fO/X6UfXhpLxCq8pgbEME8By//YCOzcZ4hLMT7UyOHUqIRxPKN/oQ8cgIf4AOeSMS3GWj62ZEoObBGJg1OU0qk0e5eu65Slsa6HnZRTNhLfjNK09dfCQ8bcoTOLgftiCWuJNQCF/JM1sMl4eBtWA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: DAMOS supports user-feedback driven quota auto-tuning, but only DAMON sysfs interface is using it. Add support of the feature on DAMON_RECLAIM by adding one more input parameter, namely 'quota_autotune_feedback', for providing the user feedback to DAMON_RECLAIM. It assumes the target value of the feedback is 10,000. Signed-off-by: SeongJae Park --- mm/damon/reclaim.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/mm/damon/reclaim.c b/mm/damon/reclaim.c index 66e190f0374a..9df6b8819998 100644 --- a/mm/damon/reclaim.c +++ b/mm/damon/reclaim.c @@ -62,6 +62,21 @@ static struct damos_quota damon_reclaim_quota = { }; DEFINE_DAMON_MODULES_DAMOS_QUOTAS(damon_reclaim_quota); +/* + * User-specifiable feedback for auto-tuning of the effective quota. + * + * While keeping the caps that set by other quotas, DAMON_RECLAIM automatically + * increases and decreases the effective level of the quota aiming receiving this + * feedback of value ``10,000`` from the user. DAMON_RECLAIM assumes the feedback + * value and the quota are positively proportional. Value zero means disabling + * this auto-tuning feature. + * + * Disabled by default. + * + */ +static unsigned long quota_autotune_feedback __read_mostly; +module_param(quota_autotune_feedback, ulong, 0600); + static struct damos_watermarks damon_reclaim_wmarks = { .metric = DAMOS_WMARK_FREE_MEM_RATE, .interval = 5000000, /* 5 seconds */ @@ -159,11 +174,13 @@ static void damon_reclaim_copy_quota_status(struct damos_quota *dst, dst->charged_from = src->charged_from; dst->charge_target_from = src->charge_target_from; dst->charge_addr_from = src->charge_addr_from; + dst->esz_bp = src->esz_bp; } static int damon_reclaim_apply_parameters(void) { struct damos *scheme, *old_scheme; + struct damos_quota_goal *goal; struct damos_filter *filter; int err = 0; @@ -180,6 +197,17 @@ static int damon_reclaim_apply_parameters(void) damon_reclaim_copy_quota_status(&scheme->quota, &old_scheme->quota); } + + if (quota_autotune_feedback) { + goal = damos_new_quota_goal(DAMOS_QUOTA_USER_INPUT, 10000); + if (!goal) { + damon_destroy_scheme(scheme); + return -ENOMEM; + } + goal->current_value = quota_autotune_feedback; + damos_add_quota_goal(&scheme->quota, goal); + } + if (skip_anon) { filter = damos_new_filter(DAMOS_FILTER_TYPE_ANON, true); if (!filter) {