提交 871f697b 编写于 作者: X Xin Hao 提交者: Andrew Morton

mm/damon/sysfs: avoid call damon_target_has_pid() repeatedly

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.comSigned-off-by: NXin Hao <xhao@linux.alibaba.com>
Reviewed-by: NSeongJae Park <sj@kernel.org>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
上级 ce732a75
...@@ -2143,9 +2143,10 @@ static int damon_sysfs_set_attrs(struct damon_ctx *ctx, ...@@ -2143,9 +2143,10 @@ static int damon_sysfs_set_attrs(struct damon_ctx *ctx,
static void damon_sysfs_destroy_targets(struct damon_ctx *ctx) static void damon_sysfs_destroy_targets(struct damon_ctx *ctx)
{ {
struct damon_target *t, *next; struct damon_target *t, *next;
bool has_pid = damon_target_has_pid(ctx);
damon_for_each_target_safe(t, next, ctx) { damon_for_each_target_safe(t, next, ctx) {
if (damon_target_has_pid(ctx)) if (has_pid)
put_pid(t->pid); put_pid(t->pid);
damon_destroy_target(t); damon_destroy_target(t);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册