Re: [PATCH] mm/damon/sysfs-schemes: fix double increment of nr_regions

From: SeongJae Park

Date: Tue May 12 2026 - 00:54:05 EST


On Tue, 12 May 2026 09:41:57 +0530 Vineet Agarwal <agarwal.vineet2006@xxxxxxxxx> wrote:

> damos_sysfs_populate_region_dir() increments
> sysfs_regions->nr_regions twice when adding a new region:
> once explicitly before kobject_init_and_add(), and once
> again through the post-increment used for the kobject name.
>
> As a result, nr_regions no longer matches the actual
> number of live regions, and region directory names skip
> numbers (1, 3, 5, ...).
>
> Use the already incremented value for naming instead of
> incrementing nr_regions a second time.
>
> Fixes: 66178e4ec30a ("mm/damon/sysfs: use damos_walk() for update_schemes_tried_{bytes,regions}")

FYI we decided [1] not to Cc stable@ because the bug is not making meaningful
real user issues. The above Fixes: is only for people who seek more contexts
about from when the bug was introduced.

> Signed-off-by: Vineet Agarwal <agarwal.vineet2006@xxxxxxxxx>

Reviewed-by: SeongJae Park <sj@xxxxxxxxxx>

> ---

>From the next time, please consider adding patch changelog [2] here, with link
to previous revision. To my understanding, this revision has no change from
the previous revision [1] except dropping the RFC tag.

[1] https://lore.kernel.org/20260511191218.98881-1-agarwal.vineet2006@xxxxxxxxx
[2] https://docs.kernel.org/process/submitting-patches.html#commentary


Thanks,
SJ

[...]