linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH V2] mm/damon/dbgfs: Optimize target_ids interface write operation
@ 2021-10-21 16:44 Xin Hao
  2021-10-21 17:30 ` SeongJae Park
  0 siblings, 1 reply; 4+ messages in thread
From: Xin Hao @ 2021-10-21 16:44 UTC (permalink / raw)
  To: sjpark; +Cc: xhao, akpm, linux-mm, linux-kernel

When we want to clear previously set target ids,
For example, it works as below now:
    # echo 42 > target_ids
    # cat target_ids
    42
    # echo > target_ids
    # cat target_ids

But in 'dbgfs_target_ids_write', there is no need to
execute other codes, except call 'damon_set_targets'
to clear previously set target ids. So there adds
the 'nr_targets' judgment, if the value is 0, just
call 'damon_set_targets', and then return.

Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
---
 mm/damon/dbgfs.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/mm/damon/dbgfs.c b/mm/damon/dbgfs.c
index a02cf6bee8e8..1d83f4138fad 100644
--- a/mm/damon/dbgfs.c
+++ b/mm/damon/dbgfs.c
@@ -362,6 +362,12 @@ static ssize_t dbgfs_target_ids_write(struct file *file,
 		goto out;
 	}

+	if (!nr_targets) {
+		/* remove targets with previously-set primitive */
+		damon_set_targets(ctx, NULL, 0);
+		goto free_targets_out;
+	}
+
 	if (id_is_pid) {
 		for (i = 0; i < nr_targets; i++) {
 			targets[i] = (unsigned long)find_get_pid(
--
2.31.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-10-22  9:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-21 16:44 [PATCH V2] mm/damon/dbgfs: Optimize target_ids interface write operation Xin Hao
2021-10-21 17:30 ` SeongJae Park
2021-10-22  2:43   ` Xin Hao
2021-10-22  9:43     ` SeongJae Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox