]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
mm/damon: add CONFIG_DAMON_DEBUG_SANITY
authorSeongJae Park <sj@kernel.org>
Fri, 6 Mar 2026 15:29:04 +0000 (07:29 -0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 5 Apr 2026 20:53:20 +0000 (13:53 -0700)
Patch series "mm/damon: add optional debugging-purpose sanity checks".

DAMON code has a few assumptions that can be critical if violated.
Validating the assumptions in code can be useful at finding such critical
bugs.  I was actually adding some such additional sanity checks in my
personal tree, and those were useful at finding bugs that I made during
the development of new patches.  We also found [1] sometimes the
assumptions are misunderstood.  The validation can work as good
documentation for such cases.

Add some of such debugging purpose sanity checks.  Because those
additional checks can impose more overhead, make those only optional via
new config, CONFIG_DAMON_DEBUG_SANITY, that is recommended for only
development and test setups.  And as recommended, enable it for DAMON
kunit tests and selftests.

Note that the verification only WARN_ON() for each of the insanity.  The
developer or tester may better to set panic_on_oops together, like
damon-tests/corr did [2].

This patch (of 10):

Add a new build config that will enable additional DAMON sanity checks.
It is recommended to be enabled on only development and test setups, since
it can impose additional overhead.

Link: https://lkml.kernel.org/r/20260306152914.86303-1-sj@kernel.org
Link: https://lkml.kernel.org/r/20260306152914.86303-2-sj@kernel.org
Link: https://lore.kernel.org/20251231070029.79682-1-sj@kernel.org
Link: https://github.com/damonitor/damon-tests/commit/a80fbee55e272f151b4e5809ee85898aea33e6ff
Signed-off-by: SeongJae Park <sj@kernel.org>
Cc: Brendan Higgins <brendan.higgins@linux.dev>
Cc: David Gow <davidgow@google.com>
Cc: Shuah Khan <shuah@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/damon/Kconfig

index 8c868f7035fce7e2bc2f0adbb96233a7f242ec9e..34631a44cdecb8741fd71793283204005a99ff45 100644 (file)
@@ -12,6 +12,17 @@ config DAMON
          See https://www.kernel.org/doc/html/latest/mm/damon/index.html for
          more information.
 
+config DAMON_DEBUG_SANITY
+       bool "Check sanity of DAMON code"
+       depends on DAMON
+       help
+         This enables additional DAMON debugging-purpose sanity checks in
+         DAMON code.  This can be useful for finding bugs, but impose
+         additional overhead.  This is therefore recommended to be enabled on
+         only development and test setups.
+
+         If unsure, say N.
+
 config DAMON_KUNIT_TEST
        bool "Test for damon" if !KUNIT_ALL_TESTS
        depends on DAMON && KUNIT=y