* [RFC PATCH v1.1 00/11] mm/damon/sysfs: kobject_del() directories that users can create/remove
@ 2026-06-17 14:47 SeongJae Park
2026-06-17 14:47 ` [RFC PATCH v1.1 01/11] mm/damon/sysfs: kobject_del() target (normal), context and kdamond dirs SeongJae Park
` (10 more replies)
0 siblings, 11 replies; 12+ messages in thread
From: SeongJae Park @ 2026-06-17 14:47 UTC (permalink / raw)
Cc: SeongJae Park, # 5 . 18 . x, Andrew Morton, Jiapeng Chong, damon,
linux-kernel, linux-mm
DAMON sysfs interface allows users to create and remove arbitrary number
of directories on sysfs, using a few files having 'nr_' prefix. For
example, 'nr_kdamonds'. When the user writes a number 'N' to the files,
directories having name starting from '0' to 'N - 1' are created in the
same directory. The pre-existing number-named directories are removed
before creating the new directories.
For the removal of the existing directories, DAMON sysfs interface use
only kobject_put(). Because DAMON sysfs interface is the only kernel
component that manages the directories, there is no problem in normal
situations. However, if CONFIG_DEBUG_KOBJECT_RELEASE is enabled, the
removal of dirs are delayed. Let's suppose a user writes a non-zero
number to the 'nr_*' files while there are pre-existing number-named
directories, on the config enabled kernel. DAMON sysfs interface
decreases the reference counts of the existing directories and
immediately creates new directories. Because the removal of the sysfs
directories is delayed, it shows some pre-existing directories of the
same names when it tries to create the new directories, and fails.
For example, the issue can be triggered like below:
# grep DEBUG_KOBJECT_RELEASE /boot/config-$(uname -r)
CONFIG_DEBUG_KOBJECT_RELEASE=y
# ls
nr_kdamonds
# echo 1 > nr_kdamonds
# echo 1 > nr_kdamonds
bash: echo: write error: File exists
# dmesg
[...]
[ 300.880458] kobject: kobject_add_internal failed for 0 with -EEXIST, don't try to register things with the same name in the same directory.
[...]
Some of the error handling paths of the directories also lack the
kobject_del() call. If the user uses nr_* file right after the errors,
similar issues can happen.
This doesn't cause catastrophic issues like kernel panics or memory
corruptions. Users can work around by removing all directories first
(write 0 to the nr_* files) and then create new directories after
confirming the old directories are gone. But, this is definitely a bug
that causes a bad user experience.
Fix the issues by calling kobject_del() before creating new directories.
Patches Sequence
================
There are a number of bugs of this class that introduced by eleven
different commits. Group fnd order fixes based on the introducing
commits.
Changes from RFC v1
- RFC v1: https://lore.kernel.org/20260616150844.88305-1-sj@kernel.org
- Add error path fixes.
SeongJae Park (11):
mm/damon/sysfs: kobject_del() target (normal), context and kdamond
dirs
mm/damon/sysfs: kobject_del() region and target (error) dirs
mm/damon/sysfs-schemes: kobject_del() scheme dirs
mm/damon/sysfs-schemes: kobject_del() scheme region dirs
mm/damon/sysfs-schemes: kobject_del() scheme filter dirs
mm/damon/sysfs-schemes: kobject_del() scheme quota goal dirs
mm/damon/sysfs-schemes: kobject_del() scheme action destination dirs
mm/damon/sysfs: kobject_del() probe dirs
mm/damon/sysfs: kobject_del() probe filter dirs
mm/damon/sysfs: kobject_del() probe dirs in probes_addd_dir error path
mm/damon/sysfs-schemes: kobject_del() region for populate_region error
mm/damon/sysfs-schemes.c | 18 ++++++++++++++----
mm/damon/sysfs.c | 25 ++++++++++++++++++++-----
2 files changed, 34 insertions(+), 9 deletions(-)
base-commit: c7d696ef153b9bea79d35140c7e9266fe9d3f7bb
--
2.47.3
^ permalink raw reply [flat|nested] 12+ messages in thread
* [RFC PATCH v1.1 01/11] mm/damon/sysfs: kobject_del() target (normal), context and kdamond dirs
2026-06-17 14:47 [RFC PATCH v1.1 00/11] mm/damon/sysfs: kobject_del() directories that users can create/remove SeongJae Park
@ 2026-06-17 14:47 ` SeongJae Park
2026-06-17 14:47 ` [RFC PATCH v1.1 02/11] mm/damon/sysfs: kobject_del() region and target (error) dirs SeongJae Park
` (9 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-06-17 14:47 UTC (permalink / raw)
Cc: SeongJae Park, # 5 . 18 . x, Andrew Morton, Jiapeng Chong, damon,
linux-kernel, linux-mm
On CONFIG_DEBUG_KOBJECT_RELEASE enabled kernel, lack of kobject_del()
could cause directories creation failures due to the name conflicts. Fix
those issues for normal creation paths of target, context and kdamond
directories, and error paths of context and kdamond directories by
adding kobject_del() calls.
Note that this fix for target directories is not complete since it has a
similar issue in the damon_sysfs_targets_add_dirs() error path. Because
the normal path issue and the error path issue are introduced by
different commits, this commit is fixing only the normal path issue. A
commit for the error path will be added next.
Fixes: c951cd3b8901 ("mm/damon: implement a minimal stub for sysfs-based DAMON interface")
Cc: <stable@vger.kernel.org> # 5.18.x
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 2e95e3bac774d..dba1c67fc188f 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -333,6 +333,7 @@ static void damon_sysfs_targets_rm_dirs(struct damon_sysfs_targets *targets)
for (i = 0; i < targets->nr; i++) {
damon_sysfs_target_rm_dirs(targets_arr[i]);
+ kobject_del(&targets_arr[i]->kobj);
kobject_put(&targets_arr[i]->kobj);
}
targets->nr = 0;
@@ -1642,6 +1643,7 @@ static void damon_sysfs_contexts_rm_dirs(struct damon_sysfs_contexts *contexts)
for (i = 0; i < contexts->nr; i++) {
damon_sysfs_context_rm_dirs(contexts_arr[i]);
+ kobject_del(&contexts_arr[i]->kobj);
kobject_put(&contexts_arr[i]->kobj);
}
contexts->nr = 0;
@@ -1680,13 +1682,15 @@ static int damon_sysfs_contexts_add_dirs(struct damon_sysfs_contexts *contexts,
err = damon_sysfs_context_add_dirs(context);
if (err)
- goto out;
+ goto del_out;
contexts_arr[i] = context;
contexts->nr++;
}
return 0;
+del_out:
+ kobject_del(&context->kobj);
out:
damon_sysfs_contexts_rm_dirs(contexts);
kobject_put(&context->kobj);
@@ -2501,6 +2505,7 @@ static void damon_sysfs_kdamonds_rm_dirs(struct damon_sysfs_kdamonds *kdamonds)
for (i = 0; i < kdamonds->nr; i++) {
damon_sysfs_kdamond_rm_dirs(kdamonds_arr[i]);
+ kobject_del(&kdamonds_arr[i]->kobj);
kobject_put(&kdamonds_arr[i]->kobj);
}
kdamonds->nr = 0;
@@ -2555,13 +2560,15 @@ static int damon_sysfs_kdamonds_add_dirs(struct damon_sysfs_kdamonds *kdamonds,
err = damon_sysfs_kdamond_add_dirs(kdamond);
if (err)
- goto out;
+ goto del_out;
kdamonds_arr[i] = kdamond;
kdamonds->nr++;
}
return 0;
+del_out:
+ kobject_del(&kdamond->kobj);
out:
damon_sysfs_kdamonds_rm_dirs(kdamonds);
kobject_put(&kdamond->kobj);
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC PATCH v1.1 02/11] mm/damon/sysfs: kobject_del() region and target (error) dirs
2026-06-17 14:47 [RFC PATCH v1.1 00/11] mm/damon/sysfs: kobject_del() directories that users can create/remove SeongJae Park
2026-06-17 14:47 ` [RFC PATCH v1.1 01/11] mm/damon/sysfs: kobject_del() target (normal), context and kdamond dirs SeongJae Park
@ 2026-06-17 14:47 ` SeongJae Park
2026-06-17 14:47 ` [RFC PATCH v1.1 03/11] mm/damon/sysfs-schemes: kobject_del() scheme dirs SeongJae Park
` (8 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-06-17 14:47 UTC (permalink / raw)
Cc: SeongJae Park, # 5 . 18 . x, Andrew Morton, damon, linux-kernel,
linux-mm
On CONFIG_DEBUG_KOBJECT_RELEASE enabled kernel, lack of kobject_del()
could cause directories creation failures due to the name conflicts. Fix
those issues for the normal creation path of region directories and the
error path of target directories, by adding kobject_del() calls.
Fixes: 2031b14ea757 ("mm/damon/sysfs: support the physical address space monitoring")
Cc: <stable@vger.kernel.org> # 5.18.x
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index dba1c67fc188f..3c349f0fe80f0 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -107,8 +107,10 @@ static void damon_sysfs_regions_rm_dirs(struct damon_sysfs_regions *regions)
struct damon_sysfs_region **regions_arr = regions->regions_arr;
int i;
- for (i = 0; i < regions->nr; i++)
+ for (i = 0; i < regions->nr; i++) {
+ kobject_del(®ions_arr[i]->kobj);
kobject_put(®ions_arr[i]->kobj);
+ }
regions->nr = 0;
kfree(regions_arr);
regions->regions_arr = NULL;
@@ -372,13 +374,15 @@ static int damon_sysfs_targets_add_dirs(struct damon_sysfs_targets *targets,
err = damon_sysfs_target_add_dirs(target);
if (err)
- goto out;
+ goto del_out;
targets_arr[i] = target;
targets->nr++;
}
return 0;
+del_out:
+ kobject_del(&target->kobj);
out:
damon_sysfs_targets_rm_dirs(targets);
kobject_put(&target->kobj);
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC PATCH v1.1 03/11] mm/damon/sysfs-schemes: kobject_del() scheme dirs
2026-06-17 14:47 [RFC PATCH v1.1 00/11] mm/damon/sysfs: kobject_del() directories that users can create/remove SeongJae Park
2026-06-17 14:47 ` [RFC PATCH v1.1 01/11] mm/damon/sysfs: kobject_del() target (normal), context and kdamond dirs SeongJae Park
2026-06-17 14:47 ` [RFC PATCH v1.1 02/11] mm/damon/sysfs: kobject_del() region and target (error) dirs SeongJae Park
@ 2026-06-17 14:47 ` SeongJae Park
2026-06-17 14:47 ` [RFC PATCH v1.1 04/11] mm/damon/sysfs-schemes: kobject_del() scheme region dirs SeongJae Park
` (7 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-06-17 14:47 UTC (permalink / raw)
Cc: SeongJae Park, # 5 . 18 . x, Andrew Morton, damon, linux-kernel,
linux-mm
On CONFIG_DEBUG_KOBJECT_RELEASE enabled kernel, lack of kobject_del()
could cause directories creation failures due to the name conflicts. Fix
those issues for scheme directories by adding kobject_del() calls.
Fixes: 7e84b1f8212a ("mm/damon/sysfs: support DAMON-based Operation Schemes")
Cc: <stable@vger.kernel.org> # 5.18.x
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs-schemes.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 0134111c3c1ff..debf2a3a0d8fc 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -2683,6 +2683,7 @@ void damon_sysfs_schemes_rm_dirs(struct damon_sysfs_schemes *schemes)
for (i = 0; i < schemes->nr; i++) {
damon_sysfs_scheme_rm_dirs(schemes_arr[i]);
+ kobject_del(&schemes_arr[i]->kobj);
kobject_put(&schemes_arr[i]->kobj);
}
schemes->nr = 0;
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC PATCH v1.1 04/11] mm/damon/sysfs-schemes: kobject_del() scheme region dirs
2026-06-17 14:47 [RFC PATCH v1.1 00/11] mm/damon/sysfs: kobject_del() directories that users can create/remove SeongJae Park
` (2 preceding siblings ...)
2026-06-17 14:47 ` [RFC PATCH v1.1 03/11] mm/damon/sysfs-schemes: kobject_del() scheme dirs SeongJae Park
@ 2026-06-17 14:47 ` SeongJae Park
2026-06-17 14:47 ` [RFC PATCH v1.1 05/11] mm/damon/sysfs-schemes: kobject_del() scheme filter dirs SeongJae Park
` (6 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-06-17 14:47 UTC (permalink / raw)
Cc: SeongJae Park, # 6 . 2 . x, Andrew Morton, damon, linux-kernel,
linux-mm
On CONFIG_DEBUG_KOBJECT_RELEASE enabled kernel, lack of kobject_del()
could cause directories creation failures due to the name conflicts. Fix
those issues for scheme region directories by adding kobject_del()
calls.
This issue was discovered [1] by Sashiko, though its analysis was
partially incorrect.
[1] https://lore.kernel.org/20260517205828.6204-1-sj@kernel.org
Fixes: 9277d0367ba1 ("mm/damon/sysfs-schemes: implement scheme region directory")
Cc: <stable@vger.kernel.org> # 6.2.x
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs-schemes.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index debf2a3a0d8fc..604b77a47a463 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -334,6 +334,7 @@ static void damon_sysfs_scheme_regions_rm_dirs(
list_for_each_entry_safe(r, next, ®ions->regions_list, list) {
damos_sysfs_region_rm_dirs(r);
list_del(&r->list);
+ kobject_del(&r->kobj);
kobject_put(&r->kobj);
regions->nr_regions--;
}
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC PATCH v1.1 05/11] mm/damon/sysfs-schemes: kobject_del() scheme filter dirs
2026-06-17 14:47 [RFC PATCH v1.1 00/11] mm/damon/sysfs: kobject_del() directories that users can create/remove SeongJae Park
` (3 preceding siblings ...)
2026-06-17 14:47 ` [RFC PATCH v1.1 04/11] mm/damon/sysfs-schemes: kobject_del() scheme region dirs SeongJae Park
@ 2026-06-17 14:47 ` SeongJae Park
2026-06-17 14:48 ` [RFC PATCH v1.1 06/11] mm/damon/sysfs-schemes: kobject_del() scheme quota goal dirs SeongJae Park
` (5 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-06-17 14:47 UTC (permalink / raw)
Cc: SeongJae Park, # 6 . 3 . x, Andrew Morton, damon, linux-kernel,
linux-mm
On CONFIG_DEBUG_KOBJECT_RELEASE enabled kernel, lack of kobject_del()
could cause directories creation failures due to the name conflicts. Fix
those issues for scheme filter directories by adding kobject_del()
calls.
Fixes: 472e2b70eda6 ("mm/damon/sysfs-schemes: connect filter directory and filters directory")
Cc: <stable@vger.kernel.org> # 6.3.x
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs-schemes.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 604b77a47a463..db6226c05b023 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -914,8 +914,10 @@ static void damon_sysfs_scheme_filters_rm_dirs(
struct damon_sysfs_scheme_filter **filters_arr = filters->filters_arr;
int i;
- for (i = 0; i < filters->nr; i++)
+ for (i = 0; i < filters->nr; i++) {
+ kobject_del(&filters_arr[i]->kobj);
kobject_put(&filters_arr[i]->kobj);
+ }
filters->nr = 0;
kfree(filters_arr);
filters->filters_arr = NULL;
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC PATCH v1.1 06/11] mm/damon/sysfs-schemes: kobject_del() scheme quota goal dirs
2026-06-17 14:47 [RFC PATCH v1.1 00/11] mm/damon/sysfs: kobject_del() directories that users can create/remove SeongJae Park
` (4 preceding siblings ...)
2026-06-17 14:47 ` [RFC PATCH v1.1 05/11] mm/damon/sysfs-schemes: kobject_del() scheme filter dirs SeongJae Park
@ 2026-06-17 14:48 ` SeongJae Park
2026-06-17 14:48 ` [RFC PATCH v1.1 07/11] mm/damon/sysfs-schemes: kobject_del() scheme action destination dirs SeongJae Park
` (4 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-06-17 14:48 UTC (permalink / raw)
Cc: SeongJae Park, # 6 . 8 . x, Andrew Morton, damon, linux-kernel,
linux-mm
On CONFIG_DEBUG_KOBJECT_RELEASE enabled kernel, lack of kobject_del()
could cause directories creation failures due to the name conflicts. Fix
those issues for scheme quota goal directories by adding kobject_del()
calls.
Fixes: 7f262da0a30d ("mm/damon/sysfs-schemes: implement files for scheme quota goals setup")
Cc: <stable@vger.kernel.org> # 6.8.x
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs-schemes.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index db6226c05b023..573a40c679be3 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -1465,8 +1465,10 @@ static void damos_sysfs_quota_goals_rm_dirs(
struct damos_sysfs_quota_goal **goals_arr = goals->goals_arr;
int i;
- for (i = 0; i < goals->nr; i++)
+ for (i = 0; i < goals->nr; i++) {
+ kobject_del(&goals_arr[i]->kobj);
kobject_put(&goals_arr[i]->kobj);
+ }
goals->nr = 0;
kfree(goals_arr);
goals->goals_arr = NULL;
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC PATCH v1.1 07/11] mm/damon/sysfs-schemes: kobject_del() scheme action destination dirs
2026-06-17 14:47 [RFC PATCH v1.1 00/11] mm/damon/sysfs: kobject_del() directories that users can create/remove SeongJae Park
` (5 preceding siblings ...)
2026-06-17 14:48 ` [RFC PATCH v1.1 06/11] mm/damon/sysfs-schemes: kobject_del() scheme quota goal dirs SeongJae Park
@ 2026-06-17 14:48 ` SeongJae Park
2026-06-17 14:48 ` [RFC PATCH v1.1 08/11] mm/damon/sysfs: kobject_del() probe dirs SeongJae Park
` (3 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-06-17 14:48 UTC (permalink / raw)
Cc: SeongJae Park, # 6 . 17 . x, Andrew Morton, damon, linux-kernel,
linux-mm
On CONFIG_DEBUG_KOBJECT_RELEASE enabled kernel, lack of kobject_del()
could cause directories creation failures due to the name conflicts. Fix
those issues for scheme action destination directories by adding
kobject_del() calls.
Fixes: 2cd0bf85a203 ("mm/damon/sysfs-schemes: implement DAMOS action destinations directory")
Cc: <stable@vger.kernel.org> # 6.17.x
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs-schemes.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 573a40c679be3..0c0c9637b594e 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -2145,8 +2145,10 @@ static void damos_sysfs_dests_rm_dirs(
struct damos_sysfs_dest **dests_arr = dests->dests_arr;
int i;
- for (i = 0; i < dests->nr; i++)
+ for (i = 0; i < dests->nr; i++) {
+ kobject_del(&dests_arr[i]->kobj);
kobject_put(&dests_arr[i]->kobj);
+ }
dests->nr = 0;
kfree(dests_arr);
dests->dests_arr = NULL;
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC PATCH v1.1 08/11] mm/damon/sysfs: kobject_del() probe dirs
2026-06-17 14:47 [RFC PATCH v1.1 00/11] mm/damon/sysfs: kobject_del() directories that users can create/remove SeongJae Park
` (6 preceding siblings ...)
2026-06-17 14:48 ` [RFC PATCH v1.1 07/11] mm/damon/sysfs-schemes: kobject_del() scheme action destination dirs SeongJae Park
@ 2026-06-17 14:48 ` SeongJae Park
2026-06-17 14:48 ` [RFC PATCH v1.1 09/11] mm/damon/sysfs: kobject_del() probe filter dirs SeongJae Park
` (2 subsequent siblings)
10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-06-17 14:48 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, damon, linux-kernel, linux-mm
On CONFIG_DEBUG_KOBJECT_RELEASE enabled kernel, lack of kobject_del()
could cause directories creation failures due to the name conflicts. Fix
those issues for data attribute probe directories by adding
kobject_del() calls.
Fixes: bf3ea3d30880 ("mm/damon/sysfs: implement probe dir")
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 3c349f0fe80f0..5ca45654cdd39 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1139,6 +1139,7 @@ static void damon_sysfs_probes_rm_dirs(
for (i = 0; i < probes->nr; i++) {
damon_sysfs_probe_rm_dirs(probes_arr[i]);
+ kobject_del(&probes_arr[i]->kobj);
kobject_put(&probes_arr[i]->kobj);
}
probes->nr = 0;
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC PATCH v1.1 09/11] mm/damon/sysfs: kobject_del() probe filter dirs
2026-06-17 14:47 [RFC PATCH v1.1 00/11] mm/damon/sysfs: kobject_del() directories that users can create/remove SeongJae Park
` (7 preceding siblings ...)
2026-06-17 14:48 ` [RFC PATCH v1.1 08/11] mm/damon/sysfs: kobject_del() probe dirs SeongJae Park
@ 2026-06-17 14:48 ` SeongJae Park
2026-06-17 14:48 ` [RFC PATCH v1.1 10/11] mm/damon/sysfs: kobject_del() probe dirs in probes_addd_dir error path SeongJae Park
2026-06-17 14:48 ` [RFC PATCH v1.1 11/11] mm/damon/sysfs-schemes: kobject_del() region for populate_region error SeongJae Park
10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-06-17 14:48 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, damon, linux-kernel, linux-mm
On CONFIG_DEBUG_KOBJECT_RELEASE enabled kernel, lack of kobject_del()
could cause directories creation failures due to the name conflicts. Fix
those issues for data attribute probe filter directories by adding
kobject_del() calls.
Fixes: 82e66aef7714 ("mm/damon/sysfs: implement filter dir")
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 5ca45654cdd39..36a0e82601697 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -962,8 +962,10 @@ static void damon_sysfs_filters_rm_dirs(struct damon_sysfs_filters *filters)
struct damon_sysfs_filter **filters_arr = filters->filters_arr;
int i;
- for (i = 0; i < filters->nr; i++)
+ for (i = 0; i < filters->nr; i++) {
+ kobject_del(&filters_arr[i]->kobj);
kobject_put(&filters_arr[i]->kobj);
+ }
filters->nr = 0;
kfree(filters_arr);
filters->filters_arr = NULL;
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC PATCH v1.1 10/11] mm/damon/sysfs: kobject_del() probe dirs in probes_addd_dir error path
2026-06-17 14:47 [RFC PATCH v1.1 00/11] mm/damon/sysfs: kobject_del() directories that users can create/remove SeongJae Park
` (8 preceding siblings ...)
2026-06-17 14:48 ` [RFC PATCH v1.1 09/11] mm/damon/sysfs: kobject_del() probe filter dirs SeongJae Park
@ 2026-06-17 14:48 ` SeongJae Park
2026-06-17 14:48 ` [RFC PATCH v1.1 11/11] mm/damon/sysfs-schemes: kobject_del() region for populate_region error SeongJae Park
10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-06-17 14:48 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, damon, linux-kernel, linux-mm
On CONFIG_DEBUG_KOBJECT_RELEASE enabled kernel, lack of kobject_del()
could cause directories creation failures due to the name conflicts.
Fix the issue for data attribute probe filter directories in the error
handling path of damon_sysfs_probes_add_dirs() by adding a kobject_del()
call.
Fixes: af7cb41af9a9 ("mm/damon/sysfs: implement filters directory")
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/mm/damon/sysfs.c b/mm/damon/sysfs.c
index 36a0e82601697..ffbc99411f53b 100644
--- a/mm/damon/sysfs.c
+++ b/mm/damon/sysfs.c
@@ -1183,6 +1183,7 @@ static int damon_sysfs_probes_add_dirs(
err = damon_sysfs_probe_add_dirs(probe);
if (err) {
+ kobject_del(&probe->kobj);
kobject_put(&probe->kobj);
damon_sysfs_probes_rm_dirs(probes);
return err;
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [RFC PATCH v1.1 11/11] mm/damon/sysfs-schemes: kobject_del() region for populate_region error
2026-06-17 14:47 [RFC PATCH v1.1 00/11] mm/damon/sysfs: kobject_del() directories that users can create/remove SeongJae Park
` (9 preceding siblings ...)
2026-06-17 14:48 ` [RFC PATCH v1.1 10/11] mm/damon/sysfs: kobject_del() probe dirs in probes_addd_dir error path SeongJae Park
@ 2026-06-17 14:48 ` SeongJae Park
10 siblings, 0 replies; 12+ messages in thread
From: SeongJae Park @ 2026-06-17 14:48 UTC (permalink / raw)
Cc: SeongJae Park, Andrew Morton, damon, linux-kernel, linux-mm
On CONFIG_DEBUG_KOBJECT_RELEASE enabled kernel, lack of kobject_del()
could cause directories creation failures due to the name conflicts.
Fix the issue for tried region directories in the error handling path of
damon_sysfs_populate_region_dir() by adding a kobject_del() call.
Fixes: b574a82d10de ("mm/damon/sysfs-schemes: implement tried_regions/<r>/probes/")
Signed-off-by: SeongJae Park <sj@kernel.org>
---
mm/damon/sysfs-schemes.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 0c0c9637b594e..d3b414f7bd205 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -3132,12 +3132,14 @@ void damos_sysfs_populate_region_dir(struct damon_sysfs_schemes *sysfs_schemes,
sysfs_regions->nr_regions))
goto out;
if (damos_sysfs_region_add_dirs(region, ctx, r))
- goto out;
+ goto del_out;
list_add_tail(®ion->list, &sysfs_regions->regions_list);
sysfs_regions->nr_regions++;
return;
+del_out:
+ kobject_del(®ion->kobj);
out:
kobject_put(®ion->kobj);
}
--
2.47.3
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2026-06-17 14:48 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-17 14:47 [RFC PATCH v1.1 00/11] mm/damon/sysfs: kobject_del() directories that users can create/remove SeongJae Park
2026-06-17 14:47 ` [RFC PATCH v1.1 01/11] mm/damon/sysfs: kobject_del() target (normal), context and kdamond dirs SeongJae Park
2026-06-17 14:47 ` [RFC PATCH v1.1 02/11] mm/damon/sysfs: kobject_del() region and target (error) dirs SeongJae Park
2026-06-17 14:47 ` [RFC PATCH v1.1 03/11] mm/damon/sysfs-schemes: kobject_del() scheme dirs SeongJae Park
2026-06-17 14:47 ` [RFC PATCH v1.1 04/11] mm/damon/sysfs-schemes: kobject_del() scheme region dirs SeongJae Park
2026-06-17 14:47 ` [RFC PATCH v1.1 05/11] mm/damon/sysfs-schemes: kobject_del() scheme filter dirs SeongJae Park
2026-06-17 14:48 ` [RFC PATCH v1.1 06/11] mm/damon/sysfs-schemes: kobject_del() scheme quota goal dirs SeongJae Park
2026-06-17 14:48 ` [RFC PATCH v1.1 07/11] mm/damon/sysfs-schemes: kobject_del() scheme action destination dirs SeongJae Park
2026-06-17 14:48 ` [RFC PATCH v1.1 08/11] mm/damon/sysfs: kobject_del() probe dirs SeongJae Park
2026-06-17 14:48 ` [RFC PATCH v1.1 09/11] mm/damon/sysfs: kobject_del() probe filter dirs SeongJae Park
2026-06-17 14:48 ` [RFC PATCH v1.1 10/11] mm/damon/sysfs: kobject_del() probe dirs in probes_addd_dir error path SeongJae Park
2026-06-17 14:48 ` [RFC PATCH v1.1 11/11] mm/damon/sysfs-schemes: kobject_del() region for populate_region error SeongJae Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox