From patchwork Fri Jul 28 20:18:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13332635 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 D7641C41513 for ; Fri, 28 Jul 2023 20:18:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C3B946B0074; Fri, 28 Jul 2023 16:18:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A0B878D0001; Fri, 28 Jul 2023 16:18:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 79F068D0002; Fri, 28 Jul 2023 16:18:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 519C06B0074 for ; Fri, 28 Jul 2023 16:18:30 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 216B2A07F8 for ; Fri, 28 Jul 2023 20:18:30 +0000 (UTC) X-FDA: 81062133180.05.CFA29F5 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf13.hostedemail.com (Postfix) with ESMTP id 539C020006 for ; Fri, 28 Jul 2023 20:18:28 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LXDARGXp; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690575508; 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=5nQkTjpE5JkIK0Ug+slCBTeILDePWtarDq+twvurfAs=; b=IR1QweGKUbtuxnS1cmk6f+tc7ws4LvZnC+BzO+618cqzkhv3ApJxoSFLqZvVB5kHamJf+V lxTsZ9mecUr8x3Xgx7Yr9BPXV9oYjQSckXMO7ubEKqSRnfSohiQbE1O5qg1ZKCJGPqC7az SJ6mPXTHI66iwfPkM9haKSXa41I/cmA= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=LXDARGXp; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf13.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690575508; a=rsa-sha256; cv=none; b=3Qs0+hp1nJgemiN1iq8wzo7MSjTcf/Fxd1vrc8pDeVPfuwEUVZq7sgG2o3SlWZb7tPYy8h uk6KZ60TvZW6oxrtz73vbK7MhC0KaGpedkFiM2xei/qdBIJLrHdOxavU2M2P1zCoSrGpNL mmwc8djCc09WWAkqJH4uTNPPAPepNuw= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D410C621FA; Fri, 28 Jul 2023 20:18:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D1EF3C433C9; Fri, 28 Jul 2023 20:18:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690575506; bh=f9khGIJiHzKXZGP9/5olstezaDHUu4yK0qoxQ3r57d0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LXDARGXp/FQxUmz94YzoxW4KJmVhaTi8JMBOSvWlDj/b+y6OEkY2wrOSS7c5yn1i0 Ci+nBCovt0ADVQQKNC0GDEWUMEuRklyBLHOS6s9X8KU0sKUxqrHnYRyxZgqA5xGIQ6 4Q+mpKNFvUoPm4uIlWa9pz0/8RiO/K43iPvbe8fM+poFQuOj0WMnoe7smZKgJWEkim G0bWwohWE+kl+R+Azlx0tgbK2DDgcccqX3oyiyPbnbyz0G74JY7JUkBX8dWeux+Iu3 d0HEGCyrbhDETvHyadG0aX7JRJ0J3k1p30E9qQFkVAowidxX/3+npipplm8elUwNUj RixUsfUXlC/gA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 1/5] mm/damon/sysfs-schemes: implement DAMOS tried total bytes file Date: Fri, 28 Jul 2023 20:18:13 +0000 Message-Id: <20230728201817.70602-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728201817.70602-1-sj@kernel.org> References: <20230728201817.70602-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 539C020006 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: jks3axc1wdkz3hyk58x33j5irqz3pgoi X-HE-Tag: 1690575508-257620 X-HE-Meta: U2FsdGVkX1/KpmPySMmboQ1ZXz1iQFdy8gVYKm+duV31jQ26wYtsXmhagaJEpYcuvqhSIF1n2tsN1al8Yh66dEeFPoEw0nE8j8ORchBmjzMXvsizGXJklMHFrzX/S124NubqtZtFTxtVhrXIUVL6QIoD19HUVEpHg/viMu5tzydmDe9KXzCnWmRmdJ7SBWtqpku1kCJocJFlp5zxuc3bS8YekgO7flojniP5cYAa+vv+epqvtXa5xbkNU7E4bOl9bDCFKw5DC/vjmz7BVzCR6HvqxSLnKEvpkcPVS5SyCI9t+b4m9MDfa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ence: bulk X-Loop: owner-majordomo@kvack.org List-ID: The tried_regions directory can be used for retrieving the monitoring results snapshot for regions of specific access pattern, by setting the scheme's action as 'stat' and the access pattern as required. While the interface provides every detail of the monitoring results, some use cases including working set size monitoring requires only the total size of the regions. For such cases, users should read all the information and calculate the total size of the regions. However, it could incur high overhead if the number of regions is high. Add a file for retrieving only the information, namely 'total_bytes' file. It allows users to get the total size by reading only the file. Signed-off-by: SeongJae Park --- mm/damon/sysfs-schemes.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 50cf89dcd898..6d3462eb31f2 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -117,6 +117,7 @@ struct damon_sysfs_scheme_regions { struct kobject kobj; struct list_head regions_list; int nr_regions; + unsigned long total_bytes; }; static struct damon_sysfs_scheme_regions * @@ -128,9 +129,19 @@ damon_sysfs_scheme_regions_alloc(void) regions->kobj = (struct kobject){}; INIT_LIST_HEAD(®ions->regions_list); regions->nr_regions = 0; + regions->total_bytes = 0; return regions; } +static ssize_t total_bytes_show(struct kobject *kobj, + struct kobj_attribute *attr, char *buf) +{ + struct damon_sysfs_scheme_regions *regions = container_of(kobj, + struct damon_sysfs_scheme_regions, kobj); + + return sysfs_emit(buf, "%lu\n", regions->total_bytes); +} + static void damon_sysfs_scheme_regions_rm_dirs( struct damon_sysfs_scheme_regions *regions) { @@ -148,7 +159,11 @@ static void damon_sysfs_scheme_regions_release(struct kobject *kobj) kfree(container_of(kobj, struct damon_sysfs_scheme_regions, kobj)); } +static struct kobj_attribute damon_sysfs_scheme_regions_total_bytes_attr = + __ATTR_RO_MODE(total_bytes, 0400); + static struct attribute *damon_sysfs_scheme_regions_attrs[] = { + &damon_sysfs_scheme_regions_total_bytes_attr.attr, NULL, }; ATTRIBUTE_GROUPS(damon_sysfs_scheme_regions); @@ -1648,6 +1663,7 @@ static int damon_sysfs_before_damos_apply(struct damon_ctx *ctx, return 0; sysfs_regions = sysfs_schemes->schemes_arr[schemes_idx]->tried_regions; + sysfs_regions->total_bytes += r->ar.end - r->ar.start; region = damon_sysfs_scheme_region_alloc(r); list_add_tail(®ion->list, &sysfs_regions->regions_list); sysfs_regions->nr_regions++; @@ -1678,6 +1694,7 @@ int damon_sysfs_schemes_clear_regions( sysfs_scheme = sysfs_schemes->schemes_arr[schemes_idx++]; damon_sysfs_scheme_regions_rm_dirs( sysfs_scheme->tried_regions); + sysfs_scheme->tried_regions->total_bytes = 0; } return 0; } From patchwork Fri Jul 28 20:18:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13332634 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 0954FC04FDF for ; Fri, 28 Jul 2023 20:18:31 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 923048D0003; Fri, 28 Jul 2023 16:18:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8FA396B0075; Fri, 28 Jul 2023 16:18:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6B0358D0001; Fri, 28 Jul 2023 16:18:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 53E9C6B0078 for ; Fri, 28 Jul 2023 16:18:30 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 16740A07F6 for ; Fri, 28 Jul 2023 20:18:30 +0000 (UTC) X-FDA: 81062133180.05.42ACB62 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 567A9A001E for ; Fri, 28 Jul 2023 20:18:28 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gtAzWRIf; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690575508; 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=6Uog1QOfMkmzFkqlp8sg/lEIxnloSXWhmoyJq/BlhU8=; b=0S9NNUiUZYB/2k1OcnMXROjcJxW6JqvuwxA5tnJsxVA//MH4Mk6a1/MstCLtoAroOaqhAK y9IQn1QpCFc/fkH0tMRvUZ+UK/PlXFnGJjeyoxR4LMp9FL2/lFDfm7MQEyVyAOWQfRYH+E 4sOeJOMQ6sppKj4n6mUAVIxoySanvR8= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=gtAzWRIf; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf15.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690575508; a=rsa-sha256; cv=none; b=7Uz8CZfrQGR78CWT6Qa3G46y8KGPiZrRXTUfS8JYJLF3HmfVVpgiUw/CikExxv4ciHAZ9O NvC6RtB1P+bGxPaJYO9wxxR7cyH9ENRt6OBPDEG43v3ym3/0sS8fmjb/zbd80pV3kGBKLJ gNSzXq2iypxCdMywKuDD8Sp2C5Bs4YU= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 7B10D621B4; Fri, 28 Jul 2023 20:18:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7D019C433CB; Fri, 28 Jul 2023 20:18:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690575506; bh=8j2+FNiZI8rNwlWT1Owk5tX0jfkbTMQHhOcdlB3rG8Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gtAzWRIf66KYbWmItbkVHlcngdgrqWJ6LlxXFcSH7JGfJ6rIgHmKBYZ7kRMu+/P14 txNVbLhn18kP7h/FruOB4BNzfTaRfdyxQfDzvotC0eQeA2xrfIAtuem17mVWLTFMV7 /4+wDQRTlL/JnV+uwEEqUkCAibVt1zSI78urjrJZZL7sPsLxC/DODW1BV37+ENcbPe F0B6CBl+QuMyHArXvm3w2EnWyl4kiIeKnMPzJuhkM/38MymeAnA5y8qF5bBqsl8Rrs Txxdl1ZJLnrUiq/iXAFgsLYphZYiKB7NtVm9ywfrDpnzz1OuifdU+0NdBSVGALVPyF Ii4l+Fdf7G2nw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/5] mm/damon/sysfs: implement a command for updating only schemes tried total bytes Date: Fri, 28 Jul 2023 20:18:14 +0000 Message-Id: <20230728201817.70602-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728201817.70602-1-sj@kernel.org> References: <20230728201817.70602-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 567A9A001E X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 6cyce61wk3fippof6femi985afe9o6dx X-HE-Tag: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dcD45/PDwFt6Z6DYJ61Zlm+EsKCIMIC4E9mZrX5aj3994Nn55GGBxf2jBhA7tfubMDp9SonN8cPPGC2Anm+IhEZTBX2N4u8azv1fAO2yJucOxK8ohPEKVSRKDEE9uUSKkO3pgjFYk2ez6VEFGzoTEtuTFL3l7a2qcAxoP86FOMcQGyEznUnHvMlEfU17NprDxnMLLOuHcBLWMCHVKW1YIDPrh41AM271NN3sCuOwgXK7YH6dEnS65EISGdMkeCVn9IE4k/fnwjCy/4ltt+Zt1uw== 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: Using tried_regions/total_bytes file, users can efficiently retrieve the total size of memory regions having specific access pattern. However, DAMON sysfs interface in kernel still populates all the infomration on the tried_regions subdirectories. That means the kernel part overhead for the construction of tried regions directories still exists. To remove the overhead, implement yet another command input for 'state' DAMON sysfs file. Writing the input to the file makes DAMON sysfs interface to update only the total_bytes file. Signed-off-by: SeongJae Park --- mm/damon/sysfs-common.h | 2 +- mm/damon/sysfs-schemes.c | 7 ++++++- mm/damon/sysfs.c | 26 ++++++++++++++++++++------ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/mm/damon/sysfs-common.h b/mm/damon/sysfs-common.h index db677eba78fd..fd482a0639b4 100644 --- a/mm/damon/sysfs-common.h +++ b/mm/damon/sysfs-common.h @@ -47,7 +47,7 @@ void damon_sysfs_schemes_update_stats( int damon_sysfs_schemes_update_regions_start( struct damon_sysfs_schemes *sysfs_schemes, - struct damon_ctx *ctx); + struct damon_ctx *ctx, bool total_bytes_only); int damon_sysfs_schemes_update_regions_stop(struct damon_ctx *ctx); diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c index 6d3462eb31f2..9a015079f3a4 100644 --- a/mm/damon/sysfs-schemes.c +++ b/mm/damon/sysfs-schemes.c @@ -1635,6 +1635,7 @@ void damon_sysfs_schemes_update_stats( */ static struct damon_sysfs_schemes *damon_sysfs_schemes_for_damos_callback; static int damon_sysfs_schemes_region_idx; +static bool damos_regions_upd_total_bytes_only; /* * DAMON callback that called before damos apply. While this callback is @@ -1664,6 +1665,9 @@ static int damon_sysfs_before_damos_apply(struct damon_ctx *ctx, sysfs_regions = sysfs_schemes->schemes_arr[schemes_idx]->tried_regions; sysfs_regions->total_bytes += r->ar.end - r->ar.start; + if (damos_regions_upd_total_bytes_only) + return 0; + region = damon_sysfs_scheme_region_alloc(r); list_add_tail(®ion->list, &sysfs_regions->regions_list); sysfs_regions->nr_regions++; @@ -1702,10 +1706,11 @@ int damon_sysfs_schemes_clear_regions( /* Called from damon_sysfs_cmd_request_callback under damon_sysfs_lock */ int damon_sysfs_schemes_update_regions_start( struct damon_sysfs_schemes *sysfs_schemes, - struct damon_ctx *ctx) + struct damon_ctx *ctx, bool total_bytes_only) { damon_sysfs_schemes_clear_regions(sysfs_schemes, ctx); damon_sysfs_schemes_for_damos_callback = sysfs_schemes; + damos_regions_upd_total_bytes_only = total_bytes_only; ctx->callback.before_damos_apply = damon_sysfs_before_damos_apply; return 0; } diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c index 533d06052c09..808a8efe0523 100644 --- a/mm/damon/sysfs.c +++ b/mm/damon/sysfs.c @@ -999,6 +999,11 @@ enum damon_sysfs_cmd { * files. */ DAMON_SYSFS_CMD_UPDATE_SCHEMES_STATS, + /* + * @DAMON_SYSFS_CMD_UPDATE_SCHEMES_TRIED_BYTES: Update + * tried_regions/total_bytes sysfs files for each scheme. + */ + DAMON_SYSFS_CMD_UPDATE_SCHEMES_TRIED_BYTES, /* * @DAMON_SYSFS_CMD_UPDATE_SCHEMES_TRIED_REGIONS: Update schemes tried * regions @@ -1021,6 +1026,7 @@ static const char * const damon_sysfs_cmd_strs[] = { "off", "commit", "update_schemes_stats", + "update_schemes_tried_bytes", "update_schemes_tried_regions", "clear_schemes_tried_regions", }; @@ -1206,12 +1212,14 @@ static void damon_sysfs_before_terminate(struct damon_ctx *ctx) { struct damon_target *t, *next; struct damon_sysfs_kdamond *kdamond; + enum damon_sysfs_cmd cmd; /* damon_sysfs_schemes_update_regions_stop() might not yet called */ kdamond = damon_sysfs_cmd_request.kdamond; - if (kdamond && damon_sysfs_cmd_request.cmd == - DAMON_SYSFS_CMD_UPDATE_SCHEMES_TRIED_REGIONS && - ctx == kdamond->damon_ctx) { + cmd = damon_sysfs_cmd_request.cmd; + if (kdamond && ctx == kdamond->damon_ctx && + (cmd == DAMON_SYSFS_CMD_UPDATE_SCHEMES_TRIED_REGIONS || + cmd == DAMON_SYSFS_CMD_UPDATE_SCHEMES_TRIED_BYTES)) { damon_sysfs_schemes_update_regions_stop(ctx); mutex_unlock(&damon_sysfs_lock); } @@ -1248,14 +1256,15 @@ static int damon_sysfs_upd_schemes_stats(struct damon_sysfs_kdamond *kdamond) } static int damon_sysfs_upd_schemes_regions_start( - struct damon_sysfs_kdamond *kdamond) + struct damon_sysfs_kdamond *kdamond, bool total_bytes_only) { struct damon_ctx *ctx = kdamond->damon_ctx; if (!ctx) return -EINVAL; return damon_sysfs_schemes_update_regions_start( - kdamond->contexts->contexts_arr[0]->schemes, ctx); + kdamond->contexts->contexts_arr[0]->schemes, ctx, + total_bytes_only); } static int damon_sysfs_upd_schemes_regions_stop( @@ -1332,6 +1341,7 @@ static int damon_sysfs_cmd_request_callback(struct damon_ctx *c) { struct damon_sysfs_kdamond *kdamond; static bool damon_sysfs_schemes_regions_updating; + bool total_bytes_only = false; int err = 0; /* avoid deadlock due to concurrent state_store('off') */ @@ -1348,9 +1358,13 @@ static int damon_sysfs_cmd_request_callback(struct damon_ctx *c) case DAMON_SYSFS_CMD_COMMIT: err = damon_sysfs_commit_input(kdamond); break; + case DAMON_SYSFS_CMD_UPDATE_SCHEMES_TRIED_BYTES: + total_bytes_only = true; + fallthrough; case DAMON_SYSFS_CMD_UPDATE_SCHEMES_TRIED_REGIONS: if (!damon_sysfs_schemes_regions_updating) { - err = damon_sysfs_upd_schemes_regions_start(kdamond); + err = damon_sysfs_upd_schemes_regions_start(kdamond, + total_bytes_only); if (!err) { damon_sysfs_schemes_regions_updating = true; goto keep_lock_out; From patchwork Fri Jul 28 20:18:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13332636 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 89123C0015E for ; Fri, 28 Jul 2023 20:18:35 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4DDF76B0075; Fri, 28 Jul 2023 16:18:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 48D756B0078; Fri, 28 Jul 2023 16:18:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 32FA88D0001; Fri, 28 Jul 2023 16:18:31 -0400 (EDT) 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 253176B0075 for ; Fri, 28 Jul 2023 16:18:31 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 95B6D1A025A for ; Fri, 28 Jul 2023 20:18:30 +0000 (UTC) X-FDA: 81062133180.29.B218692 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf20.hostedemail.com (Postfix) with ESMTP id 04F6F1C000A for ; Fri, 28 Jul 2023 20:18:28 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RX260k1o; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690575509; 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=M6iKB/8DnuuuqI3l7pYmM8Gm6s8Ppxk8Sj40hVY7DBA=; b=t5gj/jlgDd+DeVcjZ3x+rI2NQA8D2Ri87BIMpIyALEbbjfX/PYTn+twzWj6h652qT7wMSn r5QtLqcaoBXkwD+j4R4xpbkaDuatUlELOdNJhUmEx3ewYYOeTbjmINaiNjFFJzgCO02iUB 3OT/WHjiSZuCCu5055wqodgFD/aAXcM= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=RX260k1o; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf20.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690575509; a=rsa-sha256; cv=none; b=n5QbdT8cJojc4WlStfT3uoHeeAE+lAVryq+2Ht7Y5lW+OqJxaxlbK5WW8fOcgw8c1j0Od8 NnmYjE2/DOSUfbu0T5rTRmKfG6kiBWgv+qRE1V3xz+TJnKuaS5/TB3LucZcItCXn0Lt1Bb 2OBnyErBMQoH3vI+cAV8zjXzgTXGxb4= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 33DB3621F0; Fri, 28 Jul 2023 20:18:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 26B70C433C8; Fri, 28 Jul 2023 20:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690575507; bh=T0fZGypLM6vPpWaOxwTR4DXjjDDCiOe0tcjb/Q7FYeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RX260k1ogVJVTYldpyL2MGeGBk3tczpbf55SpjRAVjT3q1MLI8Xd9HW7ZUgZsmtHH Cj0LUABIEdtOyJhlJgJA5+ddILF/b7B0oCVXSNLQfQOMSZv8Vl+GTamyICVRsZYGRx qNI7iYll5IOZ7YKkhn0Fjp4aa9TYYyUMcQtFPkI93XQ4g1zKrupkRLVpcsVtOj8Bpi 7RgCEgKylHCjNMsAzUG3/JKObwfK68tEDIhlTB9zKKvqQYw4733MSpaHK1VOChBCtL w3r+CWSFwF/pvgYfNgmZh8Gd6cK6AkaI+6/VilRbS8fXBk8oV/m0Wk2SwDhShqnRa5 tuBgaodKk3dtw== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Shuah Khan , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 3/5] selftests/damon/sysfs: test tried_regions/total_bytes file Date: Fri, 28 Jul 2023 20:18:15 +0000 Message-Id: <20230728201817.70602-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728201817.70602-1-sj@kernel.org> References: <20230728201817.70602-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 04F6F1C000A X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: pp6kn7jtm534fmnp8cgdj55z4muax1th X-HE-Tag: 1690575508-233211 X-HE-Meta: U2FsdGVkX19opEltEr6e9nj4zQZ2ATfElWWV692a/Iq+wreZY9nkRwZjREQOmV4Divo3LFQBud7bAevH0PW5v1o3Lfv+lplnojQRS+DS0GL4fUItqQJjsdzejfWFdl3ts1I2UOM4uvckkcHGwiJ7j2xTtmrHJ6Y2e4m1fc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WpqgMd1mM6iQtrB0+/pkHdP1m6McIQFfNEEs29xsk4Xgtv+3FbduCChLcF9602+c/pi65YDc4kW2pGuODcHCqGhVx+cmP/M9LXKrB7TSufN0kO8oSSRQV1RNy5VkUPBLMK2opzk4EovmshVh1g== 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: Update sysfs.sh DAMON selftest for checking existence of 'total_bytes' file under the 'tried_regions' directory of DAMON sysfs interface. Signed-off-by: SeongJae Park --- tools/testing/selftests/damon/sysfs.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/damon/sysfs.sh b/tools/testing/selftests/damon/sysfs.sh index bcd4734ca094..967e27267549 100644 --- a/tools/testing/selftests/damon/sysfs.sh +++ b/tools/testing/selftests/damon/sysfs.sh @@ -84,6 +84,7 @@ test_tried_regions() { tried_regions_dir=$1 ensure_dir "$tried_regions_dir" "exist" + ensure_file "$tried_regions_dir/total_bytes" "exist" "400" } test_stats() From patchwork Fri Jul 28 20:18:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13332637 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 9B5C8EB64DD for ; Fri, 28 Jul 2023 20:18:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 99B516B0078; Fri, 28 Jul 2023 16:18:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 948BA6B007B; Fri, 28 Jul 2023 16:18:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7E9628D0001; Fri, 28 Jul 2023 16:18:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 6A83D6B007B for ; Fri, 28 Jul 2023 16:18:31 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 51FD01C92F3 for ; Fri, 28 Jul 2023 20:18:31 +0000 (UTC) X-FDA: 81062133222.25.ADF9FAC Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf29.hostedemail.com (Postfix) with ESMTP id A6C95120024 for ; Fri, 28 Jul 2023 20:18:29 +0000 (UTC) Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QyGP4+cb; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1690575509; 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=BQF35P7hXjl9TwWNqpj6Qfp3UJJFmpviFMibiLDIQgg=; b=nDQPgkUB6DAyKlL4SkcqKDuA5nvxArqZJpRtjQx3BBLNqS5CHp9EK/VCVstYOSf7+c6M3y 6+LddN+pgcTLPr77kJ26TJcc4h9GBfePmBoIn9EvSLjVNa8poALzHCuL1MguWR/lr8WOCp i+zest/b/ZCOAkWfLNQCidMLnz2qCPk= ARC-Authentication-Results: i=1; imf29.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=QyGP4+cb; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf29.hostedemail.com: domain of sj@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=sj@kernel.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690575509; a=rsa-sha256; cv=none; b=jNWuc65aH78h68d+FmiO9s0ziKWU/Auc4PMdoV+yUxq5+8NmUpVDDT79OKZj4kHEOu4InT 6JquBK1EC5wyhnyPYIeKvvdqbmFDuI4O1nmebiUCdljIwzbHbMTCGecJpyUoyyTyDRU+N1 744SrSgPKHQIMOGJVsjw9w36Xt3zZXw= Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E8002621FC; Fri, 28 Jul 2023 20:18:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D5926C433C7; Fri, 28 Jul 2023 20:18:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690575508; bh=hZi4JMj8VgF69C/0cI6pgbuOwe9TusEzinxMwIrTwRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QyGP4+cb8vPs1cOqldkfI60vHEt6GW58BND6QKRpWnpRyPcnJjNzbMiHvKbL9sr2f Gd89fZUVgnWzXVJE8Ov8HLUGJen9Lw5jd0RX+XIcilGNjDfRSNkWXm209E2KRuCtPa F8UY4Eqc6arjvEGTVzBSN1mw2IhBvPs0jAE5IqeK9kzyWeAGdTwB3M2ErhdHYFsl4G WV9PSZKsagHHQaKljpGc9LWz6H+qSthGrI3dMvNDLEQyaQblO9+IIv3nDwE6+65d83 cboN3H1SPsHUB2yduqbBqlYlsgiU5j7gNat2nzF1OVPsWcoAlJN+yhrt+M1hPRY6Y1 cPpjkWwWV1JSQ== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 4/5] Docs/ABI/damon: update for tried_regions/total_bytes Date: Fri, 28 Jul 2023 20:18:16 +0000 Message-Id: <20230728201817.70602-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728201817.70602-1-sj@kernel.org> References: <20230728201817.70602-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: A6C95120024 X-Stat-Signature: xy735n4kju41d1obyidx1wi43aceket4 X-Rspam-User: X-HE-Tag: 1690575509-915589 X-HE-Meta: U2FsdGVkX19oKAp6ED+LYpmkU0B1/QkW5C0Bmgo1SheFA/zPia78J54TJFk+3Q4XcagcTy3JnaSG52ANdLSu4OSSPiEeyfTNsYKWX1SEpske+Y3k7Tlj4hKj2mnyf5+tD6BPDoVl1lly+QtTJEm6ZAM2ZmgqpYMfbpq0T6MqmxrYvsCKkiedUl20pMZbrWWZapnrECmmunB+/WLJLihmBRvmncE/pLlTOVgKRkRg+8IK3CGqKYwn+apgd1o4BnJnkS/qKg/nJsX2jqh9WFtKpFJNikAtUuM/pdKYbf8TDqmK/rfkH9BlzS1qV6WDWxHuGs/MnHN/O871GsfMw06lm3XlMOhmKDABdOCJEjseD5nxxfIwgwpl2fLwZSsZ7Efimp2u4p0mATxV2tDuVcF1LX7GIsTfrqY8JRF+MYylFaQkEoIN9Aio+ZuD/yYRQsED+m3iK1srYh9XetY1+CUZhUJjG581kKH09bsHBYMnC9SfIwbFPCGjSxHRkjd17RFRBHa/44Htoas2d4DqjcmdJ7IY0hfJOkupyLYRfnPmLvo+/XzYEANPZvR/98jAMZbQNeqNinYZVAjYZccI7y6WG8F/GkGrHRScYkWerabxBk1A3do5pFD0eWEfTGJhSf88RYhsgBzDkDFenugth2UoO7DRxo6jNMz+IDOf/bpsjvgvc4v4ZUXOThAxrkpj/WnE9n1QKBlPPT/cTY49CKySgjxGekTc8+jQSQFPHNzgF/I5oiRT+1L/UsNX31qjJ4HRAnaey7rmVZpL/0HPNaaMPOdEDvsKYPMIIT1hFcIRfzyATgCrNAZi8QI0SoBySAVMVRAeh5TslRzw9479mDpm3AkVsWQt74V/ANyGcM2WdWRBZHeHdyXdWcjOU+supk79faDlfW3vKK+Zg7/V+rTZxyro5xjtHZUJOhgUzMwPYyogB/yUsRwbmR01KbRf6X64A37kSk/w+CxcfLwYBVW bRnScNDX 5a/W5JWIjB+DELS7104yHrFgVLyf3FAkDuM8f596zRb/oxN2DpwD2WdENLNQNRFh6cPaJ9C75HyObqjZ6cLdI3J0Af9wJ3aLYtSgGGtILikmRo1SlMymc1ud7bXgZItfD2bKMtXEzOtHalT9BmfwDbk0mUdvV4efpAzAKUDJLInWY6EISQTXylY6dOC72wqtFCQ0cRQ+4L69joEvo1Izt/mRDJ0b+XmH6DQTYSQiFQVeQ/igRRPdZ8E0PnmdXt+jYf9pEADz3Ga67/GZscMyRvpikJQJ/0DdDgj1PBsX/kZfuZ6j+v77utNCb/XBe+CD6MlM2k4UJ/pZOajSrOhHXs346heEzKCzie9I3dm6KbpFNHoUbzrSJnrWa+Gtqn6HEbvhiHg2Lybiyb13/+PAA+s45vmUtcgVzCUj0T/3giqHCz3y7S4nAsJ+l1oZU7TOo2/co 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: Update the DAMON ABI document for newly added schemes/.../tried_regions/total_bytes file and the update_schemes_tried_bytes command. Signed-off-by: SeongJae Park --- Documentation/ABI/testing/sysfs-kernel-mm-damon | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Documentation/ABI/testing/sysfs-kernel-mm-damon b/Documentation/ABI/testing/sysfs-kernel-mm-damon index 2744f21b5a6b..3d9aaa1cafa9 100644 --- a/Documentation/ABI/testing/sysfs-kernel-mm-damon +++ b/Documentation/ABI/testing/sysfs-kernel-mm-damon @@ -29,8 +29,10 @@ Description: Writing 'on' or 'off' to this file makes the kdamond starts or file updates contents of schemes stats files of the kdamond. Writing 'update_schemes_tried_regions' to the file updates contents of 'tried_regions' directory of every scheme directory - of this kdamond. Writing 'clear_schemes_tried_regions' to the - file removes contents of the 'tried_regions' directory. + of this kdamond. Writing 'update_schemes_tried_bytes' to the + file updates only '.../tried_regions/total_bytes' files of this + kdamond. Writing 'clear_schemes_tried_regions' to the file + removes contents of the 'tried_regions' directory. What: /sys/kernel/mm/damon/admin/kdamonds//pid Date: Mar 2022 @@ -317,6 +319,13 @@ Contact: SeongJae Park Description: Reading this file returns the number of the exceed events of the scheme's quotas. +What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//tried_regions/total_bytes +Date: Jul 2023 +Contact: SeongJae Park +Description: Reading this file returns the total amount of memory that + corresponding DAMON-based Operation Scheme's action has tried + to be applied. + What: /sys/kernel/mm/damon/admin/kdamonds//contexts//schemes//tried_regions//start Date: Oct 2022 Contact: SeongJae Park From patchwork Fri Jul 28 20:18:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13332638 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 17EC2C001DF for ; Fri, 28 Jul 2023 20:18:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 889EF8D0002; Fri, 28 Jul 2023 16:18:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 775278D0001; Fri, 28 Jul 2023 16:18:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 550EA8D0002; Fri, 28 Jul 2023 16:18:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 472A78D0001 for ; Fri, 28 Jul 2023 16:18:32 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 1D28DC06DB for ; Fri, 28 Jul 2023 20:18:32 +0000 (UTC) X-FDA: 81062133264.21.A1BA3C8 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 61CCE20021 for ; Fri, 28 Jul 2023 20:18:30 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WDJUz30Z; spf=pass (imf03.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=1690575510; 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-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=q09WJ0RoG3VU5Ry5RDVvaFMyJgqoOMJYC4LY2HR/5kM=; b=cW4313pM0S1vD8cYLQyFQBBDavk7g/nxFGjYmRtaxHQmAt4s9A/7nVv/NX48wTdRP1M1UZ ks1TGljx68TWGg0m6XdcZFeBX98pWnnE5E/WuOrYymsfaUQdZAFNtmGOZ9vvzjDupt08h5 ouNQs1yLhZxJzM15oOFGvxnfrnR3B4E= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1690575510; a=rsa-sha256; cv=none; b=zqpTAT2w/oYZrYWgT8hkHOscp6wNXF1iU4mflmBiOWsVEJcsU5SuPpZGriLMLXYukRIBXL S4/xFj3b6d6biHX6+UWhTbQ3Hkx7LRe+Qv5fKuOqJyHKhwGAmj3hNqWI2ewn7dC4QNwQz/ Bf4rjL6yHN6t/JJG2eo7lZXQPBpgwK0= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=WDJUz30Z; spf=pass (imf03.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 (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A583F621F8; Fri, 28 Jul 2023 20:18:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91E1BC433CA; Fri, 28 Jul 2023 20:18:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1690575509; bh=yEbF4+MD2fwxwTT+Hga32t2Dr/eR/mptRKFvKfgNyUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WDJUz30ZehPsXA+PQlXSm9ldhk+fPDLca0I+OUG/yn3vxepk0mbOOs2+GH/ZLVgH9 idSbNzHHPgRSd+wZmFUG5A4pMJ9xHp5IqXtfaMPxw7Nw9L1lNa1zDqNV+aKEWrzb8E SpKo4kEuErqGFwO7SQgmuh+u8bXDBqdIvDPCYxKX6SvpNHL6Tk3v1/R12mIXf3KnZU Q0lwrt0sVWMLxDpK7V0LGTQjb/CFLs3nG2e+LYXeiLf2AbeTn2AcPon1z/CCsEQubS pvh07PquPFmXHGk8+pCbivFx3M0GZqW177OkD5L/twoxcbMh2BbtU2zFuCZEGvX8KH 4jU15BTtd3P7A== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , Jonathan Corbet , damon@lists.linux.dev, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 5/5] Docs/admin-guide/mm/damon/usage: update for tried_regions/total_bytes Date: Fri, 28 Jul 2023 20:18:17 +0000 Message-Id: <20230728201817.70602-6-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230728201817.70602-1-sj@kernel.org> References: <20230728201817.70602-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 61CCE20021 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ff6bfw3mcmsozomagkgu4u91s1j4w1wm X-HE-Tag: 1690575510-267077 X-HE-Meta: U2FsdGVkX1/F0y2ncW9QEL3kbX/bKHGbStGmu3mX7YEnYCT5r1i/Gp0DUSXPnGNNUI2WzxZXNa3xqndd813S5vq/MQjrEBSUgta0yu0Rkpt9zOZr/6UXYb+TpmKBZr1o8Y7+cWeXVnbRBx+wyHqfzMAaPGmD8t+Pkmc1ZkLCRtzaiznN3kpJd7BcjJYI9ARsIfKlJ+dildVJudIeFgKJ56Y/nexIk04u5ZSODOJSM1CAYZ8zVTLaxfToceN0OaIM+tOSkHc3/0EAk3cZhvKMimbO1/wTaUDdZr1bW/d1efYnbhfWjKo0DlF0i38Z8NxSvCpibFG0tNT+iI3SYOfprPMGnUINv9BnpcAKllc7d4xG+ES0c5ot/DUztQ33rK5hmT3JmPvrdFdYB0tdKQPh1jXkCH1npwuT61+kk43j748WLWu9ApF4oWxOx89vDxO9PGx2FUfxg29NyV1I78EqqkRSHduEaT0Nu41yt0amJcADCCz3ISSXwZFaB3e7Gq1osva/zhHrp/0PyCir5hqoprjM35NKeXsOYfZTJZJMaITL17B1kCcIcDJvGQw1fbPovsiiaSngRoYEFNHQqX96Via2V2snBm+wkDZcMt1tufqSlL2dWN49bcreACDZH1FHiIXJssqCwNrlv9VLtJ15gRHTGWSA388hmef8Z4cH7NRQv4lkgqI4wymVo9lcTCJsGGc1Fq5i/VPqPTa/ImQk/rai9oGNqpKznB5Vyeb11uHa7awufMEgDkm6RW4O4hDJX4rIaTe/u1rdcSYV1BgQTzSFoynR4K9rHtlPZ6AnBgW7ORhG27kXyksg4ZlL0SXBIulGj8j5qQBZAPgXCeJPCYCV0PeCVIN4s6ZAfVU/8Eg/j88Pjr5hcVdfNzysqxFS3mLX9mP0pEhH006i2Vq/njR7G9DG6obslMJSSI2EkTLkjPiCp5OB97zpe/mWb++S+mycFQU0nckdZBPBnvM 5oAnhOKS A81b0erVgzMxJqPZCgPZqYdEUXRXVu4niwmMsfWxSC5NkZF0S5XjMgm1F9FKPAWZfc35dU4QKjeiNujFpgbX9qruWHUBFYgkKwBZ+CnbIvdrj8LWj4ZfW7VpItTwp5QhtrNzSI/N8NSUFClyox6VLxi3e6MeS892U8aEd5Jd4MzZonsXic8rFnt5rGVt2qLPlIx+I0dGSqgAq+evS1SEnVUkKD3d6uusg/eYPV5qr5Km0BFn6KP4oNEPhMEkPm63SePMrDAtI7+mLQvoDWoTowQhYMc77psKjqIcioYTtUgPw6YSQsrrxa6131hOddqrXJlwzifiPiXAG8xCEEUXNalJoFNtVaGRXHf2kUHV5V853KIza5liiOG9YYOyHLI2Kn5NyXESyjFK8Hh1YxaAkvvAVmAaQ0QRN4eKoCytgiHdJ8Eft+uArfBk52g== 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: Update the DAMON usage document for newly added schemes/.../tried_regions/total_bytes file and the update_schemes_tried_bytes command. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 42 +++++++++++++------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index 2d495fa85a0e..1859dd6c3834 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -87,7 +87,7 @@ comma (","). :: │ │ │ │ │ │ │ filters/nr_filters │ │ │ │ │ │ │ │ 0/type,matching,memcg_id │ │ │ │ │ │ │ stats/nr_tried,sz_tried,nr_applied,sz_applied,qt_exceeds - │ │ │ │ │ │ │ tried_regions/ + │ │ │ │ │ │ │ tried_regions/total_bytes │ │ │ │ │ │ │ │ 0/start,end,nr_accesses,age │ │ │ │ │ │ │ │ ... │ │ │ │ │ │ ... @@ -127,14 +127,18 @@ in the state. Writing ``commit`` to the ``state`` file makes kdamond reads the user inputs in the sysfs files except ``state`` file again. Writing ``update_schemes_stats`` to ``state`` file updates the contents of stats files for each DAMON-based operation scheme of the kdamond. For details of the -stats, please refer to :ref:`stats section `. Writing -``update_schemes_tried_regions`` to ``state`` file updates the DAMON-based -operation scheme action tried regions directory for each DAMON-based operation -scheme of the kdamond. Writing ``clear_schemes_tried_regions`` to ``state`` -file clears the DAMON-based operating scheme action tried regions directory for -each DAMON-based operation scheme of the kdamond. For details of the -DAMON-based operation scheme action tried regions directory, please refer to -:ref:`tried_regions section `. +stats, please refer to :ref:`stats section `. + +Writing ``update_schemes_tried_regions`` to ``state`` file updates the +DAMON-based operation scheme action tried regions directory for each +DAMON-based operation scheme of the kdamond. Writing +``update_schemes_tried_bytes`` to ``state`` file updates only +``.../tried_regions/total_bytes`` files. Writing +``clear_schemes_tried_regions`` to ``state`` file clears the DAMON-based +operating scheme action tried regions directory for each DAMON-based operation +scheme of the kdamond. For details of the DAMON-based operation scheme action +tried regions directory, please refer to :ref:`tried_regions section +`. If the state is ``on``, reading ``pid`` shows the pid of the kdamond thread. @@ -406,13 +410,21 @@ stats by writing a special keyword, ``update_schemes_stats`` to the relevant schemes//tried_regions/ -------------------------- +This directory initially has one file, ``total_bytes``. + When a special keyword, ``update_schemes_tried_regions``, is written to the -relevant ``kdamonds//state`` file, DAMON creates directories named integer -starting from ``0`` under this directory. Each directory contains files -exposing detailed information about each of the memory region that the -corresponding scheme's ``action`` has tried to be applied under this directory, -during next :ref:`aggregation interval `. The -information includes address range, ``nr_accesses``, and ``age`` of the region. +relevant ``kdamonds//state`` file, DAMON updates the ``total_bytes`` file so +that reading it returns the total size of the scheme tried regions, and creates +directories named integer starting from ``0`` under this directory. Each +directory contains files exposing detailed information about each of the memory +region that the corresponding scheme's ``action`` has tried to be applied under +this directory, during next :ref:`aggregation interval +`. The information includes address range, +``nr_accesses``, and ``age`` of the region. + +Writing ``update_schemes_tried_bytes`` to the relevant ``kdamonds//state`` +file will only update the ``total_bytes`` file, and will not create the +subdirectories. The directories will be removed when another special keyword, ``clear_schemes_tried_regions``, is written to the relevant