projects
/
linux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
ce732a7
)
mm/damon/sysfs: avoid call damon_target_has_pid() repeatedly
author
Xin Hao
<xhao@linux.alibaba.com>
Thu, 15 Sep 2022 14:22:36 +0000
(22:22 +0800)
committer
Andrew Morton
<akpm@linux-foundation.org>
Mon, 3 Oct 2022 21:03:26 +0000
(14:03 -0700)
In damon_sysfs_destroy_targets(), we call damon_target_has_pid() to check
whether the 'ctx' include a valid pid, but there no need to call
damon_target_has_pid() to check repeatedly, just need call it once.
[xhao@linux.alibaba.com: more simplified code calls damon_target_has_pid()]
Link:
https://lkml.kernel.org/r/20220916133535.7428-1-xhao@linux.alibaba.com
Link:
https://lkml.kernel.org/r/20220915142237.92529-1-xhao@linux.alibaba.com
Signed-off-by: Xin Hao <xhao@linux.alibaba.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/sysfs.c
patch
|
blob
|
history
diff --git
a/mm/damon/sysfs.c
b/mm/damon/sysfs.c
index 1fa0023f136eb7b9b1b949fa67302166004ab682..0cca1909bf67bc56b8f47d59062bfbcaf2ccf2ee 100644
(file)
--- a/
mm/damon/sysfs.c
+++ b/
mm/damon/sysfs.c
@@
-2143,9
+2143,10
@@
static int damon_sysfs_set_attrs(struct damon_ctx *ctx,
static void damon_sysfs_destroy_targets(struct damon_ctx *ctx)
{
struct damon_target *t, *next;
+ bool has_pid = damon_target_has_pid(ctx);
damon_for_each_target_safe(t, next, ctx) {
- if (
damon_target_has_pid(ctx)
)
+ if (
has_pid
)
put_pid(t->pid);
damon_destroy_target(t);
}