linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] selftests/damon: three fixes for false results
@ 2025-02-25 22:23 SeongJae Park
  2025-02-25 22:23 ` [PATCH 1/3] selftests/damon/damos_quota: make real expectation of quota exceeds SeongJae Park
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: SeongJae Park @ 2025-02-25 22:23 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Shuah Khan, damon, kernel-team, linux-kernel,
	linux-kselftest, linux-mm

Fix three DAMON selftest bugs that causes two and one false positive
failures and success.

SeongJae Park (3):
  selftests/damon/damos_quota: make real expectation of quota exceeds
  selftests/damon/damon_nr_regions: set ops update for merge results
    check to 100ms
  selftests/damon/damon_nr_regions: sort collected regiosn before
    checking with min/max boundaries

 tools/testing/selftests/damon/damon_nr_regions.py | 2 ++
 tools/testing/selftests/damon/damos_quota.py      | 9 ++++++---
 2 files changed, 8 insertions(+), 3 deletions(-)


base-commit: 0ab548cd0961a01f9ef65aa999ca84febcdb04ab
-- 
2.39.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/3] selftests/damon/damos_quota: make real expectation of quota exceeds
  2025-02-25 22:23 [PATCH 0/3] selftests/damon: three fixes for false results SeongJae Park
@ 2025-02-25 22:23 ` SeongJae Park
  2025-02-25 22:23 ` [PATCH 2/3] selftests/damon/damon_nr_regions: set ops update for merge results check to 100ms SeongJae Park
  2025-02-25 22:23 ` [PATCH 3/3] selftests/damon/damon_nr_regions: sort collected regiosn before checking with min/max boundaries SeongJae Park
  2 siblings, 0 replies; 4+ messages in thread
From: SeongJae Park @ 2025-02-25 22:23 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Shuah Khan, damon, kernel-team, linux-kernel,
	linux-kselftest, linux-mm, stable

damos_quota.py assumes the quota will always exceeded.  But whether
quota will be exceeded or not depend on the monitoring results.
Actually the monitored workload has chaning access pattern and hence
sometimes the quota may not really be exceeded.  As a result, false
positive test failures happen.  Expect how much time the quota will be
exceeded by checking the monitoring results, and use it instead of the
naive assumption.

Fixes: 51f58c9da14b ("selftests/damon: add a test for DAMOS quota")
Cc: <stable@vger.kernel.org>
Signed-off-by: SeongJae Park <sj@kernel.org>
---
 tools/testing/selftests/damon/damos_quota.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/damon/damos_quota.py b/tools/testing/selftests/damon/damos_quota.py
index 7d4c6bb2e3cd..57c4937aaed2 100755
--- a/tools/testing/selftests/damon/damos_quota.py
+++ b/tools/testing/selftests/damon/damos_quota.py
@@ -51,16 +51,19 @@ def main():
         nr_quota_exceeds = scheme.stats.qt_exceeds
 
     wss_collected.sort()
+    nr_expected_quota_exceeds = 0
     for wss in wss_collected:
         if wss > sz_quota:
             print('quota is not kept: %s > %s' % (wss, sz_quota))
             print('collected samples are as below')
             print('\n'.join(['%d' % wss for wss in wss_collected]))
             exit(1)
+        if wss == sz_quota:
+            nr_expected_quota_exceeds += 1
 
-    if nr_quota_exceeds < len(wss_collected):
-        print('quota is not always exceeded: %d > %d' %
-              (len(wss_collected), nr_quota_exceeds))
+    if nr_quota_exceeds < nr_expected_quota_exceeds:
+        print('quota is exceeded less than expected: %d < %d' %
+              (nr_quota_exceeds, nr_expected_quota_exceeds))
         exit(1)
 
 if __name__ == '__main__':
-- 
2.39.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 2/3] selftests/damon/damon_nr_regions: set ops update for merge results check to 100ms
  2025-02-25 22:23 [PATCH 0/3] selftests/damon: three fixes for false results SeongJae Park
  2025-02-25 22:23 ` [PATCH 1/3] selftests/damon/damos_quota: make real expectation of quota exceeds SeongJae Park
@ 2025-02-25 22:23 ` SeongJae Park
  2025-02-25 22:23 ` [PATCH 3/3] selftests/damon/damon_nr_regions: sort collected regiosn before checking with min/max boundaries SeongJae Park
  2 siblings, 0 replies; 4+ messages in thread
From: SeongJae Park @ 2025-02-25 22:23 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Shuah Khan, damon, kernel-team, linux-kernel,
	linux-kselftest, linux-mm, stable

damon_nr_regions.py updates max_nr_regions to a number smaller than
expected number of real regions and confirms DAMON respect the harsh
limit.  To give time for DAMON to make changes for the regions, 3
aggregation intervals (300 milliseconds) are given.

The internal mechanism works with not only the max_nr_regions, but also
sz_limit, though.  It avoids merging region if that casn make region of
size larger than sz_limit.  In the test, sz_limit is set too small to
achive the new max_nr_regions, unless it is updated for the new
min_nr_regions.  But the update is done only once per operations set
update interval, which is one second by default.

Hence, the test randomly incurs false positive failures.  Fix it by
setting the ops interval same to aggregation interval, to make sure
sz_limit is updated by the time of the check.

Fixes: 8bf890c81612 ("selftests/damon/damon_nr_regions: test online-tuned max_nr_regions")
Cc: <stable@vger.kernel.org>
Signed-off-by: SeongJae Park <sj@kernel.org>
---
 tools/testing/selftests/damon/damon_nr_regions.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/damon/damon_nr_regions.py b/tools/testing/selftests/damon/damon_nr_regions.py
index 2e8a74aff543..6f1c1d88e309 100755
--- a/tools/testing/selftests/damon/damon_nr_regions.py
+++ b/tools/testing/selftests/damon/damon_nr_regions.py
@@ -109,6 +109,7 @@ def main():
     attrs = kdamonds.kdamonds[0].contexts[0].monitoring_attrs
     attrs.min_nr_regions = 3
     attrs.max_nr_regions = 7
+    attrs.update_us = 100000
     err = kdamonds.kdamonds[0].commit()
     if err is not None:
         proc.terminate()
-- 
2.39.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/3] selftests/damon/damon_nr_regions: sort collected regiosn before checking with min/max boundaries
  2025-02-25 22:23 [PATCH 0/3] selftests/damon: three fixes for false results SeongJae Park
  2025-02-25 22:23 ` [PATCH 1/3] selftests/damon/damos_quota: make real expectation of quota exceeds SeongJae Park
  2025-02-25 22:23 ` [PATCH 2/3] selftests/damon/damon_nr_regions: set ops update for merge results check to 100ms SeongJae Park
@ 2025-02-25 22:23 ` SeongJae Park
  2 siblings, 0 replies; 4+ messages in thread
From: SeongJae Park @ 2025-02-25 22:23 UTC (permalink / raw)
  To: Andrew Morton
  Cc: SeongJae Park, Shuah Khan, damon, kernel-team, linux-kernel,
	linux-kselftest, linux-mm, stable

damon_nr_regions.py starts DAMON, periodically collect number of regions
in snapshots, and see if it is in the requested range.  The check code
assumes the numbers are sorted on the collection list, but there is no
such guarantee.  Hence this can result in false positive test success.
Sort the list before doing the check.

Fixes: 781497347d1b ("selftests/damon: implement test for min/max_nr_regions")
Cc: <stable@vger.kernel.org>
Signed-off-by: SeongJae Park <sj@kernel.org>
---
 tools/testing/selftests/damon/damon_nr_regions.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/damon/damon_nr_regions.py b/tools/testing/selftests/damon/damon_nr_regions.py
index 6f1c1d88e309..58f3291fed12 100755
--- a/tools/testing/selftests/damon/damon_nr_regions.py
+++ b/tools/testing/selftests/damon/damon_nr_regions.py
@@ -65,6 +65,7 @@ def test_nr_regions(real_nr_regions, min_nr_regions, max_nr_regions):
 
     test_name = 'nr_regions test with %d/%d/%d real/min/max nr_regions' % (
             real_nr_regions, min_nr_regions, max_nr_regions)
+    collected_nr_regions.sort()
     if (collected_nr_regions[0] < min_nr_regions or
         collected_nr_regions[-1] > max_nr_regions):
         print('fail %s' % test_name)
-- 
2.39.5


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-02-25 22:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-25 22:23 [PATCH 0/3] selftests/damon: three fixes for false results SeongJae Park
2025-02-25 22:23 ` [PATCH 1/3] selftests/damon/damos_quota: make real expectation of quota exceeds SeongJae Park
2025-02-25 22:23 ` [PATCH 2/3] selftests/damon/damon_nr_regions: set ops update for merge results check to 100ms SeongJae Park
2025-02-25 22:23 ` [PATCH 3/3] selftests/damon/damon_nr_regions: sort collected regiosn before checking with min/max boundaries SeongJae Park

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox