From patchwork Wed Aug 2 21:32:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338840 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 9901DC00528 for ; Wed, 2 Aug 2023 21:32:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id F41BC2801E8; Wed, 2 Aug 2023 17:32:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id EF22B2801AA; Wed, 2 Aug 2023 17:32:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D6B2A2801E8; Wed, 2 Aug 2023 17:32:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C72492801AA for ; Wed, 2 Aug 2023 17:32:31 -0400 (EDT) Received: from smtpin15.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 8E146C07C0 for ; Wed, 2 Aug 2023 21:32:31 +0000 (UTC) X-FDA: 81080463702.15.B0A08B9 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf23.hostedemail.com (Postfix) with ESMTP id A5DBC140014 for ; Wed, 2 Aug 2023 21:32:29 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mhAFKMX9; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.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=1691011949; 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=dT9svFhH1BBl0l+i3zVO020UnKdk/TIklIc6LYpr7J4UgBGr7bEZz7+8ZKegG0wwCQ4DhS qTMGlrnJEET0h3nlVaKcJWJZ33oUBnqusO98lZ5m2CH9Gaxwum/z4wqHNbhbzsqlitVEb5 9wlz4jk05QcP8nSDmbfn5OB3aHxFGD4= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=mhAFKMX9; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf23.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=1691011949; a=rsa-sha256; cv=none; b=AjIrorw7/JjjqsjX6GHbr5x2VeP1fu3QwHykxAWmQJTzYo7+Udq3cBVfN/0TAuFDKA9QdQ 6qv7GR/Bbtz9xX5hpgaO1NovGS5yTkxj6VEldJeLRppq3CEv+sqQyRT4PDdPeKjw/vhukf /HL6t/+WYS84HIUjXOGKdiO5l4PpuKk= 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 B66B661B40; Wed, 2 Aug 2023 21:32:28 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AE37FC433CA; Wed, 2 Aug 2023 21:32:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691011948; bh=f9khGIJiHzKXZGP9/5olstezaDHUu4yK0qoxQ3r57d0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mhAFKMX9BWvgmnVvVuE+YKjYxd17hsK/C+pCyLC9qL+02hqk3arsp5C5P1SP7ibv0 nx029Y6xQ5WdsNc/dcokX9cPYD6v4jxXD+bLFUGTnqZU+CpAM2GL3dE0DLf/mKv2MK xyGswxMq/DERqXK7S1dRnRlV/4pRuC92wzf/UhpE21z8l69eE9aIiXl2zmZEy0MOIk uO/99Ugid4LYO9nqaSqVwud/N+jYnqajNXZnYo1XU1Tbzr1krF/BB2UH87kK4D/X/r piUAiCRGvLeCU/R+wJ6IRqufBUYXGSA2yxraYB3SelUuc8r1adX3xDSK5CBGHJtltp EpVf8hvegNgJA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] mm/damon/sysfs-schemes: implement DAMOS tried total bytes file Date: Wed, 2 Aug 2023 21:32:17 +0000 Message-Id: <20230802213222.109841-2-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802213222.109841-1-sj@kernel.org> References: <20230802213222.109841-1-sj@kernel.org> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: bsenmewfzarkoz3i47e6f35czesf7zqb X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: A5DBC140014 X-HE-Tag: 1691011949-636533 X-HE-Meta: U2FsdGVkX1+9JkujoeFkX4lMLKnZOpOz6cyBQLbGbNVmxqUf3YW6unRyXN0YqRPdKc7GcXxPdqx5r+t/+8pLPOp7Yo+01PwPNQldbhCHRhk/GRUB05NkXfMpcojSuieo4zPwDwsjf5myfaE+cE7yJgtc9BS5w0RR/cJOjtQgsmQVyWsh6ubaI/sfhFCKzOZfn7MgBkV11CCoY1cYmYbOGS7gVOwUZH1HvSle7Z7MWeXHUIuq2CH1okByB2r5ngxdW+2SKL63V1T1p5Kf+C0vyu0jrzgDHKHtg5NYRwEQtTAP2BQbiouHTUVpYwWbK7N4VHyRBlmZaD5t7loPWpj6p0+X6Tr6Iv3IeOFOC2hRXlidUIvhpeksKjwK9ieRcTChIKjJtL70c5Pf1087OtT9Z/DG98sk8WjmtP4m9IBwwourfb2dyyG1hQYzArLWuzQgy0MYpQxFofkaipMfacXBmAM+a0crkhbi0f9o2LQDyAy/qZtWUQpckYCpUPsCVrXoVq5BcP4ueDsqs12MGXBIZZPFwb9ya9ozWYIqSWZIjUfiguZC7ATY9n9QZwa6oxRlRcUtIGGDFMZM9v27j753MCLWcYoT2HO275zFjI6++sPSCa/vHSgx8EW1cluEmWMmebmocc9+gLfHRei3Qbs+QFMO/jk4xIycZEuRFyWgWPKjGyRKQxnUOlxO4NloacFSPMTpnM8W79qaynsFVffQYCmlACm2QdrJWx3bQcr33hp6vp28voj96Gjq0asGWbv7SQguc98U8ZFEQw5cGUW6ccucnmmrqWS2IfTqT6OPaUE32Iv5jv06n07p7SEsmBNJbIpLkQdeqraxaalJzWe8MLDtFA9suNYUvqbg56/ukY/HFdGPdT7VMRNG8/iH7UnSRVAL6y/k31oCVxXgfbNrfPxG/60pGpKjy7W/1pvScMvBpkBM1NKwOvLuG99i8Qcn8U3iCKfM6WU3h8P9k9u lyER3e/f tX0tfCf/uWeBnZxTUPfoMQeiHHTlnCLlBj7jEyKWTMgHXP2OsJ0gjqAlz4MUkQfIcUGiGVPHIVZd48gXOy+kzfej/P+qMryidu54fPsgIY5KhlS+ciqEpqKbhwd9T5JrkkzOT30ATpL+68RdrNmbrqw5Wk19jsQEpMxXxP1pbg0WMA3RCnGKzCwanHFV5+XzMLrmfbMrZ2MwxAXhWoGqsjv5s2slZfu5+9KgAC19RDjORlMCqx/zXBlSTfNFsoqUfTizX6RYC8ITz0EjJbyJtF9JOzZP287MV8vBBEWr5XGYIcCB3ofFS/kKJ725ToQY4cQ2OQ7K9WUlTziA= 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: 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 Wed Aug 2 21:32:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338841 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 76F15C001E0 for ; Wed, 2 Aug 2023 21:32:34 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE7E32801E9; Wed, 2 Aug 2023 17:32:32 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B71762801AA; Wed, 2 Aug 2023 17:32:32 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9E8A92801E9; Wed, 2 Aug 2023 17:32:32 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 8A1922801AA for ; Wed, 2 Aug 2023 17:32:32 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 0763A160DD8 for ; Wed, 2 Aug 2023 21:32:32 +0000 (UTC) X-FDA: 81080463744.13.EBBA754 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf15.hostedemail.com (Postfix) with ESMTP id 55A04A0014 for ; Wed, 2 Aug 2023 21:32:30 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uGGKjcUz; spf=pass (imf15.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=1691011950; 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=Y8y6ZFofqxuhQim+d53dFU3tWR7Oq+gWsiH2qLyaQSA=; b=WzZuoWTXs/t8aEDRdMNtTAjkWjbaMqFepFrmwItoYkwmwwgHUZgjBYuE+rOpyYw2Tp3Qd/ qkqlxwfADusyUPhf+LUmt0sjf74uEhYPj8RjMm+rVRrjj5CeRyKZGuHQIsPMmqfTaduAMz Qulwsr38vT8NaMl4KCmYyx99UwCgnMg= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691011950; a=rsa-sha256; cv=none; b=NuoVZmWd3gjuVDtYD0+X3d2af2a5d4cJcSIVKlTbE7lBukMU+CsUuyFezsEmDvYfQ5pih7 +UhkRcchozllZFemKq5NHZPCyj7Ex7iFhBpvXJ2jX7rq7S3hHyOVrK04sAYrxYb87SlKA1 SV7/2/jB51X+J8xNdvRSjdLoSWzpz+k= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=uGGKjcUz; spf=pass (imf15.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 6E00D61B49; Wed, 2 Aug 2023 21:32:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 611F0C433CC; Wed, 2 Aug 2023 21:32:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691011948; bh=ywwkrzBmUQl1yAbJ8J8SAzYo0s1zHyng9N/GQVlAxuI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uGGKjcUzdRVYJx6iCGw2mNOxfYk2F0Zbi0payg8qfCkVAxiswPvCfUtoycnPmji2R 9xCQe4RbaWucotEQRU7vUzK/8Ph+JErkYGKaYt4/JLfv4+IA2OlbtCl2dn7NZKcr/C Np+li/YqLNEoHSBJBkHtFRlpEl4aePIzjwkNcHooheN5Zmi6E0+4tbPwHPAkCZvvgA mQQEB8Bt71voaV2qubWVy3vy7fIq5Re5P7IwIMpjM8hE3yhRfSXYxrrjMD1wVm3PG8 OEBM/FFLVOr6nDOrAwuMTbMp7CSnSx1mPyl4UwLJYYIzPLyho1Xf0LGF9qMJB21chY DFaVUjkDo4NUA== From: SeongJae Park To: Andrew Morton Cc: SeongJae Park , damon@lists.linux.dev, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/5] mm/damon/sysfs: implement a command for updating only schemes tried total bytes Date: Wed, 2 Aug 2023 21:32:18 +0000 Message-Id: <20230802213222.109841-3-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802213222.109841-1-sj@kernel.org> References: <20230802213222.109841-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 55A04A0014 X-Rspam-User: X-Stat-Signature: 6tzb1fsr5xbuyd4ax9tw4o4wajk6zm3t X-Rspamd-Server: rspam03 X-HE-Tag: 1691011950-8868 X-HE-Meta: U2FsdGVkX19OhuecntUMkYOfr3sCdCyM+oq+nzgxNV6HsWzuIgBl6JONHizLO+46klFsJgCVPrjn3WkNqIIILOxYVdwwXrgADS4K9cvWS+k75apFz5DCMBdqILfvlZPdB4Se31YotSSE0brz7/cs4Pir/C4kVsEckgIsmIUkDJt4bLuUo8ZPs4ulv65fc93nmbb9fmjgVr8L8Un2kieyearR4fcrzdzwOF30eKqK7AwM56alT3EQGZHZzW89sR8sBJtWpJCIASHCKF9X7cS7kJ7p/7SlU2TNX2YZCdL/YFlRIkDO/OES9IwtAKYS86+WkhQI0z/aMPoGGHJzR8V22zCTM7QdD+9pjfitV3OdZW+eYfsqLucZq6p/O9iEx8taWyF18Za/FZlyy63S9Z4Y8SCTP2GAbTrbxkpYNdlrGESTShwCXaCyAtiiYDQCUC3KOPkkB1mca7ngp3KvVXfqroor7xSoUL7NLw4AbTVO0KmxJ0XjD/ZbTVn1waKrOSsnMaDd/vgiLBbAd6KoMq4I/V348mAHj0Td9RNU7FYkisNbQ39rBLLk2aM9x5bT721yYSeUZrmJZDK9uxogJxX2Y4gbn46byqJ1U4Od76FJ2EN7AcdONamUURJv6rnAzR5pocTmyk6ijFF4o2xKUC54yxMF5l0xUNOfrQeL/ccqglrXCWKly5xHZfJNklRoiLIMTU65t/ylYz2OW0/XfrcfcoMb9ik5ehscGu+coODUFoa9xG5zvLgZtQOds+34d7ijqmOwNMYVP2ddHB3SHONvYqqD9Pph4vnETPijUb81u+/Kp+5bOLCETm7wHbWxz5KzWMH/eoqfO9zDhSz5Qa+8JlI4GeXlBCwf+O1oY6pvnqfaHxy5ns2XRb68AldFXQRbvzVERQm67+mPLLkFFGA7/rmBMUr0ozNPA8ec8K+WJWq8C5v1hGE0ECrAWIKotcxpxcXb5ON5es0XzBeKsFG Jow+Yqnt zMjVw1o4LHZnovPGyNDc6LHKF20VA1Z8DujdgFLU9BRXknPqq+r19IHFUiNRcKGVDu/oLQjybIirwAGUrAngwgmUr0V+Ja4VEj5Yn9Z/zrPIhr93MRoJuQkMoGKNhXmPAIrTIqAXY5lJ6zOMUEa3pj8PzRmhTalIiI22lW4uK3cMXe1OG9VBTnOoPmFRx3jukawrMkk0pSaKgqKLpEbwl2L9VqbDB5LHtsorpqwGATwPuGk9Cdt+AQG2cOHVGJwoE57KVRxB/yRYMj3QGzJTwTV3zFTJbNu+5a9KxbXkXmfe79O+09lQZ9NZL757ELP1UMJYR6N++HNpiXeeglTG9gBYw4g== 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 33e1d5c9cb54..b86ba7b0a921 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 Wed Aug 2 21:32:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338842 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 09D60C04A94 for ; Wed, 2 Aug 2023 21:32:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3F9562801EA; Wed, 2 Aug 2023 17:32:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3819C2801AA; Wed, 2 Aug 2023 17:32:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1AEB42801EA; Wed, 2 Aug 2023 17:32:33 -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 01DAB2801AA for ; Wed, 2 Aug 2023 17:32:32 -0400 (EDT) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id A011CA0F48 for ; Wed, 2 Aug 2023 21:32:32 +0000 (UTC) X-FDA: 81080463744.05.8F3671F Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf25.hostedemail.com (Postfix) with ESMTP id A9AF3A0019 for ; Wed, 2 Aug 2023 21:32:30 +0000 (UTC) Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=B8eKOqA0; spf=pass (imf25.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=1691011950; 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=ZvrN9y8/auGHJwMa31MiGlvj9Wbl7Ma0Try/eaYCec+NZ8ke39yVjlWhTmHt03PdXz8ttB 6zus/rfCGOxoohWmYxvSiTstN4DzZBpt25QKvuq82dKjx6aq+vRwrYL/kWZd+w7Pn6kwtP 4mGLUR8svQdl1skqAIAADglDpB4g7Nk= ARC-Authentication-Results: i=1; imf25.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=B8eKOqA0; spf=pass (imf25.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691011950; a=rsa-sha256; cv=none; b=Bomqp744NXSNr0mhDCADCJstJpfQIy/lGdnujLEEqNZ8mQiygO2qfO8H3gFv6MDJ+jXp3/ aYuDZ67TyTXDcn3+TViQ2OST5nDbC8ypw22hWRM7vIFXhDKEmQttbFUtdVj9Mg+aAve+yr xZFowfZoKub2zvYztxeiyDGm//7tCRY= 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 C534961B51; Wed, 2 Aug 2023 21:32:29 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14C40C433CB; Wed, 2 Aug 2023 21:32:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691011949; bh=T0fZGypLM6vPpWaOxwTR4DXjjDDCiOe0tcjb/Q7FYeA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=B8eKOqA044Ky8Eh09y4gIXYN9t2lUUZCL9kmmIy/8/wVup+Fz9JompcEKnQSE4jKf rNdmcJT9xd0IfodlTlcndLvX2Na6sPx1JbT9RuOE/wx2KM4b7YbEGyLkffuSceZ+Bc /l2rcKJrVQGxQRjm7e7wQ/sOIx8A2X90cgjvwQ9FEMNRdzU9EZEC7larfDkW0RmVUa EFomDu/3WBUrWr6v4wEUKLbqIRHSxfQoDfMG2TqcAFphcofllNeSdaHPsefS/bArI+ SqYi4oXNcrkHbCEbhjQOaUDlg/0qyd4dBsqQHZEM9pIX8GCakb9VXQJvvEx/nNj81F BQ+3vr2RfZiuw== 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: [PATCH 3/5] selftests/damon/sysfs: test tried_regions/total_bytes file Date: Wed, 2 Aug 2023 21:32:19 +0000 Message-Id: <20230802213222.109841-4-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802213222.109841-1-sj@kernel.org> References: <20230802213222.109841-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: A9AF3A0019 X-Rspam-User: X-Stat-Signature: zwn9s5xocuwfk8qmdf8pjb9nqcjmyp6h X-Rspamd-Server: rspam01 X-HE-Tag: 1691011950-239140 X-HE-Meta: U2FsdGVkX18afadhPLBlxa50MQ12zXYhGbknyHcugF6/BeF8usHueq0DDCQPr6Ho73Xygy85me5hDNySKUJD5OnIXddVWjSGQM03j6HIXWsCVH+rh1mv8Nu3uGvo1YAOWjPw4BNoBrUjLjRpJjqIEifa6GkJbyoq944mnbKnDpmXdO1wWMxQGszPZkyPiFPUTmR4awDY9sfQ3ATcMTdzIxCllPMOH8FWuJrDTbXiLLmevQh6pJi9in+0ZdH/aK2Pty0ZYmWQFN0qGKBXpZ2yIb/8UFF/Bdxa7vMtA9K6YSK1CO8U/2IUXEa/EpJToD/EXRQ9wNADW3uKw0g6Rmvoew3p0vjjxFElBMBMXvgLtSRyrqvIjnG1mhDr6EZTXs26RtNNwgeU124oekKsKbczgJiTV5XAaijaCdJUGSI3IWNjRx1p5QfCYG0M6QIZxp1+QbwLWrKxbKCZnxm0YiLC6/E8mCqNram7I79F0gC+vD9ZPHaQy5xgR9p1LOjTogCyEmznANMGC/pvOquvDpVAkyK/0VswHQw0sJAf0bgPYaNPQxTgFS38Q/Z4VJRgiQqRpgTUtpaixghr2iJv5agtKASpLaJdsq96dG66pg66yEdfNotR/5rVhJKqfjHDdAGbRhf4DGmgrRP8p1ptxx+iCRhEFKeuGZlyicD3DX8EGTaP4qULs8yrfmwSw3DnnMFd6yPg6YIt5XlH8/Q2I56ubBgpLyzyppt1osECoNFfK+qlVBNwUJ2yt2SX+LPJMobNn6GuwngIGLgiqf0YgXAG94fSbuta1d3SBcz/L7RSyW5FbynlmFgQUuuI+V42NKOtnAz0enB4CQXDwdDXbE8HYgNx2KEvX1yoiishuecNeTG7ipsxVi9OwSJet/hMWrVti3IlOCHeNJDc+tjuWJRjJvIcIugC0/N8JIzC+9v4WdaW1Ad/Seet/KQ2HyHMGEKUzLfF4T24Of2QeFHdJ+6 5EPBp6kI /RlPLtk4hKov0Si15uzutQlTkCLeTIZjgz31nVyTgtB1BNaEmQT2mv4BMVTJItp0gFHbCWF6JySUCtqGXsN5AiEneOzfvybjeoSd60/X+hYVcxUcaNzKkGLbeBlLtucExjekE18QB2zKQgURPVQPkJTloP4WqOiEhWWK5r4wj3CdGLh82kX4xRxoCeGBOB5qb8Qap8KURskJY+kVe/Tc06NhIXqNpTEiyeBmto4izx7q/vuA8y9D+oMqEqy5R5RvI9XgnzZ40MWxhTBYcH+GAEHrZEb4ziC7XWlA80f7G4v1bAfXv9hxbJ4X/f3w9QBdpSbLqeH7edJsUB+JDBrNXutntmX2ml/AdeTaRKcbVnfO0/6GBLwkFbyWruS34j34N2dcMPSiQZBOKw2H3ffrHlWcDWQ== 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 Wed Aug 2 21:32:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338843 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 760CCC00528 for ; Wed, 2 Aug 2023 21:32:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A88222801AA; Wed, 2 Aug 2023 17:32:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A38822801EB; Wed, 2 Aug 2023 17:32:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8D7542801AA; Wed, 2 Aug 2023 17:32:33 -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 51DCD2801EB for ; Wed, 2 Aug 2023 17:32:33 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 0F76C120D45 for ; Wed, 2 Aug 2023 21:32:33 +0000 (UTC) X-FDA: 81080463786.30.6FC7F14 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf01.hostedemail.com (Postfix) with ESMTP id 5132A40011 for ; Wed, 2 Aug 2023 21:32:31 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=N8XK8bu8; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.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=1691011951; 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=SS4OIxsB+um3t5947/M+1rp8UfziWiBK9Q8Z4IR+moQ2uuEya/HABFCExbE4HA+s8zP02N NbIQ0Uu+XsnkMRgquxC9BAGTfrtnhO3EPqOlBoCNhfUh+7mdSYgLEJKzNkCotmhMZBohIc 4LoDrVSAc88gyfQxjy6SXiVitnnp2Nc= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=N8XK8bu8; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf01.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=1691011951; a=rsa-sha256; cv=none; b=PuBOy7qcrIvfSP8hhK9KWdSRqu51H6T9BNNotI6zLBqdRs2CJCbV/UnUW8nTw+bTZPcEO3 GPMYD1mgdGmJgAaWFZ6KgOvKVJT/YcnBpnTf0v2lTcsTE4gax8OmSUN07dyqhfI2FEWFw6 xJiGu1WIWP9O6XmWrEO7RdTjaCcpR/4= 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 8B89F61B57; Wed, 2 Aug 2023 21:32:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D12A5C433C7; Wed, 2 Aug 2023 21:32:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691011950; bh=hZi4JMj8VgF69C/0cI6pgbuOwe9TusEzinxMwIrTwRU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=N8XK8bu8QUF7j5mokMLp4WthiMSkYqCy1cY7HO0GbwC4arQZLodLipZSG5aSuS0s0 a3brhyuqU3Czlf8mRzp//Te0l/DLvozy4eCLuUXIeVuGhH9oAjBoGX4Kgw2glbMFfr r8ZRcAJavf+7zMP6kgLEFRY5NZlrtUIdQ966iL4IIWKYkl/wj4g46mtFXYANURfcCv 5ZKTfkfycATaFOVl56xgsVul41YgKaWOm/C1gG2UuYJBSUjCDXbBaSNr7qoX6bnPcX aoMTHxcWDg4YbhqjwA9oiUrVf6TTHyEEk+ESpebMbe+tARmMq//AJ+I2leTRzzfyls z6yzxG2O4nt8A== 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: [PATCH 4/5] Docs/ABI/damon: update for tried_regions/total_bytes Date: Wed, 2 Aug 2023 21:32:20 +0000 Message-Id: <20230802213222.109841-5-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802213222.109841-1-sj@kernel.org> References: <20230802213222.109841-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 5132A40011 X-Rspam-User: X-Rspamd-Server: rspam04 X-Stat-Signature: s9od4xnuhm3o98hatms63ps9ghzh6syx X-HE-Tag: 1691011951-736707 X-HE-Meta: U2FsdGVkX1/pTQM8Cnk3EbQAIJupQ1BkY7hEjpxZXextMDu80lUIHfpwjL0+chg3LDr88TgSAZIVcyCChVXVixNKWbmEq0xIS5JL5RwB/Bc9go2apsp2R7GQjLorTj0JJtmJ/xINXZOOrmUmbnKrIgIYElR3QGsMwOOZCiX6fxp9UnwY0S7foeoQVBq1Srlo5tm9vNYYy2usqeoj6lLZTpsbEak1h8SO75QRL5YfLYV08WN6HReDi5CI4LhWu7cJJ3s71itHPCt/Ccvgdko3SQM3PJsP1Fk6jOy7GOzxd+Y9/LVZB3kS3pQ5nrxUXMozdgceVfgPTEry7b83vJIGYl5BZYH7Qid+exK2+gE9jTCrU+juzHu3PFsbyrKw7rHOJgomF9gQh5Pwg2EamI7qwOyUY7WttgTGYzROVGClGu+dQOp/mAkLw4wN8Che9052Fvj8cEy8wuGWKTv8H4D6EsS3vky2bAMfukxGX5QUzHKO6+Q2i8q/5+l/3PBKo401+EK44ZWTZeB5a0zOz/Xw1XZ40eHPLXjQKuE5TZ88GiD15YhLzxOSt9AzowNtInrv0XgXPUKsmIe+45/XkbhyEa7FR46VG1SC9e8loc8tpGZInxlNfh+ay83AlpTYJ8WTKFDIay79Vx3ookttVhLtU53BdBH2XdEbqIgMgQ3XzuWyMQRxNl2wXP/gFZzBYl/5md1THIuJdPN+BzEH5zV2qmN8k3WbrxReO8i+K1swBOLTmyDzDlGS1mXVSQcVqKifOiFRPhxDK7hZEePW5cZMyjbLqhK4Dm4L72QIC0wdJvGdrTASniOqAxosn0yR8K2uy2Q1t9o7YJEHfzRoy/wg6EwEWds4cYmJ3yr7VnE09v8bLFqHjakmRmYXothjjCFMPgPJwSgo8XZ08I/nTdFc9QHsF7xivpraH4i/VhYUaTI8FEkpz9v8bHABgYT51Tyuue+v7eBuBX5cAsMEGmI oGv+UCCc zI+LiVPs6mIpC/xULyR8XhTxFm+16nseO9ac+wJRDDzbE0hWvtvmO7ilLTNgmrMvAzkQnuTDyrxptIP3cbwJTiWBCPX2afpzciNgt4AxLEx+Lpb+cb9MQPy74oQVVbgOvmZgpr9Nxl6kwJ4dSJypQ1m/T27++0rGxS3Pc8hAMlZy4t6AuYR2M12om63PoiyJQ7d2fvKJZ6vRHBw1LI3SSG4QsgIVhLNGLJ5FbwPpC9OWu2l/HIts8u4Ipvrh0Ex5usd4z6L/Fr/8+Tcm8XSHHbFWwjtjQHn8q4JDA+rdCZGLGqif/x661Xt8tPCRJWX2K9F4+/XMI1RegDtNTvoJTXz1evGMN+YnmXqp6NwgJOG6TxPMaCYCa4XUk297567jOnIZbwLg6zr2ig+XArRt+VrBUewpr/0MwOTESQVzipxYyiaPw2wmAA41vwsTZpYZQd6tW 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 Wed Aug 2 21:32:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 13338844 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 74880C001E0 for ; Wed, 2 Aug 2023 21:32:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D48912801EC; Wed, 2 Aug 2023 17:32:34 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CD3782801EB; Wed, 2 Aug 2023 17:32:34 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A13312801EC; Wed, 2 Aug 2023 17:32:34 -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 885F72801EB for ; Wed, 2 Aug 2023 17:32:34 -0400 (EDT) Received: from smtpin19.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 5CB8E1C9F9A for ; Wed, 2 Aug 2023 21:32:34 +0000 (UTC) X-FDA: 81080463828.19.73A9C41 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf03.hostedemail.com (Postfix) with ESMTP id 9AE222001B for ; Wed, 2 Aug 2023 21:32:32 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZqyP22dR; 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=1691011952; 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=FAIixsjyWMHm+puKw9fWav5EK45e8rJQXcqvbU7FWm6PW4sGwWu6hZ+YHgj/tKqj44KgCe 9xfA6XctVKAvKmm0pGWfXgwxxkh+enowZvphmHcr0B5GXDvozrTzPMoDMBYLE/746WmJ0u ucEVxsYoESGVm1CaMTGjn0kzbsV3UP4= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=ZqyP22dR; 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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1691011952; a=rsa-sha256; cv=none; b=qAWMacHdOMBYX6Ojph3Pm9yKhvBeJdn0+veThK1cSNFqbSw7BeIpn7oNII0CgXknobW8HP EAkf3wuEPnFGX/Kfb6Cywx0TQL0PdeF7YvdlRR11YToz/Pbw3tl/P2AZs1PhFH9NyRUVZA s73RdQeJ7fUWrn02wnxgfjq33HHdoA0= 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 B602461B38; Wed, 2 Aug 2023 21:32:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9802AC433C9; Wed, 2 Aug 2023 21:32:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691011951; bh=yEbF4+MD2fwxwTT+Hga32t2Dr/eR/mptRKFvKfgNyUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZqyP22dRe9txftfj0mTUSKJdBVIfJS1fQ0q1DN993ssD71Y/JqUWnM0H60utm4t2J uMCZdbNjNYBEz2HiAbC4KO9ZTcRMCAlxOo93soa5DH1MH2yNhVq6MNYcRbGNhY0ZOB oHCr8oMfDxScd3CpAtFHklMIqLUyywRvNsuJmsL1Z3afAKXlBqtzQuw9liSjCXiwsG ZnWPOJPpSLsqkpRJCTHsn7DIS0hIFSOz0BR+yYwpUTZ8B//Vm6Re/QFwCS9iW9aQKO rVZEF0cDLe1gJGf6HsNUEyr/1p45zPFuEOX8VrD/DD6sBCE7YZRLXHgcaXt/NP7SrL sQHPQ24C4gGgg== 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: [PATCH 5/5] Docs/admin-guide/mm/damon/usage: update for tried_regions/total_bytes Date: Wed, 2 Aug 2023 21:32:21 +0000 Message-Id: <20230802213222.109841-6-sj@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230802213222.109841-1-sj@kernel.org> References: <20230802213222.109841-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Queue-Id: 9AE222001B X-Rspam-User: X-Stat-Signature: k9fdrkmmozgz95e8crebxhyngsq9psa5 X-Rspamd-Server: rspam01 X-HE-Tag: 1691011952-566225 X-HE-Meta: U2FsdGVkX1/wP7ge+hlR6jY9FuLKBiwq0A/3KC27KTh+a+y/J+h6Jv7JzumE3KGk5vk7hlrBL4atU3eoxlY7LTWC6hDCK8oG3w5U17FDgMcybSJ8zzbHdfssHpiOvevLm+S7m3j7Jd7/gxVutNL2TJpXtYvqEr5aaPbre88Alryl1GLngQFQrcqkNCVEqKy1uy+C+mNkVcDVlyvE979D73kbHfnDJVtVNFTfkOk6K12yImz5/LyX/CvUZg6yVkErJBTjTwhn/9yove4fImL2DZu97YSftz1LLgvO4vM5gWbYpS+Gtoxa4HsNZhzPHBAyka6etTeEgFTqkyQKnxTOn4DWOt8fQdfTSV6jC1S1ARGe6v8kek+SEt81U7u7WhH5FwNLK1Tlf7OCs/uBcvhJ0fn4GZHGBDd6ob5cDcqSOCtNebtVij5r6gtpkRTENy320kfNMBJ+z3PIMUJ5o7oU6m8ShpJDKLsaT63oB3cV/N2JsdbkZ3NNJwI3Jf8BVCX/4JptOktEQ8Ey7Eh3bN0Y4RLdOni8i5QRRmoNDQgruwPTms1Lj3+xGTSjjVFCFk1Fuq0lbiGkuk+Euyd8Y0Eb4WZ5FxjaSxIIpW1LcokN/f791qIPl3689zokrw/GOOXVpsovh6DrAJJSlDtCOI2iVhMC7Kiv3gY2s7sBAWh8mP+WQ1t/zvDIS+q0Eb8idl+J/Mrl6Peie3MqYRMg98ucBNwekItP5YPu4ym14TZirBEjSixSKxDmcMxiNjL5jPCqCUB6LchVuG1Da+6yF0gXbhUcNQUHyYSvVPJ1jQYiz8IgDQZCzpLGQFJZ+e8I0IKinrH9zLK77qNxpF2jYltyQm019iHmG7lSk/jYw+Bm3DCk7pFomRaiWaNY4lj+ZEa8xFsPGgTc6FD2mZNdPWRR5jSmeTBTIVYvV/Z4DMFYTmeYcucJqrZKe4r106w4/hx/jaBp1UFjihk4GkaGcPy ZZGfE85F D9p58ECwKnM7JV8XA0fn0O89P7tAEu5eM1qR9gj1lhY6hrwVGzpGQ+HFG795VAcKrF1dnhCmrksgLFUctlMpUbujjZyPXNnMV1liuuYrGRiXPCJEp2v9tWOyErJ/0awDhE+uVpbkfC/GYsSya3Tp9zpUKAsgdlm1MuQZLgti8P7VjH8i1dZjJ2qKFKCoP3xsJXng9XwE2fXjXzsk9rQj80Vcma3ZYNylbjycHLTW+hPktG6r13IPXu4m+RgR4dVoKty/8U7gb2YKXG0jZa+Zewp5LokkbSH8YdClz+k8VuVLjpK0vvqptEDmHImGeCh8R6vHIoghm9u18iCttgh/cnXnpDcia0Eyr4TC0a7cTKfmmbGhdbNpjzQIQ+X27iUUFAfXvgoVIbfGHjAWZ7xtDPK2A+b5nTXTGUK5XQR865m7diERCvZikBeK2DA== 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