Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1336593rdb; Mon, 19 Feb 2024 11:48:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUxZTSehk7K2Yvz+4D49KheznR/qkmA/1XOmymBP4XkVuomJdNsa12IL3T36Zn5ZAFm4Qqwwlg+rs3rJzBnNzNcgKGBZ4MVQJcA+ZE5pQ== X-Google-Smtp-Source: AGHT+IFjNw2iaV8drzxH1GTeeYf5PT3j7q+aH3HOAPxu4RB3bh9MUDrGnLhemUXJVEsCnzaroqts X-Received: by 2002:a2e:a589:0:b0:2d2:c80:fc7f with SMTP id m9-20020a2ea589000000b002d20c80fc7fmr10713156ljp.6.1708372138995; Mon, 19 Feb 2024 11:48:58 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372138; cv=pass; d=google.com; s=arc-20160816; b=SlHtwZMLk6ncj+YbxAApeBnSU4y+Ir4/zidCVrO4792MDLxKPsd2EKZ0sBV2x3VWUh 6GBCjH748Ygd9X5fuG3LW9VY4EOivZk3Qy72IXYkMbX6yq/4CDA1OKGkTAUMQVJ4zCiR rbMSuQtkri3M8jDFaXDqLPlsAcoL4FpBajfzuZJtv88YkZAiPJELXdpbqkXfJrXMxMDO LYnxsCyOpMpBHq0dzbBpo8DhGmL8JETNPLLlFJqWQwQ1iCwAar+qxVVCuXz9tqX42Vmm mIs3TuEKQsOqIWsxE44xLtZjllD3HPhL13fUEB7rDMQuzhfuMCvA9BfY31V5ojW3l9VT 941A== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=riSQdEiVLB6Q12bND90ux+qR3YMcKh9xiFH3w7RB5OQ=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=scgJJfH4pgdEDvHJ6Ta9/c2/e7XIFxIbmfAKy+3z1mRUft9anGy8yPB7oFd1orvr4Q KWUWjD1DyF4r+9gw95qtxT+1iLrp8DKhRR03N4Y3mG3hnEXNjOYbTdQkoJYSq3IDwwQc tUhd7iLvsmPyX++R84mLP9oNAl9RcJG0SaVuh56w27GnuW54cjOz9v1TrR+DZ0DBUUgD GxbqGCVdH5D8eKpxNHyKFryB2y5tl7/+Q06H0UEUXj9GtVtlhVJ3ptUSiZ04lMnvZp5D CojSFRMAI6kWzxJbn5jF0foXq3vzkE4FakXMItl0rsKceEvVDneErtUxfpyNOZ0Y0540 c3tA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rFJSr6uM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71900-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71900-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a19-20020a509b53000000b00561d07bc984si2709975edj.603.2024.02.19.11.48.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:48:58 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71900-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rFJSr6uM; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-71900-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71900-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BB6AB1F222EA for ; Mon, 19 Feb 2024 19:48:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1AC0C5BAE6; Mon, 19 Feb 2024 19:44:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rFJSr6uM" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1BF215B1F1; Mon, 19 Feb 2024 19:44:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371890; cv=none; b=St1dBuFDlytkJldvv2+Nt6LzJgoy9CCwXBdUrKC3dBExjM/SiorVBt27Vs4RMZ4ZxbFuJreAWH3aGHza1wh3vQ0UTtnIMEFdOswTrtgL+VY7T0iJnkoR+EieLwWVcS5WsplpfO8VdflgsP5/sLz4ZRqD0ThbHkh9P/A6xvRVNeg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708371890; c=relaxed/simple; bh=md7Aj2wC1qQQtLcqUJ8iiiADXUQCURmj3A5KbIYpZeI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eARbbFadEAxRXuZGhS6+byLjNpoDbr7dXgvZ5+Zd/coLU1sPFVJbjB64PDdbkwvNklZidjrkOaZG/RbBHBdIbC9AFQWscuGCbrtKLOB4+gRTsZUsqnBm/um5mKSRB6Fm126uTT1NFirvYCzo9dSLxsyOH2BM0PA32IQVIZwX1kY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rFJSr6uM; arc=none smtp.client-ip=10.30.226.201 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> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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) { -- 2.39.2