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.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>
This commit is contained in:
parent
ce732a7520
commit
871f697b49
@ -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);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user