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: 171697 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp113763vqy; Wed, 29 Nov 2023 18:38:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEZX3cYddzcpEOXciEHyADFLYqUX/59dEBCe7rlJIElx6g6gT2k76Rp0SZxI//CdbaziRz4 X-Received: by 2002:a05:6a20:4425:b0:18b:cb93:ebd9 with SMTP id ce37-20020a056a20442500b0018bcb93ebd9mr22270970pzb.54.1701311894421; Wed, 29 Nov 2023 18:38:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701311894; cv=none; d=google.com; s=arc-20160816; b=sXjQxirCaIR8HD+0frF7IJXXlJHBwu6XjaJCdX7UGVFA/GtacbR6qw5qkfXZGBDa41 rgcM9TB0jHIjNllY2pXFLC79LKemgR2gAQWM6hvUOngv+7kjZmA+x+GB9FGz9vQ0d4F9 a5G5jYwNitCr53eNmTbiuo241LeF4UR41IMW4tQxfCv235NwbH4YL3IFZ6/4D3l05YwB qbV5wHWvLkSoyklpk8BONJ1aebUSAVWzvw2F2PmEYSfKWx/wSQGi+5XqNuLh+hdb8BFx kQXC+dy8IPKo50y4pQdShJMNXTKdEC4f06UQh6L3Ubij+eLUiRVsLHTg5pJjMWbMS4dS EjCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RWxJmVCUjuGymk8ZXTQSqzcRQhY6Zmmd8YT9lOas1Vk=; fh=BzdeVYqZhG5iuwuKJRNLP969rvCput73lx0iwx2zu7A=; b=lB2+JA0kzejA1JPspumY679uAcfkx8Vnaei7Rj/5+J+zRiapWg8gHTk5ouDd9xPwWB 3MzsR2IRUi0UdjZ/qgxgOjlCaUUNnw61HEOAVL2SRC5Nld/Wy4AoB9dQtveOQyB0gOmf B4JbO8HyqKhqR01ExL2eQ6mFwZxlmgCfBHc3XP4lAttAAGheiAXcuBcOb/QXLozUfV+B Y6OZ97xj61jb7w+rFTOBwW3wg+UCLaeO9EVfmuwkwJoLJfQeOLJOaoHfPHGPmP8wnTh9 XyawwDdt87/ctvgENbal0cIsGDsCDdeY6fI7zcQopkybnnAm63Nc1dFSz+e46SxpHvZw 0J0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LBI5+n2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id q7-20020a170902eb8700b001cfc46abb07si162572plg.128.2023.11.29.18.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Nov 2023 18:38:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LBI5+n2+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id EBD9B8030A6F; Wed, 29 Nov 2023 18:38:11 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344207AbjK3Chi (ORCPT + 99 others); Wed, 29 Nov 2023 21:37:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234934AbjK3Cha (ORCPT ); Wed, 29 Nov 2023 21:37:30 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A600426AF for ; Wed, 29 Nov 2023 18:37:02 -0800 (PST) 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-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 29 Nov 2023 18:38:12 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1783954820926284777 X-GMAIL-MSGID: 1783954820926284777 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;