From patchwork Thu Dec 9 13:18:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12666555 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 525B7C4332F for ; Thu, 9 Dec 2021 13:20:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 259126B0078; Thu, 9 Dec 2021 08:18:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 209076B007B; Thu, 9 Dec 2021 08:18:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 0D08B6B007D; Thu, 9 Dec 2021 08:18:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0158.hostedemail.com [216.40.44.158]) by kanga.kvack.org (Postfix) with ESMTP id F06E36B0078 for ; Thu, 9 Dec 2021 08:18:30 -0500 (EST) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id B2C0D8245578 for ; Thu, 9 Dec 2021 13:18:20 +0000 (UTC) X-FDA: 78898309560.19.80C5940 Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf26.hostedemail.com (Postfix) with ESMTP id 1D7B014000D for ; Thu, 9 Dec 2021 13:18:19 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id EC060CE25B2; Thu, 9 Dec 2021 13:18:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9B9EBC341C8; Thu, 9 Dec 2021 13:18:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639055894; bh=mK2nEZXnZRM/OafiraNlq9hogkM+YDJ/mLO4T08owA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fSljaKrmzEuBRhBwkVY3vMtIZlwnt4myFFDpVfUoIzsjoRWVGDfX060/EsxTHJ40Y OKkb7Kf5c8Af78yQGSqvKPxohLRTI1+7TmQAsnUUUU8Gd43CG1l7IbMjqH9dP1VlHx 7SrxU89ebExSuGjxIV6xB+VG6x5V2UUt/+Dccoz35iVucsYJ3M05myRVSfiaR3C/cS De3si+zY25j5oUoLp0LFzQvZ0uP9KFKG+C0syM2PEm8j8c8q1hwQO5jop9Z4CPIjQU m79OFu+KWPCR5doVgsZYWnLAMRbgCKEhu5RtD/EBFM7FQ19BeWd9dvzPs/P7G5lElx MHNj2VkRqCJHQ== From: SeongJae Park To: akpm@linux-foundation.org Cc: corbet@lwn.net, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 1/6] mm/damon: Convert macro functions to static inline functions Date: Thu, 9 Dec 2021 13:18:01 +0000 Message-Id: <20211209131806.19317-2-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211209131806.19317-1-sj@kernel.org> References: <20211209131806.19317-1-sj@kernel.org> X-Stat-Signature: 9qfq18iszo3cxomrow3mre4ago16ea4b Authentication-Results: imf26.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=fSljaKrm; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf26.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 1D7B014000D X-HE-Tag: 1639055899-481728 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: This commit converts macro functions in DAMON to static inline functions, for better type checking, code documentation, etc[1]. [1] https://lore.kernel.org/linux-mm/20211202151213.6ec830863342220da4141bc5@linux-foundation.org/ Signed-off-by: SeongJae Park --- include/linux/damon.h | 18 ++++++++++++------ mm/damon/core.c | 5 ++++- mm/damon/vaddr.c | 6 ++++-- 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index e2c8152985b7..2dbc1f545da2 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -399,14 +399,20 @@ struct damon_ctx { struct list_head schemes; }; -#define damon_next_region(r) \ - (container_of(r->list.next, struct damon_region, list)) +static inline struct damon_region *damon_next_region(struct damon_region *r) +{ + return container_of(r->list.next, struct damon_region, list); +} -#define damon_prev_region(r) \ - (container_of(r->list.prev, struct damon_region, list)) +static inline struct damon_region *damon_prev_region(struct damon_region *r) +{ + return container_of(r->list.prev, struct damon_region, list); +} -#define damon_last_region(t) \ - (list_last_entry(&t->regions_list, struct damon_region, list)) +static inline struct damon_region *damon_last_region(struct damon_target *t) +{ + return list_last_entry(&t->regions_list, struct damon_region, list); +} #define damon_for_each_region(r, t) \ list_for_each_entry(r, &t->regions_list, list) diff --git a/mm/damon/core.c b/mm/damon/core.c index e981fb40052f..70771cf7da89 100644 --- a/mm/damon/core.c +++ b/mm/damon/core.c @@ -767,7 +767,10 @@ static void kdamond_apply_schemes(struct damon_ctx *c) } } -#define sz_damon_region(r) (r->ar.end - r->ar.start) +static inline unsigned long sz_damon_region(struct damon_region *r) +{ + return r->ar.end - r->ar.start; +} /* * Merge two adjacent regions into one region diff --git a/mm/damon/vaddr.c b/mm/damon/vaddr.c index 78ff2bcb66eb..68d9e4134816 100644 --- a/mm/damon/vaddr.c +++ b/mm/damon/vaddr.c @@ -26,8 +26,10 @@ * 't->id' should be the pointer to the relevant 'struct pid' having reference * count. Caller must put the returned task, unless it is NULL. */ -#define damon_get_task_struct(t) \ - (get_pid_task((struct pid *)t->id, PIDTYPE_PID)) +static inline struct task_struct *damon_get_task_struct(struct damon_target *t) +{ + return get_pid_task((struct pid *)t->id, PIDTYPE_PID); +} /* * Get the mm_struct of the given target From patchwork Thu Dec 9 13:18:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12666559 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 079F2C433EF for ; Thu, 9 Dec 2021 13:21:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 196846B007D; Thu, 9 Dec 2021 08:18:32 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 145936B007E; Thu, 9 Dec 2021 08:18:32 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 00CB36B0080; Thu, 9 Dec 2021 08:18:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay037.a.hostedemail.com [64.99.140.37]) by kanga.kvack.org (Postfix) with ESMTP id E59F06B007D for ; Thu, 9 Dec 2021 08:18:31 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id A130521A43 for ; Thu, 9 Dec 2021 13:18:21 +0000 (UTC) X-FDA: 78898309602.03.C2FA5EC Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf16.hostedemail.com (Postfix) with ESMTP id 944A2180003 for ; Thu, 9 Dec 2021 13:18:20 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id B52DCCE25BF; Thu, 9 Dec 2021 13:18:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63383C341CB; Thu, 9 Dec 2021 13:18:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639055894; bh=QA+PLCJTKX1CMiiZrikOJzosVrVeMSXoOItIEqk6seg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iV+/+6ZZsbRjigS8Md/c+hhicbcaaYoIzES6+ZacXHjcEWcNFG0P881J/0GTn1al0 0+cqS0clEbqlE6uvHW7AWia4mo70XrRlT+clB7GXEhBq0dvTJY1ldx4aG9owE6bgz3 Lfh1lss45gGuMjwgWJsQA2aYHpSSvwNWJ4qiC1nv8J0JhHseb9IODMKcRWTskmQG5s 4uCTnq2Jaue+ctoA3mwn7D09FK5sxElH5LRHHHSj2UTLcE4XUpxHQk7Wr4WAr+e73X oSIZbh2y1/BioSioKLKIAiuAK/WXHTgVCn9AFE/XRv3WiFxxolVl8cvUuqgvnURgfj YGOF2R0tovW+Q== From: SeongJae Park To: akpm@linux-foundation.org Cc: corbet@lwn.net, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 2/6] Docs/admin-guide/mm/damon/usage: Update for scheme quotas and watermarks Date: Thu, 9 Dec 2021 13:18:02 +0000 Message-Id: <20211209131806.19317-3-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211209131806.19317-1-sj@kernel.org> References: <20211209131806.19317-1-sj@kernel.org> X-Stat-Signature: ihq7caxy5a6wwc6xwq4yyqrznr959168 Authentication-Results: imf16.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="iV+/+6ZZ"; spf=pass (imf16.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 944A2180003 X-HE-Tag: 1639055900-186382 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: DAMOS features including time/space quota limits and watermarks are not described in the DAMON debugfs interface document. This commit updates the document for the features. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 123 +++++++++++++++---- 1 file changed, 98 insertions(+), 25 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index ed96bbf0daff..1ab9b714fca2 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -131,24 +131,38 @@ Schemes For usual DAMON-based data access aware memory management optimizations, users would simply want the system to apply a memory management action to a memory -region of a specific size having a specific access frequency for a specific -time. DAMON receives such formalized operation schemes from the user and -applies those to the target processes. It also counts the total number and -size of regions that each scheme is applied. This statistics can be used for -online analysis or tuning of the schemes. +region of a specific access pattern. DAMON receives such formalized operation +schemes from the user and applies those to the target processes. Users can get and set the schemes by reading from and writing to ``schemes`` debugfs file. Reading the file also shows the statistics of each scheme. To -the file, each of the schemes should be represented in each line in below form: +the file, each of the schemes should be represented in each line in below +form:: - min-size max-size min-acc max-acc min-age max-age action + -Note that the ranges are closed interval. Bytes for the size of regions -(``min-size`` and ``max-size``), number of monitored accesses per aggregate -interval for access frequency (``min-acc`` and ``max-acc``), number of -aggregate intervals for the age of regions (``min-age`` and ``max-age``), and a -predefined integer for memory management actions should be used. The supported -numbers and their meanings are as below. +You can disable schemes by simply writing an empty string to the file. + +Target Access Pattern +~~~~~~~~~~~~~~~~~~~~~ + +The ```` is constructed with three ranges in below +form:: + + min-size max-size min-acc max-acc min-age max-age + +Specifically, bytes for the size of regions (``min-size`` and ``max-size``), +number of monitored accesses per aggregate interval for access frequency +(``min-acc`` and ``max-acc``), number of aggregate intervals for the age of +regions (``min-age`` and ``max-age``) are specified. Note that the ranges are +closed interval. + +Action +~~~~~~ + +The ```` is a predefined integer for memory management actions, which +DAMON will apply to the regions having the target access pattern. The +supported numbers and their meanings are as below. - 0: Call ``madvise()`` for the region with ``MADV_WILLNEED`` - 1: Call ``madvise()`` for the region with ``MADV_COLD`` @@ -157,20 +171,79 @@ numbers and their meanings are as below. - 4: Call ``madvise()`` for the region with ``MADV_NOHUGEPAGE`` - 5: Do nothing but count the statistics -You can disable schemes by simply writing an empty string to the file. For -example, below commands applies a scheme saying "If a memory region of size in -[4KiB, 8KiB] is showing accesses per aggregate interval in [0, 5] for aggregate -interval in [10, 20], page out the region", check the entered scheme again, and -finally remove the scheme. :: +Quota +~~~~~ - # cd /damon - # echo "4096 8192 0 5 10 20 2" > schemes - # cat schemes - 4096 8192 0 5 10 20 2 0 0 - # echo > schemes +Optimal ``target access pattern`` for each ``action`` is workload dependent, so +not easy to find. Worse yet, setting a scheme of some action too aggressive +can cause severe overhead. To avoid such overhead, users can limit time and +size quota for the scheme via the ```` in below form:: + + + +This makes DAMON to try to use only up to ```` milliseconds for applying +the action to memory regions of the ``target access pattern`` within the +```` milliseconds, and to apply the action to only up to +```` bytes of memory regions within the ````. Setting both +```` and ```` zero disables the quota limits. + +When the quota limit is expected to be exceeded, DAMON prioritizes found memory +regions of the ``target access pattern`` based on their size, access frequency, +and age. For personalized prioritization, users can set the weights for the +three properties in ```` in below form:: + + + +Watermarks +~~~~~~~~~~ -The last two integers in the 4th line of above example is the total number and -the total size of the regions that the scheme is applied. +Some schemes would need to run based on current value of the system's specific +metrics like free memory ratio. For such cases, users can specify watermarks +for the condition.:: + + + +```` is a predefined integer for the metric to be checked. The +supported numbers and their meanings are as below. + + - 0: Ignore the watermarks + - 1: System's free memory rate (per thousand) + +The value of the metric is checked every ```` microseconds. + +If the value is higher than ```` or lower than ````, the +scheme is deactivated. If the value is lower than ````, the scheme +is activated. + +Statistics +~~~~~~~~~~ + +It also counts the total number and bytes of regions that each scheme is +applied. This statistics can be used for online analysis or tuning of the +schemes. + +The statistics can be shown by reading the ``schemes`` file. Reading the file +will show each scheme you entered in each line, and the two numbers for the +statistics will be added at the end of each line. + +Example +~~~~~~~ + +Below commands applies a scheme saying "If a memory region of size in [4KiB, +8KiB] is showing accesses per aggregate interval in [0, 5] for aggregate +interval in [10, 20], page out the region. For the paging out, use only up to +10ms per second, and also don't page out more than 1GiB per second. Under the +limitation, page out memory regions having longer age first. Also, check the +free memory rate of the system every 5 seconds, start the monitoring and paging +out when the free memory rate becomes lower than 50%, but stop it if the free +memory rate becomes larger than 60%, or lower than 30%".:: + + # cd /damon + # scheme="4096 8192 0 5 10 20 2" # target access pattern and action + # scheme+=" 10 $((1024*1024*1024)) 1000" # quotas + # scheme+=" 0 0 100" # prioritization weights + # scheme+=" 1 5000000 600 500 300" # watermarks + # echo "$scheme" > schemes Turning On/Off From patchwork Thu Dec 9 13:18:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12666557 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 BA0DBC433EF for ; Thu, 9 Dec 2021 13:21:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C6016B007B; Thu, 9 Dec 2021 08:18:31 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 674CE6B007D; Thu, 9 Dec 2021 08:18:31 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 563196B007E; Thu, 9 Dec 2021 08:18:31 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0230.hostedemail.com [216.40.44.230]) by kanga.kvack.org (Postfix) with ESMTP id 45A8D6B007B for ; Thu, 9 Dec 2021 08:18:31 -0500 (EST) Received: from smtpin11.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 00A1418023878 for ; Thu, 9 Dec 2021 13:18:20 +0000 (UTC) X-FDA: 78898309602.11.C98737B Received: from sin.source.kernel.org (sin.source.kernel.org [145.40.73.55]) by imf08.hostedemail.com (Postfix) with ESMTP id 7863B16000C for ; Thu, 9 Dec 2021 13:18:19 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sin.source.kernel.org (Postfix) with ESMTPS id 6DECDCE25B6; Thu, 9 Dec 2021 13:18:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2AF58C004DD; Thu, 9 Dec 2021 13:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639055895; bh=cGjJG9Y0KtC0r7X3ZCwpLsoPwAqXqoEmtJZuLNlHnrk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=h7bFRd/As9m73q7wHv4PpLWzBczRGv9MAL2AS3ibo7KcdBVMtZTyqTitJUQmL0PQy +9bv3h4Kfv9wOWUJDJw+l/gfD47w1E3skhWe9G6oB9eAUyMebM92iu6VsHAjmGkL4+ OjZyBpEar984+3hUYGAaSfstkQSoLjklfDKK4zlkSM/ba5IhvVEs7bOP+lYHIeAW7+ GTxi1cM/e7JFTHN50gWV2J3ffE6RWhM+6wTSCm5T1h2lD/GH6R9BxC5AWRzaIAd7HV /0KgGdgoknomCIE8uTe/x8oixSecaCSDtjvdrmAGETKEykwguzc87v5SO3zBgjxpd1 OXD5iIOPbTFbg== From: SeongJae Park To: akpm@linux-foundation.org Cc: corbet@lwn.net, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 3/6] Docs/admin-guide/mm/damon/usage: Remove redundant information Date: Thu, 9 Dec 2021 13:18:03 +0000 Message-Id: <20211209131806.19317-4-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211209131806.19317-1-sj@kernel.org> References: <20211209131806.19317-1-sj@kernel.org> MIME-Version: 1.0 X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: 7863B16000C X-Stat-Signature: h9bio1prdatfnxga9gf7wczxuxtjt7gh Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="h7bFRd/A"; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf08.hostedemail.com: domain of sj@kernel.org designates 145.40.73.55 as permitted sender) smtp.mailfrom=sj@kernel.org X-HE-Tag: 1639055899-526113 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: DAMON usage document mentions DAMON user space tool and programming interface twice. This commit integrates those and remove unnecessary part. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 44 ++++++++++---------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index 1ab9b714fca2..24137312f601 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -7,30 +7,30 @@ Detailed Usages DAMON provides below three interfaces for different users. - *DAMON user space tool.* - This is for privileged people such as system administrators who want a - just-working human-friendly interface. Using this, users can use the DAMON’s - major features in a human-friendly way. It may not be highly tuned for - special cases, though. It supports both virtual and physical address spaces - monitoring. + `This `_ is for privileged people such as + system administrators who want a just-working human-friendly interface. + Using this, users can use the DAMON’s major features in a human-friendly way. + It may not be highly tuned for special cases, though. It supports both + virtual and physical address spaces monitoring. For more detail, please + refer to its `usage document + `_. - *debugfs interface.* - This is for privileged user space programmers who want more optimized use of - DAMON. Using this, users can use DAMON’s major features by reading - from and writing to special debugfs files. Therefore, you can write and use - your personalized DAMON debugfs wrapper programs that reads/writes the - debugfs files instead of you. The DAMON user space tool is also a reference - implementation of such programs. It supports both virtual and physical - address spaces monitoring. + :ref:`This ` is for privileged user space programmers who + want more optimized use of DAMON. Using this, users can use DAMON’s major + features by reading from and writing to special debugfs files. Therefore, + you can write and use your personalized DAMON debugfs wrapper programs that + reads/writes the debugfs files instead of you. The `DAMON user space tool + `_ is one example of such programs. It + supports both virtual and physical address spaces monitoring. - *Kernel Space Programming Interface.* - This is for kernel space programmers. Using this, users can utilize every - feature of DAMON most flexibly and efficiently by writing kernel space - DAMON application programs for you. You can even extend DAMON for various - address spaces. - -Nevertheless, you could write your own user space tool using the debugfs -interface. A reference implementation is available at -https://github.com/awslabs/damo. If you are a kernel programmer, you could -refer to :doc:`/vm/damon/api` for the kernel space programming interface. For -the reason, this document describes only the debugfs interface + :doc:`This ` is for kernel space programmers. Using this, + users can utilize every feature of DAMON most flexibly and efficiently by + writing kernel space DAMON application programs for you. You can even extend + DAMON for various address spaces. For detail, please refer to the interface + :doc:`document `. + + +.. _debugfs_interface: debugfs Interface ================= From patchwork Thu Dec 9 13:18:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12666551 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 C9B5CC433F5 for ; Thu, 9 Dec 2021 13:19:29 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D3FF26B0075; Thu, 9 Dec 2021 08:18:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D2D306B0074; Thu, 9 Dec 2021 08:18:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B56EA6B0078; Thu, 9 Dec 2021 08:18:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0119.hostedemail.com [216.40.44.119]) by kanga.kvack.org (Postfix) with ESMTP id A731A6B0074 for ; Thu, 9 Dec 2021 08:18:29 -0500 (EST) Received: from smtpin18.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 6CA438248076 for ; Thu, 9 Dec 2021 13:18:19 +0000 (UTC) X-FDA: 78898309518.18.D7339DD Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf30.hostedemail.com (Postfix) with ESMTP id B5E5D80003 for ; Thu, 9 Dec 2021 13:18:18 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 9F958B82461; Thu, 9 Dec 2021 13:18:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D78F2C341C3; Thu, 9 Dec 2021 13:18:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639055896; bh=/ttFN3eSciKNUE5fSV4TMsI/toseuwV9QrzeM0zwrU0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KpTcUDjvvrtIOZanOTBRCQ+o1lqYG9W3U2hVeDd6SuXDDtkyTFXole99UZi3alFUM VuOthHNIbLiel0ZXwdWPN2eiolX5cRVO9vNkBG94Pr7yKC344oeq935U8mwFP1nE+3 epzZM5FTHYpqVUPTZAAFp78z081PeK78R3WLnx95RNtYtjmDLHd0Gy/Zk/UAXSbpIM rv6W6GSPWyDDnGt9xOEjyNDgfiAEOZhG40LjybR/E2ugNCDdMqrBgjUAzv/JkRxG2q 92wBuHA9yMgNFGb051/Fl0uitxzWyAtdoWk6VLVBqsm5UUyOVl2Kw9fKaa5Ik+7BaW 0BtpzzXzWXP7w== From: SeongJae Park To: akpm@linux-foundation.org Cc: corbet@lwn.net, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 4/6] Docs/admin-guide/mm/damon/usage: Mention tracepoint at the beginning Date: Thu, 9 Dec 2021 13:18:04 +0000 Message-Id: <20211209131806.19317-5-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211209131806.19317-1-sj@kernel.org> References: <20211209131806.19317-1-sj@kernel.org> Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=KpTcUDjv; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf30.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: B5E5D80003 X-Stat-Signature: esftrzi5fyakdktdizdtte81doayciia X-HE-Tag: 1639055898-900999 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: To get detailed monitoring results from the user space, users need to use the damon_aggregated tracepoint. This commit adds a brief mention of it at the beginning of the usage document. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index 24137312f601..846c85bf4b9d 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -21,7 +21,10 @@ DAMON provides below three interfaces for different users. you can write and use your personalized DAMON debugfs wrapper programs that reads/writes the debugfs files instead of you. The `DAMON user space tool `_ is one example of such programs. It - supports both virtual and physical address spaces monitoring. + supports both virtual and physical address spaces monitoring. Note that this + interface provides only simple :ref:`statistics ` for the + monitoring results. For detailed monitoring results, DAMON provides a + :ref:`tracepoint `. - *Kernel Space Programming Interface.* :doc:`This ` is for kernel space programmers. Using this, users can utilize every feature of DAMON most flexibly and efficiently by @@ -215,6 +218,8 @@ If the value is higher than ```` or lower than ````, the scheme is deactivated. If the value is lower than ````, the scheme is activated. +.. _damos_stats: + Statistics ~~~~~~~~~~ @@ -268,6 +273,8 @@ the monitoring is turned on. If you write to the files while DAMON is running, an error code such as ``-EBUSY`` will be returned. +.. _tracepoint: + Tracepoint for Monitoring Results ================================= From patchwork Thu Dec 9 13:18:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12666549 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 41A5FC433F5 for ; Thu, 9 Dec 2021 13:18:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 602F86B0073; Thu, 9 Dec 2021 08:18:29 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 5B1E76B0074; Thu, 9 Dec 2021 08:18:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 47A626B0075; Thu, 9 Dec 2021 08:18:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0180.hostedemail.com [216.40.44.180]) by kanga.kvack.org (Postfix) with ESMTP id 3A7CB6B0073 for ; Thu, 9 Dec 2021 08:18:29 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 06578180BD753 for ; Thu, 9 Dec 2021 13:18:19 +0000 (UTC) X-FDA: 78898309518.15.3B26D07 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf24.hostedemail.com (Postfix) with ESMTP id C7A06180006 for ; Thu, 9 Dec 2021 13:18:17 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 68C90B82460; Thu, 9 Dec 2021 13:18:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8EA3BC341CD; Thu, 9 Dec 2021 13:18:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639055897; bh=/bpNJdZ+aWFgZMWnCW/UQJnzz/QzCabU/kmiGB685LY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rqBxCVD9tK2L6PRlcpj9j0zEiuALm4LQ7ospbxpM4oDC5NKgK+pT7NUtvDfGzBXUv bowLQ+AmJqq6kcLmKORujrQUXgjUlB2rhme7i9QkYFEgTzAJNOFzt9CihaSobak9WQ jcvrSsPSaB6kAOUo0hi0gfb4277d0a11jjVo9PmTWSL90sipI6vlZGV8f7xnX6n2Rj mtkPVUb9gaA53tlPz3xcfQZ2fO+7HD6sXLSVZ1ck7n7Uvl2Y8h/HMEt1HKtpCraAt5 HCU2fCR2UIm5TG58PKhtZv1/GLPYbAh8HinZcApUrLE9jGAxA1ERh76os2lUMhxaqN gCi6JrpcbEaRA== From: SeongJae Park To: akpm@linux-foundation.org Cc: corbet@lwn.net, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 5/6] Docs/admin-guide/mm/damon/usage: Update for kdamond_pid and (mk|rm)_contexts Date: Thu, 9 Dec 2021 13:18:05 +0000 Message-Id: <20211209131806.19317-6-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211209131806.19317-1-sj@kernel.org> References: <20211209131806.19317-1-sj@kernel.org> X-Rspamd-Server: rspam09 X-Rspamd-Queue-Id: C7A06180006 X-Stat-Signature: xt7rndosuf5ggqfqjh6sgqy5iyegs4rp Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=rqBxCVD9; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf24.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-HE-Tag: 1639055897-324545 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 DAMON debugfs usage document is missing descriptions for 'kdamond_pid', 'mk_contexts', and 'rm_contexts' debugfs files. This commit adds those. Signed-off-by: SeongJae Park --- Documentation/admin-guide/mm/damon/usage.rst | 52 ++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/Documentation/admin-guide/mm/damon/usage.rst b/Documentation/admin-guide/mm/damon/usage.rst index 846c85bf4b9d..cb614c84ba9e 100644 --- a/Documentation/admin-guide/mm/damon/usage.rst +++ b/Documentation/admin-guide/mm/damon/usage.rst @@ -38,9 +38,9 @@ DAMON provides below three interfaces for different users. debugfs Interface ================= -DAMON exports five files, ``attrs``, ``target_ids``, ``init_regions``, -``schemes`` and ``monitor_on`` under its debugfs directory, -``/damon/``. +DAMON exports eight files, ``attrs``, ``target_ids``, ``init_regions``, +``schemes``, ``monitor_on``, ``kdamond_pid``, ``mk_contexts`` and +``rm_contexts`` under its debugfs directory, ``/damon/``. Attributes @@ -273,6 +273,52 @@ the monitoring is turned on. If you write to the files while DAMON is running, an error code such as ``-EBUSY`` will be returned. +Monitoring Thread PID +--------------------- + +DAMON does requested monitoring with a kernel thread called ``kdamond``. You +can get the pid of the thread by reading the ``kdamond_pid`` file. When the +monitoring is turned off, reading the file returns ``none``. :: + + # cd /damon + # cat monitor_on + off + # cat kdamond_pid + none + # echo on > monitor_on + # cat kdamond_pid + 18594 + + +Using Multiple Monitoring Threads +--------------------------------- + +One ``kdamond`` thread is created for each monitoring context. You can create +and remove monitoring contexts for multiple ``kdamond`` required use case using +the ``mk_contexts`` and ``rm_contexts`` files. + +Writing the name of the new context to the ``mk_contexts`` file creates a +directory of the name on the DAMON debugfs directory. The directory will have +DAMON debugfs files for the context. :: + + # cd /damon + # ls foo + # ls: cannot access 'foo': No such file or directory + # echo foo > mk_contexts + # ls foo + # attrs init_regions kdamond_pid schemes target_ids + +If the context is not needed anymore, you can remove it and the corresponding +directory by putting the name of the context to the ``rm_contexts`` file. :: + + # echo foo > rm_contexts + # ls foo + # ls: cannot access 'foo': No such file or directory + +Note that ``mk_contexts``, ``rm_contexts``, and ``monitor_on`` files are in the +root directory only. + + .. _tracepoint: Tracepoint for Monitoring Results From patchwork Thu Dec 9 13:18:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SeongJae Park X-Patchwork-Id: 12666553 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 7A1E0C433F5 for ; Thu, 9 Dec 2021 13:20:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 0765E6B0074; Thu, 9 Dec 2021 08:18:30 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id F2CF16B007B; Thu, 9 Dec 2021 08:18:29 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CDE306B007D; Thu, 9 Dec 2021 08:18:29 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0091.hostedemail.com [216.40.44.91]) by kanga.kvack.org (Postfix) with ESMTP id BBD656B0074 for ; Thu, 9 Dec 2021 08:18:29 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 79C05824556B for ; Thu, 9 Dec 2021 13:18:19 +0000 (UTC) X-FDA: 78898309518.07.925D091 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by imf17.hostedemail.com (Postfix) with ESMTP id 6A7044000B for ; Thu, 9 Dec 2021 13:18:17 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 215D9B82463; Thu, 9 Dec 2021 13:18:18 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 56D6EC341CC; Thu, 9 Dec 2021 13:18:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1639055897; bh=9y13d4UGVte5kVTshQHjYNu0Pvs+CgZxzC/70rI3BNo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n24cV9uSApZ0x1t+Y3NW1RtTEtQ7UKbI9RPdc+2hYAh/VekpFo9L+cghjOz5e70B4 sDfNp0r6Tg9wMJWjXHViRCfJOHy/N9MbF15q0LFEyt77bK2p2wYTpL1HCiUKPMNGRj k8KKB01OoOgIk+MPjoh7U9djNnLlAlvjL3hlnnked0dkveyDOom20wSvG8jXSE2VuV J8ZD8vshn36sIfJFq7dPmTivzp3riEzkwgItYWF0DwMgL4bAN/qkPzXWmfxKfakUHs +uU0czXojcnhMNfLM7e9+Pt2+ET2swg9BQO6rlqnjJid97VHyxfvognO4NYaMj1vKE OhawgWj7FsZHg== From: SeongJae Park To: akpm@linux-foundation.org Cc: corbet@lwn.net, linux-mm@kvack.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, SeongJae Park Subject: [PATCH 6/6] mm/damon: Remove a mistakenly added comment for a future feature Date: Thu, 9 Dec 2021 13:18:06 +0000 Message-Id: <20211209131806.19317-7-sj@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211209131806.19317-1-sj@kernel.org> References: <20211209131806.19317-1-sj@kernel.org> X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 6A7044000B X-Stat-Signature: cxqwnbf11roqhmyr5zra3u11sutdfpq8 Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b=n24cV9uS; dmarc=pass (policy=none) header.from=kernel.org; spf=pass (imf17.hostedemail.com: domain of sj@kernel.org designates 145.40.68.75 as permitted sender) smtp.mailfrom=sj@kernel.org X-HE-Tag: 1639055897-569056 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: Due to a mistake in patches reordering, a comment for a future feature called 'arbitrary monitoring target support'[1], which is still under development, has added. Because it only introduces confusion and we don't have a plan to post the patches soon, this commit removes the mistakenly added part. [1] https://lore.kernel.org/linux-mm/20201215115448.25633-3-sjpark@amazon.com/ Fixes: 1f366e421c8f ("mm/damon/core: implement DAMON-based Operation Schemes (DAMOS)") Signed-off-by: SeongJae Park --- include/linux/damon.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/linux/damon.h b/include/linux/damon.h index 2dbc1f545da2..97f4a224e950 100644 --- a/include/linux/damon.h +++ b/include/linux/damon.h @@ -281,7 +281,7 @@ struct damon_ctx; * as an integer in [0, &DAMOS_MAX_SCORE]. * @apply_scheme is called from @kdamond when a region for user provided * DAMON-based operation scheme is found. It should apply the scheme's action - * to the region. This is not used for &DAMON_ARBITRARY_TARGET case. + * to the region. * @target_valid should check whether the target is still valid for the * monitoring. * @cleanup is called from @kdamond just before its termination.