Re: [PATCH] selftests: damon: add script dir to sys.path for PYTHONSAFEPATH compatibility

From: SJ Park

Date: Tue Sep 08 2026 - 20:20:48 EST


On Wed, 9 Sep 2026 00:42:35 +0300 Eva Kurchatova <eva.kurchatova@xxxxxxxxxxxxx> wrote:

> 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.

Thank you for finding and fixing this, Eva!

>
> Signed-off-by: Eva Kurchatova <eva.kurchatova@xxxxxxxxxxxxx>

Reviewed-by: SJ Park <sj@xxxxxxxxxx>

This patch is applied to damon/next [1] tree. If this patch is not added to
mm.git in short term (~1 week?), I will ask mm.git maintainer (Andrew Morton)
to pick this. So, no action from your side is needed for now. If it seems I
also forgot doing that or you cannot wait for my action, please feel free to
directly ask that to Andrew.

[1] https://origin.kernel.org/doc/html/latest/mm/damon/maintainer-profile.html#scm-trees


Thanks,
SJ

[...]