[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200818072501.30396-8-sjpark@amazon.com>
Date: Tue, 18 Aug 2020 09:24:58 +0200
From: SeongJae Park <sjpark@...zon.com>
To: <akpm@...ux-foundation.org>
CC: SeongJae Park <sjpark@...zon.de>, <Jonathan.Cameron@...wei.com>,
<aarcange@...hat.com>, <acme@...nel.org>,
<alexander.shishkin@...ux.intel.com>, <amit@...nel.org>,
<benh@...nel.crashing.org>, <brendan.d.gregg@...il.com>,
<brendanhiggins@...gle.com>, <cai@....pw>,
<colin.king@...onical.com>, <corbet@....net>, <david@...hat.com>,
<dwmw@...zon.com>, <fan.du@...el.com>, <foersleo@...zon.de>,
<gthelen@...gle.com>, <irogers@...gle.com>, <jolsa@...hat.com>,
<kirill@...temov.name>, <mark.rutland@....com>, <mgorman@...e.de>,
<minchan@...nel.org>, <mingo@...hat.com>, <namhyung@...nel.org>,
<peterz@...radead.org>, <rdunlap@...radead.org>,
<riel@...riel.com>, <rientjes@...gle.com>, <rostedt@...dmis.org>,
<rppt@...nel.org>, <sblbir@...zon.com>, <shakeelb@...gle.com>,
<shuah@...nel.org>, <sj38.park@...il.com>, <snu@...zon.de>,
<vbabka@...e.cz>, <vdavydov.dev@...il.com>,
<yang.shi@...ux.alibaba.com>, <ying.huang@...el.com>,
<zgf574564920@...il.com>, <linux-damon@...zon.com>,
<linux-mm@...ck.org>, <linux-doc@...r.kernel.org>,
<linux-kernel@...r.kernel.org>
Subject: [RFC v7 07/10] mm/damon/debugfs: Support physical memory monitoring
From: SeongJae Park <sjpark@...zon.de>
This commit makes the debugfs interface to support the physical memory
monitoring, in addition to the virtual memory monitoring.
Users can do the physical memory monitoring by writing a special
keyword, 'paddr\n' to the 'pids' debugfs file. Then, DAMON will check
the special keyword and configure the callbacks of the monitoring
context for the debugfs user for physical memory. This will internally
add one fake monitoring target process, which has pid as -1.
Unlike the virtual memory monitoring, DAMON debugfs will not
automatically set the monitoring target region. Therefore, users should
also set the monitoring target address region using the 'init_regions'
debugfs file. While doing this, the 'pid' in the input should be '-1'.
Finally, the physical memory monitoring will not automatically
terminated because it has fake monitoring target process. The user
should explicitly turn off the monitoring by writing 'off' to the
'monitor_on' debugfs file.
Signed-off-by: SeongJae Park <sjpark@...zon.de>
---
mm/damon.c | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/mm/damon.c b/mm/damon.c
index d0d55656553b..6f078d68c401 100644
--- a/mm/damon.c
+++ b/mm/damon.c
@@ -2113,9 +2113,29 @@ static ssize_t debugfs_target_ids_write(struct file *file,
return PTR_ERR(kbuf);
nrs = kbuf;
- if (!strncmp(kbuf, "pidfd ", 6)) {
- received_pidfds = true;
- nrs = &kbuf[6];
+ if (!strncmp(kbuf, "paddr\n", count)) {
+ /* Configure the context for physical memory monitoring */
+ ctx->init_target_regions = kdamond_init_phys_regions;
+ ctx->update_target_regions = kdamond_update_phys_regions;
+ ctx->prepare_access_checks = kdamond_prepare_phys_access_checks;
+ ctx->check_accesses = kdamond_check_phys_accesses;
+ ctx->target_valid = NULL;
+ ctx->cleanup = NULL;
+
+ /* target id is meaningless here, but we set it just for fun */
+ snprintf(kbuf, count, "42 ");
+ } else {
+ /* Configure the context for virtual memory monitoring */
+ ctx->init_target_regions = kdamond_init_vm_regions;
+ ctx->update_target_regions = kdamond_update_vm_regions;
+ ctx->prepare_access_checks = kdamond_prepare_vm_access_checks;
+ ctx->check_accesses = kdamond_check_vm_accesses;
+ ctx->target_valid = kdamond_vm_target_valid;
+ ctx->cleanup = kdamond_vm_cleanup;
+ if (!strncmp(kbuf, "pidfd ", 6)) {
+ received_pidfds = true;
+ nrs = &kbuf[6];
+ }
}
targets = str_to_target_ids(nrs, ret, &nr_targets);
--
2.17.1
Powered by blists - more mailing lists