Skip to contentSkip to conversation

selftests-damon-prevent-cross-context-state-pollution-in-damonctx.patch removed from -mm tree

merged mm-stable Andrew Morton 1 participant 1 message Jul 29

lore
Share & tools
lore

Andrew Morton

author tree notice Applied
#0 lore raw

The quilt patch titled
Subject: selftests/damon: prevent cross-context state pollution in DamonCtx
has been removed from the -mm tree. Its filename was
selftests-damon-prevent-cross-context-state-pollution-in-damonctx.patch

This patch was dropped because it was merged into the mm-stable branch of git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm

------------------------------------------------------
From: Kunwu Chan <[email protected]>
Subject: selftests/damon: prevent cross-context state pollution in DamonCtx
Date: Mon, 29 Jun 2026 07:46:44 -0700

Patch series "selftests/damon: misc fixes for test bugs", v3.

This series fixes several bugs in the DAMON selftests. Most are trivial but makes test output wrong or even silently pass the one test case for 'avail_operation' file existence check.

Patch 1 fixes mutable default arguments in DamonCtx.__init__() that cause state to leak between test instances.

Patch 2 fixes wrong operator precedence and join TypeError in damos_tried_regions.py.

Patch 3 fixes several wrong strings that produce dead elif branches, skipped file existence checks, and broken dict key lookups.

This patch (of 3):

DamonCtx.__init__() uses mutable default values for monitoring_attrs, targets, and schemes. In Python these are evaluated once at function definition time, so multiple DamonCtx instances can unintentionally share the same lists and DamonAttrs instance.

Replace the mutable defaults with None sentinels and initialize the objects when needed.

---

 tools/testing/selftests/damon/_damon_sysfs.py |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
tools/testing/selftests/damon/_damon_sysfs.py renamed from tools/testing/selftests/damon/_damon_sysfs.py~selftests-damon-prevent-cross-context-state-pollution-in-damonctx +8 -2
@@ -624,17 +624,23 @@ class DamonCtx:
     pause = None
     idx = None
 
-    def __init__(self, ops='paddr', monitoring_attrs=DamonAttrs(), targets=[],
-            schemes=[], pause=False):
+    def __init__(self, ops='paddr', monitoring_attrs=None, targets=None,
+            schemes=None, pause=False):
         self.ops = ops
+        if monitoring_attrs is None:
+            monitoring_attrs = DamonAttrs()
         self.monitoring_attrs = monitoring_attrs
         self.monitoring_attrs.context = self
 
+        if targets is None:
+            targets = []
         self.targets = targets
         for idx, target in enumerate(self.targets):
             target.idx = idx
             target.context = self
 
+        if schemes is None:
+            schemes = []
         self.schemes = schemes
         for idx, scheme in enumerate(self.schemes):
             scheme.idx = idx

_

Patches currently in -mm which might be from [email protected] are