Linux Perf Users
 help / color / mirror / Atom feed
* [PATCH 0/3] perf build: Fix pylint build failures
@ 2026-09-30  9:01 Leo Yan
  2026-09-30  9:01 ` [PATCH 1/3] perf build: Build the Python extension before pylint consumers Leo Yan
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Leo Yan @ 2026-09-30  9:01 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
	Adrian Hunter, James Clark, Aishwarya TCV
  Cc: linux-perf-users, linux-kernel, Arnaldo Carvalho de Melo, Leo Yan

Recent changes to perf's Python module, including enabling pylint by
default, exposed build failures in our CI. For example:

  tests/shell/lib/perf_brstack_max.py:8:0: E0401: Unable to import 'perf' (import-error)

This series ensures the perf Python extension is built before running
pylint on its consumers and prepends the output Python directory to
PYTHONPATH for out-of-tree builds.

The series also mutes the optparse deprecation warning from older pylint
versions. Python has reversed this deprecation, and newer pylint
versions no longer report it.

Signed-off-by: Leo Yan <leo.yan@arm.com>
---
Leo Yan (3):
      perf build: Build the Python extension before pylint consumers
      perf build: Add the output Python directory to pylint's PYTHONPATH
      perf test: Suppress optparse deprecation warning with older pylint

 tools/perf/Makefile.perf           | 8 +++++++-
 tools/perf/tests/shell/lib/attr.py | 3 ++-
 2 files changed, 9 insertions(+), 2 deletions(-)
---
base-commit: 45d15e89a783a0a279b7a54f9018c230127380d7
change-id: 20260930-perf_fix_pylint_errors-3cef583b1e47

Best regards,
-- 
Leo Yan <leo.yan@arm.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] perf build: Build the Python extension before pylint consumers
  2026-09-30  9:01 [PATCH 0/3] perf build: Fix pylint build failures Leo Yan
@ 2026-09-30  9:01 ` Leo Yan
  2026-09-30  9:15   ` sashiko-bot
  2026-09-30  9:01 ` [PATCH 2/3] perf build: Add the output Python directory to pylint's PYTHONPATH Leo Yan
  2026-09-30  9:01 ` [PATCH 3/3] perf test: Suppress optparse deprecation warning with older pylint Leo Yan
  2 siblings, 1 reply; 8+ messages in thread
From: Leo Yan @ 2026-09-30  9:01 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
	Adrian Hunter, James Clark, Aishwarya TCV
  Cc: linux-perf-users, linux-kernel, Arnaldo Carvalho de Melo, Leo Yan

Pylint checks for tests and standalone Python scripts can run before the
perf Python extension is available. On a clean parallel build, an import
error can stop make before the extension is built.

When pylint is enabled, make the perf and perf-test sub-makes wait for the
enabled language bindings using an order-only dependency. The extension
does not depend on either consumer, so this does not introduce a cycle.

Fixes: 8a54784e708b ("perf build: Add pylint build tests")
Reported-by: Aishwarya TCV <aishwarya.tcv@arm.com>
Assisted-by: Codex:gpt-6
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/Makefile.perf | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index 0102c3468a0b79fb22966d8cbd8fa8525d2ff3ae..d350d085542c64fc6d0bed4c5d7d1daac51efa8b 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -578,6 +578,12 @@ strip: $(PROGRAMS) $(OUTPUT)perf
 	$(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
 
 PERF_IN := $(OUTPUT)perf-in.o
+
+ifdef PYLINT
+# Build the Python extension before starting sub-makes that lint its users.
+$(PERF_IN) $(LIBPERF_TEST_IN): | $(LANG_BINDINGS)
+endif
+
 export NO_JEVENTS
 
 build := -f $(srctree)/tools/build/Makefile.build dir=. obj

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] perf build: Add the output Python directory to pylint's PYTHONPATH
  2026-09-30  9:01 [PATCH 0/3] perf build: Fix pylint build failures Leo Yan
  2026-09-30  9:01 ` [PATCH 1/3] perf build: Build the Python extension before pylint consumers Leo Yan
@ 2026-09-30  9:01 ` Leo Yan
  2026-09-30  9:07   ` sashiko-bot
  2026-09-30  9:01 ` [PATCH 3/3] perf test: Suppress optparse deprecation warning with older pylint Leo Yan
  2 siblings, 1 reply; 8+ messages in thread
From: Leo Yan @ 2026-09-30  9:01 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
	Adrian Hunter, James Clark, Aishwarya TCV
  Cc: linux-perf-users, linux-kernel, Arnaldo Carvalho de Melo, Leo Yan

Prepend the output Python directory to pylint's PYTHONPATH so builds
using O= can also find the generated extension.

Fixes: 5fe83fb352c8 ("perf build: Make pylint build test opt-out (NO_PYLINT=1)")
Reported-by: Aishwarya TCV <aishwarya.tcv@arm.com>
Assisted-by: Codex:gpt-6
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/Makefile.perf | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
index d350d085542c64fc6d0bed4c5d7d1daac51efa8b..0151aac394569671b98c98a42d97f75d380856cc 100644
--- a/tools/perf/Makefile.perf
+++ b/tools/perf/Makefile.perf
@@ -310,7 +310,7 @@ ifneq ($(force_fixdep),1)
       $(warning Warning: pylint version is older than 2.16.0, skipping pylint checks.)
       override PYLINT :=
     else
-      override PYLINT := PYTHONPATH=$(srctree)/tools/perf/python:$(srctree)/tools/perf/pmu-events \
+      override PYLINT := PYTHONPATH=$(abspath $(OUTPUT)python):$(srctree)/tools/perf/python:$(srctree)/tools/perf/pmu-events \
         $(PYLINT) --disable=all --enable=E,W --disable=W0123,W0311,W0511,W0603,W0622,W0718 \
         --ignored-modules=textual,setproctitle
     endif

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] perf test: Suppress optparse deprecation warning with older pylint
  2026-09-30  9:01 [PATCH 0/3] perf build: Fix pylint build failures Leo Yan
  2026-09-30  9:01 ` [PATCH 1/3] perf build: Build the Python extension before pylint consumers Leo Yan
  2026-09-30  9:01 ` [PATCH 2/3] perf build: Add the output Python directory to pylint's PYTHONPATH Leo Yan
@ 2026-09-30  9:01 ` Leo Yan
  2026-09-30  9:04   ` sashiko-bot
  2 siblings, 1 reply; 8+ messages in thread
From: Leo Yan @ 2026-09-30  9:01 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Namhyung Kim, Jiri Olsa, Ian Rogers,
	Adrian Hunter, James Clark, Aishwarya TCV
  Cc: linux-perf-users, linux-kernel, Arnaldo Carvalho de Melo, Leo Yan

Python 3.13 reversed optparse's deprecation, and pylint 3.3.5 removed it
from the deprecated-module list. Perf supports older pylint versions,
so suppress the warning on this import and document the reason. Keep
other deprecated-module diagnostics enabled.

Link: https://docs.python.org/3.13/whatsnew/3.13.html#optparse
Link: https://pylint.readthedocs.io/en/latest/whatsnew/3/3.3/index.html#what-s-new-in-pylint-3-3-5
Fixes: 8a54784e708b ("perf build: Add pylint build tests")
Reported-by: Aishwarya TCV <aishwarya.tcv@arm.com>
Assisted-by: Codex:gpt-6
Signed-off-by: Leo Yan <leo.yan@arm.com>
---
 tools/perf/tests/shell/lib/attr.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/tests/shell/lib/attr.py b/tools/perf/tests/shell/lib/attr.py
index 7f3d5b64b00dd7de45baff4f7d9baff89e003147..523257bcf8e126cb662af589727144bb26cff4d5 100644
--- a/tools/perf/tests/shell/lib/attr.py
+++ b/tools/perf/tests/shell/lib/attr.py
@@ -4,7 +4,8 @@ import configparser
 import os
 import sys
 import glob
-import optparse
+# Pylint before 3.3.5 still treats optparse as deprecated.
+import optparse  # pylint: disable=deprecated-module
 import platform
 import tempfile
 import logging

-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] perf test: Suppress optparse deprecation warning with older pylint
  2026-09-30  9:01 ` [PATCH 3/3] perf test: Suppress optparse deprecation warning with older pylint Leo Yan
@ 2026-09-30  9:04   ` sashiko-bot
  0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-09-30  9:04 UTC (permalink / raw)
  To: Leo Yan; +Cc: linux-perf-users

> Python 3.13 reversed optparse's deprecation, and pylint 3.3.5 removed it
> from the deprecated-module list. Perf supports older pylint versions,
> so suppress the warning on this import and document the reason. Keep
> other deprecated-module diagnostics enabled.
> 
> Link: https://docs.python.org/3.13/whatsnew/3.13.html#optparse
> Link: https://pylint.readthedocs.io/en/latest/whatsnew/3/3.3/index.html#what-s-new-in-pylint-3-3-5
> Fixes: 8a54784e708b ("perf build: Add pylint build tests")
> Reported-by: Aishwarya TCV <aishwarya.tcv@arm.com>
> Assisted-by: Codex:gpt-6
> Signed-off-by: Leo Yan <leo.yan@arm.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260930-perf_fix_pylint_errors-v1-0-f72151d8b255@arm.com?part=3


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 2/3] perf build: Add the output Python directory to pylint's PYTHONPATH
  2026-09-30  9:01 ` [PATCH 2/3] perf build: Add the output Python directory to pylint's PYTHONPATH Leo Yan
@ 2026-09-30  9:07   ` sashiko-bot
  0 siblings, 0 replies; 8+ messages in thread
From: sashiko-bot @ 2026-09-30  9:07 UTC (permalink / raw)
  To: Leo Yan; +Cc: linux-perf-users

> Prepend the output Python directory to pylint's PYTHONPATH so builds
> using O= can also find the generated extension.
> 
> Fixes: 5fe83fb352c8 ("perf build: Make pylint build test opt-out (NO_PYLINT=1)")
> Reported-by: Aishwarya TCV <aishwarya.tcv@arm.com>
> Assisted-by: Codex:gpt-6
> Signed-off-by: Leo Yan <leo.yan@arm.com>

Sashiko has reviewed this patch and found no issues. It looks great!

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260930-perf_fix_pylint_errors-v1-0-f72151d8b255@arm.com?part=2


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] perf build: Build the Python extension before pylint consumers
  2026-09-30  9:01 ` [PATCH 1/3] perf build: Build the Python extension before pylint consumers Leo Yan
@ 2026-09-30  9:15   ` sashiko-bot
  2026-09-30 11:12     ` Leo Yan
  0 siblings, 1 reply; 8+ messages in thread
From: sashiko-bot @ 2026-09-30  9:15 UTC (permalink / raw)
  To: Leo Yan; +Cc: linux-perf-users

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] perf build: parallel compilation serialized due to order-only dependency
--

commit b4e3b80b8bd24b069f41f7f4f4f217b8194d4514
Author: Leo Yan <leo.yan@arm.com>

perf build: Build the Python extension before pylint consumers

This commit delays the perf and perf-test sub-makes until the Python
extension is built when pylint is enabled. This is intended to prevent
an import error that stops parallel builds before the extension is available.

> diff --git a/tools/perf/Makefile.perf b/tools/perf/Makefile.perf
> index 0102c3468a0b7..d350d085542c6 100644
> --- a/tools/perf/Makefile.perf
> +++ b/tools/perf/Makefile.perf
> @@ -578,6 +578,12 @@ strip: $(PROGRAMS) $(OUTPUT)perf
>  	$(STRIP) $(STRIP_OPTS) $(PROGRAMS) $(OUTPUT)perf
>  
>  PERF_IN := $(OUTPUT)perf-in.o
> +
> +ifdef PYLINT
> +# Build the Python extension before starting sub-makes that lint its users.
> +$(PERF_IN) $(LIBPERF_TEST_IN): | $(LANG_BINDINGS)

[Severity: Low]
Does this order-only dependency block the $(PERF_IN) sub-make from executing
until $(LANG_BINDINGS) and all its prerequisites (including $(LIBPERF_UTIL))
are fully built?

$(PERF_IN) launches the sub-make that compiles all builtin-*.c files.
Meanwhile, $(LANG_BINDINGS) depends on $(PERFLIBS_PY), which launches the
sub-make that compiles all util/*.c files.

Does this completely serialize the compilation of the builtin/ directory
behind the full compilation of the util/ directory and the Python extension,
impacting concurrent parallel build efficiency?

Furthermore, does it force an isolated make perf to needlessly build the
Python extension when PYLINT is enabled on the host?

> +endif
> +
>  export NO_JEVENTS

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260930-perf_fix_pylint_errors-v1-0-f72151d8b255@arm.com?part=1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/3] perf build: Build the Python extension before pylint consumers
  2026-09-30  9:15   ` sashiko-bot
@ 2026-09-30 11:12     ` Leo Yan
  0 siblings, 0 replies; 8+ messages in thread
From: Leo Yan @ 2026-09-30 11:12 UTC (permalink / raw)
  To: sashiko-reviews; +Cc: linux-perf-users

On Wed, Sep 30, 2026 at 09:15:25AM +0000, sashiko-bot@kernel.org wrote:

[...]

> > +ifdef PYLINT
> > +# Build the Python extension before starting sub-makes that lint its users.
> > +$(PERF_IN) $(LIBPERF_TEST_IN): | $(LANG_BINDINGS)
> 
> [Severity: Low]
> Does this order-only dependency block the $(PERF_IN) sub-make from executing
> until $(LANG_BINDINGS) and all its prerequisites (including $(LIBPERF_UTIL))
> are fully built?
> 
> $(PERF_IN) launches the sub-make that compiles all builtin-*.c files.
> Meanwhile, $(LANG_BINDINGS) depends on $(PERFLIBS_PY), which launches the
> sub-make that compiles all util/*.c files.
> 
> Does this completely serialize the compilation of the builtin/ directory
> behind the full compilation of the util/ directory and the Python extension,
> impacting concurrent parallel build efficiency?


> Furthermore, does it force an isolated make perf to needlessly build the
> Python extension when PYLINT is enabled on the host?

Fair point. I will update the Makefile to separate pylint from C
compilation, this can avoid dependency within C files, and can avoid
the dependency between perf binary and python extension.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-09-30 11:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-30  9:01 [PATCH 0/3] perf build: Fix pylint build failures Leo Yan
2026-09-30  9:01 ` [PATCH 1/3] perf build: Build the Python extension before pylint consumers Leo Yan
2026-09-30  9:15   ` sashiko-bot
2026-09-30 11:12     ` Leo Yan
2026-09-30  9:01 ` [PATCH 2/3] perf build: Add the output Python directory to pylint's PYTHONPATH Leo Yan
2026-09-30  9:07   ` sashiko-bot
2026-09-30  9:01 ` [PATCH 3/3] perf test: Suppress optparse deprecation warning with older pylint Leo Yan
2026-09-30  9:04   ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox