Linux-mm Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Kunwu Chan <kunwu.chan@linux.dev>
To: sj@kernel.org, shuah@kernel.org
Cc: damon@lists.linux.dev, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-mm@kvack.org,
	Kunwu Chan <kunwu.chan@gmail.com>,
	Wang Lian <lianux.mm@gmail.com>, Kunwu Chan <chentao@kylinos.cn>
Subject: [PATCH 4/5] selftests/damon/damos_tried_regions: handle empty tried regions in early cycles
Date: Sun, 31 May 2026 17:17:23 +0800	[thread overview]
Message-ID: <20260531091724.84381-4-kunwu.chan@linux.dev> (raw)
In-Reply-To: <20260531091724.84381-1-kunwu.chan@linux.dev>

From: Kunwu Chan <kunwu.chan@gmail.com>

The test aborts if the initial aggregation cycles produce zero
tried regions.  This can happen on slow machines, causing false
failures.  Skip empty cycles and retry up to 200 times before
giving up.  Also check that enough samples were collected before
computing the 50th percentile.

Co-developed-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Wang Lian <lianux.mm@gmail.com>
Signed-off-by: Kunwu Chan <chentao@kylinos.cn>
---
 .../selftests/damon/damos_tried_regions.py       | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/tools/testing/selftests/damon/damos_tried_regions.py b/tools/testing/selftests/damon/damos_tried_regions.py
index d6472e6a6e08..cc6895c56820 100755
--- a/tools/testing/selftests/damon/damos_tried_regions.py
+++ b/tools/testing/selftests/damon/damos_tried_regions.py
@@ -28,7 +28,9 @@ def main():
         exit(1)
 
     collected_nr_regions = []
-    while proc.poll() is None:
+    nr_retries = 0
+    while proc.poll() is None and nr_retries < 200:
+        nr_retries += 1
         time.sleep(0.1)
         err = kdamonds.kdamonds[0].update_schemes_tried_regions()
         if err is not None:
@@ -38,20 +40,20 @@ def main():
 
         scheme = kdamonds.kdamonds[0].contexts[0].schemes[0]
         if scheme.tried_regions is None:
-            proc.terminate()
-            print('tried regions is not collected')
-            exit(1)
+            continue
 
         nr_tried_regions = len(scheme.tried_regions)
         if nr_tried_regions <= 0:
-            proc.terminate()
-            print('tried regions is not created')
-            exit(1)
+            continue
         collected_nr_regions.append(nr_tried_regions)
         if len(collected_nr_regions) > 10:
             break
     proc.terminate()
 
+    if len(collected_nr_regions) <= 4:
+        print('too few tried regions samples collected')
+        exit(1)
+
     collected_nr_regions.sort()
     sample = collected_nr_regions[4]
     print('50-th percentile nr_regions: %d' % sample)
-- 
2.43.0



  parent reply	other threads:[~2026-05-31  9:18 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-31  8:56 [PATCH 0/5] selftests/damon: misc fixes for test bugs Kunwu Chan
2026-05-31  9:17 ` [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx Kunwu Chan
2026-05-31  9:17   ` [PATCH 2/5] selftests/damon: fix memcg filter path handling Kunwu Chan
2026-05-31 16:36     ` SeongJae Park
2026-06-01  2:19       ` Kunwu Chan
2026-05-31  9:17   ` [PATCH 3/5] selftests/damon/damos_tried_regions: fix expectation output and join TypeError Kunwu Chan
2026-05-31 16:39     ` SeongJae Park
2026-05-31  9:17   ` Kunwu Chan [this message]
2026-05-31 16:54     ` [PATCH 4/5] selftests/damon/damos_tried_regions: handle empty tried regions in early cycles SeongJae Park
2026-06-01  2:33       ` Kunwu Chan
2026-05-31  9:17   ` [PATCH 5/5] selftests/damon: fix dead code, skipped checks, and broken lookups Kunwu Chan
2026-05-31 16:59     ` SeongJae Park
2026-05-31 16:30   ` [PATCH 1/5] selftests/damon: prevent cross-context state pollution in DamonCtx SeongJae Park
2026-06-01  2:11     ` Kunwu Chan
2026-05-31 17:08 ` [PATCH 0/5] selftests/damon: misc fixes for test bugs SeongJae Park
2026-06-01  2:38   ` Kunwu Chan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260531091724.84381-4-kunwu.chan@linux.dev \
    --to=kunwu.chan@linux.dev \
    --cc=chentao@kylinos.cn \
    --cc=damon@lists.linux.dev \
    --cc=kunwu.chan@gmail.com \
    --cc=lianux.mm@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    --cc=shuah@kernel.org \
    --cc=sj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox