Re: [PATCH] perf build: Do not use the mypy cache

From: Ian Rogers

Date: Fri Dec 04 2026 - 12:36:41 EST


On Fri, Dec 4, 2026 at 8:47 AM Sasha Levin <sashal@xxxxxxxxxx> wrote:
>
> The build runs one mypy process per Python file, in parallel, and since
> commit b3e9c396d0ac ("perf build: Make mypy build test opt-out
> (NO_MYPY=1)") it does so whenever mypy is installed. All of them use
> the default cache, .mypy_cache in tools/perf of the source tree.
>
> Since mypy 1.20 that cache is an SQLite database by default. mypy 2.4.1
> sets the journal mode of the database every time it opens it, and that
> fails if another process has the database locked at that moment:
>
> sqlite3.OperationalError: database is locked
>
> mypy reports this as an internal error and the build fails:
>
> error: INTERNAL ERROR -- Please try using mypy master on GitHub:
> [...]
> make[3]: *** [util/Build:426:
> /tmp/kci/kernel_build/util/setup.py.mypy_log] Error 1
>
> Which files fail changes from build to build. KernelCI's arm64 perf
> build of mainline, with mypy 2.4.1, has failed this way in 17 of 22
> builds since November 26.
>
> Pass --cache-dir=/dev/null so that mypy uses no cache. The build also no
> longer writes .mypy_cache into the source tree.
>
> mypy does not start worker processes without a cache and exits with
> "Cache must be enabled in parallel mode" when MYPY_NUM_WORKERS or
> num_workers in a mypy configuration file asks for them, so set
> MYPY_NUM_WORKERS=0 for these runs. Each run checks a single file, so
> workers would not help.
>
> Fixes: b3e9c396d0ac ("perf build: Make mypy build test opt-out (NO_MYPY=1)")
> Reported-by: kernelci.org bot <bot@xxxxxxxxxxxx>
> Closes: https://lore.kernel.org/all/179589234320.273234.15340882774679334017@xxxxxxxxxxxx/
> Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

Reviewed-by: Ian Rogers <irogers@xxxxxxxxxx>

Thanks,
Ian

> ---
>
> tools/perf/Makefile.perf | 8 +++++++-
> 1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 4cc5bb3011da4..142237fc626f4 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -269,6 +269,11 @@ endif
> # (substituting escaped spaces so multi-word overrides like MYPY="mypy --strict"
> # are removed as a single token) so child Makefile.build sub-makes inherit the
> # MYPYPATH-wrapped export MYPY environment variable.
> +# One mypy process runs per file and they run in parallel. mypy's cache cannot
> +# be shared by concurrent runs (opening its SQLite database fails with
> +# "database is locked"), so turn it off. mypy does not start worker processes
> +# without a cache, so set MYPY_NUM_WORKERS=0, which also overrides num_workers
> +# in a mypy configuration file.
> ifneq ($(force_fixdep),1)
> MAKEOVERRIDES := $(subst __SPACE__,\ ,$(filter-out MYPY=%,$(subst \ ,__SPACE__,$(MAKEOVERRIDES))))
> ifeq ($(NO_MYPY),1)
> @@ -278,7 +283,8 @@ ifneq ($(force_fixdep),1)
> endif
>
> ifneq ($(MYPY),)
> - override MYPY := MYPYPATH=$(srctree)/tools/perf/python $(MYPY) --ignore-missing-imports
> + override MYPY := MYPYPATH=$(srctree)/tools/perf/python MYPY_NUM_WORKERS=0 $(MYPY) \
> + --ignore-missing-imports --cache-dir=/dev/null
> endif
> endif
>
>
> base-commit: 007722b8211f7b34fdf21b1e6a9c32497633ea29
> --
> 2.53.0
>