From patchwork Sun Nov 12 19:46:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 164279 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b909:0:b0:403:3b70:6f57 with SMTP id t9csp840694vqg; Sun, 12 Nov 2023 11:47:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IFq6B8M9JkD2hoTJHxNRRT1vNdiO4Ie1eWCJUaTkVp7U8wIWINpW260aBczjw+QGUFyMisL X-Received: by 2002:a05:6830:10cb:b0:6b7:5687:8a9e with SMTP id z11-20020a05683010cb00b006b756878a9emr5317094oto.15.1699818431771; Sun, 12 Nov 2023 11:47:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699818431; cv=none; d=google.com; s=arc-20160816; b=izXAMJJKKuLqFtdYgPQzPuIZIA8DwoDNB5vrLwiY/E/MtErv/AoZ+zWDkeV2h3NlLO ps5U1nbQY1mhvXNArYZLRMgF80k/3ZD8ZV8KMZyoQousC4VG+4zQzephDT6wCjlzT/+P 8/iJZpyEXxU7u4e9xl3qk2AC9GOjviOWN8tno5PUfQSyLP2SzDNqqeRlLGPBxZxYtlrP BkjqCBY0LjAsOrxWgTf0twUIszvPUYqjTsu/L7dB5HaVczUgwkxoQzqk2DMqGRbe4tWs dsLWe8jZ9UU4lYElJT2d8qIX6GeZfTGyoQnU8zU3SjDlqgv8GErPv6HXLo3vLqCmnLTs MRdw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:from :dkim-signature; bh=8jJDnazw4CPbQhsvvDn1i0KylqzCFjmFWUxf5kvsA0k=; fh=vqNpWvtrgKyqgLywmXrl7l1d0QUXOIwW93A3X4awQbI=; b=iv70WvRkh/5yKaiOGSea15XE3MsIcLb4s1U6rjndhr0n6ZbboCKDvepVaHIXGdRPT8 qNoPqgoKQGNx3G6MNSBvMx3h+5HBDnP6eJT97GN+9ky8dPlumYbczHgJExlzs9YTLuwH WkT18OzFJ29xEkpQhOA8UOlax0bajOl9uGSIQNfJlLs3QNyc0fYEKRYTMVm2+bQEPyib ReDWrF26EIOnhmSE/njxDoU5toVAIbdhGBdpw2TkhsXJGAjlAu2wYuVu6NdkH9SAOiqs E4mpupRgGRQnp1yYbE0xMxluh6g7a0sTnroxQ+r7i2eZDZQh9pcXuZXf9D/NRDTW4bFY wHKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b="ilsJm/vr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id x64-20020a638643000000b005be14925624si3991193pgd.714.2023.11.12.11.47.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 12 Nov 2023 11:47:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=fail header.i=@kernel.org header.s=k20201202 header.b="ilsJm/vr"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id 47797809788A; Sun, 12 Nov 2023 11:46:37 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232282AbjKLTqb (ORCPT + 30 others); Sun, 12 Nov 2023 14:46:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232184AbjKLTqT (ORCPT ); Sun, 12 Nov 2023 14:46:19 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0C9B1BFF for ; Sun, 12 Nov 2023 11:46:15 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2906DC433C7; Sun, 12 Nov 2023 19:46:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1699818375; bh=3hLtCq4IeSzVAzt9xwdt8SFMTkOmxWIve71ZhjNphZs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ilsJm/vrsBo6Yu1ARBJXfw+m015LoFYGrGhL/3VpYDAsxMUdX9vYwdMYJDtgee/3r 2BobP/nc2JGuXBqoYQqTNwcHNW5Ul9h5jQBXL8J9jNE/kU9f+YyP4IB3ucA1GKwMF/ aVX7CwYjHhsScSiQ6bEPXWZXfsqDaxSSXIIamlhSeqRsvgt7urc/TcfeDoBssuSlIs 5nsUjlIN3IEX+FEQIB4x0276ygds0KDvX8pHGguetiHuUDPLdMrlnI0JiCa8UY/bm7 Hd5jdrzrPWfkBHm2Us92VOCJDsEJu9z7ez2YSTrZ29EZEOa9USrpWHji/+z1pjDsqj yaPQldDJREiJg== From: SeongJae Park Cc: SeongJae Park , Andrew Morton , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 4/8] mm/damon/sysfs-schemes: implement a command for scheme quota goals only commit Date: Sun, 12 Nov 2023 19:46:03 +0000 Message-Id: <20231112194607.61399-5-sj@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231112194607.61399-1-sj@kernel.org> References: <20231112194607.61399-1-sj@kernel.org> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, RCVD_IN_DNSWL_BLOCKED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net To: unlisted-recipients:; (no To-header on input) 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 (snail.vger.email [0.0.0.0]); Sun, 12 Nov 2023 11:46:37 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1782388811679234952 X-GMAIL-MSGID: 1782388811679234952 To update DAMOS quota goals, users need to enter 'commit' command to the 'state' file of the kdamond, which reads and commits 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 10d8678e48ea..273fb7862fce 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1888,6 +1888,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 2d31390edfc0..f6952cec9f19 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;