Re: [RFC PATCH 02/10] mm/damon/sysfs: add pause file under context dir
From: SeongJae Park
Date: Tue Mar 17 2026 - 00:26:53 EST
On Sun, 15 Mar 2026 14:00:01 -0700 SeongJae Park <sj@xxxxxxxxxx> wrote:
> Add pause DAMON sysfs file under the context directory. It exposes the
> damon_ctx->pause API parameter to the users so that they can use the
> pause/resume feature.
>
> Signed-off-by: SeongJae Park <sj@xxxxxxxxxx>
> ---
> mm/damon/sysfs.c | 30 ++++++++++++++++++++++++++++++
> 1 file changed, 30 insertions(+)
>
> diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
> index 576d1ddd736bf..4cbb8b9aaba3c 100644
> --- a/mm/damon/sysfs.c
> +++ b/mm/damon/sysfs.c
> @@ -866,6 +866,7 @@ struct damon_sysfs_context {
> struct damon_sysfs_attrs *attrs;
> struct damon_sysfs_targets *targets;
> struct damon_sysfs_schemes *schemes;
> + bool pause;
> };
sashiko.dev comments [1] below.
: Is the new pause field left uninitialized when a context is allocated?
:
: Looking at damon_sysfs_context_alloc(), memory is allocated via kmalloc_obj()
: which does not zero-fill by default, and the new field is not explicitly
: initialized:
:
: static struct damon_sysfs_context *damon_sysfs_context_alloc(
: enum damon_ops_id ops_id)
: {
: struct damon_sysfs_context *context = kmalloc_obj(*context);
:
: if (!context)
: return NULL;
: context->kobj = (struct kobject){};
: context->ops_id = ops_id;
: context->addr_unit = 1;
: return context;
: }
:
: If a user reads the pause sysfs file before writing to it, could this return
: uninitialized kernel heap memory?
Good catch. I will add below fixup to the next spin.
'''
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1432,6 +1432,7 @@ static struct damon_sysfs_context *damon_sysfs_context_alloc(
context->kobj = (struct kobject){};
context->ops_id = ops_id;
context->addr_unit = 1;
+ context->pause = false;
return context;
}
'''
Btw, somehow sashiko.dev added the comment to not this patch but the sixth
patch of this series.
[1] https://sashiko.dev/#/patchset/20260315210012.94846-7-sj@xxxxxxxxxx
Thanks,
SJ
[...]