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;