2022-09-08 02:27:58

by haoxin

[permalink] [raw]
Subject: [PATCH V2] mm/damon: simplify damon_ctx check in damon_sysfs_before_terminate

In damon_sysfs_before_terminate() func, it need to check whether
ctx->ops.id supports 'DAMON_OPS_VADDR' or 'DAMON_OPS_FVADDR', there we
can use damon_target_has_pid() instead.

Signed-off-by: Xin Hao <[email protected]>
Reviewed-by: SeongJae Park <[email protected]>
---
mm/damon/sysfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 7488e27c87c3..88f208ff235d 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -2309,7 +2309,7 @@ static void damon_sysfs_before_terminate(struct damon_ctx *ctx)
{
struct damon_target *t, *next;

- if (ctx->ops.id != DAMON_OPS_VADDR && ctx->ops.id != DAMON_OPS_FVADDR)
+ if (!damon_target_has_pid(ctx))
return;

mutex_lock(&ctx->kdamond_lock);
--
2.31.0


2022-09-08 18:21:24

by SeongJae Park

[permalink] [raw]
Subject: Re: [PATCH V2] mm/damon: simplify damon_ctx check in damon_sysfs_before_terminate

Just for a record. Apparently Andrew has already added this in mm:
https://lore.kernel.org/mm-commits/[email protected]/


Thanks,
SJ

On Thu, 8 Sep 2022 10:19:12 +0800 Xin Hao <[email protected]> wrote:

> In damon_sysfs_before_terminate() func, it need to check whether
> ctx->ops.id supports 'DAMON_OPS_VADDR' or 'DAMON_OPS_FVADDR', there we
> can use damon_target_has_pid() instead.
>
> Signed-off-by: Xin Hao <[email protected]>
> Reviewed-by: SeongJae Park <[email protected]>
> ---
> mm/damon/sysfs.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
> index 7488e27c87c3..88f208ff235d 100644
> --- a/mm/damon/sysfs.c
> +++ b/mm/damon/sysfs.c
> @@ -2309,7 +2309,7 @@ static void damon_sysfs_before_terminate(struct damon_ctx *ctx)
> {
> struct damon_target *t, *next;
>
> - if (ctx->ops.id != DAMON_OPS_VADDR && ctx->ops.id != DAMON_OPS_FVADDR)
> + if (!damon_target_has_pid(ctx))
> return;
>
> mutex_lock(&ctx->kdamond_lock);
> --
> 2.31.0