From: Xin Hao <xhao@linux.alibaba.com>
To: sj@kernel.org
Cc: xhao@linux.alibaba.com, akpm@linux-foundation.org,
linux-mm@kvack.org, linux-kernel@vger.kernel.org
Subject: [PATCH V1 1/2] mm/damon/dbgfs: Put "paddr" check into damon_pa_check() func
Date: Fri, 21 Jan 2022 00:04:27 +0800 [thread overview]
Message-ID: <44060c744a3760b1ecf6ce52a9b4ec842fa55eef.1642722660.git.xhao@linux.alibaba.com> (raw)
In-Reply-To: <cover.1642722660.git.xhao@linux.alibaba.com>
The purpose of putting "paddr" check into damon_pa_check() func
is to better solve "DAMON_DBGFS" dependency on both "DAMON_VADDR"
and "DAMON_PADDR".
Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
---
include/linux/damon.h | 1 +
mm/damon/dbgfs.c | 2 +-
mm/damon/paddr.c | 8 ++++++++
3 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/include/linux/damon.h b/include/linux/damon.h
index 5e1e3a128b77..794b5f453662 100644
--- a/include/linux/damon.h
+++ b/include/linux/damon.h
@@ -504,6 +504,7 @@ void damon_va_set_primitives(struct damon_ctx *ctx);
#endif /* CONFIG_DAMON_VADDR */
#ifdef CONFIG_DAMON_PADDR
+bool damon_pa_check(char *buf, size_t count);
bool damon_pa_target_valid(void *t);
void damon_pa_set_primitives(struct damon_ctx *ctx);
#endif /* CONFIG_DAMON_PADDR */
diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
index 5b899601e56c..cdb9c1e2ab29 100644
--- a/mm/damon/dbgfs.c
+++ b/mm/damon/dbgfs.c
@@ -374,7 +374,7 @@ static ssize_t dbgfs_target_ids_write(struct file *file,
if (IS_ERR(kbuf))
return PTR_ERR(kbuf);
- if (!strncmp(kbuf, "paddr\n", count)) {
+ if (damon_pa_check(kbuf, count)) {
id_is_pid = false;
/* target id is meaningless here, but we set it just for fun */
scnprintf(kbuf, count, "42 ");
diff --git a/mm/damon/paddr.c b/mm/damon/paddr.c
index 5e8244f65a1a..14a6bf2a2adb 100644
--- a/mm/damon/paddr.c
+++ b/mm/damon/paddr.c
@@ -208,6 +208,14 @@ static unsigned int damon_pa_check_accesses(struct damon_ctx *ctx)
return max_nr_accesses;
}
+bool damon_pa_check(char *buf, size_t count)
+{
+ if (!strncmp(buf, "paddr\n", count))
+ return true;
+
+ return false;
+}
+
bool damon_pa_target_valid(void *t)
{
return true;
--
2.27.0
next parent reply other threads:[~2022-01-20 16:04 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1642722660.git.xhao@linux.alibaba.com>
2022-01-20 16:04 ` Xin Hao [this message]
2022-01-20 17:47 ` SeongJae Park
2022-01-20 16:04 ` [PATCH V1 2/2] mm/damon/dbgfs: Modify Damon dbfs interface dependency in Kconfig Xin Hao
2022-01-20 17:46 ` SeongJae Park
2022-01-21 2:14 ` Xin Hao
2022-01-21 9:45 ` SeongJae Park
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44060c744a3760b1ecf6ce52a9b4ec842fa55eef.1642722660.git.xhao@linux.alibaba.com \
--to=xhao@linux.alibaba.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=sj@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox