* [PATCH] mm/damon/sysfs-schemes: fix double increment of nr_regions
@ 2026-05-12 4:11 Vineet Agarwal
2026-05-12 4:53 ` SeongJae Park
0 siblings, 1 reply; 2+ messages in thread
From: Vineet Agarwal @ 2026-05-12 4:11 UTC (permalink / raw)
To: sj; +Cc: akpm, damon, linux-mm, linux-kernel, Vineet Agarwal
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}")
Signed-off-by: Vineet Agarwal <agarwal.vineet2006@gmail.com>
---
mm/damon/sysfs-schemes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 622c3799db87..5d966ac86419 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -2998,7 +2998,7 @@ void damos_sysfs_populate_region_dir(struct damon_sysfs_schemes *sysfs_schemes,
if (kobject_init_and_add(®ion->kobj,
&damon_sysfs_scheme_region_ktype,
&sysfs_regions->kobj, "%d",
- sysfs_regions->nr_regions++)) {
+ sysfs_regions->nr_regions)) {
kobject_put(®ion->kobj);
}
}
--
2.54.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] mm/damon/sysfs-schemes: fix double increment of nr_regions
2026-05-12 4:11 [PATCH] mm/damon/sysfs-schemes: fix double increment of nr_regions Vineet Agarwal
@ 2026-05-12 4:53 ` SeongJae Park
0 siblings, 0 replies; 2+ messages in thread
From: SeongJae Park @ 2026-05-12 4:53 UTC (permalink / raw)
To: Vineet Agarwal; +Cc: SeongJae Park, akpm, damon, linux-mm, linux-kernel
On Tue, 12 May 2026 09:41:57 +0530 Vineet Agarwal <agarwal.vineet2006@gmail.com> 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@gmail.com>
Reviewed-by: SeongJae Park <sj@kernel.org>
> ---
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@gmail.com
[2] https://docs.kernel.org/process/submitting-patches.html#commentary
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-12 4:54 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-12 4:11 [PATCH] mm/damon/sysfs-schemes: fix double increment of nr_regions Vineet Agarwal
2026-05-12 4:53 ` SeongJae Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox