From nobody Fri Sep 25 20:07:31 2026 Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 41CFC49AA28; Tue, 8 Sep 2026 21:42:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=130.117.225.111 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788903768; cv=none; b=PSHAQbWBR2c/wC9cCwTaKUPEv2cxIgKyAeVmo3ZISQS8JzxuQPFQ0c+JQqKTSg5RR4rz+jvPuHDU4rricPobGyGUvtbdOYkdx6X13Foz5VJGJz13tbUDJemjHaVAWWK7TCg5x0J/eNaCewqPzxW8ycCklZXiWdDphnt3xl6cUDE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788903768; c=relaxed/simple; bh=ynL4sTPqoRxUi/bbstz9Ih55gEIocNQe5Y8y9Op4EvE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=GUnfIIh5TK0JRL6iDu6T0T14uO+wje2N6sRZcUC/KIT1kCODawElksktRwsOKokxkSQq51hidFMyEeokklCchnOj5UkQ8miFPi2MY0bZXC8QKCebF2DU5vo8kIDYnsDQCMUokvQRCBcTAWyIdxmMOgZSp3mulDXB6jfaL5NxPnU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=virtuozzo.com; spf=pass smtp.mailfrom=virtuozzo.com; dkim=pass (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b=ETKbjd3P; arc=none smtp.client-ip=130.117.225.111 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=virtuozzo.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=virtuozzo.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="ETKbjd3P" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=O3DiMovYc6B1Qy4ylGXWdug+s2LRTGdo7r7Q/lm2Uiw=; b=ETKbjd3P0aIS zLSFZ4jfN+wofW8JHslFcmsD/O8r/7CEOqA2CgQBIibGHKTUOX8LU1w20IQX/08IABQFAVcKGRY/V nvDD4NqKToHgZCbe7G868ys1SH3bS9dxZTs7KBtnS1i2+7iYdXqp/fauxBg24bSsnL4FoCwOJY7+v /n7uAIcXQYOCNmidfaxypgH/uI+fb8kUwRqIC87TLKhn7EK3sKy/U6hmNqC+yN+7JDtOn5RVzEXmX 6o9I/XnywtrvKrzzmK3viVCj5TCSB7idsz7smYg52LiN0tQxYG5mm6wKDUH3FY39X2lGI7EGujwE7 AiWkOhwaUM4nj261WH+Csw==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=LekKit-T14) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1x43Xv-002j23-0I; Tue, 08 Sep 2026 23:42:31 +0200 From: Eva Kurchatova To: SJ Park , Shuah Khan Cc: linux-kernel@vger.kernel.org, Eva Kurchatova , damon@lists.linux.dev, linux-mm@kvack.org, linux-kselftest@vger.kernel.org Subject: [PATCH] selftests: damon: add script dir to sys.path for PYTHONSAFEPATH compatibility Date: Wed, 9 Sep 2026 00:42:35 +0300 Message-ID: <20260908214238.2680324-1-eva.kurchatova@virtuozzo.com> X-Mailer: git-send-email 2.55.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: SJ Park --- 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/test= ing/selftests/damon/damon_nr_regions.py index 58f3291fed12..e55239813c65 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 =20 +import os import subprocess +import sys import time =20 +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs =20 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 0f2f36584e48..0bf7768b2006 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 =20 +import os import subprocess +import sys import time =20 +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs =20 def main(): diff --git a/tools/testing/selftests/damon/damos_quota.py b/tools/testing/s= elftests/damon/damos_quota.py index 57c4937aaed2..879115a499bf 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 =20 +import os import subprocess +import sys import time =20 +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs =20 def main(): diff --git a/tools/testing/selftests/damon/damos_quota_goal.py b/tools/test= ing/selftests/damon/damos_quota_goal.py index 661e4ba4765a..fed033a0afdf 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 =20 +import os import subprocess +import sys import time =20 +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs =20 def main(): diff --git a/tools/testing/selftests/damon/damos_tried_regions.py b/tools/t= esting/selftests/damon/damos_tried_regions.py index d6472e6a6e08..6941f87c10b1 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 =20 +import os import subprocess +import sys import time =20 +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs =20 def main(): diff --git a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regio= ns_hang.py b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regio= ns_hang.py index 28c887a0108f..625761c243b5 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 =20 +import os import subprocess +import sys import time =20 +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs =20 def main(): diff --git a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regio= ns_wss_estimation.py b/tools/testing/selftests/damon/sysfs_update_schemes_t= ried_regions_wss_estimation.py index 16fdc6e7fc56..36e7ae5f826d 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 =20 +import os import subprocess +import sys import time =20 +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs =20 def pass_wss_estimation(sz_region): --=20 2.55.0