From: SJ Park <sj@kernel.org>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: Eva Kurchatova <eva.kurchatova@virtuozzo.com>,
SJ Park <sj@kernel.org>, Shuah Khan <shuah@kernel.org>,
damon@lists.linux.dev, linux-kernel@vger.kernel.org,
linux-kselftest@vger.kernel.org, linux-mm@kvack.org
Subject: [PATCH 3/6] selftests/damon: add script dir to sys.path for PYTHONSAFEPATH compatibility
Date: Mon, 14 Sep 2026 07:19:48 -0700 [thread overview]
Message-ID: <20260914141952.91465-4-sj@kernel.org> (raw)
In-Reply-To: <20260914141952.91465-1-sj@kernel.org>
From: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Running these tests under Python's safe path mode, either with -P on the
interpreter command line or with PYTHONSAFEPATH set in the environment,
stops the script's own directory being prepended to sys.path. Some
distributions (RHEL, for example) build the tests with -P in the shebang.
This breaks all 7 DAMON Python selftests that import the _damon_sysfs
helper module located in the same directory:
ModuleNotFoundError: No module named '_damon_sysfs'
Fix this by explicitly adding the script's directory to sys.path before
importing _damon_sysfs, following the same pattern used in commit
c3b3eb565bd7 ("tools: ynl: add script dir to sys.path") which fixed the
identical issue for the YNL tools.
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
Reviewed-by: SJ Park <sj@kernel.org>
Signed-off-by: SJ Park <sj@kernel.org>
---
Changes from v1
- v1: https://lore.kernel.org/20260908214238.2680324-1-eva.kurchatova@virtuozzo.com
- Collect R-b: from SJ.
- Rebase to latest mm-new.
tools/testing/selftests/damon/damon_nr_regions.py | 3 +++
tools/testing/selftests/damon/damos_apply_interval.py | 3 +++
tools/testing/selftests/damon/damos_quota.py | 3 +++
tools/testing/selftests/damon/damos_quota_goal.py | 3 +++
tools/testing/selftests/damon/damos_tried_regions.py | 3 +++
.../selftests/damon/sysfs_update_schemes_tried_regions_hang.py | 3 +++
.../damon/sysfs_update_schemes_tried_regions_wss_estimation.py | 3 +++
7 files changed, 21 insertions(+)
diff --git a/tools/testing/selftests/damon/damon_nr_regions.py b/tools/testing/selftests/damon/damon_nr_regions.py
index 58f3291fed12a..e55239813c654 100755
--- a/tools/testing/selftests/damon/damon_nr_regions.py
+++ b/tools/testing/selftests/damon/damon_nr_regions.py
@@ -1,9 +1,12 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
+import os
import subprocess
+import sys
import time
+sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import _damon_sysfs
def test_nr_regions(real_nr_regions, min_nr_regions, max_nr_regions):
diff --git a/tools/testing/selftests/damon/damos_apply_interval.py b/tools/testing/selftests/damon/damos_apply_interval.py
index 0f2f36584e48c..0bf7768b2006a 100755
--- a/tools/testing/selftests/damon/damos_apply_interval.py
+++ b/tools/testing/selftests/damon/damos_apply_interval.py
@@ -1,9 +1,12 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
+import os
import subprocess
+import sys
import time
+sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import _damon_sysfs
def main():
diff --git a/tools/testing/selftests/damon/damos_quota.py b/tools/testing/selftests/damon/damos_quota.py
index 57c4937aaed28..879115a499bf8 100755
--- a/tools/testing/selftests/damon/damos_quota.py
+++ b/tools/testing/selftests/damon/damos_quota.py
@@ -1,9 +1,12 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
+import os
import subprocess
+import sys
import time
+sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import _damon_sysfs
def main():
diff --git a/tools/testing/selftests/damon/damos_quota_goal.py b/tools/testing/selftests/damon/damos_quota_goal.py
index 661e4ba4765ae..fed033a0afdf9 100755
--- a/tools/testing/selftests/damon/damos_quota_goal.py
+++ b/tools/testing/selftests/damon/damos_quota_goal.py
@@ -1,9 +1,12 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
+import os
import subprocess
+import sys
import time
+sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import _damon_sysfs
def main():
diff --git a/tools/testing/selftests/damon/damos_tried_regions.py b/tools/testing/selftests/damon/damos_tried_regions.py
index d6472e6a6e082..6941f87c10b1c 100755
--- a/tools/testing/selftests/damon/damos_tried_regions.py
+++ b/tools/testing/selftests/damon/damos_tried_regions.py
@@ -1,9 +1,12 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
+import os
import subprocess
+import sys
import time
+sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import _damon_sysfs
def main():
diff --git a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py
index 28c887a0108fd..625761c243b58 100755
--- a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py
+++ b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py
@@ -1,9 +1,12 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
+import os
import subprocess
+import sys
import time
+sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import _damon_sysfs
def main():
diff --git a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py
index 16fdc6e7fc566..36e7ae5f826d8 100755
--- a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py
+++ b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py
@@ -1,9 +1,12 @@
#!/usr/bin/env python3
# SPDX-License-Identifier: GPL-2.0
+import os
import subprocess
+import sys
import time
+sys.path.append(os.path.dirname(os.path.abspath(__file__)))
import _damon_sysfs
def pass_wss_estimation(sz_region):
--
2.47.3
next prev parent reply other threads:[~2026-09-14 14:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-14 14:19 [PATCH 0/6] mm/damon: misc improvements in tests and documents SJ Park
2026-09-14 14:19 ` [PATCH 1/6] selftests/damon: stop kdamond on error exits of no-op commit test SJ Park
2026-09-14 14:19 ` [PATCH 2/6] selftests/damon: ignore test-generated damon_dump_output SJ Park
2026-09-14 14:19 ` SJ Park [this message]
2026-09-14 14:19 ` [PATCH 4/6] mm/damon/tests/core-kunit: improve nr_samples_per_aggr test isolation SJ Park
2026-09-14 14:19 ` [PATCH 5/6] Docs/mm/damon/design: clarify when qt_exceeds increases SJ Park
2026-09-14 14:19 ` [PATCH 6/6] Docs/mm/damon/design: fix typos in temporal auto-tuning algorithm section SJ Park
2026-09-14 14:50 ` [PATCH 0/6] mm/damon: misc improvements in tests and documents SJ Park
2026-09-15 2:00 ` Andrew Morton
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=20260914141952.91465-4-sj@kernel.org \
--to=sj@kernel.org \
--cc=akpm@linux-foundation.org \
--cc=damon@lists.linux.dev \
--cc=eva.kurchatova@virtuozzo.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=shuah@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
all inboxes | Powered by JetHome®