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: 203246 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp6871dyc; Mon, 19 Feb 2024 11:49:33 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUdK1tQYrCliEmTO9jWCbujdyFoB0t/QiNuA2EYGDLTIicHwZX+CEwujiZ+NJyemJwCmMtxz/bRRq0LJYAfAn20lNNQ4A== X-Google-Smtp-Source: AGHT+IGs7bh/prwi68bndIMyS4dSyiqW7piw8onUyt4axtVxMP4H5fyHUg817d40kpapbulK+cJt X-Received: by 2002:a05:6830:204a:b0:6e2:deab:fe54 with SMTP id f10-20020a056830204a00b006e2deabfe54mr10750588otp.30.1708372172840; Mon, 19 Feb 2024 11:49:32 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708372172; cv=pass; d=google.com; s=arc-20160816; b=0o2UzMmy7yXRgig72CuaUUfgmUMunwwa/TNaHf5HPN7Ffa52DcWzm/MmdYYCxjQxNz QWDJi6tWWrfUyk6pZXBYfufcBFuQvFJWRmjj4Moziru/lWmYzRHKYjNTzOVKXk8Tu+lM twsCoCWMYhb7vcm7tH2RW65zh/oiRi7riTdD1Mnu9fHVt0XvsAi9CjG0NZXxPXQN5HMU dQiZ/o96I0ge5fFtwldWNHrcosmFmiXEriECiA3O3d+fWD9Ol/w86HqU/qTplTje5hNa Nsx5AsFLJGIYQ4pq6Jnor4MDDKKnFgd4aHf37KwJjTj6dIm+qUWjECG/G0yI55Fr4nce iZ1A== 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71900-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 2-20020ac85942000000b0042c44e321d2si7853028qtz.206.2024.02.19.11.49.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 11:49:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71900-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71900-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 94CD51C218D9 for ; Mon, 19 Feb 2024 19:49:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D8B535CDE5; Mon, 19 Feb 2024 19:44:52 +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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791358059921120004 X-GMAIL-MSGID: 1791358059921120004 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) {