Skip to contentSkip to conversation

perf: Complete transition to standalone Python scripts

PATCH Superseded Ian Rogers 5 participants 410 messages Sep 20 – Sep 26 Page 7 of 7

Subsystems (2)
lore
Share & tools
lore
#398 lore raw

Re: [PATCH v4 46/49] perf: Remove libpython support and legacy Python scripts

In reply to Ian Rogers
Quoted 4 lines · Ian Rogers

Remove embedded Python interpreter support (libpython) from perf, as all Python scripts have been migrated to standalone scripts using the perf Python extension module.

Quoted 11 lines

Changes include:
- Remove libpython detection and build flags from Makefile.config.
- Remove legacy Python script installation rules from Makefile.perf.
- Delete tools/perf/util/scripting-engines/trace-event-python.c and tools/perf/scripts/python/Perf-Trace-Util/Context.c.
- Remove Python scripting engine registration from trace-event-scripting.c.
- Remove libpython from the supported features list in builtin-check.c and Documentation/perf-check.txt.
- Delete the legacy Python scripts and bin wrappers in tools/perf/scripts/python/ and update shell tests.

This one had a small clash with the python 3.9 patch, I'll put this in tmp.perf-tools-next so that you can double check if I resolved the conflict correctly.

- Arnaldo

Quoted 11,326 lines
Assisted-by Antigravity:gemini-3.1-pro
---
 tools/perf/Documentation/perf-check.txt       |    1 -
 tools/perf/Makefile.config                    |   26 +-
 tools/perf/Makefile.perf                      |    7 +-
 tools/perf/builtin-check.c                    |    2 +-
 tools/perf/scripts/Build                      |   27 -
 .../perf/scripts/python/Perf-Trace-Util/Build |    4 -
 .../scripts/python/Perf-Trace-Util/Context.c  |  225 --
 .../Perf-Trace-Util/lib/Perf/Trace/Core.py    |  116 -
 .../lib/Perf/Trace/EventClass.py              |   97 -
 .../lib/Perf/Trace/SchedGui.py                |  184 --
 .../Perf-Trace-Util/lib/Perf/Trace/Util.py    |   92 -
 .../scripts/python/arm-cs-trace-disasm.py     |  356 ---
 .../python/bin/compaction-times-record        |    2 -
 .../python/bin/compaction-times-report        |    4 -
 .../python/bin/event_analyzing_sample-record  |    8 -
 .../python/bin/event_analyzing_sample-report  |    3 -
 .../python/bin/export-to-postgresql-record    |    8 -
 .../python/bin/export-to-postgresql-report    |   29 -
 .../python/bin/export-to-sqlite-record        |    8 -
 .../python/bin/export-to-sqlite-report        |   29 -
 .../python/bin/failed-syscalls-by-pid-record  |    3 -
 .../python/bin/failed-syscalls-by-pid-report  |   10 -
 .../perf/scripts/python/bin/flamegraph-record |    2 -
 .../perf/scripts/python/bin/flamegraph-report |    3 -
 .../python/bin/futex-contention-record        |    2 -
 .../python/bin/futex-contention-report        |    4 -
 tools/perf/scripts/python/bin/gecko-record    |    2 -
 tools/perf/scripts/python/bin/gecko-report    |    7 -
 .../scripts/python/bin/intel-pt-events-record |   13 -
 .../scripts/python/bin/intel-pt-events-report |    3 -
 .../scripts/python/bin/mem-phys-addr-record   |   19 -
 .../scripts/python/bin/mem-phys-addr-report   |    3 -
 .../scripts/python/bin/net_dropmonitor-record |    2 -
 .../scripts/python/bin/net_dropmonitor-report |    4 -
 .../scripts/python/bin/netdev-times-record    |    8 -
 .../scripts/python/bin/netdev-times-report    |    5 -
 .../scripts/python/bin/powerpc-hcalls-record  |    2 -
 .../scripts/python/bin/powerpc-hcalls-report  |    2 -
 .../scripts/python/bin/sched-migration-record |    2 -
 .../scripts/python/bin/sched-migration-report |    3 -
 tools/perf/scripts/python/bin/sctop-record    |    3 -
 tools/perf/scripts/python/bin/sctop-report    |   24 -
 .../scripts/python/bin/stackcollapse-record   |    8 -
 .../scripts/python/bin/stackcollapse-report   |    3 -
 .../python/bin/syscall-counts-by-pid-record   |    3 -
 .../python/bin/syscall-counts-by-pid-report   |   10 -
 .../scripts/python/bin/syscall-counts-record  |    3 -
 .../scripts/python/bin/syscall-counts-report  |   10 -
 .../scripts/python/bin/task-analyzer-record   |    2 -
 .../scripts/python/bin/task-analyzer-report   |    3 -
 tools/perf/scripts/python/check-perf-trace.py |   84 -
 tools/perf/scripts/python/compaction-times.py |  311 ---
 .../scripts/python/event_analyzing_sample.py  |  192 --
 .../scripts/python/export-to-postgresql.py    | 1114 --------
 tools/perf/scripts/python/export-to-sqlite.py |  799 ------
 .../scripts/python/failed-syscalls-by-pid.py  |   79 -
 tools/perf/scripts/python/flamegraph.py       |  267 --
 tools/perf/scripts/python/futex-contention.py |   57 -
 tools/perf/scripts/python/gecko.py            |  395 ---
 tools/perf/scripts/python/intel-pt-events.py  |  494 ----
 tools/perf/scripts/python/libxed.py           |  107 -
 tools/perf/scripts/python/mem-phys-addr.py    |  127 -
 tools/perf/scripts/python/net_dropmonitor.py  |   78 -
 tools/perf/scripts/python/netdev-times.py     |  473 ----
 tools/perf/scripts/python/powerpc-hcalls.py   |  335 ---
 tools/perf/scripts/python/sched-migration.py  |  462 ----
 tools/perf/scripts/python/sctop.py            |   89 -
 tools/perf/scripts/python/stackcollapse.py    |  127 -
 tools/perf/scripts/python/stat-cpi.py         |   79 -
 .../scripts/python/syscall-counts-by-pid.py   |   75 -
 tools/perf/scripts/python/syscall-counts.py   |   65 -
 tools/perf/scripts/python/task-analyzer.py    |  934 -------
 tools/perf/tests/shell/script.sh              |   42 -
 tools/perf/tests/shell/script_python.sh       |  113 -
 tools/perf/util/scripting-engines/Build       |    4 -
 .../scripting-engines/trace-event-python.c    | 2335 -----------------
 tools/perf/util/trace-event-scripting.c       |    9 -
 77 files changed, 4 insertions(+), 10638 deletions(-)
 delete mode 100644 tools/perf/scripts/python/Perf-Trace-Util/Build
 delete mode 100644 tools/perf/scripts/python/Perf-Trace-Util/Context.c
 delete mode 100644 tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py
 delete mode 100755 tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/EventClass.py
 delete mode 100644 tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/SchedGui.py
 delete mode 100644 tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py
 delete mode 100755 tools/perf/scripts/python/arm-cs-trace-disasm.py
 delete mode 100644 tools/perf/scripts/python/bin/compaction-times-record
 delete mode 100644 tools/perf/scripts/python/bin/compaction-times-report
 delete mode 100644 tools/perf/scripts/python/bin/event_analyzing_sample-record
 delete mode 100644 tools/perf/scripts/python/bin/event_analyzing_sample-report
 delete mode 100644 tools/perf/scripts/python/bin/export-to-postgresql-record
 delete mode 100644 tools/perf/scripts/python/bin/export-to-postgresql-report
 delete mode 100644 tools/perf/scripts/python/bin/export-to-sqlite-record
 delete mode 100644 tools/perf/scripts/python/bin/export-to-sqlite-report
 delete mode 100644 tools/perf/scripts/python/bin/failed-syscalls-by-pid-record
 delete mode 100644 tools/perf/scripts/python/bin/failed-syscalls-by-pid-report
 delete mode 100755 tools/perf/scripts/python/bin/flamegraph-record
 delete mode 100755 tools/perf/scripts/python/bin/flamegraph-report
 delete mode 100644 tools/perf/scripts/python/bin/futex-contention-record
 delete mode 100644 tools/perf/scripts/python/bin/futex-contention-report
 delete mode 100644 tools/perf/scripts/python/bin/gecko-record
 delete mode 100755 tools/perf/scripts/python/bin/gecko-report
 delete mode 100644 tools/perf/scripts/python/bin/intel-pt-events-record
 delete mode 100644 tools/perf/scripts/python/bin/intel-pt-events-report
 delete mode 100644 tools/perf/scripts/python/bin/mem-phys-addr-record
 delete mode 100644 tools/perf/scripts/python/bin/mem-phys-addr-report
 delete mode 100755 tools/perf/scripts/python/bin/net_dropmonitor-record
 delete mode 100755 tools/perf/scripts/python/bin/net_dropmonitor-report
 delete mode 100644 tools/perf/scripts/python/bin/netdev-times-record
 delete mode 100644 tools/perf/scripts/python/bin/netdev-times-report
 delete mode 100644 tools/perf/scripts/python/bin/powerpc-hcalls-record
 delete mode 100644 tools/perf/scripts/python/bin/powerpc-hcalls-report
 delete mode 100644 tools/perf/scripts/python/bin/sched-migration-record
 delete mode 100644 tools/perf/scripts/python/bin/sched-migration-report
 delete mode 100644 tools/perf/scripts/python/bin/sctop-record
 delete mode 100644 tools/perf/scripts/python/bin/sctop-report
 delete mode 100755 tools/perf/scripts/python/bin/stackcollapse-record
 delete mode 100755 tools/perf/scripts/python/bin/stackcollapse-report
 delete mode 100644 tools/perf/scripts/python/bin/syscall-counts-by-pid-record
 delete mode 100644 tools/perf/scripts/python/bin/syscall-counts-by-pid-report
 delete mode 100644 tools/perf/scripts/python/bin/syscall-counts-record
 delete mode 100644 tools/perf/scripts/python/bin/syscall-counts-report
 delete mode 100755 tools/perf/scripts/python/bin/task-analyzer-record
 delete mode 100755 tools/perf/scripts/python/bin/task-analyzer-report
 delete mode 100644 tools/perf/scripts/python/check-perf-trace.py
 delete mode 100644 tools/perf/scripts/python/compaction-times.py
 delete mode 100644 tools/perf/scripts/python/event_analyzing_sample.py
 delete mode 100644 tools/perf/scripts/python/export-to-postgresql.py
 delete mode 100644 tools/perf/scripts/python/export-to-sqlite.py
 delete mode 100644 tools/perf/scripts/python/failed-syscalls-by-pid.py
 delete mode 100755 tools/perf/scripts/python/flamegraph.py
 delete mode 100644 tools/perf/scripts/python/futex-contention.py
 delete mode 100644 tools/perf/scripts/python/gecko.py
 delete mode 100644 tools/perf/scripts/python/intel-pt-events.py
 delete mode 100644 tools/perf/scripts/python/libxed.py
 delete mode 100644 tools/perf/scripts/python/mem-phys-addr.py
 delete mode 100755 tools/perf/scripts/python/net_dropmonitor.py
 delete mode 100644 tools/perf/scripts/python/netdev-times.py
 delete mode 100644 tools/perf/scripts/python/powerpc-hcalls.py
 delete mode 100644 tools/perf/scripts/python/sched-migration.py
 delete mode 100644 tools/perf/scripts/python/sctop.py
 delete mode 100755 tools/perf/scripts/python/stackcollapse.py
 delete mode 100644 tools/perf/scripts/python/stat-cpi.py
 delete mode 100644 tools/perf/scripts/python/syscall-counts-by-pid.py
 delete mode 100644 tools/perf/scripts/python/syscall-counts.py
 delete mode 100755 tools/perf/scripts/python/task-analyzer.py
 delete mode 100755 tools/perf/tests/shell/script_python.sh
 delete mode 100644 tools/perf/util/scripting-engines/trace-event-python.c
tools/perf/Documentation/perf-check.txt +0 -1
index 09e1d35677f5..3d169e5bb372 100644
@@ -60,7 +60,6 @@ feature::
                 libopencsd              /  HAVE_CSTRACE_SUPPORT
                 libperl                 /  HAVE_LIBPERL_SUPPORT
                 libpfm4                 /  HAVE_LIBPFM
-                libpython               /  HAVE_LIBPYTHON_SUPPORT
                 libslang                /  HAVE_SLANG_SUPPORT
                 libtraceevent           /  HAVE_LIBTRACEEVENT
                 libunwind               /  HAVE_LIBUNWIND_SUPPORT
tools/perf/Makefile.config +1 -25
index b288ae0191ac..e6cfcbe0483b 100644
@@ -800,27 +800,6 @@ ifdef GTK4
   endif
 endif
 
-ifdef LIBPERL
-  PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
-  PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
-  PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
-  PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
-  PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
-  PERL_EMBED_CCOPTS := $(filter-out -flto% -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
-  PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
-  FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
-
-  $(call feature_check,libperl)
-  ifneq ($(feature-libperl), 1)
-    $(error Missing perl devel files. Please install perl-ExtUtils-Embed/libperl-dev)
-  else
-    LDFLAGS += $(PERL_EMBED_LDFLAGS)
-    EXTLIBS += $(PERL_EMBED_LIBADD)
-    CFLAGS += -DHAVE_LIBPERL_SUPPORT
-    $(call detected,CONFIG_LIBPERL)
-  endif
-endif
-
 ifeq ($(feature-timerfd), 1)
   CFLAGS += -DHAVE_TIMERFD_SUPPORT
 else
@@ -851,8 +830,7 @@ else
       ifneq ($(feature-libpython), 1)
         $(call disable-python,No 'Python.h' was found: disables Python support - please install python-devel/python-dev)
       else
-         LDFLAGS += $(PYTHON_EMBED_LDFLAGS)
-         EXTLIBS += $(PYTHON_EMBED_LIBADD)
+         CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
          PYTHON_SETUPTOOLS_INSTALLED := $(shell $(PYTHON) -c 'import setuptools;' 2> /dev/null && echo "yes" || echo "no")
          ifeq ($(PYTHON_SETUPTOOLS_INSTALLED), yes)
            PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])')
@@ -863,8 +841,6 @@ else
 	 else
            $(warning Missing python setuptools, the python binding won't be built, please install python3-setuptools or equivalent)
          endif
-         CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
-         $(call detected,CONFIG_LIBPYTHON)
          ifeq ($(filter -fPIC,$(CFLAGS)),)
            # Building a shared library requires position independent code.
            CFLAGS += -fPIC
tools/perf/Makefile.perf +2 -5
index 89edf2720fc1..eaff13a31c50 100644
@@ -902,11 +902,8 @@ ifdef LIBPERL
 endif
 ifndef NO_LIBPYTHON
 	$(call QUIET_INSTALL, python-scripts) \
-		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
-		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'; \
-		$(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
-		$(INSTALL) scripts/python/*.py -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
-		$(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
+		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
+		$(INSTALL) python/*.py -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'
 	$(call QUIET_INSTALL, python-scripts-standalone) \
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/python' && \
 		$(INSTALL) python/*.py -m 755 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/python' && \
tools/perf/builtin-check.c +1 -1
index 60437650c50f..35272aaeb613 100644
@@ -52,8 +52,8 @@ struct feature_status supported_features[] = {
 	FEATURE_STATUS("libnuma", HAVE_LIBNUMA_SUPPORT),
 	FEATURE_STATUS("libopencsd", HAVE_CSTRACE_SUPPORT),
 	FEATURE_STATUS_TIP("libperl", HAVE_LIBPERL_SUPPORT, "Deprecated, use LIBPERL=1 and install perl-ExtUtils-Embed/libperl-dev to build with it"),
+	FEATURE_STATUS("python-module", HAVE_LIBPYTHON_SUPPORT),
 	FEATURE_STATUS("libpfm4", HAVE_LIBPFM),
-	FEATURE_STATUS("libpython", HAVE_LIBPYTHON_SUPPORT),
 	FEATURE_STATUS("libslang", HAVE_SLANG_SUPPORT),
 	FEATURE_STATUS("libtraceevent", HAVE_LIBTRACEEVENT),
 	FEATURE_STATUS_TIP("libunwind", HAVE_LIBUNWIND_SUPPORT, "Deprecated, use LIBUNWIND=1 and install libunwind-dev[el] to build with it"),
tools/perf/scripts/Build +0 -27
index 91229a1fe3ff..fbeab8fff88b 100644
@@ -1,30 +1,3 @@
 ifeq ($(CONFIG_LIBTRACEEVENT),y)
   perf-util-$(CONFIG_LIBPERL)   += perl/Perf-Trace-Util/
 endif
-perf-util-$(CONFIG_LIBPYTHON) += python/Perf-Trace-Util/
-
-ifdef MYPY
-  PY_TESTS := $(shell find python -type f -name '*.py')
-  MYPY_TEST_LOGS := $(PY_TESTS:python/%=python/%.mypy_log)
-else
-  MYPY_TEST_LOGS :=
-endif
-
-$(OUTPUT)%.mypy_log: %
-	$(call rule_mkdir)
-	$(Q)$(call echo-cmd,test)mypy "$<" > $@ || (cat $@ && rm $@ && false)
-
-perf-y += $(MYPY_TEST_LOGS)
-
-ifdef PYLINT
-  PY_TESTS := $(shell find python -type f -name '*.py')
-  PYLINT_TEST_LOGS := $(PY_TESTS:python/%=python/%.pylint_log)
-else
-  PYLINT_TEST_LOGS :=
-endif
-
-$(OUTPUT)%.pylint_log: %
-	$(call rule_mkdir)
-	$(Q)$(call echo-cmd,test)pylint "$<" > $@ || (cat $@ && rm $@ && false)
-
-perf-y += $(PYLINT_TEST_LOGS)
tools/perf/scripts/python/Perf-Trace-Util/Build deleted +0 -4
deleted file mode 100644
index be3710c61320..000000000000
@@ -1,4 +0,0 @@
-perf-util-y += Context.o
-
-# -Wno-declaration-after-statement: The python headers have mixed code with declarations (decls after asserts, for instance)
-CFLAGS_Context.o += $(PYTHON_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-unused-parameter -Wno-nested-externs -Wno-declaration-after-statement
tools/perf/scripts/python/Perf-Trace-Util/Context.c deleted +0 -225
deleted file mode 100644
index c19f44610983..000000000000
@@ -1,225 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * Context.c.  Python interfaces for perf script.
- *
- * Copyright (C) 2010 Tom Zanussi <[email protected]>
- */
-
-/*
- * Use Py_ssize_t for '#' formats to avoid DeprecationWarning: PY_SSIZE_T_CLEAN
- * will be required for '#' formats.
- */
-#define PY_SSIZE_T_CLEAN
-
-#include <Python.h>
-#include "../../../util/config.h"
-#include "../../../util/trace-event.h"
-#include "../../../util/event.h"
-#include "../../../util/symbol.h"
-#include "../../../util/thread.h"
-#include "../../../util/map.h"
-#include "../../../util/maps.h"
-#include "../../../util/auxtrace.h"
-#include "../../../util/session.h"
-#include "../../../util/srcline.h"
-#include "../../../util/srccode.h"
-
-#define _PyCapsule_GetPointer(arg1, arg2) \
-  PyCapsule_GetPointer((arg1), (arg2))
-#define _PyBytes_FromStringAndSize(arg1, arg2) \
-  PyBytes_FromStringAndSize((arg1), (arg2))
-#define _PyUnicode_AsUTF8(arg) \
-  PyUnicode_AsUTF8(arg)
-
-PyMODINIT_FUNC PyInit_perf_trace_context(void);
-
-static struct scripting_context *get_args(PyObject *args, const char *name, PyObject **arg2)
-{
-	int cnt = 1 + !!arg2;
-	PyObject *context;
-
-	if (!PyArg_UnpackTuple(args, name, 1, cnt, &context, arg2))
-		return NULL;
-
-	return _PyCapsule_GetPointer(context, NULL);
-}
-
-static struct scripting_context *get_scripting_context(PyObject *args)
-{
-	return get_args(args, "context", NULL);
-}
-
-#ifdef HAVE_LIBTRACEEVENT
-static PyObject *perf_trace_context_common_pc(PyObject *obj, PyObject *args)
-{
-	struct scripting_context *c = get_scripting_context(args);
-
-	if (!c)
-		return NULL;
-
-	return Py_BuildValue("i", common_pc(c));
-}
-
-static PyObject *perf_trace_context_common_flags(PyObject *obj,
-						 PyObject *args)
-{
-	struct scripting_context *c = get_scripting_context(args);
-
-	if (!c)
-		return NULL;
-
-	return Py_BuildValue("i", common_flags(c));
-}
-
-static PyObject *perf_trace_context_common_lock_depth(PyObject *obj,
-						      PyObject *args)
-{
-	struct scripting_context *c = get_scripting_context(args);
-
-	if (!c)
-		return NULL;
-
-	return Py_BuildValue("i", common_lock_depth(c));
-}
-#endif
-
-static PyObject *perf_sample_insn(PyObject *obj, PyObject *args)
-{
-	struct scripting_context *c = get_scripting_context(args);
-
-	if (!c)
-		return NULL;
-
-	if (c->sample->ip && !c->sample->insn_len && thread__maps(c->al->thread)) {
-		struct machine *machine =  maps__machine(thread__maps(c->al->thread));
-
-		perf_sample__fetch_insn(c->sample, c->al->thread, machine);
-	}
-	if (!c->sample->insn_len)
-		Py_RETURN_NONE; /* N.B. This is a return statement */
-
-	return _PyBytes_FromStringAndSize(c->sample->insn, c->sample->insn_len);
-}
-
-static PyObject *perf_set_itrace_options(PyObject *obj, PyObject *args)
-{
-	struct scripting_context *c;
-	const char *itrace_options;
-	int retval = -1;
-	PyObject *str;
-
-	c = get_args(args, "itrace_options", &str);
-	if (!c)
-		return NULL;
-
-	if (!c->session || !c->session->itrace_synth_opts)
-		goto out;
-
-	if (c->session->itrace_synth_opts->set) {
-		retval = 1;
-		goto out;
-	}
-
-	itrace_options = _PyUnicode_AsUTF8(str);
-
-	retval = itrace_do_parse_synth_opts(c->session->itrace_synth_opts, itrace_options, 0);
-out:
-	return Py_BuildValue("i", retval);
-}
-
-static PyObject *perf_sample_src(PyObject *obj, PyObject *args, bool get_srccode)
-{
-	struct scripting_context *c = get_scripting_context(args);
-	unsigned int line = 0;
-	char *srcfile = NULL;
-	char *srccode = NULL;
-	PyObject *result;
-	struct map *map;
-	struct dso *dso;
-	int len = 0;
-	u64 addr;
-
-	if (!c)
-		return NULL;
-
-	map = c->al->map;
-	addr = c->al->addr;
-	dso = map ? map__dso(map) : NULL;
-
-	if (dso)
-		srcfile = get_srcline_split(dso, map__rip_2objdump(map, addr), &line);
-
-	if (get_srccode) {
-		if (srcfile)
-			srccode = find_sourceline(srcfile, line, &len);
-		result = Py_BuildValue("(sIs#)", srcfile, line, srccode, (Py_ssize_t)len);
-	} else {
-		result = Py_BuildValue("(sI)", srcfile, line);
-	}
-
-	free(srcfile);
-
-	return result;
-}
-
-static PyObject *perf_sample_srcline(PyObject *obj, PyObject *args)
-{
-	return perf_sample_src(obj, args, false);
-}
-
-static PyObject *perf_sample_srccode(PyObject *obj, PyObject *args)
-{
-	return perf_sample_src(obj, args, true);
-}
-
-static PyObject *__perf_config_get(PyObject *obj, PyObject *args)
-{
-	const char *config_name;
-
-	if (!PyArg_ParseTuple(args, "s", &config_name))
-		return NULL;
-	return Py_BuildValue("s", perf_config_get(config_name));
-}
-
-static PyMethodDef ContextMethods[] = {
-#ifdef HAVE_LIBTRACEEVENT
-	{ "common_pc", perf_trace_context_common_pc, METH_VARARGS,
-	  "Get the common preempt count event field value."},
-	{ "common_flags", perf_trace_context_common_flags, METH_VARARGS,
-	  "Get the common flags event field value."},
-	{ "common_lock_depth", perf_trace_context_common_lock_depth,
-	  METH_VARARGS,	"Get the common lock depth event field value."},
-#endif
-	{ "perf_sample_insn", perf_sample_insn,
-	  METH_VARARGS,	"Get the machine code instruction."},
-	{ "perf_set_itrace_options", perf_set_itrace_options,
-	  METH_VARARGS,	"Set --itrace options."},
-	{ "perf_sample_srcline", perf_sample_srcline,
-	  METH_VARARGS,	"Get source file name and line number."},
-	{ "perf_sample_srccode", perf_sample_srccode,
-	  METH_VARARGS,	"Get source file name, line number and line."},
-	{ "perf_config_get", __perf_config_get, METH_VARARGS, "Get perf config entry"},
-	{ NULL, NULL, 0, NULL}
-};
-
-PyMODINIT_FUNC PyInit_perf_trace_context(void)
-{
-	static struct PyModuleDef moduledef = {
-		PyModuleDef_HEAD_INIT,
-		"perf_trace_context",	/* m_name */
-		"",			/* m_doc */
-		-1,			/* m_size */
-		ContextMethods,		/* m_methods */
-		NULL,			/* m_reload */
-		NULL,			/* m_traverse */
-		NULL,			/* m_clear */
-		NULL,			/* m_free */
-	};
-	PyObject *mod;
-
-	mod = PyModule_Create(&moduledef);
-	/* Add perf_script_context to the module so it can be imported */
-	PyObject_SetAttrString(mod, "perf_script_context", Py_None);
-
-	return mod;
-}
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Core.py deleted +0 -116
deleted file mode 100644
index 54ace2f6bc36..000000000000
@@ -1,116 +0,0 @@
-# Core.py - Python extension for perf script, core functions
-#
-# Copyright (C) 2010 by Tom Zanussi <[email protected]>
-#
-# This software may be distributed under the terms of the GNU General
-# Public License ("GPL") version 2 as published by the Free Software
-# Foundation.
-
-from collections import defaultdict
-
-def autodict():
-    return defaultdict(autodict)
-
-flag_fields = autodict()
-symbolic_fields = autodict()
-
-def define_flag_field(event_name, field_name, delim):
-    flag_fields[event_name][field_name]['delim'] = delim
-
-def define_flag_value(event_name, field_name, value, field_str):
-    flag_fields[event_name][field_name]['values'][value] = field_str
-
-def define_symbolic_field(event_name, field_name):
-    # nothing to do, really
-    pass
-
-def define_symbolic_value(event_name, field_name, value, field_str):
-    symbolic_fields[event_name][field_name]['values'][value] = field_str
-
-def flag_str(event_name, field_name, value):
-    string = ""
-
-    if flag_fields[event_name][field_name]:
-        print_delim = 0
-        for idx in sorted(flag_fields[event_name][field_name]['values']):
-            if not value and not idx:
-                string += flag_fields[event_name][field_name]['values'][idx]
-                break
-            if idx and (value & idx) == idx:
-                if print_delim and flag_fields[event_name][field_name]['delim']:
-                    string += " " + flag_fields[event_name][field_name]['delim'] + " "
-                string += flag_fields[event_name][field_name]['values'][idx]
-                print_delim = 1
-                value &= ~idx
-
-    return string
-
-def symbol_str(event_name, field_name, value):
-    string = ""
-
-    if symbolic_fields[event_name][field_name]:
-        for idx in sorted(symbolic_fields[event_name][field_name]['values']):
-            if not value and not idx:
-                string = symbolic_fields[event_name][field_name]['values'][idx]
-                break
-            if (value == idx):
-                string = symbolic_fields[event_name][field_name]['values'][idx]
-                break
-
-    return string
-
-trace_flags = { 0x00: "NONE", \
-                    0x01: "IRQS_OFF", \
-                    0x02: "IRQS_NOSUPPORT", \
-                    0x04: "NEED_RESCHED", \
-                    0x08: "HARDIRQ", \
-                    0x10: "SOFTIRQ" }
-
-def trace_flag_str(value):
-    string = ""
-    print_delim = 0
-
-    for idx in trace_flags:
-        if not value and not idx:
-            string += "NONE"
-            break
-
-        if idx and (value & idx) == idx:
-            if print_delim:
-                string += " | ";
-            string += trace_flags[idx]
-            print_delim = 1
-            value &= ~idx
-
-    return string
-
-
-def taskState(state):
-	states = {
-		0 : "R",
-		1 : "S",
-		2 : "D",
-		64: "DEAD"
-	}
-
-	if state not in states:
-		return "Unknown"
-
-	return states[state]
-
-
-class EventHeaders:
-	def __init__(self, common_cpu, common_secs, common_nsecs,
-		     common_pid, common_comm, common_callchain):
-		self.cpu = common_cpu
-		self.secs = common_secs
-		self.nsecs = common_nsecs
-		self.pid = common_pid
-		self.comm = common_comm
-		self.callchain = common_callchain
-
-	def ts(self):
-		return (self.secs * (10 ** 9)) + self.nsecs
-
-	def ts_format(self):
-		return "%d.%d" % (self.secs, int(self.nsecs / 1000))
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/EventClass.py deleted +0 -97
deleted file mode 100755
index 21a7a1298094..000000000000
@@ -1,97 +0,0 @@
-# EventClass.py
-# SPDX-License-Identifier: GPL-2.0
-#
-# This is a library defining some events types classes, which could
-# be used by other scripts to analyzing the perf samples.
-#
-# Currently there are just a few classes defined for examples,
-# PerfEvent is the base class for all perf event sample, PebsEvent
-# is a HW base Intel x86 PEBS event, and user could add more SW/HW
-# event classes based on requirements.
-from __future__ import print_function
-
-import struct
-
-# Event types, user could add more here
-EVTYPE_GENERIC  = 0
-EVTYPE_PEBS     = 1     # Basic PEBS event
-EVTYPE_PEBS_LL  = 2     # PEBS event with load latency info
-EVTYPE_IBS      = 3
-
-#
-# Currently we don't have good way to tell the event type, but by
-# the size of raw buffer, raw PEBS event with load latency data's
-# size is 176 bytes, while the pure PEBS event's size is 144 bytes.
-#
-def create_event(name, comm, dso, symbol, raw_buf):
-        if (len(raw_buf) == 144):
-                event = PebsEvent(name, comm, dso, symbol, raw_buf)
-        elif (len(raw_buf) == 176):
-                event = PebsNHM(name, comm, dso, symbol, raw_buf)
-        else:
-                event = PerfEvent(name, comm, dso, symbol, raw_buf)
-
-        return event
-
-class PerfEvent(object):
-        event_num = 0
-        def __init__(self, name, comm, dso, symbol, raw_buf, ev_type=EVTYPE_GENERIC):
-                self.name       = name
-                self.comm       = comm
-                self.dso        = dso
-                self.symbol     = symbol
-                self.raw_buf    = raw_buf
-                self.ev_type    = ev_type
-                PerfEvent.event_num += 1
-
-        def show(self):
-                print("PMU event: name=%12s, symbol=%24s, comm=%8s, dso=%12s" %
-                      (self.name, self.symbol, self.comm, self.dso))
-
-#
-# Basic Intel PEBS (Precise Event-based Sampling) event, whose raw buffer
-# contains the context info when that event happened: the EFLAGS and
-# linear IP info, as well as all the registers.
-#
-class PebsEvent(PerfEvent):
-        pebs_num = 0
-        def __init__(self, name, comm, dso, symbol, raw_buf, ev_type=EVTYPE_PEBS):
-                tmp_buf=raw_buf[0:80]
-                flags, ip, ax, bx, cx, dx, si, di, bp, sp = struct.unpack('QQQQQQQQQQ', tmp_buf)
-                self.flags = flags
-                self.ip    = ip
-                self.ax    = ax
-                self.bx    = bx
-                self.cx    = cx
-                self.dx    = dx
-                self.si    = si
-                self.di    = di
-                self.bp    = bp
-                self.sp    = sp
-
-                PerfEvent.__init__(self, name, comm, dso, symbol, raw_buf, ev_type)
-                PebsEvent.pebs_num += 1
-                del tmp_buf
-
-#
-# Intel Nehalem and Westmere support PEBS plus Load Latency info which lie
-# in the four 64 bit words write after the PEBS data:
-#       Status: records the IA32_PERF_GLOBAL_STATUS register value
-#       DLA:    Data Linear Address (EIP)
-#       DSE:    Data Source Encoding, where the latency happens, hit or miss
-#               in L1/L2/L3 or IO operations
-#       LAT:    the actual latency in cycles
-#
-class PebsNHM(PebsEvent):
-        pebs_nhm_num = 0
-        def __init__(self, name, comm, dso, symbol, raw_buf, ev_type=EVTYPE_PEBS_LL):
-                tmp_buf=raw_buf[144:176]
-                status, dla, dse, lat = struct.unpack('QQQQ', tmp_buf)
-                self.status = status
-                self.dla = dla
-                self.dse = dse
-                self.lat = lat
-
-                PebsEvent.__init__(self, name, comm, dso, symbol, raw_buf, ev_type)
-                PebsNHM.pebs_nhm_num += 1
-                del tmp_buf
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/SchedGui.py deleted +0 -184
deleted file mode 100644
index cac7b2542ee8..000000000000
@@ -1,184 +0,0 @@
-# SchedGui.py - Python extension for perf script, basic GUI code for
-#		traces drawing and overview.
-#
-# Copyright (C) 2010 by Frederic Weisbecker <[email protected]>
-#
-# This software is distributed under the terms of the GNU General
-# Public License ("GPL") version 2 as published by the Free Software
-# Foundation.
-
-
-try:
-	import wx
-except ImportError:
-	raise ImportError("You need to install the wxpython lib for this script")
-
-
-class RootFrame(wx.Frame):
-	Y_OFFSET = 100
-	RECT_HEIGHT = 100
-	RECT_SPACE = 50
-	EVENT_MARKING_WIDTH = 5
-
-	def __init__(self, sched_tracer, title, parent = None, id = -1):
-		wx.Frame.__init__(self, parent, id, title)
-
-		(self.screen_width, self.screen_height) = wx.GetDisplaySize()
-		self.screen_width -= 10
-		self.screen_height -= 10
-		self.zoom = 0.5
-		self.scroll_scale = 20
-		self.sched_tracer = sched_tracer
-		self.sched_tracer.set_root_win(self)
-		(self.ts_start, self.ts_end) = sched_tracer.interval()
-		self.update_width_virtual()
-		self.nr_rects = sched_tracer.nr_rectangles() + 1
-		self.height_virtual = RootFrame.Y_OFFSET + (self.nr_rects * (RootFrame.RECT_HEIGHT + RootFrame.RECT_SPACE))
-
-		# whole window panel
-		self.panel = wx.Panel(self, size=(self.screen_width, self.screen_height))
-
-		# scrollable container
-		self.scroll = wx.ScrolledWindow(self.panel)
-		self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, self.height_virtual / self.scroll_scale)
-		self.scroll.EnableScrolling(True, True)
-		self.scroll.SetFocus()
-
-		# scrollable drawing area
-		self.scroll_panel = wx.Panel(self.scroll, size=(self.screen_width - 15, self.screen_height / 2))
-		self.scroll_panel.Bind(wx.EVT_PAINT, self.on_paint)
-		self.scroll_panel.Bind(wx.EVT_KEY_DOWN, self.on_key_press)
-		self.scroll_panel.Bind(wx.EVT_LEFT_DOWN, self.on_mouse_down)
-		self.scroll.Bind(wx.EVT_PAINT, self.on_paint)
-		self.scroll.Bind(wx.EVT_KEY_DOWN, self.on_key_press)
-		self.scroll.Bind(wx.EVT_LEFT_DOWN, self.on_mouse_down)
-
-		self.scroll.Fit()
-		self.Fit()
-
-		self.scroll_panel.SetDimensions(-1, -1, self.width_virtual, self.height_virtual, wx.SIZE_USE_EXISTING)
-
-		self.txt = None
-
-		self.Show(True)
-
-	def us_to_px(self, val):
-		return val / (10 ** 3) * self.zoom
-
-	def px_to_us(self, val):
-		return (val / self.zoom) * (10 ** 3)
-
-	def scroll_start(self):
-		(x, y) = self.scroll.GetViewStart()
-		return (x * self.scroll_scale, y * self.scroll_scale)
-
-	def scroll_start_us(self):
-		(x, y) = self.scroll_start()
-		return self.px_to_us(x)
-
-	def paint_rectangle_zone(self, nr, color, top_color, start, end):
-		offset_px = self.us_to_px(start - self.ts_start)
-		width_px = self.us_to_px(end - self.ts_start)
-
-		offset_py = RootFrame.Y_OFFSET + (nr * (RootFrame.RECT_HEIGHT + RootFrame.RECT_SPACE))
-		width_py = RootFrame.RECT_HEIGHT
-
-		dc = self.dc
-
-		if top_color is not None:
-			(r, g, b) = top_color
-			top_color = wx.Colour(r, g, b)
-			brush = wx.Brush(top_color, wx.SOLID)
-			dc.SetBrush(brush)
-			dc.DrawRectangle(offset_px, offset_py, width_px, RootFrame.EVENT_MARKING_WIDTH)
-			width_py -= RootFrame.EVENT_MARKING_WIDTH
-			offset_py += RootFrame.EVENT_MARKING_WIDTH
-
-		(r ,g, b) = color
-		color = wx.Colour(r, g, b)
-		brush = wx.Brush(color, wx.SOLID)
-		dc.SetBrush(brush)
-		dc.DrawRectangle(offset_px, offset_py, width_px, width_py)
-
-	def update_rectangles(self, dc, start, end):
-		start += self.ts_start
-		end += self.ts_start
-		self.sched_tracer.fill_zone(start, end)
-
-	def on_paint(self, event):
-		dc = wx.PaintDC(self.scroll_panel)
-		self.dc = dc
-
-		width = min(self.width_virtual, self.screen_width)
-		(x, y) = self.scroll_start()
-		start = self.px_to_us(x)
-		end = self.px_to_us(x + width)
-		self.update_rectangles(dc, start, end)
-
-	def rect_from_ypixel(self, y):
-		y -= RootFrame.Y_OFFSET
-		rect = y / (RootFrame.RECT_HEIGHT + RootFrame.RECT_SPACE)
-		height = y % (RootFrame.RECT_HEIGHT + RootFrame.RECT_SPACE)
-
-		if rect < 0 or rect > self.nr_rects - 1 or height > RootFrame.RECT_HEIGHT:
-			return -1
-
-		return rect
-
-	def update_summary(self, txt):
-		if self.txt:
-			self.txt.Destroy()
-		self.txt = wx.StaticText(self.panel, -1, txt, (0, (self.screen_height / 2) + 50))
-
-
-	def on_mouse_down(self, event):
-		(x, y) = event.GetPositionTuple()
-		rect = self.rect_from_ypixel(y)
-		if rect == -1:
-			return
-
-		t = self.px_to_us(x) + self.ts_start
-
-		self.sched_tracer.mouse_down(rect, t)
-
-
-	def update_width_virtual(self):
-		self.width_virtual = self.us_to_px(self.ts_end - self.ts_start)
-
-	def __zoom(self, x):
-		self.update_width_virtual()
-		(xpos, ypos) = self.scroll.GetViewStart()
-		xpos = self.us_to_px(x) / self.scroll_scale
-		self.scroll.SetScrollbars(self.scroll_scale, self.scroll_scale, self.width_virtual / self.scroll_scale, self.height_virtual / self.scroll_scale, xpos, ypos)
-		self.Refresh()
-
-	def zoom_in(self):
-		x = self.scroll_start_us()
-		self.zoom *= 2
-		self.__zoom(x)
-
-	def zoom_out(self):
-		x = self.scroll_start_us()
-		self.zoom /= 2
-		self.__zoom(x)
-
-
-	def on_key_press(self, event):
-		key = event.GetRawKeyCode()
-		if key == ord("+"):
-			self.zoom_in()
-			return
-		if key == ord("-"):
-			self.zoom_out()
-			return
-
-		key = event.GetKeyCode()
-		(x, y) = self.scroll.GetViewStart()
-		if key == wx.WXK_RIGHT:
-			self.scroll.Scroll(x + 1, y)
-		elif key == wx.WXK_LEFT:
-			self.scroll.Scroll(x - 1, y)
-		elif key == wx.WXK_DOWN:
-			self.scroll.Scroll(x, y + 1)
-		elif key == wx.WXK_UP:
-			self.scroll.Scroll(x, y - 1)
tools/perf/scripts/python/Perf-Trace-Util/lib/Perf/Trace/Util.py deleted +0 -92
deleted file mode 100644
index b75d31858e54..000000000000
@@ -1,92 +0,0 @@
-# Util.py - Python extension for perf script, miscellaneous utility code
-#
-# Copyright (C) 2010 by Tom Zanussi <[email protected]>
-#
-# This software may be distributed under the terms of the GNU General
-# Public License ("GPL") version 2 as published by the Free Software
-# Foundation.
-from __future__ import print_function
-
-import errno, os
-
-FUTEX_WAIT = 0
-FUTEX_WAKE = 1
-FUTEX_PRIVATE_FLAG = 128
-FUTEX_CLOCK_REALTIME = 256
-FUTEX_CMD_MASK = ~(FUTEX_PRIVATE_FLAG | FUTEX_CLOCK_REALTIME)
-
-NSECS_PER_SEC    = 1000000000
-
-def avg(total, n):
-    return total / n
-
-def nsecs(secs, nsecs):
-    return secs * NSECS_PER_SEC + nsecs
-
-def nsecs_secs(nsecs):
-    return nsecs / NSECS_PER_SEC
-
-def nsecs_nsecs(nsecs):
-    return nsecs % NSECS_PER_SEC
-
-def nsecs_str(nsecs):
-    str = "%5u.%09u" % (nsecs_secs(nsecs), nsecs_nsecs(nsecs)),
-    return str
-
-def add_stats(dict, key, value):
-	if key not in dict:
-		dict[key] = (value, value, value, 1)
-	else:
-		min, max, avg, count = dict[key]
-		if value < min:
-			min = value
-		if value > max:
-			max = value
-		avg = (avg + value) / 2
-		dict[key] = (min, max, avg, count + 1)
-
-def clear_term():
-    print("\x1b[H\x1b[2J")
-
-audit_package_warned = False
-
-try:
-	import audit
-	machine_to_id = {
-		'x86_64': audit.MACH_86_64,
-		'aarch64': audit.MACH_AARCH64,
-		'alpha'	: audit.MACH_ALPHA,
-		'ia64'	: audit.MACH_IA64,
-		'ppc'	: audit.MACH_PPC,
-		'ppc64'	: audit.MACH_PPC64,
-		'ppc64le' : audit.MACH_PPC64LE,
-		's390'	: audit.MACH_S390,
-		's390x'	: audit.MACH_S390X,
-		'i386'	: audit.MACH_X86,
-		'i586'	: audit.MACH_X86,
-		'i686'	: audit.MACH_X86,
-	}
-	try:
-		machine_to_id['armeb'] = audit.MACH_ARMEB
-	except:
-		pass
-	machine_id = machine_to_id[os.uname()[4]]
-except:
-	if not audit_package_warned:
-		audit_package_warned = True
-		print("Install the python-audit package to get syscall names.\n"
-                    "For example:\n  # apt-get install python3-audit (Ubuntu)"
-                    "\n  # yum install python3-audit (Fedora)"
-                    "\n  etc.\n")
-
-def syscall_name(id):
-	try:
-		return audit.audit_syscall_to_name(id, machine_id)
-	except:
-		return str(id)
-
-def strerror(nr):
-	try:
-		return errno.errorcode[abs(nr)]
-	except:
-		return "Unknown %d errno" % nr
tools/perf/scripts/python/arm-cs-trace-disasm.py deleted +0 -356
deleted file mode 100755
index 42579f858684..000000000000
@@ -1,356 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-# arm-cs-trace-disasm.py: ARM CoreSight Trace Dump With Disassember
-#
-# Author: Tor Jeremiassen <[email protected]>
-#         Mathieu Poirier <[email protected]>
-#         Leo Yan <[email protected]>
-#         Al Grant <[email protected]>
-
-from __future__ import print_function
-import os
-from os import path
-import re
-from subprocess import *
-import argparse
-import platform
-
-from perf_trace_context import perf_sample_srccode, perf_config_get
-
-# Below are some example commands for using this script.
-# Note a --kcore recording is required for accurate decode
-# due to the alternatives patching mechanism. In addition to this,
-# source line info comes from Perf, and when using kcore there is
-# no debug info. The following lists the supported features in each mode:
-#
-# +-----------+-----------------+------------------+------------------+
-# | Recording | Accurate decode | Source line dump | Disassembly dump |
-# +-----------+-----------------+------------------+------------------+
-# | --kcore   | yes             | no               | yes              |
-# | normal    | no              | yes (inaccurate) | yes (inaccurate) |
-# +-----------+-----------------+------------------+------------------+
-#
-# Output disassembly with objdump and auto detect vmlinux
-# (when running on same machine.):
-#  perf script --itrace=b -s scripts/python/arm-cs-trace-disasm.py \
-#       -- -d
-#
-# Output disassembly with llvm-objdump:
-#  perf script --itrace=b -s scripts/python/arm-cs-trace-disasm.py \
-#		-- -d llvm-objdump-11 -k path/to/vmlinux
-#
-# Output accurate disassembly by passing kcore to script:
-#  perf script --itrace=b -s scripts/python/arm-cs-trace-disasm.py \
-#		-- -d -k perf.data/kcore_dir/kcore
-#
-# Output only source line and symbols:
-#  perf script --itrace=b -s scripts/python/arm-cs-trace-disasm.py
-
-def default_objdump():
-	config = perf_config_get("annotate.objdump")
-	return config if config else "objdump"
-
-# Command line parsing.
-def int_arg(v):
-	v = int(v)
-	if v < 0:
-		raise argparse.ArgumentTypeError("Argument must be a positive integer")
-	return v
-
-args = argparse.ArgumentParser()
-args.add_argument("-k", "--vmlinux",
-		  help="Set path to vmlinux or kcore file. Omit to autodetect if running on same machine")
-args.add_argument("-d", "--objdump", nargs="?", const=default_objdump(),
-		  help="Show disassembly. Can also be used to change the objdump path"),
-args.add_argument("-v", "--verbose", action="store_true", help="Enable debugging log")
-args.add_argument("--start-time", type=int_arg, help="Monotonic clock time of sample to start from. "
-		  "See 'time' field on samples in -v mode.")
-args.add_argument("--stop-time", type=int_arg, help="Monotonic clock time of sample to stop at. "
-		  "See 'time' field on samples in -v mode.")
-args.add_argument("--start-sample", type=int_arg, help="Index of sample to start from. "
-		  "See 'index' field on samples in -v mode.")
-args.add_argument("--stop-sample", type=int_arg, help="Index of sample to stop at. "
-		  "See 'index' field on samples in -v mode.")
-
-options = args.parse_args()
-if (options.start_time and options.stop_time and
-    options.start_time >= options.stop_time):
-	print("--start-time must less than --stop-time")
-	exit(2)
-if (options.start_sample and options.stop_sample and
-    options.start_sample >= options.stop_sample):
-	print("--start-sample must less than --stop-sample")
-	exit(2)
-
-# Initialize global dicts and regular expression
-disasm_cache = dict()
-cpu_data = dict()
-disasm_re = re.compile(r"^\s*([0-9a-fA-F]+):")
-disasm_func_re = re.compile(r"^\s*([0-9a-fA-F]+)\s.*:")
-cache_size = 64*1024
-sample_idx = -1
-
-glb_source_file_name	= None
-glb_line_number		= None
-glb_dso			= None
-
-kver = platform.release()
-vmlinux_paths = [
-	f"/usr/lib/debug/boot/vmlinux-{kver}.debug",
-	f"/usr/lib/debug/lib/modules/{kver}/vmlinux",
-	f"/lib/modules/{kver}/build/vmlinux",
-	f"/usr/lib/debug/boot/vmlinux-{kver}",
-	f"/boot/vmlinux-{kver}",
-	f"/boot/vmlinux",
-	f"vmlinux"
-]
-
-def get_optional(perf_dict, field):
-       if field in perf_dict:
-               return perf_dict[field]
-       return "[unknown]"
-
-def get_offset(perf_dict, field):
-	if field in perf_dict:
-		return "+%#x" % perf_dict[field]
-	return ""
-
-def find_vmlinux():
-	if hasattr(find_vmlinux, "path"):
-		return find_vmlinux.path
-
-	for v in vmlinux_paths:
-		if os.access(v, os.R_OK):
-			find_vmlinux.path = v
-			break
-	else:
-		find_vmlinux.path = None
-
-	return find_vmlinux.path
-
-def get_dso_file_path(dso_name, dso_build_id):
-	if (dso_name == "[kernel.kallsyms]" or dso_name == "vmlinux"):
-		if (options.vmlinux):
-			return options.vmlinux;
-		else:
-			return find_vmlinux() if find_vmlinux() else dso_name
-
-	if (dso_name == "[vdso]") :
-		append = "/vdso"
-	else:
-		append = "/elf"
-
-	dso_path = os.environ['PERF_BUILDID_DIR'] + "/" + dso_name + "/" + dso_build_id + append;
-	# Replace duplicate slash chars to single slash char
-	dso_path = dso_path.replace('//', '/', 1)
-	return dso_path
-
-def read_disam(dso_fname, dso_start, start_addr, stop_addr):
-	addr_range = str(start_addr) + ":" + str(stop_addr) + ":" + dso_fname
-
-	# Don't let the cache get too big, clear it when it hits max size
-	if (len(disasm_cache) > cache_size):
-		disasm_cache.clear();
-
-	if addr_range in disasm_cache:
-		disasm_output = disasm_cache[addr_range];
-	else:
-		start_addr = start_addr - dso_start;
-		stop_addr = stop_addr - dso_start;
-		disasm = [ options.objdump, "-d", "-z",
-			   "--start-address="+format(start_addr,"#x"),
-			   "--stop-address="+format(stop_addr,"#x") ]
-		disasm += [ dso_fname ]
-		disasm_output = check_output(disasm).decode('utf-8').split('\n')
-		disasm_cache[addr_range] = disasm_output
-
-	return disasm_output
-
-def print_disam(dso_fname, dso_start, start_addr, stop_addr):
-	for line in read_disam(dso_fname, dso_start, start_addr, stop_addr):
-		m = disasm_func_re.search(line)
-		if m is None:
-			m = disasm_re.search(line)
-			if m is None:
-				continue
-		print("\t" + line)
-
-def print_sample(sample):
-	print("Sample = { cpu: %04d addr: 0x%016x phys_addr: 0x%016x ip: 0x%016x " \
-	      "pid: %d tid: %d period: %d time: %d index: %d}" % \
-	      (sample['cpu'], sample['addr'], sample['phys_addr'], \
-	       sample['ip'], sample['pid'], sample['tid'], \
-	       sample['period'], sample['time'], sample_idx))
-
-def trace_begin():
-	print('ARM CoreSight Trace Data Assembler Dump')
-
-def trace_end():
-	print('End')
-
-def trace_unhandled(event_name, context, event_fields_dict):
-	print(' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]))
-
-def common_start_str(comm, sample):
-	sec = int(sample["time"] / 1000000000)
-	ns = sample["time"] % 1000000000
-	cpu = sample["cpu"]
-	pid = sample["pid"]
-	tid = sample["tid"]
-	return "%16s %5u/%-5u [%04u] %9u.%09u  " % (comm, pid, tid, cpu, sec, ns)
-
-# This code is copied from intel-pt-events.py for printing source code
-# line and symbols.
-def print_srccode(comm, param_dict, sample, symbol, dso):
-	ip = sample["ip"]
-	if symbol == "[unknown]":
-		start_str = common_start_str(comm, sample) + ("%x" % ip).rjust(16).ljust(40)
-	else:
-		offs = get_offset(param_dict, "symoff")
-		start_str = common_start_str(comm, sample) + (symbol + offs).ljust(40)
-
-	global glb_source_file_name
-	global glb_line_number
-	global glb_dso
-
-	source_file_name, line_number, source_line = perf_sample_srccode(perf_script_context)
-	if source_file_name:
-		if glb_line_number == line_number and glb_source_file_name == source_file_name:
-			src_str = ""
-		else:
-			if len(source_file_name) > 40:
-				src_file = ("..." + source_file_name[-37:]) + " "
-			else:
-				src_file = source_file_name.ljust(41)
-
-			if source_line is None:
-				src_str = src_file + str(line_number).rjust(4) + " <source not found>"
-			else:
-				src_str = src_file + str(line_number).rjust(4) + " " + source_line
-		glb_dso = None
-	elif dso == glb_dso:
-		src_str = ""
-	else:
-		src_str = dso
-		glb_dso = dso
-
-	glb_line_number = line_number
-	glb_source_file_name = source_file_name
-
-	print(start_str, src_str)
-
-def process_event(param_dict):
-	global cache_size
-	global options
-	global sample_idx
-
-	sample = param_dict["sample"]
-	comm = param_dict["comm"]
-
-	name = param_dict["ev_name"]
-	dso = get_optional(param_dict, "dso")
-	dso_bid = get_optional(param_dict, "dso_bid")
-	dso_start = get_optional(param_dict, "dso_map_start")
-	dso_end = get_optional(param_dict, "dso_map_end")
-	symbol = get_optional(param_dict, "symbol")
-	map_pgoff = get_optional(param_dict, "map_pgoff")
-	# check for valid map offset
-	if (str(map_pgoff) == '[unknown]'):
-		map_pgoff = 0
-
-	cpu = sample["cpu"]
-	ip = sample["ip"]
-	addr = sample["addr"]
-
-	sample_idx += 1
-
-	if (options.start_time and sample["time"] < options.start_time):
-		return
-	if (options.stop_time and sample["time"] > options.stop_time):
-		exit(0)
-	if (options.start_sample and sample_idx < options.start_sample):
-		return
-	if (options.stop_sample and sample_idx > options.stop_sample):
-		exit(0)
-
-	if (options.verbose == True):
-		print("Event type: %s" % name)
-		print_sample(sample)
-
-	# Initialize CPU data if it's empty, and directly return back
-	# if this is the first tracing event for this CPU.
-	if (cpu_data.get(str(cpu) + 'addr') == None):
-		cpu_data[str(cpu) + 'addr'] = addr
-		return
-
-	# If cannot find dso so cannot dump assembler, bail out
-	if (dso == '[unknown]'):
-		return
-
-	# Validate dso start and end addresses
-	if ((dso_start == '[unknown]') or (dso_end == '[unknown]')):
-		print("Failed to find valid dso map for dso %s" % dso)
-		return
-
-	if (name[0:12] == "instructions"):
-		print_srccode(comm, param_dict, sample, symbol, dso)
-		return
-
-	# Don't proceed if this event is not a branch sample, .
-	if (name[0:8] != "branches"):
-		return
-
-	# The format for packet is:
-	#
-	#		  +------------+------------+------------+
-	#  sample_prev:   |    addr    |    ip	    |	 cpu	 |
-	#		  +------------+------------+------------+
-	#  sample_next:   |    addr    |    ip	    |	 cpu	 |
-	#		  +------------+------------+------------+
-	#
-	# We need to combine the two continuous packets to get the instruction
-	# range for sample_prev::cpu:
-	#
-	#     [ sample_prev::addr .. sample_next::ip ]
-	#
-	# For this purose, sample_prev::addr is stored into cpu_data structure
-	# and read back for 'start_addr' when the new packet comes, and we need
-	# to use sample_next::ip to calculate 'stop_addr', plusing extra 4 for
-	# 'stop_addr' is for the sake of objdump so the final assembler dump can
-	# include last instruction for sample_next::ip.
-	start_addr = cpu_data[str(cpu) + 'addr']
-	stop_addr  = ip + 4
-
-	# Record for previous sample packet
-	cpu_data[str(cpu) + 'addr'] = addr
-
-	# Filter out zero start_address. Optionally identify CS_ETM_TRACE_ON packet
-	if (start_addr == 0):
-		if ((stop_addr == 4) and (options.verbose == True)):
-			print("CPU%d: CS_ETM_TRACE_ON packet is inserted" % cpu)
-		return
-
-	if (start_addr < int(dso_start) or start_addr > int(dso_end)):
-		print("Start address 0x%x is out of range [ 0x%x .. 0x%x ] for dso %s" % (start_addr, int(dso_start), int(dso_end), dso))
-		return
-
-	if (stop_addr < int(dso_start) or stop_addr > int(dso_end)):
-		print("Stop address 0x%x is out of range [ 0x%x .. 0x%x ] for dso %s" % (stop_addr, int(dso_start), int(dso_end), dso))
-		return
-
-	if (options.objdump != None):
-		# It doesn't need to decrease virtual memory offset for disassembly
-		# for kernel dso and executable file dso, so in this case we set
-		# vm_start to zero.
-		if (dso == "[kernel.kallsyms]" or dso_start == 0x400000):
-			dso_vm_start = 0
-			map_pgoff = 0
-		else:
-			dso_vm_start = int(dso_start)
-
-		dso_fname = get_dso_file_path(dso, dso_bid)
-		if path.exists(dso_fname):
-			print_disam(dso_fname, dso_vm_start, start_addr + map_pgoff, stop_addr + map_pgoff)
-		else:
-			print("Failed to find dso %s for address range [ 0x%x .. 0x%x ]" % (dso, start_addr + map_pgoff, stop_addr + map_pgoff))
-
-	print_srccode(comm, param_dict, sample, symbol, dso)
tools/perf/scripts/python/bin/compaction-times-record deleted +0 -2
deleted file mode 100644
index 6edcd40e14e8..000000000000
@@ -1,2 +0,0 @@
-#!/bin/bash
-perf record -e compaction:mm_compaction_begin -e compaction:mm_compaction_end -e compaction:mm_compaction_migratepages -e compaction:mm_compaction_isolate_migratepages -e compaction:mm_compaction_isolate_freepages $@
tools/perf/scripts/python/bin/compaction-times-report deleted +0 -4
deleted file mode 100644
index 3dc13897cfde..000000000000
@@ -1,4 +0,0 @@
-#!/bin/bash
-#description: display time taken by mm compaction
-#args: [-h] [-u] [-p|-pv] [-t | [-m] [-fs] [-ms]] [pid|pid-range|comm-regex]
-perf script -s "$PERF_EXEC_PATH"/scripts/python/compaction-times.py $@
tools/perf/scripts/python/bin/event_analyzing_sample-record deleted +0 -8
deleted file mode 100644
index 5ce652dabd02..000000000000
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-#
-# event_analyzing_sample.py can cover all type of perf samples including
-# the tracepoints, so no special record requirements, just record what
-# you want to analyze.
-#
-perf record $@
tools/perf/scripts/python/bin/event_analyzing_sample-report deleted +0 -3
deleted file mode 100644
index 0941fc94e158..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-# description: analyze all perf samples
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/event_analyzing_sample.py
tools/perf/scripts/python/bin/export-to-postgresql-record deleted +0 -8
deleted file mode 100644
index 221d66e05713..000000000000
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-#
-# export perf data to a postgresql database. Can cover
-# perf ip samples (excluding the tracepoints). No special
-# record requirements, just record what you want to export.
-#
-perf record $@
tools/perf/scripts/python/bin/export-to-postgresql-report deleted +0 -29
deleted file mode 100644
index cd335b6e2a01..000000000000
@@ -1,29 +0,0 @@
-#!/bin/bash
-# description: export perf data to a postgresql database
-# args: [database name] [columns] [calls]
-n_args=0
-for i in "$@"
-do
-    if expr match "$i" "-" > /dev/null ; then
-	break
-    fi
-    n_args=$(( $n_args + 1 ))
-done
-if [ "$n_args" -gt 3 ] ; then
-    echo "usage: export-to-postgresql-report [database name] [columns] [calls]"
-    exit
-fi
-if [ "$n_args" -gt 2 ] ; then
-    dbname=$1
-    columns=$2
-    calls=$3
-    shift 3
-elif [ "$n_args" -gt 1 ] ; then
-    dbname=$1
-    columns=$2
-    shift 2
-elif [ "$n_args" -gt 0 ] ; then
-    dbname=$1
-    shift
-fi
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/export-to-postgresql.py $dbname $columns $calls
tools/perf/scripts/python/bin/export-to-sqlite-record deleted +0 -8
deleted file mode 100644
index 070204fd6d00..000000000000
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-#
-# export perf data to a sqlite3 database. Can cover
-# perf ip samples (excluding the tracepoints). No special
-# record requirements, just record what you want to export.
-#
-perf record $@
tools/perf/scripts/python/bin/export-to-sqlite-report deleted +0 -29
deleted file mode 100644
index 5ff6033e70ba..000000000000
@@ -1,29 +0,0 @@
-#!/bin/bash
-# description: export perf data to a sqlite3 database
-# args: [database name] [columns] [calls]
-n_args=0
-for i in "$@"
-do
-    if expr match "$i" "-" > /dev/null ; then
-	break
-    fi
-    n_args=$(( $n_args + 1 ))
-done
-if [ "$n_args" -gt 3 ] ; then
-    echo "usage: export-to-sqlite-report [database name] [columns] [calls]"
-    exit
-fi
-if [ "$n_args" -gt 2 ] ; then
-    dbname=$1
-    columns=$2
-    calls=$3
-    shift 3
-elif [ "$n_args" -gt 1 ] ; then
-    dbname=$1
-    columns=$2
-    shift 2
-elif [ "$n_args" -gt 0 ] ; then
-    dbname=$1
-    shift
-fi
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/export-to-sqlite.py $dbname $columns $calls
tools/perf/scripts/python/bin/failed-syscalls-by-pid-record deleted +0 -3
deleted file mode 100644
index 74685f318379..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-(perf record -e raw_syscalls:sys_exit $@ || \
- perf record -e syscalls:sys_exit $@) 2> /dev/null
tools/perf/scripts/python/bin/failed-syscalls-by-pid-report deleted +0 -10
deleted file mode 100644
index fda5096d0cbf..000000000000
@@ -1,10 +0,0 @@
-#!/bin/bash
-# description: system-wide failed syscalls, by pid
-# args: [comm]
-if [ $# -gt 0 ] ; then
-    if ! expr match "$1" "-" > /dev/null ; then
-	comm=$1
-	shift
-    fi
-fi
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/failed-syscalls-by-pid.py $comm
tools/perf/scripts/python/bin/flamegraph-record deleted +0 -2
deleted file mode 100755
index 7df5a19c0163..000000000000
@@ -1,2 +0,0 @@
-#!/bin/bash
-perf record -g "$@"
tools/perf/scripts/python/bin/flamegraph-report deleted +0 -3
deleted file mode 100755
index 453a6918afbe..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-# description: create flame graphs
-perf script -s "$PERF_EXEC_PATH"/scripts/python/flamegraph.py "$@"
tools/perf/scripts/python/bin/futex-contention-record deleted +0 -2
deleted file mode 100644
index b1495c9a9b20..000000000000
@@ -1,2 +0,0 @@
-#!/bin/bash
-perf record -e syscalls:sys_enter_futex -e syscalls:sys_exit_futex $@
tools/perf/scripts/python/bin/futex-contention-report deleted +0 -4
deleted file mode 100644
index 6c44271091ab..000000000000
@@ -1,4 +0,0 @@
-#!/bin/bash
-# description: futext contention measurement
-
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/futex-contention.py
tools/perf/scripts/python/bin/gecko-record deleted +0 -2
deleted file mode 100644
index f0d1aa55f171..000000000000
@@ -1,2 +0,0 @@
-#!/bin/bash
-perf record -F 99 -g "$@"
tools/perf/scripts/python/bin/gecko-report deleted +0 -7
deleted file mode 100755
index 1867ec8d9757..000000000000
@@ -1,7 +0,0 @@
-#!/bin/bash
-# description: create firefox gecko profile json format from perf.data
-if [ "$*" = "-i -" ]; then
-perf script -s "$PERF_EXEC_PATH"/scripts/python/gecko.py
-else
-perf script -s "$PERF_EXEC_PATH"/scripts/python/gecko.py -- "$@"
-fi
tools/perf/scripts/python/bin/intel-pt-events-record deleted +0 -13
deleted file mode 100644
index 6b9877cfe23e..000000000000
@@ -1,13 +0,0 @@
-#!/bin/bash
-
-#
-# print Intel PT Events including Power Events and PTWRITE. The intel_pt PMU
-# event needs to be specified with appropriate config terms.
-#
-if ! echo "$@" | grep -q intel_pt ; then
-	echo "Options must include the Intel PT event e.g. -e intel_pt/pwr_evt,ptw/"
-	echo "and for power events it probably needs to be system wide i.e. -a option"
-	echo "For example: -a -e intel_pt/pwr_evt,branch=0/ sleep 1"
-	exit 1
-fi
-perf record $@
tools/perf/scripts/python/bin/intel-pt-events-report deleted +0 -3
deleted file mode 100644
index beeac3fde9db..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-# description: print Intel PT Events including Power Events and PTWRITE
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/intel-pt-events.py
tools/perf/scripts/python/bin/mem-phys-addr-record deleted +0 -19
deleted file mode 100644
index 5a875122a904..000000000000
@@ -1,19 +0,0 @@
-#!/bin/bash
-
-#
-# Profiling physical memory by all retired load instructions/uops event
-# MEM_INST_RETIRED.ALL_LOADS or MEM_UOPS_RETIRED.ALL_LOADS
-#
-
-load=`perf list | grep mem_inst_retired.all_loads`
-if [ -z "$load" ]; then
-	load=`perf list | grep mem_uops_retired.all_loads`
-fi
-if [ -z "$load" ]; then
-	echo "There is no event to count all retired load instructions/uops."
-	exit 1
-fi
-
-arg=$(echo $load | tr -d ' ')
-arg="$arg:P"
-perf record --phys-data -e $arg $@
tools/perf/scripts/python/bin/mem-phys-addr-report deleted +0 -3
deleted file mode 100644
index 3f2b847e2eab..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-# description: resolve physical address samples
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/mem-phys-addr.py
tools/perf/scripts/python/bin/net_dropmonitor-record deleted +0 -2
deleted file mode 100755
index 423fb81dadae..000000000000
@@ -1,2 +0,0 @@
-#!/bin/bash
-perf record -e skb:kfree_skb $@
tools/perf/scripts/python/bin/net_dropmonitor-report deleted +0 -4
deleted file mode 100755
index 8d698f5a06aa..000000000000
@@ -1,4 +0,0 @@
-#!/bin/bash
-# description: display a table of dropped frames
-
-perf script -s "$PERF_EXEC_PATH"/scripts/python/net_dropmonitor.py $@
tools/perf/scripts/python/bin/netdev-times-record deleted +0 -8
deleted file mode 100644
index 558754b840a9..000000000000
@@ -1,8 +0,0 @@
-#!/bin/bash
-perf record -e net:net_dev_xmit -e net:net_dev_queue		\
-		-e net:netif_receive_skb -e net:netif_rx		\
-		-e skb:consume_skb -e skb:kfree_skb			\
-		-e skb:skb_copy_datagram_iovec -e napi:napi_poll	\
-		-e irq:irq_handler_entry -e irq:irq_handler_exit	\
-		-e irq:softirq_entry -e irq:softirq_exit		\
-		-e irq:softirq_raise $@
tools/perf/scripts/python/bin/netdev-times-report deleted +0 -5
deleted file mode 100644
index 8f759291da86..000000000000
@@ -1,5 +0,0 @@
-#!/bin/bash
-# description: display a process of packet and processing time
-# args: [tx] [rx] [dev=] [debug]
-
-perf script -s "$PERF_EXEC_PATH"/scripts/python/netdev-times.py $@
tools/perf/scripts/python/bin/powerpc-hcalls-record deleted +0 -2
deleted file mode 100644
index b7402aa9147d..000000000000
@@ -1,2 +0,0 @@
-#!/bin/bash
-perf record -e "{powerpc:hcall_entry,powerpc:hcall_exit}" $@
tools/perf/scripts/python/bin/powerpc-hcalls-report deleted +0 -2
deleted file mode 100644
index dd32ad7465f6..000000000000
@@ -1,2 +0,0 @@
-#!/bin/bash
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/powerpc-hcalls.py
tools/perf/scripts/python/bin/sched-migration-record deleted +0 -2
deleted file mode 100644
index 7493fddbe995..000000000000
@@ -1,2 +0,0 @@
-#!/bin/bash
-perf record -m 16384 -e sched:sched_wakeup -e sched:sched_wakeup_new -e sched:sched_switch -e sched:sched_migrate_task $@
tools/perf/scripts/python/bin/sched-migration-report deleted +0 -3
deleted file mode 100644
index 68b037a1849b..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-# description: sched migration overview
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/sched-migration.py
tools/perf/scripts/python/bin/sctop-record deleted +0 -3
deleted file mode 100644
index d6940841e54f..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-(perf record -e raw_syscalls:sys_enter $@ || \
- perf record -e syscalls:sys_enter $@) 2> /dev/null
tools/perf/scripts/python/bin/sctop-report deleted +0 -24
deleted file mode 100644
index c32db294124d..000000000000
@@ -1,24 +0,0 @@
-#!/bin/bash
-# description: syscall top
-# args: [comm] [interval]
-n_args=0
-for i in "$@"
-do
-    if expr match "$i" "-" > /dev/null ; then
-	break
-    fi
-    n_args=$(( $n_args + 1 ))
-done
-if [ "$n_args" -gt 2 ] ; then
-    echo "usage: sctop-report [comm] [interval]"
-    exit
-fi
-if [ "$n_args" -gt 1 ] ; then
-    comm=$1
-    interval=$2
-    shift 2
-elif [ "$n_args" -gt 0 ] ; then
-    interval=$1
-    shift
-fi
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/sctop.py $comm $interval
tools/perf/scripts/python/bin/stackcollapse-record deleted +0 -8
deleted file mode 100755
index 9d8f9f0f3a17..000000000000
@@ -1,8 +0,0 @@
-#!/bin/sh
-
-#
-# stackcollapse.py can cover all type of perf samples including
-# the tracepoints, so no special record requirements, just record what
-# you want to analyze.
-#
-perf record "$@"
tools/perf/scripts/python/bin/stackcollapse-report deleted +0 -3
deleted file mode 100755
index 21a356bd27f6..000000000000
@@ -1,3 +0,0 @@
-#!/bin/sh
-# description: produce callgraphs in short form for scripting use
-perf script -s "$PERF_EXEC_PATH"/scripts/python/stackcollapse.py "$@"
tools/perf/scripts/python/bin/syscall-counts-by-pid-record deleted +0 -3
deleted file mode 100644
index d6940841e54f..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-(perf record -e raw_syscalls:sys_enter $@ || \
- perf record -e syscalls:sys_enter $@) 2> /dev/null
tools/perf/scripts/python/bin/syscall-counts-by-pid-report deleted +0 -10
deleted file mode 100644
index 16eb8d65c543..000000000000
@@ -1,10 +0,0 @@
-#!/bin/bash
-# description: system-wide syscall counts, by pid
-# args: [comm]
-if [ $# -gt 0 ] ; then
-    if ! expr match "$1" "-" > /dev/null ; then
-	comm=$1
-	shift
-    fi
-fi
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/syscall-counts-by-pid.py $comm
tools/perf/scripts/python/bin/syscall-counts-record deleted +0 -3
deleted file mode 100644
index d6940841e54f..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-(perf record -e raw_syscalls:sys_enter $@ || \
- perf record -e syscalls:sys_enter $@) 2> /dev/null
tools/perf/scripts/python/bin/syscall-counts-report deleted +0 -10
deleted file mode 100644
index 0f0e9d453bb4..000000000000
@@ -1,10 +0,0 @@
-#!/bin/bash
-# description: system-wide syscall counts
-# args: [comm]
-if [ $# -gt 0 ] ; then
-    if ! expr match "$1" "-" > /dev/null ; then
-	comm=$1
-	shift
-    fi
-fi
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/python/syscall-counts.py $comm
tools/perf/scripts/python/bin/task-analyzer-record deleted +0 -2
deleted file mode 100755
index 0f6b51bb2767..000000000000
@@ -1,2 +0,0 @@
-#!/bin/bash
-perf record -e sched:sched_switch -e sched:sched_migrate_task "$@"
tools/perf/scripts/python/bin/task-analyzer-report deleted +0 -3
deleted file mode 100755
index 4b16a8cc40a0..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-# description: analyze timings of tasks
-perf script -s "$PERF_EXEC_PATH"/scripts/python/task-analyzer.py -- "$@"
tools/perf/scripts/python/check-perf-trace.py deleted +0 -84
deleted file mode 100644
index d2c22954800d..000000000000
@@ -1,84 +0,0 @@
-# perf script event handlers, generated by perf script -g python
-# (c) 2010, Tom Zanussi <[email protected]>
-# Licensed under the terms of the GNU GPL License version 2
-#
-# This script tests basic functionality such as flag and symbol
-# strings, common_xxx() calls back into perf, begin, end, unhandled
-# events, etc.  Basically, if this script runs successfully and
-# displays expected results, Python scripting support should be ok.
-
-from __future__ import print_function
-
-import os
-import sys
-
-sys.path.append(os.environ['PERF_EXEC_PATH'] + \
-	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
-
-from Core import *
-from perf_trace_context import *
-
-unhandled = autodict()
-
-def trace_begin():
-	print("trace_begin")
-	pass
-
-def trace_end():
-	print_unhandled()
-
-def irq__softirq_entry(event_name, context, common_cpu,
-		       common_secs, common_nsecs, common_pid, common_comm,
-		       common_callchain, vec):
-	print_header(event_name, common_cpu, common_secs, common_nsecs,
-		common_pid, common_comm)
-
-	print_uncommon(context)
-
-	print("vec=%s" % (symbol_str("irq__softirq_entry", "vec", vec)))
-
-def kmem__kmalloc(event_name, context, common_cpu,
-		  common_secs, common_nsecs, common_pid, common_comm,
-		  common_callchain, call_site, ptr, bytes_req, bytes_alloc,
-		  gfp_flags):
-	print_header(event_name, common_cpu, common_secs, common_nsecs,
-		common_pid, common_comm)
-
-	print_uncommon(context)
-
-	print("call_site=%u, ptr=%u, bytes_req=%u, "
-		"bytes_alloc=%u, gfp_flags=%s" %
-		(call_site, ptr, bytes_req, bytes_alloc,
-		flag_str("kmem__kmalloc", "gfp_flags", gfp_flags)))
-
-def trace_unhandled(event_name, context, event_fields_dict):
-	try:
-		unhandled[event_name] += 1
-	except TypeError:
-		unhandled[event_name] = 1
-
-def print_header(event_name, cpu, secs, nsecs, pid, comm):
-	print("%-20s %5u %05u.%09u %8u %-20s " %
-		(event_name, cpu, secs, nsecs, pid, comm),
-		end=' ')
-
-# print trace fields not included in handler args
-def print_uncommon(context):
-	print("common_preempt_count=%d, common_flags=%s, "
-		"common_lock_depth=%d, " %
-		(common_pc(context), trace_flag_str(common_flags(context)),
-		common_lock_depth(context)))
-
-def print_unhandled():
-	keys = unhandled.keys()
-	if not keys:
-		return
-
-	print("\nunhandled events:\n")
-
-	print("%-40s  %10s" % ("event", "count"))
-	print("%-40s  %10s" % ("----------------------------------------",
-				"-----------"))
-
-	for event_name in keys:
-		print("%-40s  %10d\n" % (event_name, unhandled[event_name]))
tools/perf/scripts/python/compaction-times.py deleted +0 -311
deleted file mode 100644
index 9401f7c14747..000000000000
@@ -1,311 +0,0 @@
-# report time spent in compaction
-# Licensed under the terms of the GNU GPL License version 2
-
-# testing:
-# 'echo 1 > /proc/sys/vm/compact_memory' to force compaction of all zones
-
-import os
-import sys
-import re
-
-import signal
-signal.signal(signal.SIGPIPE, signal.SIG_DFL)
-
-usage = "usage: perf script report compaction-times.py -- [-h] [-u] [-p|-pv] [-t | [-m] [-fs] [-ms]] [pid|pid-range|comm-regex]\n"
-
-class popt:
-	DISP_DFL = 0
-	DISP_PROC = 1
-	DISP_PROC_VERBOSE=2
-
-class topt:
-	DISP_TIME = 0
-	DISP_MIG = 1
-	DISP_ISOLFREE = 2
-	DISP_ISOLMIG = 4
-	DISP_ALL = 7
-
-class comm_filter:
-	def __init__(self, re):
-		self.re = re
-
-	def filter(self, pid, comm):
-		m = self.re.search(comm)
-		return m == None or m.group() == ""
-
-class pid_filter:
-	def __init__(self, low, high):
-		self.low = (0 if low == "" else int(low))
-		self.high = (0 if high == "" else int(high))
-
-	def filter(self, pid, comm):
-		return not (pid >= self.low and (self.high == 0 or pid <= self.high))
-
-def set_type(t):
-	global opt_disp
-	opt_disp = (t if opt_disp == topt.DISP_ALL else opt_disp|t)
-
-def ns(sec, nsec):
-	return (sec * 1000000000) + nsec
-
-def time(ns):
-	return "%dns" % ns if opt_ns else "%dus" % (round(ns, -3) / 1000)
-
-class pair:
-	def __init__(self, aval, bval, alabel = None, blabel = None):
-		self.alabel = alabel
-		self.blabel = blabel
-		self.aval = aval
-		self.bval = bval
-
-	def __add__(self, rhs):
-		self.aval += rhs.aval
-		self.bval += rhs.bval
-		return self
-
-	def __str__(self):
-		return "%s=%d %s=%d" % (self.alabel, self.aval, self.blabel, self.bval)
-
-class cnode:
-	def __init__(self, ns):
-		self.ns = ns
-		self.migrated = pair(0, 0, "moved", "failed")
-		self.fscan = pair(0,0, "scanned", "isolated")
-		self.mscan = pair(0,0, "scanned", "isolated")
-
-	def __add__(self, rhs):
-		self.ns += rhs.ns
-		self.migrated += rhs.migrated
-		self.fscan += rhs.fscan
-		self.mscan += rhs.mscan
-		return self
-
-	def __str__(self):
-		prev = 0
-		s = "%s " % time(self.ns)
-		if (opt_disp & topt.DISP_MIG):
-			s += "migration: %s" % self.migrated
-			prev = 1
-		if (opt_disp & topt.DISP_ISOLFREE):
-			s += "%sfree_scanner: %s" % (" " if prev else "", self.fscan)
-			prev = 1
-		if (opt_disp & topt.DISP_ISOLMIG):
-			s += "%smigration_scanner: %s" % (" " if prev else "", self.mscan)
-		return s
-
-	def complete(self, secs, nsecs):
-		self.ns = ns(secs, nsecs) - self.ns
-
-	def increment(self, migrated, fscan, mscan):
-		if (migrated != None):
-			self.migrated += migrated
-		if (fscan != None):
-			self.fscan += fscan
-		if (mscan != None):
-			self.mscan += mscan
-
-
-class chead:
-	heads = {}
-	val = cnode(0);
-	fobj = None
-
-	@classmethod
-	def add_filter(cls, filter):
-		cls.fobj = filter
-
-	@classmethod
-	def create_pending(cls, pid, comm, start_secs, start_nsecs):
-		filtered = 0
-		try:
-			head = cls.heads[pid]
-			filtered = head.is_filtered()
-		except KeyError:
-			if cls.fobj != None:
-				filtered = cls.fobj.filter(pid, comm)
-			head = cls.heads[pid] = chead(comm, pid, filtered)
-
-		if not filtered:
-			head.mark_pending(start_secs, start_nsecs)
-
-	@classmethod
-	def increment_pending(cls, pid, migrated, fscan, mscan):
-		head = cls.heads[pid]
-		if not head.is_filtered():
-			if head.is_pending():
-				head.do_increment(migrated, fscan, mscan)
-			else:
-				sys.stderr.write("missing start compaction event for pid %d\n" % pid)
-
-	@classmethod
-	def complete_pending(cls, pid, secs, nsecs):
-		head = cls.heads[pid]
-		if not head.is_filtered():
-			if head.is_pending():
-				head.make_complete(secs, nsecs)
-			else:
-				sys.stderr.write("missing start compaction event for pid %d\n" % pid)
-
-	@classmethod
-	def gen(cls):
-		if opt_proc != popt.DISP_DFL:
-			for i in cls.heads:
-				yield cls.heads[i]
-
-	@classmethod
-	def str(cls):
-		return cls.val
-
-	def __init__(self, comm, pid, filtered):
-		self.comm = comm
-		self.pid = pid
-		self.val = cnode(0)
-		self.pending = None
-		self.filtered = filtered
-		self.list = []
-
-	def __add__(self, rhs):
-		self.ns += rhs.ns
-		self.val += rhs.val
-		return self
-
-	def mark_pending(self, secs, nsecs):
-		self.pending = cnode(ns(secs, nsecs))
-
-	def do_increment(self, migrated, fscan, mscan):
-		self.pending.increment(migrated, fscan, mscan)
-
-	def make_complete(self, secs, nsecs):
-		self.pending.complete(secs, nsecs)
-		chead.val += self.pending
-
-		if opt_proc != popt.DISP_DFL:
-			self.val += self.pending
-
-			if opt_proc == popt.DISP_PROC_VERBOSE:
-				self.list.append(self.pending)
-		self.pending = None
-
-	def enumerate(self):
-		if opt_proc == popt.DISP_PROC_VERBOSE and not self.is_filtered():
-			for i, pelem in enumerate(self.list):
-				sys.stdout.write("%d[%s].%d: %s\n" % (self.pid, self.comm, i+1, pelem))
-
-	def is_pending(self):
-		return self.pending != None
-
-	def is_filtered(self):
-		return self.filtered
-
-	def display(self):
-		if not self.is_filtered():
-			sys.stdout.write("%d[%s]: %s\n" % (self.pid, self.comm, self.val))
-
-
-def trace_end():
-	sys.stdout.write("total: %s\n" % chead.str())
-	for i in chead.gen():
-		i.display(),
-		i.enumerate()
-
-def compaction__mm_compaction_migratepages(event_name, context, common_cpu,
-	common_secs, common_nsecs, common_pid, common_comm,
-	common_callchain, nr_migrated, nr_failed):
-
-	chead.increment_pending(common_pid,
-		pair(nr_migrated, nr_failed), None, None)
-
-def compaction__mm_compaction_isolate_freepages(event_name, context, common_cpu,
-	common_secs, common_nsecs, common_pid, common_comm,
-	common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
-
-	chead.increment_pending(common_pid,
-		None, pair(nr_scanned, nr_taken), None)
-
-def compaction__mm_compaction_isolate_migratepages(event_name, context, common_cpu,
-	common_secs, common_nsecs, common_pid, common_comm,
-	common_callchain, start_pfn, end_pfn, nr_scanned, nr_taken):
-
-	chead.increment_pending(common_pid,
-		None, None, pair(nr_scanned, nr_taken))
-
-def compaction__mm_compaction_end(event_name, context, common_cpu,
-	common_secs, common_nsecs, common_pid, common_comm,
-	common_callchain, zone_start, migrate_start, free_start, zone_end,
-	sync, status):
-
-	chead.complete_pending(common_pid, common_secs, common_nsecs)
-
-def compaction__mm_compaction_begin(event_name, context, common_cpu,
-	common_secs, common_nsecs, common_pid, common_comm,
-	common_callchain, zone_start, migrate_start, free_start, zone_end,
-	sync):
-
-	chead.create_pending(common_pid, common_comm, common_secs, common_nsecs)
-
-def pr_help():
-	global usage
-
-	sys.stdout.write(usage)
-	sys.stdout.write("\n")
-	sys.stdout.write("-h	display this help\n")
-	sys.stdout.write("-p	display by process\n")
-	sys.stdout.write("-pv	display by process (verbose)\n")
-	sys.stdout.write("-t	display stall times only\n")
-	sys.stdout.write("-m	display stats for migration\n")
-	sys.stdout.write("-fs	display stats for free scanner\n")
-	sys.stdout.write("-ms	display stats for migration scanner\n")
-	sys.stdout.write("-u	display results in microseconds (default nanoseconds)\n")
-
-
-comm_re = None
-pid_re = None
-pid_regex = r"^(\d*)-(\d*)$|^(\d*)$"
-
-opt_proc = popt.DISP_DFL
-opt_disp = topt.DISP_ALL
-
-opt_ns = True
-
-argc = len(sys.argv) - 1
-if argc >= 1:
-	pid_re = re.compile(pid_regex)
-
-	for i, opt in enumerate(sys.argv[1:]):
-		if opt[0] == "-":
-			if opt == "-h":
-				pr_help()
-				exit(0);
-			elif opt == "-p":
-				opt_proc = popt.DISP_PROC
-			elif opt == "-pv":
-				opt_proc = popt.DISP_PROC_VERBOSE
-			elif opt == '-u':
-				opt_ns = False
-			elif opt == "-t":
-				set_type(topt.DISP_TIME)
-			elif opt == "-m":
-				set_type(topt.DISP_MIG)
-			elif opt == "-fs":
-				set_type(topt.DISP_ISOLFREE)
-			elif opt == "-ms":
-				set_type(topt.DISP_ISOLMIG)
-			else:
-				sys.exit(usage)
-
-		elif i == argc - 1:
-			m = pid_re.search(opt)
-			if m != None and m.group() != "":
-				if m.group(3) != None:
-					f = pid_filter(m.group(3), m.group(3))
-				else:
-					f = pid_filter(m.group(1), m.group(2))
-			else:
-				try:
-					comm_re=re.compile(opt)
-				except:
-					sys.stderr.write("invalid regex '%s'" % opt)
-					sys.exit(usage)
-				f = comm_filter(comm_re)
-
-			chead.add_filter(f)
tools/perf/scripts/python/event_analyzing_sample.py deleted +0 -192
deleted file mode 100644
index aa1e2cfa26a6..000000000000
@@ -1,192 +0,0 @@
-# event_analyzing_sample.py: general event handler in python
-# SPDX-License-Identifier: GPL-2.0
-#
-# Current perf report is already very powerful with the annotation integrated,
-# and this script is not trying to be as powerful as perf report, but
-# providing end user/developer a flexible way to analyze the events other
-# than trace points.
-#
-# The 2 database related functions in this script just show how to gather
-# the basic information, and users can modify and write their own functions
-# according to their specific requirement.
-#
-# The first function "show_general_events" just does a basic grouping for all
-# generic events with the help of sqlite, and the 2nd one "show_pebs_ll" is
-# for a x86 HW PMU event: PEBS with load latency data.
-#
-
-from __future__ import print_function
-
-import os
-import sys
-import math
-import struct
-import sqlite3
-
-sys.path.append(os.environ['PERF_EXEC_PATH'] + \
-        '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
-
-from perf_trace_context import *
-from EventClass import *
-
-#
-# If the perf.data has a big number of samples, then the insert operation
-# will be very time consuming (about 10+ minutes for 10000 samples) if the
-# .db database is on disk. Move the .db file to RAM based FS to speedup
-# the handling, which will cut the time down to several seconds.
-#
-con = sqlite3.connect("/dev/shm/perf.db")
-con.isolation_level = None
-
-def trace_begin():
-        print("In trace_begin:\n")
-
-        #
-        # Will create several tables at the start, pebs_ll is for PEBS data with
-        # load latency info, while gen_events is for general event.
-        #
-        con.execute("""
-                create table if not exists gen_events (
-                        name text,
-                        symbol text,
-                        comm text,
-                        dso text
-                );""")
-        con.execute("""
-                create table if not exists pebs_ll (
-                        name text,
-                        symbol text,
-                        comm text,
-                        dso text,
-                        flags integer,
-                        ip integer,
-                        status integer,
-                        dse integer,
-                        dla integer,
-                        lat integer
-                );""")
-
-#
-# Create and insert event object to a database so that user could
-# do more analysis with simple database commands.
-#
-def process_event(param_dict):
-        event_attr = param_dict["attr"]
-        sample     = param_dict["sample"]
-        raw_buf    = param_dict["raw_buf"]
-        comm       = param_dict["comm"]
-        name       = param_dict["ev_name"]
-
-        # Symbol and dso info are not always resolved
-        if ("dso" in param_dict):
-                dso = param_dict["dso"]
-        else:
-                dso = "Unknown_dso"
-
-        if ("symbol" in param_dict):
-                symbol = param_dict["symbol"]
-        else:
-                symbol = "Unknown_symbol"
-
-        # Create the event object and insert it to the right table in database
-        event = create_event(name, comm, dso, symbol, raw_buf)
-        insert_db(event)
-
-def insert_db(event):
-        if event.ev_type == EVTYPE_GENERIC:
-                con.execute("insert into gen_events values(?, ?, ?, ?)",
-                                (event.name, event.symbol, event.comm, event.dso))
-        elif event.ev_type == EVTYPE_PEBS_LL:
-                event.ip &= 0x7fffffffffffffff
-                event.dla &= 0x7fffffffffffffff
-                con.execute("insert into pebs_ll values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
-                        (event.name, event.symbol, event.comm, event.dso, event.flags,
-                                event.ip, event.status, event.dse, event.dla, event.lat))
-
-def trace_end():
-        print("In trace_end:\n")
-        # We show the basic info for the 2 type of event classes
-        show_general_events()
-        show_pebs_ll()
-        con.close()
-
-#
-# As the event number may be very big, so we can't use linear way
-# to show the histogram in real number, but use a log2 algorithm.
-#
-
-def num2sym(num):
-        # Each number will have at least one '#'
-        snum = '#' * (int)(math.log(num, 2) + 1)
-        return snum
-
-def show_general_events():
-
-        # Check the total record number in the table
-        count = con.execute("select count(*) from gen_events")
-        for t in count:
-                print("There is %d records in gen_events table" % t[0])
-                if t[0] == 0:
-                        return
-
-        print("Statistics about the general events grouped by thread/symbol/dso: \n")
-
-         # Group by thread
-        commq = con.execute("select comm, count(comm) from gen_events group by comm order by -count(comm)")
-        print("\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42))
-        for row in commq:
-             print("%16s %8d     %s" % (row[0], row[1], num2sym(row[1])))
-
-        # Group by symbol
-        print("\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58))
-        symbolq = con.execute("select symbol, count(symbol) from gen_events group by symbol order by -count(symbol)")
-        for row in symbolq:
-             print("%32s %8d     %s" % (row[0], row[1], num2sym(row[1])))
-
-        # Group by dso
-        print("\n%40s %8s %16s\n%s" % ("dso", "number", "histogram", "="*74))
-        dsoq = con.execute("select dso, count(dso) from gen_events group by dso order by -count(dso)")
-        for row in dsoq:
-             print("%40s %8d     %s" % (row[0], row[1], num2sym(row[1])))
-
-#
-# This function just shows the basic info, and we could do more with the
-# data in the tables, like checking the function parameters when some
-# big latency events happen.
-#
-def show_pebs_ll():
-
-        count = con.execute("select count(*) from pebs_ll")
-        for t in count:
-                print("There is %d records in pebs_ll table" % t[0])
-                if t[0] == 0:
-                        return
-
-        print("Statistics about the PEBS Load Latency events grouped by thread/symbol/dse/latency: \n")
-
-        # Group by thread
-        commq = con.execute("select comm, count(comm) from pebs_ll group by comm order by -count(comm)")
-        print("\n%16s %8s %16s\n%s" % ("comm", "number", "histogram", "="*42))
-        for row in commq:
-             print("%16s %8d     %s" % (row[0], row[1], num2sym(row[1])))
-
-        # Group by symbol
-        print("\n%32s %8s %16s\n%s" % ("symbol", "number", "histogram", "="*58))
-        symbolq = con.execute("select symbol, count(symbol) from pebs_ll group by symbol order by -count(symbol)")
-        for row in symbolq:
-             print("%32s %8d     %s" % (row[0], row[1], num2sym(row[1])))
-
-        # Group by dse
-        dseq = con.execute("select dse, count(dse) from pebs_ll group by dse order by -count(dse)")
-        print("\n%32s %8s %16s\n%s" % ("dse", "number", "histogram", "="*58))
-        for row in dseq:
-             print("%32s %8d     %s" % (row[0], row[1], num2sym(row[1])))
-
-        # Group by latency
-        latq = con.execute("select lat, count(lat) from pebs_ll group by lat order by lat")
-        print("\n%32s %8s %16s\n%s" % ("latency", "number", "histogram", "="*58))
-        for row in latq:
-             print("%32s %8d     %s" % (row[0], row[1], num2sym(row[1])))
-
-def trace_unhandled(event_name, context, event_fields_dict):
-        print (' '.join(['%s=%s'%(k,str(v))for k,v in sorted(event_fields_dict.items())]))
tools/perf/scripts/python/export-to-postgresql.py deleted +0 -1114
deleted file mode 100644
index 3a6bdcd74e60..000000000000
@@ -1,1114 +0,0 @@
-# export-to-postgresql.py: export perf data to a postgresql database
-# Copyright (c) 2014, Intel Corporation.
-#
-# This program is free software; you can redistribute it and/or modify it
-# under the terms and conditions of the GNU General Public License,
-# version 2, as published by the Free Software Foundation.
-#
-# This program is distributed in the hope it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-# more details.
-
-from __future__ import print_function
-
-import os
-import sys
-import struct
-import datetime
-
-# To use this script you will need to have installed package python-pyside which
-# provides LGPL-licensed Python bindings for Qt.  You will also need the package
-# libqt4-sql-psql for Qt postgresql support.
-#
-# The script assumes postgresql is running on the local machine and that the
-# user has postgresql permissions to create databases. Examples of installing
-# postgresql and adding such a user are:
-#
-# fedora:
-#
-#	$ sudo yum install postgresql postgresql-server qt-postgresql
-#	$ sudo su - postgres -c initdb
-#	$ sudo service postgresql start
-#	$ sudo su - postgres
-#	$ createuser -s <your user id here>    # Older versions may not support -s, in which case answer the prompt below:
-#	Shall the new role be a superuser? (y/n) y
-#	$ sudo yum install python-pyside
-#
-#	Alternately, to use Python3 and/or pyside 2, one of the following:
-#		$ sudo yum install python3-pyside
-#		$ pip install --user PySide2
-#		$ pip3 install --user PySide2
-#
-# ubuntu:
-#
-#	$ sudo apt-get install postgresql
-#	$ sudo su - postgres
-#	$ createuser -s <your user id here>
-#	$ sudo apt-get install python-pyside.qtsql libqt4-sql-psql
-#
-#	Alternately, to use Python3 and/or pyside 2, one of the following:
-#
-#		$ sudo apt-get install python3-pyside.qtsql libqt4-sql-psql
-#		$ sudo apt-get install python-pyside2.qtsql libqt5sql5-psql
-#		$ sudo apt-get install python3-pyside2.qtsql libqt5sql5-psql
-#
-# An example of using this script with Intel PT:
-#
-#	$ perf record -e intel_pt//u ls
-#	$ perf script -s ~/libexec/perf-core/scripts/python/export-to-postgresql.py pt_example branches calls
-#	2015-05-29 12:49:23.464364 Creating database...
-#	2015-05-29 12:49:26.281717 Writing to intermediate files...
-#	2015-05-29 12:49:27.190383 Copying to database...
-#	2015-05-29 12:49:28.140451 Removing intermediate files...
-#	2015-05-29 12:49:28.147451 Adding primary keys
-#	2015-05-29 12:49:28.655683 Adding foreign keys
-#	2015-05-29 12:49:29.365350 Done
-#
-# To browse the database, psql can be used e.g.
-#
-#	$ psql pt_example
-#	pt_example=# select * from samples_view where id < 100;
-#	pt_example=# \d+
-#	pt_example=# \d+ samples_view
-#	pt_example=# \q
-#
-# An example of using the database is provided by the script
-# exported-sql-viewer.py.  Refer to that script for details.
-#
-# Tables:
-#
-#	The tables largely correspond to perf tools' data structures.  They are largely self-explanatory.
-#
-#	samples
-#
-#		'samples' is the main table. It represents what instruction was executing at a point in time
-#		when something (a selected event) happened.  The memory address is the instruction pointer or 'ip'.
-#
-#	calls
-#
-#		'calls' represents function calls and is related to 'samples' by 'call_id' and 'return_id'.
-#		'calls' is only created when the 'calls' option to this script is specified.
-#
-#	call_paths
-#
-#		'call_paths' represents all the call stacks.  Each 'call' has an associated record in 'call_paths'.
-#		'calls_paths' is only created when the 'calls' option to this script is specified.
-#
-#	branch_types
-#
-#		'branch_types' provides descriptions for each type of branch.
-#
-#	comm_threads
-#
-#		'comm_threads' shows how 'comms' relates to 'threads'.
-#
-#	comms
-#
-#		'comms' contains a record for each 'comm' - the name given to the executable that is running.
-#
-#	dsos
-#
-#		'dsos' contains a record for each executable file or library.
-#
-#	machines
-#
-#		'machines' can be used to distinguish virtual machines if virtualization is supported.
-#
-#	selected_events
-#
-#		'selected_events' contains a record for each kind of event that has been sampled.
-#
-#	symbols
-#
-#		'symbols' contains a record for each symbol.  Only symbols that have samples are present.
-#
-#	threads
-#
-#		'threads' contains a record for each thread.
-#
-# Views:
-#
-#	Most of the tables have views for more friendly display.  The views are:
-#
-#		calls_view
-#		call_paths_view
-#		comm_threads_view
-#		dsos_view
-#		machines_view
-#		samples_view
-#		symbols_view
-#		threads_view
-#
-# More examples of browsing the database with psql:
-#   Note that some of the examples are not the most optimal SQL query.
-#   Note that call information is only available if the script's 'calls' option has been used.
-#
-#	Top 10 function calls (not aggregated by symbol):
-#
-#		SELECT * FROM calls_view ORDER BY elapsed_time DESC LIMIT 10;
-#
-#	Top 10 function calls (aggregated by symbol):
-#
-#		SELECT symbol_id,(SELECT name FROM symbols WHERE id = symbol_id) AS symbol,
-#			SUM(elapsed_time) AS tot_elapsed_time,SUM(branch_count) AS tot_branch_count
-#			FROM calls_view GROUP BY symbol_id ORDER BY tot_elapsed_time DESC LIMIT 10;
-#
-#		Note that the branch count gives a rough estimation of cpu usage, so functions
-#		that took a long time but have a relatively low branch count must have spent time
-#		waiting.
-#
-#	Find symbols by pattern matching on part of the name (e.g. names containing 'alloc'):
-#
-#		SELECT * FROM symbols_view WHERE name LIKE '%alloc%';
-#
-#	Top 10 function calls for a specific symbol (e.g. whose symbol_id is 187):
-#
-#		SELECT * FROM calls_view WHERE symbol_id = 187 ORDER BY elapsed_time DESC LIMIT 10;
-#
-#	Show function calls made by function in the same context (i.e. same call path) (e.g. one with call_path_id 254):
-#
-#		SELECT * FROM calls_view WHERE parent_call_path_id = 254;
-#
-#	Show branches made during a function call (e.g. where call_id is 29357 and return_id is 29370 and tid is 29670)
-#
-#		SELECT * FROM samples_view WHERE id >= 29357 AND id <= 29370 AND tid = 29670 AND event LIKE 'branches%';
-#
-#	Show transactions:
-#
-#		SELECT * FROM samples_view WHERE event = 'transactions';
-#
-#		Note transaction start has 'in_tx' true whereas, transaction end has 'in_tx' false.
-#		Transaction aborts have branch_type_name 'transaction abort'
-#
-#	Show transaction aborts:
-#
-#		SELECT * FROM samples_view WHERE event = 'transactions' AND branch_type_name = 'transaction abort';
-#
-# To print a call stack requires walking the call_paths table.  For example this python script:
-#   #!/usr/bin/python2
-#
-#   import sys
-#   from PySide.QtSql import *
-#
-#   if __name__ == '__main__':
-#           if (len(sys.argv) < 3):
-#                   print >> sys.stderr, "Usage is: printcallstack.py <database name> <call_path_id>"
-#                   raise Exception("Too few arguments")
-#           dbname = sys.argv[1]
-#           call_path_id = sys.argv[2]
-#           db = QSqlDatabase.addDatabase('QPSQL')
-#           db.setDatabaseName(dbname)
-#           if not db.open():
-#                   raise Exception("Failed to open database " + dbname + " error: " + db.lastError().text())
-#           query = QSqlQuery(db)
-#           print "    id          ip  symbol_id  symbol                          dso_id  dso_short_name"
-#           while call_path_id != 0 and call_path_id != 1:
-#                   ret = query.exec_('SELECT * FROM call_paths_view WHERE id = ' + str(call_path_id))
-#                   if not ret:
-#                           raise Exception("Query failed: " + query.lastError().text())
-#                   if not query.next():
-#                           raise Exception("Query failed")
-#                   print "{0:>6}  {1:>10}  {2:>9}  {3:<30}  {4:>6}  {5:<30}".format(query.value(0), query.value(1), query.value(2), query.value(3), query.value(4), query.value(5))
-#                   call_path_id = query.value(6)
-
-pyside_version_1 = True
-if not "pyside-version-1" in sys.argv:
-	try:
-		from PySide2.QtSql import *
-		pyside_version_1 = False
-	except:
-		pass
-
-if pyside_version_1:
-	from PySide.QtSql import *
-
-if sys.version_info < (3, 0):
-	def toserverstr(str):
-		return str
-	def toclientstr(str):
-		return str
-else:
-	# Assume UTF-8 server_encoding and client_encoding
-	def toserverstr(str):
-		return bytes(str, "UTF_8")
-	def toclientstr(str):
-		return bytes(str, "UTF_8")
-
-# Need to access PostgreSQL C library directly to use COPY FROM STDIN
-from ctypes import *
-libpq = CDLL("libpq.so.5")
-PQconnectdb = libpq.PQconnectdb
-PQconnectdb.restype = c_void_p
-PQconnectdb.argtypes = [ c_char_p ]
-PQfinish = libpq.PQfinish
-PQfinish.argtypes = [ c_void_p ]
-PQstatus = libpq.PQstatus
-PQstatus.restype = c_int
-PQstatus.argtypes = [ c_void_p ]
-PQexec = libpq.PQexec
-PQexec.restype = c_void_p
-PQexec.argtypes = [ c_void_p, c_char_p ]
-PQresultStatus = libpq.PQresultStatus
-PQresultStatus.restype = c_int
-PQresultStatus.argtypes = [ c_void_p ]
-PQputCopyData = libpq.PQputCopyData
-PQputCopyData.restype = c_int
-PQputCopyData.argtypes = [ c_void_p, c_void_p, c_int ]
-PQputCopyEnd = libpq.PQputCopyEnd
-PQputCopyEnd.restype = c_int
-PQputCopyEnd.argtypes = [ c_void_p, c_void_p ]
-
-sys.path.append(os.environ['PERF_EXEC_PATH'] + \
-	'/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
-
-# These perf imports are not used at present
-#from perf_trace_context import *
-#from Core import *
-
-perf_db_export_mode = True
-perf_db_export_calls = False
-perf_db_export_callchains = False
-
-def printerr(*args, **kw_args):
-	print(*args, file=sys.stderr, **kw_args)
-
-def printdate(*args, **kw_args):
-        print(datetime.datetime.today(), *args, sep=' ', **kw_args)
-
-def usage():
-	printerr("Usage is: export-to-postgresql.py <database name> [<columns>] [<calls>] [<callchains>] [<pyside-version-1>]");
-	printerr("where:  columns            'all' or 'branches'");
-	printerr("        calls              'calls' => create calls and call_paths table");
-	printerr("        callchains         'callchains' => create call_paths table");
-	printerr("        pyside-version-1   'pyside-version-1' => use pyside version 1");
-	raise Exception("Too few or bad arguments")
-
-if (len(sys.argv) < 2):
-	usage()
-
-dbname = sys.argv[1]
-
-if (len(sys.argv) >= 3):
-	columns = sys.argv[2]
-else:
-	columns = "all"
-
-if columns not in ("all", "branches"):
-	usage()
-
-branches = (columns == "branches")
-
-for i in range(3,len(sys.argv)):
-	if (sys.argv[i] == "calls"):
-		perf_db_export_calls = True
-	elif (sys.argv[i] == "callchains"):
-		perf_db_export_callchains = True
-	elif (sys.argv[i] == "pyside-version-1"):
-		pass
-	else:
-		usage()
-
-output_dir_name = os.getcwd() + "/" + dbname + "-perf-data"
-os.mkdir(output_dir_name)
-
-def do_query(q, s):
-	if (q.exec_(s)):
-		return
-	raise Exception("Query failed: " + q.lastError().text())
-
-printdate("Creating database...")
-
-db = QSqlDatabase.addDatabase('QPSQL')
-query = QSqlQuery(db)
-db.setDatabaseName('postgres')
-db.open()
-try:
-	do_query(query, 'CREATE DATABASE ' + dbname)
-except:
-	os.rmdir(output_dir_name)
-	raise
-query.finish()
-query.clear()
-db.close()
-
-db.setDatabaseName(dbname)
-db.open()
-
-query = QSqlQuery(db)
-do_query(query, 'SET client_min_messages TO WARNING')
-
-do_query(query, 'CREATE TABLE selected_events ('
-		'id		bigint		NOT NULL,'
-		'name		varchar(80))')
-do_query(query, 'CREATE TABLE machines ('
-		'id		bigint		NOT NULL,'
-		'pid		integer,'
-		'root_dir 	varchar(4096))')
-do_query(query, 'CREATE TABLE threads ('
-		'id		bigint		NOT NULL,'
-		'machine_id	bigint,'
-		'process_id	bigint,'
-		'pid		integer,'
-		'tid		integer)')
-do_query(query, 'CREATE TABLE comms ('
-		'id		bigint		NOT NULL,'
-		'comm		varchar(16),'
-		'c_thread_id	bigint,'
-		'c_time		bigint,'
-		'exec_flag	boolean)')
-do_query(query, 'CREATE TABLE comm_threads ('
-		'id		bigint		NOT NULL,'
-		'comm_id	bigint,'
-		'thread_id	bigint)')
-do_query(query, 'CREATE TABLE dsos ('
-		'id		bigint		NOT NULL,'
-		'machine_id	bigint,'
-		'short_name	varchar(256),'
-		'long_name	varchar(4096),'
-		'build_id	varchar(64))')
-do_query(query, 'CREATE TABLE symbols ('
-		'id		bigint		NOT NULL,'
-		'dso_id		bigint,'
-		'sym_start	bigint,'
-		'sym_end	bigint,'
-		'binding	integer,'
-		'name		varchar(2048))')
-do_query(query, 'CREATE TABLE branch_types ('
-		'id		integer		NOT NULL,'
-		'name		varchar(80))')
-
-if branches:
-	do_query(query, 'CREATE TABLE samples ('
-		'id		bigint		NOT NULL,'
-		'evsel_id	bigint,'
-		'machine_id	bigint,'
-		'thread_id	bigint,'
-		'comm_id	bigint,'
-		'dso_id		bigint,'
-		'symbol_id	bigint,'
-		'sym_offset	bigint,'
-		'ip		bigint,'
-		'time		bigint,'
-		'cpu		integer,'
-		'to_dso_id	bigint,'
-		'to_symbol_id	bigint,'
-		'to_sym_offset	bigint,'
-		'to_ip		bigint,'
-		'branch_type	integer,'
-		'in_tx		boolean,'
-		'call_path_id	bigint,'
-		'insn_count	bigint,'
-		'cyc_count	bigint,'
-		'flags		integer)')
-else:
-	do_query(query, 'CREATE TABLE samples ('
-		'id		bigint		NOT NULL,'
-		'evsel_id	bigint,'
-		'machine_id	bigint,'
-		'thread_id	bigint,'
-		'comm_id	bigint,'
-		'dso_id		bigint,'
-		'symbol_id	bigint,'
-		'sym_offset	bigint,'
-		'ip		bigint,'
-		'time		bigint,'
-		'cpu		integer,'
-		'to_dso_id	bigint,'
-		'to_symbol_id	bigint,'
-		'to_sym_offset	bigint,'
-		'to_ip		bigint,'
-		'period		bigint,'
-		'weight		bigint,'
-		'transaction	bigint,'
-		'data_src	bigint,'
-		'branch_type	integer,'
-		'in_tx		boolean,'
-		'call_path_id	bigint,'
-		'insn_count	bigint,'
-		'cyc_count	bigint,'
-		'flags		integer)')
-
-if perf_db_export_calls or perf_db_export_callchains:
-	do_query(query, 'CREATE TABLE call_paths ('
-		'id		bigint		NOT NULL,'
-		'parent_id	bigint,'
-		'symbol_id	bigint,'
-		'ip		bigint)')
-if perf_db_export_calls:
-	do_query(query, 'CREATE TABLE calls ('
-		'id		bigint		NOT NULL,'
-		'thread_id	bigint,'
-		'comm_id	bigint,'
-		'call_path_id	bigint,'
-		'call_time	bigint,'
-		'return_time	bigint,'
-		'branch_count	bigint,'
-		'call_id	bigint,'
-		'return_id	bigint,'
-		'parent_call_path_id	bigint,'
-		'flags		integer,'
-		'parent_id	bigint,'
-		'insn_count	bigint,'
-		'cyc_count	bigint)')
-
-do_query(query, 'CREATE TABLE ptwrite ('
-	'id		bigint		NOT NULL,'
-	'payload	bigint,'
-	'exact_ip	boolean)')
-
-do_query(query, 'CREATE TABLE cbr ('
-	'id		bigint		NOT NULL,'
-	'cbr		integer,'
-	'mhz		integer,'
-	'percent	integer)')
-
-do_query(query, 'CREATE TABLE mwait ('
-	'id		bigint		NOT NULL,'
-	'hints		integer,'
-	'extensions	integer)')
-
-do_query(query, 'CREATE TABLE pwre ('
-	'id		bigint		NOT NULL,'
-	'cstate		integer,'
-	'subcstate	integer,'
-	'hw		boolean)')
-
-do_query(query, 'CREATE TABLE exstop ('
-	'id		bigint		NOT NULL,'
-	'exact_ip	boolean)')
-
-do_query(query, 'CREATE TABLE pwrx ('
-	'id		bigint		NOT NULL,'
-	'deepest_cstate	integer,'
-	'last_cstate	integer,'
-	'wake_reason	integer)')
-
-do_query(query, 'CREATE TABLE context_switches ('
-		'id		bigint		NOT NULL,'
-		'machine_id	bigint,'
-		'time		bigint,'
-		'cpu		integer,'
-		'thread_out_id	bigint,'
-		'comm_out_id	bigint,'
-		'thread_in_id	bigint,'
-		'comm_in_id	bigint,'
-		'flags		integer)')
-
-do_query(query, 'CREATE VIEW machines_view AS '
-	'SELECT '
-		'id,'
-		'pid,'
-		'root_dir,'
-		'CASE WHEN id=0 THEN \'unknown\' WHEN pid=-1 THEN \'host\' ELSE \'guest\' END AS host_or_guest'
-	' FROM machines')
-
-do_query(query, 'CREATE VIEW dsos_view AS '
-	'SELECT '
-		'id,'
-		'machine_id,'
-		'(SELECT host_or_guest FROM machines_view WHERE id = machine_id) AS host_or_guest,'
-		'short_name,'
-		'long_name,'
-		'build_id'
-	' FROM dsos')
-
-do_query(query, 'CREATE VIEW symbols_view AS '
-	'SELECT '
-		'id,'
-		'name,'
-		'(SELECT short_name FROM dsos WHERE id=dso_id) AS dso,'
-		'dso_id,'
-		'sym_start,'
-		'sym_end,'
-		'CASE WHEN binding=0 THEN \'local\' WHEN binding=1 THEN \'global\' ELSE \'weak\' END AS binding'
-	' FROM symbols')
-
-do_query(query, 'CREATE VIEW threads_view AS '
-	'SELECT '
-		'id,'
-		'machine_id,'
-		'(SELECT host_or_guest FROM machines_view WHERE id = machine_id) AS host_or_guest,'
-		'process_id,'
-		'pid,'
-		'tid'
-	' FROM threads')
-
-do_query(query, 'CREATE VIEW comm_threads_view AS '
-	'SELECT '
-		'comm_id,'
-		'(SELECT comm FROM comms WHERE id = comm_id) AS command,'
-		'thread_id,'
-		'(SELECT pid FROM threads WHERE id = thread_id) AS pid,'
-		'(SELECT tid FROM threads WHERE id = thread_id) AS tid'
-	' FROM comm_threads')
-
-if perf_db_export_calls or perf_db_export_callchains:
-	do_query(query, 'CREATE VIEW call_paths_view AS '
-		'SELECT '
-			'c.id,'
-			'to_hex(c.ip) AS ip,'
-			'c.symbol_id,'
-			'(SELECT name FROM symbols WHERE id = c.symbol_id) AS symbol,'
-			'(SELECT dso_id FROM symbols WHERE id = c.symbol_id) AS dso_id,'
-			'(SELECT dso FROM symbols_view  WHERE id = c.symbol_id) AS dso_short_name,'
-			'c.parent_id,'
-			'to_hex(p.ip) AS parent_ip,'
-			'p.symbol_id AS parent_symbol_id,'
-			'(SELECT name FROM symbols WHERE id = p.symbol_id) AS parent_symbol,'
-			'(SELECT dso_id FROM symbols WHERE id = p.symbol_id) AS parent_dso_id,'
-			'(SELECT dso FROM symbols_view  WHERE id = p.symbol_id) AS parent_dso_short_name'
-		' FROM call_paths c INNER JOIN call_paths p ON p.id = c.parent_id')
-if perf_db_export_calls:
-	do_query(query, 'CREATE VIEW calls_view AS '
-		'SELECT '
-			'calls.id,'
-			'thread_id,'
-			'(SELECT pid FROM threads WHERE id = thread_id) AS pid,'
-			'(SELECT tid FROM threads WHERE id = thread_id) AS tid,'
-			'(SELECT comm FROM comms WHERE id = comm_id) AS command,'
-			'call_path_id,'
-			'to_hex(ip) AS ip,'
-			'symbol_id,'
-			'(SELECT name FROM symbols WHERE id = symbol_id) AS symbol,'
-			'call_time,'
-			'return_time,'
-			'return_time - call_time AS elapsed_time,'
-			'branch_count,'
-			'insn_count,'
-			'cyc_count,'
-			'CASE WHEN cyc_count=0 THEN CAST(0 AS NUMERIC(20, 2)) ELSE CAST((CAST(insn_count AS FLOAT) / cyc_count) AS NUMERIC(20, 2)) END AS IPC,'
-			'call_id,'
-			'return_id,'
-			'CASE WHEN flags=0 THEN \'\' WHEN flags=1 THEN \'no call\' WHEN flags=2 THEN \'no return\' WHEN flags=3 THEN \'no call/return\' WHEN flags=6 THEN \'jump\' ELSE CAST ( flags AS VARCHAR(6) ) END AS flags,'
-			'parent_call_path_id,'
-			'calls.parent_id'
-		' FROM calls INNER JOIN call_paths ON call_paths.id = call_path_id')
-
-do_query(query, 'CREATE VIEW samples_view AS '
-	'SELECT '
-		'id,'
-		'time,'
-		'cpu,'
-		'(SELECT pid FROM threads WHERE id = thread_id) AS pid,'
-		'(SELECT tid FROM threads WHERE id = thread_id) AS tid,'
-		'(SELECT comm FROM comms WHERE id = comm_id) AS command,'
-		'(SELECT name FROM selected_events WHERE id = evsel_id) AS event,'
-		'to_hex(ip) AS ip_hex,'
-		'(SELECT name FROM symbols WHERE id = symbol_id) AS symbol,'
-		'sym_offset,'
-		'(SELECT short_name FROM dsos WHERE id = dso_id) AS dso_short_name,'
-		'to_hex(to_ip) AS to_ip_hex,'
-		'(SELECT name FROM symbols WHERE id = to_symbol_id) AS to_symbol,'
-		'to_sym_offset,'
-		'(SELECT short_name FROM dsos WHERE id = to_dso_id) AS to_dso_short_name,'
-		'(SELECT name FROM branch_types WHERE id = branch_type) AS branch_type_name,'
-		'in_tx,'
-		'insn_count,'
-		'cyc_count,'
-		'CASE WHEN cyc_count=0 THEN CAST(0 AS NUMERIC(20, 2)) ELSE CAST((CAST(insn_count AS FLOAT) / cyc_count) AS NUMERIC(20, 2)) END AS IPC,'
-		'flags'
-	' FROM samples')
-
-do_query(query, 'CREATE VIEW ptwrite_view AS '
-	'SELECT '
-		'ptwrite.id,'
-		'time,'
-		'cpu,'
-		'to_hex(payload) AS payload_hex,'
-		'CASE WHEN exact_ip=FALSE THEN \'False\' ELSE \'True\' END AS exact_ip'
-	' FROM ptwrite'
-	' INNER JOIN samples ON samples.id = ptwrite.id')
-
-do_query(query, 'CREATE VIEW cbr_view AS '
-	'SELECT '
-		'cbr.id,'
-		'time,'
-		'cpu,'
-		'cbr,'
-		'mhz,'
-		'percent'
-	' FROM cbr'
-	' INNER JOIN samples ON samples.id = cbr.id')
-
-do_query(query, 'CREATE VIEW mwait_view AS '
-	'SELECT '
-		'mwait.id,'
-		'time,'
-		'cpu,'
-		'to_hex(hints) AS hints_hex,'
-		'to_hex(extensions) AS extensions_hex'
-	' FROM mwait'
-	' INNER JOIN samples ON samples.id = mwait.id')
-
-do_query(query, 'CREATE VIEW pwre_view AS '
-	'SELECT '
-		'pwre.id,'
-		'time,'
-		'cpu,'
-		'cstate,'
-		'subcstate,'
-		'CASE WHEN hw=FALSE THEN \'False\' ELSE \'True\' END AS hw'
-	' FROM pwre'
-	' INNER JOIN samples ON samples.id = pwre.id')
-
-do_query(query, 'CREATE VIEW exstop_view AS '
-	'SELECT '
-		'exstop.id,'
-		'time,'
-		'cpu,'
-		'CASE WHEN exact_ip=FALSE THEN \'False\' ELSE \'True\' END AS exact_ip'
-	' FROM exstop'
-	' INNER JOIN samples ON samples.id = exstop.id')
-
-do_query(query, 'CREATE VIEW pwrx_view AS '
-	'SELECT '
-		'pwrx.id,'
-		'time,'
-		'cpu,'
-		'deepest_cstate,'
-		'last_cstate,'
-		'CASE     WHEN wake_reason=1 THEN \'Interrupt\''
-			' WHEN wake_reason=2 THEN \'Timer Deadline\''
-			' WHEN wake_reason=4 THEN \'Monitored Address\''
-			' WHEN wake_reason=8 THEN \'HW\''
-			' ELSE CAST ( wake_reason AS VARCHAR(2) )'
-		'END AS wake_reason'
-	' FROM pwrx'
-	' INNER JOIN samples ON samples.id = pwrx.id')
-
-do_query(query, 'CREATE VIEW power_events_view AS '
-	'SELECT '
-		'samples.id,'
-		'samples.time,'
-		'samples.cpu,'
-		'selected_events.name AS event,'
-		'FORMAT(\'%6s\', cbr.cbr) AS cbr,'
-		'FORMAT(\'%6s\', cbr.mhz) AS MHz,'
-		'FORMAT(\'%5s\', cbr.percent) AS percent,'
-		'to_hex(mwait.hints) AS hints_hex,'
-		'to_hex(mwait.extensions) AS extensions_hex,'
-		'FORMAT(\'%3s\', pwre.cstate) AS cstate,'
-		'FORMAT(\'%3s\', pwre.subcstate) AS subcstate,'
-		'CASE WHEN pwre.hw=FALSE THEN \'False\' WHEN pwre.hw=TRUE THEN \'True\' ELSE NULL END AS hw,'
-		'CASE WHEN exstop.exact_ip=FALSE THEN \'False\' WHEN exstop.exact_ip=TRUE THEN \'True\' ELSE NULL END AS exact_ip,'
-		'FORMAT(\'%3s\', pwrx.deepest_cstate) AS deepest_cstate,'
-		'FORMAT(\'%3s\', pwrx.last_cstate) AS last_cstate,'
-		'CASE     WHEN pwrx.wake_reason=1 THEN \'Interrupt\''
-			' WHEN pwrx.wake_reason=2 THEN \'Timer Deadline\''
-			' WHEN pwrx.wake_reason=4 THEN \'Monitored Address\''
-			' WHEN pwrx.wake_reason=8 THEN \'HW\''
-			' ELSE FORMAT(\'%2s\', pwrx.wake_reason)'
-		'END AS wake_reason'
-	' FROM cbr'
-	' FULL JOIN mwait ON mwait.id = cbr.id'
-	' FULL JOIN pwre ON pwre.id = cbr.id'
-	' FULL JOIN exstop ON exstop.id = cbr.id'
-	' FULL JOIN pwrx ON pwrx.id = cbr.id'
-	' INNER JOIN samples ON samples.id = coalesce(cbr.id, mwait.id, pwre.id, exstop.id, pwrx.id)'
-	' INNER JOIN selected_events ON selected_events.id = samples.evsel_id'
-	' ORDER BY samples.id')
-
-do_query(query, 'CREATE VIEW context_switches_view AS '
-	'SELECT '
-		'context_switches.id,'
-		'context_switches.machine_id,'
-		'context_switches.time,'
-		'context_switches.cpu,'
-		'th_out.pid AS pid_out,'
-		'th_out.tid AS tid_out,'
-		'comm_out.comm AS comm_out,'
-		'th_in.pid AS pid_in,'
-		'th_in.tid AS tid_in,'
-		'comm_in.comm AS comm_in,'
-		'CASE	  WHEN context_switches.flags = 0 THEN \'in\''
-			' WHEN context_switches.flags = 1 THEN \'out\''
-			' WHEN context_switches.flags = 3 THEN \'out preempt\''
-			' ELSE CAST ( context_switches.flags AS VARCHAR(11) )'
-		'END AS flags'
-	' FROM context_switches'
-	' INNER JOIN threads AS th_out ON th_out.id   = context_switches.thread_out_id'
-	' INNER JOIN threads AS th_in  ON th_in.id    = context_switches.thread_in_id'
-	' INNER JOIN comms AS comm_out ON comm_out.id = context_switches.comm_out_id'
-	' INNER JOIN comms AS comm_in  ON comm_in.id  = context_switches.comm_in_id')
-
-file_header = struct.pack("!11sii", b"PGCOPY\n\377\r\n\0", 0, 0)
-file_trailer = b"\377\377"
-
-def open_output_file(file_name):
-	path_name = output_dir_name + "/" + file_name
-	file = open(path_name, "wb+")
-	file.write(file_header)
-	return file
-
-def close_output_file(file):
-	file.write(file_trailer)
-	file.close()
-
-def copy_output_file_direct(file, table_name):
-	close_output_file(file)
-	sql = "COPY " + table_name + " FROM '" + file.name + "' (FORMAT 'binary')"
-	do_query(query, sql)
-
-# Use COPY FROM STDIN because security may prevent postgres from accessing the files directly
-def copy_output_file(file, table_name):
-	conn = PQconnectdb(toclientstr("dbname = " + dbname))
-	if (PQstatus(conn)):
-		raise Exception("COPY FROM STDIN PQconnectdb failed")
-	file.write(file_trailer)
-	file.seek(0)
-	sql = "COPY " + table_name + " FROM STDIN (FORMAT 'binary')"
-	res = PQexec(conn, toclientstr(sql))
-	if (PQresultStatus(res) != 4):
-		raise Exception("COPY FROM STDIN PQexec failed")
-	data = file.read(65536)
-	while (len(data)):
-		ret = PQputCopyData(conn, data, len(data))
-		if (ret != 1):
-			raise Exception("COPY FROM STDIN PQputCopyData failed, error " + str(ret))
-		data = file.read(65536)
-	ret = PQputCopyEnd(conn, None)
-	if (ret != 1):
-		raise Exception("COPY FROM STDIN PQputCopyEnd failed, error " + str(ret))
-	PQfinish(conn)
-
-def remove_output_file(file):
-	name = file.name
-	file.close()
-	os.unlink(name)
-
-evsel_file		= open_output_file("evsel_table.bin")
-machine_file		= open_output_file("machine_table.bin")
-thread_file		= open_output_file("thread_table.bin")
-comm_file		= open_output_file("comm_table.bin")
-comm_thread_file	= open_output_file("comm_thread_table.bin")
-dso_file		= open_output_file("dso_table.bin")
-symbol_file		= open_output_file("symbol_table.bin")
-branch_type_file	= open_output_file("branch_type_table.bin")
-sample_file		= open_output_file("sample_table.bin")
-if perf_db_export_calls or perf_db_export_callchains:
-	call_path_file		= open_output_file("call_path_table.bin")
-if perf_db_export_calls:
-	call_file		= open_output_file("call_table.bin")
-ptwrite_file		= open_output_file("ptwrite_table.bin")
-cbr_file		= open_output_file("cbr_table.bin")
-mwait_file		= open_output_file("mwait_table.bin")
-pwre_file		= open_output_file("pwre_table.bin")
-exstop_file		= open_output_file("exstop_table.bin")
-pwrx_file		= open_output_file("pwrx_table.bin")
-context_switches_file	= open_output_file("context_switches_table.bin")
-
-def trace_begin():
-	printdate("Writing to intermediate files...")
-	# id == 0 means unknown.  It is easier to create records for them than replace the zeroes with NULLs
-	evsel_table(0, "unknown")
-	machine_table(0, 0, "unknown")
-	thread_table(0, 0, 0, -1, -1)
-	comm_table(0, "unknown", 0, 0, 0)
-	dso_table(0, 0, "unknown", "unknown", "")
-	symbol_table(0, 0, 0, 0, 0, "unknown")
-	sample_table(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
-	if perf_db_export_calls or perf_db_export_callchains:
-		call_path_table(0, 0, 0, 0)
-		call_return_table(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
-
-unhandled_count = 0
-
-def is_table_empty(table_name):
-	do_query(query, 'SELECT * FROM ' + table_name + ' LIMIT 1');
-	if query.next():
-		return False
-	return True
-
-def drop(table_name):
-	do_query(query, 'DROP VIEW ' + table_name + '_view');
-	do_query(query, 'DROP TABLE ' + table_name);
-
-def trace_end():
-	printdate("Copying to database...")
-	copy_output_file(evsel_file,		"selected_events")
-	copy_output_file(machine_file,		"machines")
-	copy_output_file(thread_file,		"threads")
-	copy_output_file(comm_file,		"comms")
-	copy_output_file(comm_thread_file,	"comm_threads")
-	copy_output_file(dso_file,		"dsos")
-	copy_output_file(symbol_file,		"symbols")
-	copy_output_file(branch_type_file,	"branch_types")
-	copy_output_file(sample_file,		"samples")
-	if perf_db_export_calls or perf_db_export_callchains:
-		copy_output_file(call_path_file,	"call_paths")
-	if perf_db_export_calls:
-		copy_output_file(call_file,		"calls")
-	copy_output_file(ptwrite_file,		"ptwrite")
-	copy_output_file(cbr_file,		"cbr")
-	copy_output_file(mwait_file,		"mwait")
-	copy_output_file(pwre_file,		"pwre")
-	copy_output_file(exstop_file,		"exstop")
-	copy_output_file(pwrx_file,		"pwrx")
-	copy_output_file(context_switches_file,	"context_switches")
-
-	printdate("Removing intermediate files...")
-	remove_output_file(evsel_file)
-	remove_output_file(machine_file)
-	remove_output_file(thread_file)
-	remove_output_file(comm_file)
-	remove_output_file(comm_thread_file)
-	remove_output_file(dso_file)
-	remove_output_file(symbol_file)
-	remove_output_file(branch_type_file)
-	remove_output_file(sample_file)
-	if perf_db_export_calls or perf_db_export_callchains:
-		remove_output_file(call_path_file)
-	if perf_db_export_calls:
-		remove_output_file(call_file)
-	remove_output_file(ptwrite_file)
-	remove_output_file(cbr_file)
-	remove_output_file(mwait_file)
-	remove_output_file(pwre_file)
-	remove_output_file(exstop_file)
-	remove_output_file(pwrx_file)
-	remove_output_file(context_switches_file)
-	os.rmdir(output_dir_name)
-	printdate("Adding primary keys")
-	do_query(query, 'ALTER TABLE selected_events ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE machines        ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE threads         ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE comms           ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE comm_threads    ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE dsos            ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE symbols         ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE branch_types    ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE samples         ADD PRIMARY KEY (id)')
-	if perf_db_export_calls or perf_db_export_callchains:
-		do_query(query, 'ALTER TABLE call_paths      ADD PRIMARY KEY (id)')
-	if perf_db_export_calls:
-		do_query(query, 'ALTER TABLE calls           ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE ptwrite         ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE cbr             ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE mwait           ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE pwre            ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE exstop          ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE pwrx            ADD PRIMARY KEY (id)')
-	do_query(query, 'ALTER TABLE context_switches ADD PRIMARY KEY (id)')
-
-	printdate("Adding foreign keys")
-	do_query(query, 'ALTER TABLE threads '
-					'ADD CONSTRAINT machinefk  FOREIGN KEY (machine_id)   REFERENCES machines   (id),'
-					'ADD CONSTRAINT processfk  FOREIGN KEY (process_id)   REFERENCES threads    (id)')
-	do_query(query, 'ALTER TABLE comms '
-					'ADD CONSTRAINT threadfk   FOREIGN KEY (c_thread_id)  REFERENCES threads    (id)')
-	do_query(query, 'ALTER TABLE comm_threads '
-					'ADD CONSTRAINT commfk     FOREIGN KEY (comm_id)      REFERENCES comms      (id),'
-					'ADD CONSTRAINT threadfk   FOREIGN KEY (thread_id)    REFERENCES threads    (id)')
-	do_query(query, 'ALTER TABLE dsos '
-					'ADD CONSTRAINT machinefk  FOREIGN KEY (machine_id)   REFERENCES machines   (id)')
-	do_query(query, 'ALTER TABLE symbols '
-					'ADD CONSTRAINT dsofk      FOREIGN KEY (dso_id)       REFERENCES dsos       (id)')
-	do_query(query, 'ALTER TABLE samples '
-					'ADD CONSTRAINT evselfk    FOREIGN KEY (evsel_id)     REFERENCES selected_events (id),'
-					'ADD CONSTRAINT machinefk  FOREIGN KEY (machine_id)   REFERENCES machines   (id),'
-					'ADD CONSTRAINT threadfk   FOREIGN KEY (thread_id)    REFERENCES threads    (id),'
-					'ADD CONSTRAINT commfk     FOREIGN KEY (comm_id)      REFERENCES comms      (id),'
-					'ADD CONSTRAINT dsofk      FOREIGN KEY (dso_id)       REFERENCES dsos       (id),'
-					'ADD CONSTRAINT symbolfk   FOREIGN KEY (symbol_id)    REFERENCES symbols    (id),'
-					'ADD CONSTRAINT todsofk    FOREIGN KEY (to_dso_id)    REFERENCES dsos       (id),'
-					'ADD CONSTRAINT tosymbolfk FOREIGN KEY (to_symbol_id) REFERENCES symbols    (id)')
-	if perf_db_export_calls or perf_db_export_callchains:
-		do_query(query, 'ALTER TABLE call_paths '
-					'ADD CONSTRAINT parentfk    FOREIGN KEY (parent_id)    REFERENCES call_paths (id),'
-					'ADD CONSTRAINT symbolfk    FOREIGN KEY (symbol_id)    REFERENCES symbols    (id)')
-	if perf_db_export_calls:
-		do_query(query, 'ALTER TABLE calls '
-					'ADD CONSTRAINT threadfk    FOREIGN KEY (thread_id)    REFERENCES threads    (id),'
-					'ADD CONSTRAINT commfk      FOREIGN KEY (comm_id)      REFERENCES comms      (id),'
-					'ADD CONSTRAINT call_pathfk FOREIGN KEY (call_path_id) REFERENCES call_paths (id),'
-					'ADD CONSTRAINT callfk      FOREIGN KEY (call_id)      REFERENCES samples    (id),'
-					'ADD CONSTRAINT returnfk    FOREIGN KEY (return_id)    REFERENCES samples    (id),'
-					'ADD CONSTRAINT parent_call_pathfk FOREIGN KEY (parent_call_path_id) REFERENCES call_paths (id)')
-		do_query(query, 'CREATE INDEX pcpid_idx ON calls (parent_call_path_id)')
-		do_query(query, 'CREATE INDEX pid_idx ON calls (parent_id)')
-		do_query(query, 'ALTER TABLE comms ADD has_calls boolean')
-		do_query(query, 'UPDATE comms SET has_calls = TRUE WHERE comms.id IN (SELECT DISTINCT comm_id FROM calls)')
-	do_query(query, 'ALTER TABLE ptwrite '
-					'ADD CONSTRAINT idfk        FOREIGN KEY (id)           REFERENCES samples   (id)')
-	do_query(query, 'ALTER TABLE  cbr '
-					'ADD CONSTRAINT idfk        FOREIGN KEY (id)           REFERENCES samples   (id)')
-	do_query(query, 'ALTER TABLE  mwait '
-					'ADD CONSTRAINT idfk        FOREIGN KEY (id)           REFERENCES samples   (id)')
-	do_query(query, 'ALTER TABLE  pwre '
-					'ADD CONSTRAINT idfk        FOREIGN KEY (id)           REFERENCES samples   (id)')
-	do_query(query, 'ALTER TABLE  exstop '
-					'ADD CONSTRAINT idfk        FOREIGN KEY (id)           REFERENCES samples   (id)')
-	do_query(query, 'ALTER TABLE  pwrx '
-					'ADD CONSTRAINT idfk        FOREIGN KEY (id)           REFERENCES samples   (id)')
-	do_query(query, 'ALTER TABLE  context_switches '
-					'ADD CONSTRAINT machinefk   FOREIGN KEY (machine_id)    REFERENCES machines (id),'
-					'ADD CONSTRAINT toutfk      FOREIGN KEY (thread_out_id) REFERENCES threads  (id),'
-					'ADD CONSTRAINT tinfk       FOREIGN KEY (thread_in_id)  REFERENCES threads  (id),'
-					'ADD CONSTRAINT coutfk      FOREIGN KEY (comm_out_id)   REFERENCES comms    (id),'
-					'ADD CONSTRAINT cinfk       FOREIGN KEY (comm_in_id)    REFERENCES comms    (id)')
-
-	printdate("Dropping unused tables")
-	if is_table_empty("ptwrite"):
-		drop("ptwrite")
-	if is_table_empty("mwait") and is_table_empty("pwre") and is_table_empty("exstop") and is_table_empty("pwrx"):
-		do_query(query, 'DROP VIEW power_events_view');
-		drop("mwait")
-		drop("pwre")
-		drop("exstop")
-		drop("pwrx")
-		if is_table_empty("cbr"):
-			drop("cbr")
-	if is_table_empty("context_switches"):
-		drop("context_switches")
-
-	if (unhandled_count):
-		printdate("Warning: ", unhandled_count, " unhandled events")
-	printdate("Done")
-
-def trace_unhandled(event_name, context, event_fields_dict):
-	global unhandled_count
-	unhandled_count += 1
-
-def sched__sched_switch(*x):
-	pass
-
-def evsel_table(evsel_id, evsel_name, *x):
-	evsel_name = toserverstr(evsel_name)
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/export-to-sqlite.py deleted +0 -799
deleted file mode 100644
index 73c992feb1b9..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/failed-syscalls-by-pid.py deleted +0 -79
deleted file mode 100644
index 310efe5e7e23..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/flamegraph.py deleted +0 -267
deleted file mode 100755
index ad735990c5be..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/futex-contention.py deleted +0 -57
deleted file mode 100644
index 7e884d46f920..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/gecko.py deleted +0 -395
deleted file mode 100644
index bc5a72f94bfa..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/intel-pt-events.py deleted +0 -494
deleted file mode 100644
index 346c89bd16d6..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/libxed.py deleted +0 -107
deleted file mode 100644
index 2c70a5a7eb9c..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/mem-phys-addr.py deleted +0 -127
deleted file mode 100644
index 5e237a5a5f1b..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/net_dropmonitor.py deleted +0 -78
deleted file mode 100755
index a97e7a6e0940..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/netdev-times.py deleted +0 -473
deleted file mode 100644
index 30c4bccee5b2..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/powerpc-hcalls.py deleted +0 -335
deleted file mode 100644
index fedce1b68cad..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/sched-migration.py deleted +0 -462
deleted file mode 100644
index 8196e3087c9e..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/sctop.py deleted +0 -89
deleted file mode 100644
index 6e0278dcb092..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/stackcollapse.py deleted +0 -127
deleted file mode 100755
index b1c4def1410a..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/stat-cpi.py deleted +0 -79
deleted file mode 100644
index 01fa933ff3cf..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/syscall-counts-by-pid.py deleted +0 -75
deleted file mode 100644
index f254e40c6f0f..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/syscall-counts.py deleted +0 -65
deleted file mode 100644
index 8adb95ff1664..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/scripts/python/task-analyzer.py deleted +0 -934
deleted file mode 100755
index 3f1df9894246..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/script.sh +0 -42
index 254fc3ae94e7..af687c7cfe44 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/script_python.sh deleted +0 -113
deleted file mode 100755
index 6bc66074a31f..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/util/scripting-engines/Build +0 -4
index 24f087b0cd11..3f1dc10526f8 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/scripting-engines/trace-event-python.c deleted +0 -2335
deleted file mode 100644
index 038c4268a429..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/util/trace-event-scripting.c +0 -9
index dc584ac316a3..c78b317978dd 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog

Part of the diff is not shown here. View the raw message.

#401 lore raw

Re: [PATCH v4 47/49] perf Makefile: Update Python script installation path

In reply to Ian Rogers
Quoted 10 lines · Ian Rogers

Replace the libpython feature test with a python-module feature test checking for Python C extension build capability, and update feature test references accordingly.

Remove references to the legacy scripts/python directory and install standalone Python scripts (python/*.py), type stubs (python/perf.pyi), and the compiled perf extension module (python/perf*.so, when built) directly under the python directory in libexec. Update the TUI script browser (ui/browsers/scripts.c) to discover standalone scripts from the updated installation path.

Resolved a conflict here, final result:

⬢ [acme@toolbx perf-tools-next]$ diff -u tools/perf/Makefile.perf.orig tools/perf/Makefile.perf

perf/Makefile.perf renamed from perf/Makefile.perf.orig +2 -8
@@ -19,7 +19,7 @@
 #
 # Define LIBPERL to enable perl script extension.
 #
-# Define NO_LIBPYTHON to disable python script extension.
+# Define NO_PYTHON_MODULE to disable python script extension.
 #
 # Define PYTHON to point to the python binary if the default
 # `python' is not correct; for example: PYTHON=python2
@@ -900,14 +900,8 @@
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
 		$(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
 endif
-ifndef NO_LIBPYTHON
+ifndef NO_PYTHON_MODULE
 	$(call QUIET_INSTALL, python-scripts) \
-		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
-		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'; \
-		$(INSTALL) scripts/python/Perf-Trace-Util/lib/Perf/Trace/* -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/Perf-Trace-Util/lib/Perf/Trace'; \
-		$(INSTALL) scripts/python/*.py -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
-		$(INSTALL) scripts/python/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python/bin'
-	$(call QUIET_INSTALL, python-scripts-standalone) \
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/python' && \
 		$(INSTALL) python/*.py -m 755 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/python' && \
 		$(INSTALL) python/perf.pyi -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/python' && \

⬢ [acme@toolbx perf-tools-next]$

and:

tools/perf/Makefile.config +8 -9
index e04125ad4f28fc94..6cb6b02fb0d23808 100644
@@ -312,7 +312,7 @@ PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
 
 # Python 3.8 changed the output of `python-config --ldflags` to not include the
 # '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
-# libpython fails if that flag is not included in LDFLAGS
+# python-module fails if that flag is not included in LDFLAGS
 ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
   PYTHON_CONFIG_LDFLAGS := --ldflags --embed
 else
@@ -335,8 +335,8 @@ ifdef PYTHON_CONFIG
   endif
 endif
 
-FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
-FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
+FEATURE_CHECK_CFLAGS-python-module := $(PYTHON_EMBED_CCOPTS)
+FEATURE_CHECK_LDFLAGS-python-module := $(PYTHON_EMBED_LDOPTS)
 
 FEATURE_CHECK_LDFLAGS-libaio = -lrt
 
@@ -808,9 +808,8 @@ endif
 
 disable-python = $(eval $(disable-python_code))
 define disable-python_code
-  CFLAGS += -DNO_LIBPYTHON
   $(warning $1)
-  NO_LIBPYTHON := 1
+  NO_PYTHON_MODULE := 1
 endef
 
 # Minimum Python version for the interpreters perf runs while building,
@@ -824,7 +823,7 @@ ifdef PYTHON
 endif
 
 PYTHON_EXTENSION_SUFFIX := '.so'
-ifdef NO_LIBPYTHON
+ifdef NO_PYTHON_MODULE
   $(call disable-python,Python support disabled by user)
 else
 
@@ -837,7 +836,7 @@ else
       $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
     else
 
-      ifneq ($(feature-libpython), 1)
+      ifneq ($(feature-python-module), 1)
         $(call disable-python,No 'Python.h' was found: disables Python support - please install python-devel/python-dev)
       else
          # The binding is built even when jevents generation is turned off
@@ -846,9 +845,9 @@ else
          # older interpreters with "TypeError: 'type' object is not
          # subscriptable" instead of a Makefile error.
          ifneq ($(PYTHON_39_GOOD), 1)
-           $(error ERROR: Python interpreter needed for the python binding too old (older than 3.9). Install a newer python or build with NO_LIBPYTHON=1.)
+           $(error ERROR: Python interpreter needed for the python binding too old (older than 3.9). Install a newer python or build with NO_PYTHON_MODULE=1.)
          endif
-         CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
+         CFLAGS += -DHAVE_PYTHON_MODULE_SUPPORT
          PYTHON_SETUPTOOLS_INSTALLED := $(shell $(PYTHON) -c 'import setuptools;' 2> /dev/null && echo "yes" || echo "no")
          ifeq ($(PYTHON_SETUPTOOLS_INSTALLED), yes)
            PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])')
Quoted 524 lines
Assisted-by Antigravity:gemini-3.1-pro
---
 tools/build/Makefile.feature             |   4 +-
 tools/build/feature/Makefile             |   4 +-
 tools/build/feature/test-all.c           |   6 +-
 tools/build/feature/test-libpython.c     |  10 --
 tools/build/feature/test-python-module.c |  13 ++
 tools/perf/Documentation/perf-check.txt  |   1 +
 tools/perf/Makefile.config               |  15 +-
 tools/perf/Makefile.perf                 |   8 +-
 tools/perf/builtin-check.c               |   2 +-
 tools/perf/scripts/install-build-deps.sh |   4 +-
 tools/perf/tests/make                    |   8 +-
 tools/perf/ui/browsers/scripts.c         | 184 +++++++++++++++--------
 12 files changed, 156 insertions(+), 103 deletions(-)
 delete mode 100644 tools/build/feature/test-libpython.c
 create mode 100644 tools/build/feature/test-python-module.c
tools/build/Makefile.feature +2 -2
index 331f5cdfc34b..3ca7a4f5c7fd 100644
@@ -79,7 +79,7 @@ FEATURE_TESTS_BASIC :=                  \
         libelf-zstd                     \
         libnuma                         \
         numa_num_possible_cpus          \
-        libpython                       \
+        python-module                   \
         libslang                        \
         libtraceevent                   \
         libcpupower                     \
@@ -145,7 +145,7 @@ FEATURE_DISPLAY ?=              \
          libelf                 \
          libnuma                \
          numa_num_possible_cpus \
-         libpython              \
+         python-module          \
          libcapstone            \
          llvm-perf              \
          zlib                   \
tools/build/feature/Makefile +2 -2
index cdf89f132074..269af8e8f5cf 100644
@@ -32,7 +32,7 @@ FILES=                                          \
          test-libnuma.bin                       \
          test-numa_num_possible_cpus.bin        \
          test-libperl.bin                       \
-         test-libpython.bin                     \
+         test-python-module.bin                 \
          test-libslang.bin                      \
          test-libtraceevent.bin                 \
          test-libcpupower.bin                   \
@@ -261,7 +261,7 @@ endif
 $(OUTPUT)test-libperl.bin:
 	$(BUILD) $(FLAGS_PERL_EMBED)
 
-$(OUTPUT)test-libpython.bin:
+$(OUTPUT)test-python-module.bin:
 	$(BUILD) $(FLAGS_PYTHON_EMBED)
 
 $(OUTPUT)test-libbfd.bin:
tools/build/feature/test-all.c +3 -3
index 544563d62950..0ee16eccd9e0 100644
@@ -10,8 +10,8 @@
  * Quirk: Python headers cannot be in arbitrary places, so keep this testcase at
  * the top:
  */
-#define main main_test_libpython
-# include "test-libpython.c"
+#define main main_test_python_module
+# include "test-python-module.c"
 #undef main
 
 #define main main_test_hello
@@ -148,7 +148,7 @@
 
 int main(int argc, char *argv[])
 {
-	main_test_libpython();
+	main_test_python_module();
 	main_test_hello();
 	main_test_libelf();
 	main_test_gettid();
tools/build/feature/test-libpython.c deleted +0 -10
deleted file mode 100644
index 371c9113e49d..000000000000
@@ -1,10 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <Python.h>
-
-int main(void)
-{
-	Py_Initialize();
-
-	return 0;
-}
-#undef _GNU_SOURCE
tools/build/feature/test-python-module.c new file +13 -0
new file mode 100644
index 000000000000..50e9e5062feb
@@ -0,0 +1,13 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <Python.h>
+
+int main(void)
+{
+	static struct PyModuleDef moduledef = {
+		PyModuleDef_HEAD_INIT,
+		.m_name = "test",
+	};
+	PyObject *module = PyModule_Create(&moduledef);
+
+	return module ? 0 : -1;
+}
tools/perf/Documentation/perf-check.txt +1 -0
index 3d169e5bb372..a80913794eb6 100644
@@ -65,6 +65,7 @@ feature::
                 libunwind               /  HAVE_LIBUNWIND_SUPPORT
                 lzma                    /  HAVE_LZMA_SUPPORT
                 numa_num_possible_cpus  /  HAVE_LIBNUMA_SUPPORT
+                python-module           /  HAVE_PYTHON_MODULE_SUPPORT
                 zlib                    /  HAVE_ZLIB_SUPPORT
                 zstd                    /  HAVE_ZSTD_SUPPORT
 
tools/perf/Makefile.config +7 -8
index e6cfcbe0483b..6c0071db8523 100644
@@ -312,7 +312,7 @@ PYTHON_CONFIG_SQ := $(call shell-sq,$(PYTHON_CONFIG))
 
 # Python 3.8 changed the output of `python-config --ldflags` to not include the
 # '-lpythonX.Y' flag unless '--embed' is also passed. The feature check for
-# libpython fails if that flag is not included in LDFLAGS
+# python-module fails if that flag is not included in LDFLAGS
 ifeq ($(shell $(PYTHON_CONFIG_SQ) --ldflags --embed 2>&1 1>/dev/null; echo $$?), 0)
   PYTHON_CONFIG_LDFLAGS := --ldflags --embed
 else
@@ -335,8 +335,8 @@ ifdef PYTHON_CONFIG
   endif
 endif
 
-FEATURE_CHECK_CFLAGS-libpython := $(PYTHON_EMBED_CCOPTS)
-FEATURE_CHECK_LDFLAGS-libpython := $(PYTHON_EMBED_LDOPTS)
+FEATURE_CHECK_CFLAGS-python-module := $(PYTHON_EMBED_CCOPTS)
+FEATURE_CHECK_LDFLAGS-python-module := $(PYTHON_EMBED_LDOPTS)
 
 FEATURE_CHECK_LDFLAGS-libaio = -lrt
 
@@ -808,13 +808,12 @@ endif
 
 disable-python = $(eval $(disable-python_code))
 define disable-python_code
-  CFLAGS += -DNO_LIBPYTHON
   $(warning $1)
-  NO_LIBPYTHON := 1
+  NO_PYTHON_MODULE := 1
 endef
 
 PYTHON_EXTENSION_SUFFIX := '.so'
-ifdef NO_LIBPYTHON
+ifdef NO_PYTHON_MODULE
   $(call disable-python,Python support disabled by user)
 else
 
@@ -827,10 +826,10 @@ else
       $(call disable-python,No 'python-config' tool was found: disables Python support - please install python-devel/python-dev)
     else
 
-      ifneq ($(feature-libpython), 1)
+      ifneq ($(feature-python-module), 1)
         $(call disable-python,No 'Python.h' was found: disables Python support - please install python-devel/python-dev)
       else
-         CFLAGS += -DHAVE_LIBPYTHON_SUPPORT
+         CFLAGS += -DHAVE_PYTHON_MODULE_SUPPORT
          PYTHON_SETUPTOOLS_INSTALLED := $(shell $(PYTHON) -c 'import setuptools;' 2> /dev/null && echo "yes" || echo "no")
          ifeq ($(PYTHON_SETUPTOOLS_INSTALLED), yes)
            PYTHON_EXTENSION_SUFFIX := $(shell $(PYTHON) -c 'from importlib import machinery; print(machinery.EXTENSION_SUFFIXES[0])')
tools/perf/Makefile.perf +3 -5
index eaff13a31c50..8fe603aa9773 100644
@@ -19,7 +19,7 @@ include ../scripts/utilities.mak
 #
 # Define LIBPERL to enable perl script extension.
 #
-# Define NO_LIBPYTHON to disable python script extension.
+# Define NO_PYTHON_MODULE to disable python script extension.
 #
 # Define PYTHON to point to the python binary if the default
 # `python' is not correct; for example: PYTHON=python2
@@ -900,11 +900,9 @@ ifdef LIBPERL
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
 		$(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
 endif
-ifndef NO_LIBPYTHON
+
+ifndef NO_PYTHON_MODULE
 	$(call QUIET_INSTALL, python-scripts) \
-		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'; \
-		$(INSTALL) python/*.py -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/python'
-	$(call QUIET_INSTALL, python-scripts-standalone) \
 		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/python' && \
 		$(INSTALL) python/*.py -m 755 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/python' && \
 		$(INSTALL) python/perf.pyi -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/python' && \
tools/perf/builtin-check.c +1 -1
index 35272aaeb613..06711362d37f 100644
@@ -52,7 +52,7 @@ struct feature_status supported_features[] = {
 	FEATURE_STATUS("libnuma", HAVE_LIBNUMA_SUPPORT),
 	FEATURE_STATUS("libopencsd", HAVE_CSTRACE_SUPPORT),
 	FEATURE_STATUS_TIP("libperl", HAVE_LIBPERL_SUPPORT, "Deprecated, use LIBPERL=1 and install perl-ExtUtils-Embed/libperl-dev to build with it"),
-	FEATURE_STATUS("python-module", HAVE_LIBPYTHON_SUPPORT),
+	FEATURE_STATUS("python-module", HAVE_PYTHON_MODULE_SUPPORT),
 	FEATURE_STATUS("libpfm4", HAVE_LIBPFM),
 	FEATURE_STATUS("libslang", HAVE_SLANG_SUPPORT),
 	FEATURE_STATUS("libtraceevent", HAVE_LIBTRACEEVENT),
tools/perf/scripts/install-build-deps.sh +2 -2
index a601a5260c17..3e53c7bf0f85 100755
@@ -155,7 +155,7 @@ fedora_pkg_for() {
 	libcapstone)
 		echo "capstone-devel"
 		;;
-	libpython)
+	python-module)
 		echo "python3-devel"
 		;;
 	libtraceevent)
@@ -314,7 +314,7 @@ debian_pkg_for() {
 	libcapstone)
 		echo "libcapstone-dev"
 		;;
-	libpython)
+	python-module)
 		echo "python3-dev"
 		;;
 	libtraceevent)
tools/perf/tests/make +4 -4
index 8e55ff1aecbd..cf9d4b5d3153 100644
@@ -80,8 +80,8 @@ make_jevents_all    := JEVENTS_ARCH=all
 make_no_bpf_skel    := BUILD_BPF_SKEL=0
 make_gen_vmlinux_h  := GEN_VMLINUX_H=1
 make_libperl        := LIBPERL=1
-make_no_libpython   := NO_LIBPYTHON=1
-make_no_scripts     := NO_LIBPYTHON=1
+make_no_python_module := NO_PYTHON_MODULE=1
+make_no_scripts     := NO_PYTHON_MODULE=1
 make_no_slang       := NO_SLANG=1
 make_no_demangle    := NO_DEMANGLE=1
 make_no_libelf      := NO_LIBELF=1
@@ -121,7 +121,7 @@ make_install_prefix_slash := install prefix=/tmp/krava/
 make_static         := LDFLAGS=-static NO_PERF_READ_VDSO32=1 NO_PERF_READ_VDSOX32=1 NO_JVMTI=1 NO_LIBTRACEEVENT=1 NO_LIBELF=1
 
 # all the NO_* variable combined
-make_minimal        := NO_LIBPYTHON=1
+make_minimal        := NO_PYTHON_MODULE=1
 make_minimal        += NO_DEMANGLE=1 NO_LIBELF=1 NO_BACKTRACE=1
 make_minimal        += NO_LIBNUMA=1 NO_LIBBIONIC=1 NO_LIBDW=1
 make_minimal        += NO_LIBBPF=1
@@ -176,7 +176,7 @@ run += make_jevents_all
 run += make_no_bpf_skel
 run += make_gen_vmlinux_h
 run += make_libperl
-run += make_no_libpython
+run += make_no_python_module
 run += make_no_scripts
 run += make_no_slang
 run += make_no_demangle
tools/perf/ui/browsers/scripts.c +118 -66
index 94cc1f427c96..b8a3383ec02a 100644
@@ -1,4 +1,11 @@
 // SPDX-License-Identifier: GPL-2.0
+#include <dirent.h>
+#include <fcntl.h>
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
 #include "../../util/util.h" // perf_exe()
 #include "../util.h"
 #include "../../util/evlist.h"
@@ -14,7 +21,6 @@
 #include <linux/string.h>
 #include <linux/zalloc.h>
 #include <subcmd/exec-cmd.h>
-#include <stdlib.h>
 
 #define SCRIPT_NAMELEN	128
 #define SCRIPT_MAX_NO	64
@@ -128,7 +134,7 @@ static int check_ev_match(int dir_fd, const char *scriptname, struct perf_sessio
 			if (!len)
 				break;
 
-			snprintf(evname, len + 1, "%s", p);
+			snprintf(evname, sizeof(evname), "%.*s", (int)len, p);
 
 			match = 0;
 			evlist__for_each_entry(session->evlist, pos) {
@@ -159,6 +165,7 @@ static int check_ev_match(int dir_fd, const char *scriptname, struct perf_sessio
 static int find_scripts(char **scripts_array, char **scripts_path_array, int num,
 		 int pathlen)
 {
+	int namelen;
 	struct dirent *script_dirent, *lang_dirent;
 	int scripts_dir_fd, lang_dir_fd;
 	DIR *scripts_dir, *lang_dir;
@@ -180,73 +187,118 @@ static int find_scripts(char **scripts_array, char **scripts_path_array, int num
 
 		snprintf(scripts_path, sizeof(scripts_path), "%s/scripts", exec_path);
 		scripts_dir_fd = open(scripts_path, O_DIRECTORY);
-		pr_err("Failed to open directory '%s'", scripts_path);
-		if (scripts_dir_fd == -1) {
-			perf_session__delete(session);
-			return -1;
-		}
 	}
-	scripts_dir = fdopendir(scripts_dir_fd);
-	if (!scripts_dir) {
-		close(scripts_dir_fd);
-		perf_session__delete(session);
-		return -1;
+	if (scripts_dir_fd != -1) {
+		scripts_dir = fdopendir(scripts_dir_fd);
+		if (scripts_dir) {
+			while ((lang_dirent = readdir(scripts_dir)) != NULL) {
+				if (lang_dirent->d_type != DT_DIR &&
+				    (lang_dirent->d_type == DT_UNKNOWN &&
+				     !is_directory_at(scripts_dir_fd, lang_dirent->d_name)))
+					continue;
+				if (!strcmp(lang_dirent->d_name, ".") ||
+				    !strcmp(lang_dirent->d_name, ".."))
+					continue;
+
+				if (strstr(lang_dirent->d_name, "python"))
+					continue;
+
+				lang_dir_fd = openat(scripts_dir_fd, lang_dirent->d_name,
+					     O_DIRECTORY);
+				if (lang_dir_fd == -1)
+					continue;
+				lang_dir = fdopendir(lang_dir_fd);
+				if (!lang_dir) {
+					close(lang_dir_fd);
+					continue;
+				}
+				while ((script_dirent = readdir(lang_dir)) != NULL) {
+					if (script_dirent->d_type == DT_DIR)
+						continue;
+					if (script_dirent->d_type == DT_UNKNOWN &&
+					    is_directory_at(lang_dir_fd, script_dirent->d_name))
+						continue;
+					/* Skip those real time scripts: xxxtop.p[yl] */
+					if (strstr(script_dirent->d_name, "top."))
+						continue;
+					if (i >= num)
+						break;
+					scnprintf(scripts_path_array[i], pathlen,
+						  "%s/scripts/%s/%s", exec_path,
+						  lang_dirent->d_name,
+						  script_dirent->d_name);
+					temp = strrchr(script_dirent->d_name, '.');
+					namelen = temp ? (int)(temp - script_dirent->d_name)
+							       : (int)strlen(script_dirent->d_name);
+
+					if (namelen >= SCRIPT_NAMELEN)
+						namelen = SCRIPT_NAMELEN - 1;
+					snprintf(scripts_array[i], namelen + 1, "%s",
+						 script_dirent->d_name);
+
+					if (check_ev_match(lang_dir_fd, scripts_array[i], session))
+						continue;
+
+					i++;
+				}
+				closedir(lang_dir);
+			}
+			closedir(scripts_dir);
+		} else {
+			close(scripts_dir_fd);
+		}
 	}
 
-	while ((lang_dirent = readdir(scripts_dir)) != NULL) {
-		if (lang_dirent->d_type != DT_DIR &&
-		    (lang_dirent->d_type == DT_UNKNOWN &&
-		     !is_directory_at(scripts_dir_fd, lang_dirent->d_name)))
-			continue;
-		if (!strcmp(lang_dirent->d_name, ".") || !strcmp(lang_dirent->d_name, ".."))
-			continue;
-
-#ifndef HAVE_LIBPERL_SUPPORT
-		if (strstr(lang_dirent->d_name, "perl"))
-			continue;
-#endif
-#ifndef HAVE_LIBPYTHON_SUPPORT
-		if (strstr(lang_dirent->d_name, "python"))
-			continue;
-#endif
-
-		lang_dir_fd = openat(scripts_dir_fd, lang_dirent->d_name, O_DIRECTORY);
-		if (lang_dir_fd == -1)
-			continue;
-		lang_dir = fdopendir(lang_dir_fd);
-		if (!lang_dir) {
-			close(lang_dir_fd);
-			continue;
-		}
-		while ((script_dirent = readdir(lang_dir)) != NULL) {
-			if (script_dirent->d_type == DT_DIR)
-				continue;
-			if (script_dirent->d_type == DT_UNKNOWN &&
-			    is_directory_at(lang_dir_fd, script_dirent->d_name))
-				continue;
-			/* Skip those real time scripts: xxxtop.p[yl] */
-			if (strstr(script_dirent->d_name, "top."))
-				continue;
-			if (i >= num)
-				break;
-			scnprintf(scripts_path_array[i], pathlen, "%s/scripts/%s/%s",
-				exec_path,
-				lang_dirent->d_name,
-				script_dirent->d_name);
-			temp = strchr(script_dirent->d_name, '.');
-			snprintf(scripts_array[i],
-				(temp - script_dirent->d_name) + 1,
-				"%s", script_dirent->d_name);
-
-			if (check_ev_match(lang_dir_fd, scripts_array[i], session))
-				continue;
-
-			i++;
+#ifdef HAVE_PYTHON_MODULE_SUPPORT
+	{
+		char py_scripts_path[PATH_MAX];
+		int py_scripts_dir_fd;
+		DIR *py_scripts_dir;
+		int len;
+
+		snprintf(py_scripts_path, sizeof(py_scripts_path), "%s/python", exec_path);
+		py_scripts_dir_fd = open(py_scripts_path, O_DIRECTORY);
+		if (py_scripts_dir_fd != -1) {
+			py_scripts_dir = fdopendir(py_scripts_dir_fd);
+			if (py_scripts_dir) {
+				while ((script_dirent = readdir(py_scripts_dir)) != NULL) {
+					if (script_dirent->d_type == DT_DIR)
+						continue;
+					if (script_dirent->d_type == DT_UNKNOWN &&
+					    is_directory_at(py_scripts_dir_fd,
+						    script_dirent->d_name))
+						continue;
+					/* Skip those real time scripts: xxxtop.p[yl] */
+					if (strstr(script_dirent->d_name, "top."))
+						continue;
+					if (i >= num)
+						break;
+					len = strlen(script_dirent->d_name);
+					if (len <= 3 ||
+					    strcmp(script_dirent->d_name + len - 3, ".py"))
+						continue;
+
+					scnprintf(scripts_path_array[i], pathlen, "%s/python/%s",
+						exec_path,
+						script_dirent->d_name);
+					temp = strrchr(script_dirent->d_name, '.');
+					namelen = temp ? (int)(temp - script_dirent->d_name)
+							       : (int)strlen(script_dirent->d_name);
+
+					if (namelen >= SCRIPT_NAMELEN)
+						namelen = SCRIPT_NAMELEN - 1;
+					snprintf(scripts_array[i], namelen + 1, "%s",
+						 script_dirent->d_name);
+
+					i++;
+				}
+				closedir(py_scripts_dir);
+			} else {
+				close(py_scripts_dir_fd);
+			}
 		}
-		closedir(lang_dir);
 	}
-
-	closedir(scripts_dir);
+#endif
 	perf_session__delete(session);
 	return i;
 }
@@ -264,7 +316,7 @@ static int list_scripts(char *script_name, bool *custom,
 	int ret = 0;
 	int max_std, custom_perf;
 	char pbuf[256];
-	const char *perf = perf_exe(pbuf, sizeof pbuf);
+	const char *perf = perf_exe(pbuf, sizeof(pbuf));
 	struct script_config scriptc = {
 		.names = (const char **)names,
 		.paths = paths,
@@ -354,7 +406,7 @@ int script_browse(const char *script_opt, struct evsel *evsel)
 		return -1;
 
 	if (asprintf(&cmd, "%s%s %s %s%s 2>&1 | less",
-			custom ? "perf script -s " : "",
+			custom ? "perf script " : "",
 			script_name,
 			script_opt ? script_opt : "",
 			input_name ? "-i " : "",
Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog
#404 lore raw

Re: [PATCH v4 48/49] perf script: Support standalone scripts and remove embedded scripting

In reply to Ian Rogers
Quoted 10 lines · Ian Rogers

Refactor 'perf script' to launch standalone scripts directly via fork() and execvp() and remove the legacy embedded Perl and Python scripting engines:
- Remove the embedded Perl scripting engine (util/scripting-engines/trace-event-perl.c), Perl scripts, bin wrappers, and Trace-Util library (scripts/perl/Perf-Trace-Util/), and script_perl.sh test.
- Remove libperl feature checks from Makefile.config, Makefile.perf, builtin-check.c, and Documentation/perf-check.txt.
- Remove -g / --gen-script option and scripting_ops dispatch table from

Quoted 8 lines

builtin-script.c and trace-event-scripting.c.
- Hide the legacy -s / --script option and update script discovery in find_script() and list_available_scripts() to prioritize the system 'python' directory over bare filenames in the current directory.
- Update the Python script shell tests (test_arm_coresight_disasm.sh, test_task_analyzer.sh, and test_*_python.sh) to invoke scripts via 'perf script <script>' rather than running the Python interpreter directly on the script file path.

Minor conflict: the removal of the LIBPERL block, I removed it manually, end result should be the same.

- Arnaldo

Quoted 5,591 lines
Assisted-by Antigravity:gemini-3.1-pro
---
 tools/build/Makefile.feature                  |    1 -
 tools/build/feature/Makefile                  |   20 -
 tools/build/feature/test-libperl.c            |   10 -
 tools/perf/Build                              |    1 -
 tools/perf/Documentation/perf-check.txt       |    1 -
 tools/perf/Makefile.config                    |    1 -
 tools/perf/Makefile.perf                      |   14 -
 tools/perf/builtin-check.c                    |    1 -
 tools/perf/builtin-script.c                   | 1016 +++++++++--------
 tools/perf/scripts/Build                      |    3 -
 tools/perf/scripts/perl/Perf-Trace-Util/Build |    9 -
 .../scripts/perl/Perf-Trace-Util/Context.c    |  122 --
 .../scripts/perl/Perf-Trace-Util/Context.xs   |   42 -
 .../scripts/perl/Perf-Trace-Util/Makefile.PL  |   18 -
 .../perf/scripts/perl/Perf-Trace-Util/README  |   59 -
 .../Perf-Trace-Util/lib/Perf/Trace/Context.pm |   55 -
 .../Perf-Trace-Util/lib/Perf/Trace/Core.pm    |  192 ----
 .../Perf-Trace-Util/lib/Perf/Trace/Util.pm    |   94 --
 .../perf/scripts/perl/Perf-Trace-Util/typemap |    1 -
 .../scripts/perl/bin/check-perf-trace-record  |    2 -
 .../scripts/perl/bin/failed-syscalls-record   |    3 -
 .../scripts/perl/bin/failed-syscalls-report   |   10 -
 tools/perf/scripts/perl/bin/rw-by-file-record |    3 -
 tools/perf/scripts/perl/bin/rw-by-file-report |   10 -
 tools/perf/scripts/perl/bin/rw-by-pid-record  |    2 -
 tools/perf/scripts/perl/bin/rw-by-pid-report  |    3 -
 tools/perf/scripts/perl/bin/rwtop-record      |    2 -
 tools/perf/scripts/perl/bin/rwtop-report      |   20 -
 .../scripts/perl/bin/wakeup-latency-record    |    6 -
 .../scripts/perl/bin/wakeup-latency-report    |    3 -
 tools/perf/scripts/perl/check-perf-trace.pl   |  106 --
 tools/perf/scripts/perl/failed-syscalls.pl    |   47 -
 tools/perf/scripts/perl/rw-by-file.pl         |  106 --
 tools/perf/scripts/perl/rw-by-pid.pl          |  184 ---
 tools/perf/scripts/perl/rwtop.pl              |  203 ----
 tools/perf/scripts/perl/wakeup-latency.pl     |  107 --
 tools/perf/tests/make                         |    2 -
 .../coresight/test_arm_coresight_disasm.sh    |   14 +-
 tools/perf/tests/shell/script_perl.sh         |  102 --
 .../shell/test_check_perf_trace_python.sh     |    2 +-
 .../shell/test_compaction_times_python.sh     |    6 +-
 .../test_event_analyzing_sample_python.sh     |    3 +-
 .../shell/test_export_to_postgresql_python.sh |    8 +-
 .../shell/test_export_to_sqlite_python.sh     |    4 +-
 .../test_failed_syscalls_by_pid_python.sh     |    7 +-
 .../shell/test_failed_syscalls_python.sh      |    2 +-
 .../tests/shell/test_flamegraph_python.sh     |    8 +-
 .../shell/test_futex_contention_python.sh     |    2 +-
 tools/perf/tests/shell/test_gecko_python.sh   |    2 +-
 .../shell/test_intel_pt_events_python.sh      |    2 +-
 .../tests/shell/test_mem_phys_addr_python.sh  |    3 +-
 .../shell/test_net_dropmonitor_python.sh      |    2 +-
 .../tests/shell/test_netdev_times_python.sh   |    2 +-
 .../tests/shell/test_powerpc_hcalls_python.sh |    2 +-
 .../tests/shell/test_rw_by_file_python.sh     |    2 +-
 .../perf/tests/shell/test_rw_by_pid_python.sh |    2 +-
 tools/perf/tests/shell/test_rwtop_python.sh   |    2 +-
 .../shell/test_sched_migration_python.sh      |    2 +-
 tools/perf/tests/shell/test_sctop_python.sh   |    4 +-
 .../tests/shell/test_stackcollapse_python.sh  |    6 +-
 .../perf/tests/shell/test_stat_cpi_python.sh  |    4 +-
 .../test_syscall_counts_by_pid_python.sh      |    7 +-
 .../tests/shell/test_syscall_counts_python.sh |    4 +-
 tools/perf/tests/shell/test_task_analyzer.sh  |   58 +-
 .../tests/shell/test_wakeup_latency_python.sh |    4 +-
 tools/perf/ui/browsers/scripts.c              |  161 +--
 tools/perf/util/Build                         |    3 -
 tools/perf/util/scripting-engines/Build       |    5 -
 .../util/scripting-engines/trace-event-perl.c |  770 -------------
 tools/perf/util/trace-event-parse.c           |   65 --
 tools/perf/util/trace-event-scripting.c       |  398 -------
 tools/perf/util/trace-event.h                 |   72 +-
 72 files changed, 607 insertions(+), 3612 deletions(-)
 delete mode 100644 tools/build/feature/test-libperl.c
 delete mode 100644 tools/perf/scripts/Build
 delete mode 100644 tools/perf/scripts/perl/Perf-Trace-Util/Build
 delete mode 100644 tools/perf/scripts/perl/Perf-Trace-Util/Context.c
 delete mode 100644 tools/perf/scripts/perl/Perf-Trace-Util/Context.xs
 delete mode 100644 tools/perf/scripts/perl/Perf-Trace-Util/Makefile.PL
 delete mode 100644 tools/perf/scripts/perl/Perf-Trace-Util/README
 delete mode 100644 tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Context.pm
 delete mode 100644 tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Core.pm
 delete mode 100644 tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Util.pm
 delete mode 100644 tools/perf/scripts/perl/Perf-Trace-Util/typemap
 delete mode 100644 tools/perf/scripts/perl/bin/check-perf-trace-record
 delete mode 100644 tools/perf/scripts/perl/bin/failed-syscalls-record
 delete mode 100644 tools/perf/scripts/perl/bin/failed-syscalls-report
 delete mode 100644 tools/perf/scripts/perl/bin/rw-by-file-record
 delete mode 100644 tools/perf/scripts/perl/bin/rw-by-file-report
 delete mode 100644 tools/perf/scripts/perl/bin/rw-by-pid-record
 delete mode 100644 tools/perf/scripts/perl/bin/rw-by-pid-report
 delete mode 100644 tools/perf/scripts/perl/bin/rwtop-record
 delete mode 100644 tools/perf/scripts/perl/bin/rwtop-report
 delete mode 100644 tools/perf/scripts/perl/bin/wakeup-latency-record
 delete mode 100644 tools/perf/scripts/perl/bin/wakeup-latency-report
 delete mode 100644 tools/perf/scripts/perl/check-perf-trace.pl
 delete mode 100644 tools/perf/scripts/perl/failed-syscalls.pl
 delete mode 100644 tools/perf/scripts/perl/rw-by-file.pl
 delete mode 100644 tools/perf/scripts/perl/rw-by-pid.pl
 delete mode 100644 tools/perf/scripts/perl/rwtop.pl
 delete mode 100644 tools/perf/scripts/perl/wakeup-latency.pl
 delete mode 100755 tools/perf/tests/shell/script_perl.sh
 delete mode 100644 tools/perf/util/scripting-engines/Build
 delete mode 100644 tools/perf/util/scripting-engines/trace-event-perl.c
 delete mode 100644 tools/perf/util/trace-event-scripting.c
tools/build/Makefile.feature +0 -1
index 3ca7a4f5c7fd..dbef5b6c4e43 100644
@@ -121,7 +121,6 @@ FEATURE_TESTS_EXTRA :=                  \
          libbfd-liberty                 \
          libbfd-liberty-z               \
          libopencsd                     \
-         libperl                        \
          llvm                           \
          libbpf                         \
          libpfm4                        \
tools/build/feature/Makefile +0 -20
index 269af8e8f5cf..62f9cbf3dee9 100644
@@ -31,7 +31,6 @@ FILES=                                          \
          test-libdebuginfod.bin                 \
          test-libnuma.bin                       \
          test-numa_num_possible_cpus.bin        \
-         test-libperl.bin                       \
          test-python-module.bin                 \
          test-libslang.bin                      \
          test-libtraceevent.bin                 \
@@ -242,25 +241,6 @@ $(OUTPUT)test-libtracefs.bin:
 $(OUTPUT)test-gtk4.bin:
 	$(BUILD) $(shell $(PKG_CONFIG) --libs --cflags gtk4 2>/dev/null)
 
-grep-libs  = $(filter -l%,$(1))
-strip-libs = $(filter-out -l%,$(1))
-
-PERL_EMBED_LDOPTS = $(shell perl -MExtUtils::Embed -e ldopts 2>/dev/null)
-PERL_EMBED_LDFLAGS = $(call strip-libs,$(PERL_EMBED_LDOPTS))
-PERL_EMBED_LIBADD = $(call grep-libs,$(PERL_EMBED_LDOPTS))
-PERL_EMBED_CCOPTS = $(shell perl -MExtUtils::Embed -e ccopts 2>/dev/null)
-FLAGS_PERL_EMBED=$(PERL_EMBED_CCOPTS) $(PERL_EMBED_LDOPTS)
-
-ifeq ($(CC_NO_CLANG), 0)
-  PERL_EMBED_LDOPTS := $(filter-out -specs=%,$(PERL_EMBED_LDOPTS))
-  PERL_EMBED_CCOPTS := $(filter-out -flto=auto -ffat-lto-objects, $(PERL_EMBED_CCOPTS))
-  PERL_EMBED_CCOPTS := $(filter-out -specs=%,$(PERL_EMBED_CCOPTS))
-  FLAGS_PERL_EMBED += -Wno-compound-token-split-by-macro
-endif
-
-$(OUTPUT)test-libperl.bin:
-	$(BUILD) $(FLAGS_PERL_EMBED)
-
 $(OUTPUT)test-python-module.bin:
 	$(BUILD) $(FLAGS_PYTHON_EMBED)
 
tools/build/feature/test-libperl.c deleted +0 -10
deleted file mode 100644
index 0415f437eb31..000000000000
@@ -1,10 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include <EXTERN.h>
-#include <perl.h>
-
-int main(void)
-{
-	perl_alloc();
-
-	return 0;
-}
tools/perf/Build +0 -1
index 5bd0e58d7cb0..8a0b5592a973 100644
@@ -61,7 +61,6 @@ perf-util-y += arch/
 perf-y += arch/
 perf-test-y += arch/
 perf-ui-y += ui/
-perf-util-y += scripts/
 
 gtk-y += ui/gtk/
 
tools/perf/Documentation/perf-check.txt +0 -1
index a80913794eb6..1406a41c5d09 100644
@@ -58,7 +58,6 @@ feature::
                 libLLVM                 /  HAVE_LIBLLVM_SUPPORT
                 libnuma                 /  HAVE_LIBNUMA_SUPPORT
                 libopencsd              /  HAVE_CSTRACE_SUPPORT
-                libperl                 /  HAVE_LIBPERL_SUPPORT
                 libpfm4                 /  HAVE_LIBPFM
                 libslang                /  HAVE_SLANG_SUPPORT
                 libtraceevent           /  HAVE_LIBTRACEEVENT
tools/perf/Makefile.config +0 -1
index 6c0071db8523..6e92f66afe90 100644
@@ -1280,7 +1280,6 @@ $(call detected_var,tipdir_SQ)
 $(call detected_var,srcdir_SQ)
 $(call detected_var,LIBDIR)
 $(call detected_var,GTK_CFLAGS)
-$(call detected_var,PERL_EMBED_CCOPTS)
 $(call detected_var,PYTHON_EMBED_CCOPTS)
 ifneq ($(BISON_FILE_PREFIX_MAP),)
 $(call detected_var,BISON_FILE_PREFIX_MAP)
tools/perf/Makefile.perf +0 -14
index 8fe603aa9773..1768948d17b5 100644
@@ -17,7 +17,6 @@ include ../scripts/utilities.mak
 #
 # Define CROSS_COMPILE as prefix name of compiler if you want cross-builds.
 #
-# Define LIBPERL to enable perl script extension.
 #
 # Define NO_PYTHON_MODULE to disable python script extension.
 #
@@ -483,11 +482,6 @@ OTHER_PROGRAMS = $(OUTPUT)perf
 ifndef SHELL_PATH
   SHELL_PATH = /bin/sh
 endif
-ifndef PERL_PATH
-  PERL_PATH = /usr/bin/perl
-endif
-
-export PERL_PATH
 
 LIBPERF_BENCH_IN := $(OUTPUT)perf-bench-in.o
 LIBPERF_BENCH := $(OUTPUT)libperf-bench.a
@@ -892,14 +886,6 @@ endif
 		$(INSTALL) $(OUTPUT)perf-archive -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
 	$(call QUIET_INSTALL, perf-iostat) \
 		$(INSTALL) $(OUTPUT)perf-iostat -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)'
-ifdef LIBPERL
-	$(call QUIET_INSTALL, perl-scripts) \
-		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
-		$(INSTALL) scripts/perl/Perf-Trace-Util/lib/Perf/Trace/* -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/Perf-Trace-Util/lib/Perf/Trace'; \
-		$(INSTALL) scripts/perl/*.pl -m 644 -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl'; \
-		$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'; \
-		$(INSTALL) scripts/perl/bin/* -t '$(DESTDIR_SQ)$(perfexec_instdir_SQ)/scripts/perl/bin'
-endif
 
 ifndef NO_PYTHON_MODULE
 	$(call QUIET_INSTALL, python-scripts) \
tools/perf/builtin-check.c +0 -1
index 06711362d37f..1e43e097e7a7 100644
@@ -51,7 +51,6 @@ struct feature_status supported_features[] = {
 	FEATURE_STATUS("libLLVM", HAVE_LIBLLVM_SUPPORT),
 	FEATURE_STATUS("libnuma", HAVE_LIBNUMA_SUPPORT),
 	FEATURE_STATUS("libopencsd", HAVE_CSTRACE_SUPPORT),
-	FEATURE_STATUS_TIP("libperl", HAVE_LIBPERL_SUPPORT, "Deprecated, use LIBPERL=1 and install perl-ExtUtils-Embed/libperl-dev to build with it"),
 	FEATURE_STATUS("python-module", HAVE_PYTHON_MODULE_SUPPORT),
 	FEATURE_STATUS("libpfm4", HAVE_LIBPFM),
 	FEATURE_STATUS("libslang", HAVE_SLANG_SUPPORT),
tools/perf/builtin-script.c +522 -494
index 565ee8d55f80..b6691ebb1b4e 100644
@@ -1,8 +1,12 @@
 // SPDX-License-Identifier: GPL-2.0
 #include <errno.h>
 #include <inttypes.h>
+#include <limits.h>
 #include <signal.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <strings.h>
 
 #include <dirent.h>
 #include <fcntl.h>
@@ -18,6 +22,7 @@
 #include <sys/param.h>
 #include <sys/stat.h>
 #include <sys/types.h>
+#include <sys/wait.h>
 #include <sys/utsname.h>
 #include <unistd.h>
 
@@ -77,8 +82,7 @@
 #include <event-parse.h>
 #endif
 
-static char const		*script_name;
-static char const		*generate_script_lang;
+static char			*script_name;
 static bool			reltime;
 static bool			deltatime;
 static u64			initial_time;
@@ -88,7 +92,6 @@ static u64			last_timestamp;
 static u64			nr_unordered;
 static bool			no_callchain;
 static bool			latency_format;
-static bool			system_wide;
 static bool			print_flags;
 static const char		*cpu_list;
 static DECLARE_BITMAP(cpu_bitmap, MAX_NR_CPUS);
@@ -96,6 +99,7 @@ static int			max_blocks;
 static struct dlfilter		*dlfilter;
 static int			dlargc;
 static char			**dlargv;
+static unsigned int		scripting_max_stack = PERF_MAX_STACK_DEPTH;
 
 enum perf_output_field {
 	PERF_OUTPUT_COMM            = 1ULL << 0,
@@ -1810,6 +1814,144 @@ static int perf_sample__fprintf_bts(struct perf_sample *sample,
 	return printed;
 }
 
+#define SAMPLE_FLAGS_BUF_SIZE 64
+#define SAMPLE_FLAGS_STR_ALIGNED_SIZE	21
+
+static int sample_flags_to_name(u32 flags, char *str, size_t size)
+{
+	static const struct {
+		u32 flags;
+		const char *name;
+	} sample_flags[] = {
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL, "call"},
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN, "return"},
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CONDITIONAL, "jcc"},
+		{PERF_IP_FLAG_BRANCH, "jmp"},
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_INTERRUPT, "int"},
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_INTERRUPT, "iret"},
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_SYSCALLRET, "syscall"},
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_RETURN | PERF_IP_FLAG_SYSCALLRET, "sysret"},
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_ASYNC, "async"},
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL |
+		 PERF_IP_FLAG_ASYNC | PERF_IP_FLAG_INTERRUPT,
+		 "hw int"},
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TX_ABORT, "tx abrt"},
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_BEGIN, "tr strt"},
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_TRACE_END, "tr end"},
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_VMENTRY, "vmentry"},
+		{PERF_IP_FLAG_BRANCH | PERF_IP_FLAG_CALL | PERF_IP_FLAG_VMEXIT, "vmexit"},
+		{0, NULL}
+	};
+	static const struct {
+		u32 flags;
+		const char *name;
+	} branch_events[] = {
+		{PERF_IP_FLAG_BRANCH_MISS, "miss"},
+		{PERF_IP_FLAG_NOT_TAKEN, "not_taken"},
+		{0, NULL}
+	};
+	int i;
+	const char *prefix;
+	int pos = 0, ret, ev_idx = 0;
+	u32 xf = flags & PERF_ADDITIONAL_STATE_MASK;
+	u32 types, events;
+	char xs[16] = { 0 };
+
+	/* Clear additional state bits */
+	flags &= ~PERF_ADDITIONAL_STATE_MASK;
+
+	if (flags & PERF_IP_FLAG_TRACE_BEGIN)
+		prefix = "tr strt ";
+	else if (flags & PERF_IP_FLAG_TRACE_END)
+		prefix = "tr end  ";
+	else
+		prefix = "";
+
+	ret = snprintf(str + pos, size - pos, "%s", prefix);
+	if (ret < 0)
+		return ret;
+	pos += ret;
+
+	flags &= ~(PERF_IP_FLAG_TRACE_BEGIN | PERF_IP_FLAG_TRACE_END);
+
+	types = flags & ~PERF_IP_FLAG_BRANCH_EVENT_MASK;
+	for (i = 0; sample_flags[i].name; i++) {
+		if (sample_flags[i].flags != types)
+			continue;
+
+		ret = snprintf(str + pos, size - pos, "%s", sample_flags[i].name);
+		if (ret < 0)
+			return ret;
+		pos += ret;
+		break;
+	}
+
+	events = flags & PERF_IP_FLAG_BRANCH_EVENT_MASK;
+	for (i = 0; branch_events[i].name; i++) {
+		if (!(branch_events[i].flags & events))
+			continue;
+
+		ret = snprintf(str + pos, size - pos, !ev_idx ? "/%s" : ",%s",
+			       branch_events[i].name);
+		if (ret < 0)
+			return ret;
+		pos += ret;
+		ev_idx++;
+	}
+
+	/* Add an end character '/' for events */
+	if (ev_idx) {
+		ret = snprintf(str + pos, size - pos, "/");
+		if (ret < 0)
+			return ret;
+		pos += ret;
+	}
+
+	if (!xf)
+		return pos;
+
+	snprintf(xs, sizeof(xs), "(%s%s%s)",
+		 flags & PERF_IP_FLAG_IN_TX ? "x" : "",
+		 flags & PERF_IP_FLAG_INTR_DISABLE ? "D" : "",
+		 flags & PERF_IP_FLAG_INTR_TOGGLE ? "t" : "");
+
+	/* Right align the string if its length is less than the limit */
+	if ((pos + strlen(xs)) < SAMPLE_FLAGS_STR_ALIGNED_SIZE)
+		ret = snprintf(str + pos, size - pos, "%*s",
+			       (int)(SAMPLE_FLAGS_STR_ALIGNED_SIZE - ret), xs);
+	else
+		ret = snprintf(str + pos, size - pos, " %s", xs);
+	if (ret < 0)
+		return ret;
+
+	return pos + ret;
+}
+
+static int perf_sample__sprintf_flags(u32 flags, char *str, size_t sz)
+{
+	const char *chars = PERF_IP_FLAG_CHARS;
+	const size_t n = strlen(PERF_IP_FLAG_CHARS);
+	size_t i, pos = 0;
+	int ret;
+
+	ret = sample_flags_to_name(flags, str, sz);
+	if (ret > 0)
+		return ret;
+
+	for (i = 0; i < n; i++, flags >>= 1) {
+		if ((flags & 1) && pos < sz)
+			str[pos++] = chars[i];
+	}
+	for (; i < 32; i++, flags >>= 1) {
+		if ((flags & 1) && pos < sz)
+			str[pos++] = '?';
+	}
+	if (pos < sz)
+		str[pos] = 0;
+
+	return pos;
+}
+
 static int perf_sample__fprintf_flags(u32 flags, FILE *fp)
 {
 	char str[SAMPLE_FLAGS_BUF_SIZE];
@@ -2654,8 +2796,6 @@ static void process_event(struct perf_script *script,
 		fflush(fp);
 }
 
-static struct scripting_ops	*scripting_ops;
-
 static void __process_stat(struct evsel *counter, u64 tstamp)
 {
 	int nthreads = perf_thread_map__nr(counter->core.threads);
@@ -2690,36 +2830,11 @@ static void __process_stat(struct evsel *counter, u64 tstamp)
 
 static void process_stat(struct evsel *counter, u64 tstamp)
 {
-	if (scripting_ops && scripting_ops->process_stat)
-		scripting_ops->process_stat(&stat_config, counter, tstamp);
-	else
-		__process_stat(counter, tstamp);
-}
-
-static void process_stat_interval(u64 tstamp)
-{
-	if (scripting_ops && scripting_ops->process_stat_interval)
-		scripting_ops->process_stat_interval(tstamp);
-}
-
-static void setup_scripting(void)
-{
-#ifdef HAVE_LIBTRACEEVENT
-	setup_perl_scripting();
-#endif
-	setup_python_scripting();
+	__process_stat(counter, tstamp);
 }
 
-static int flush_scripting(void)
+static void process_stat_interval(u64 tstamp __maybe_unused)
 {
-	return scripting_ops ? scripting_ops->flush_script() : 0;
-}
-
-static int cleanup_scripting(void)
-{
-	pr_debug("\nperf script stopped\n");
-
-	return scripting_ops ? scripting_ops->stop_script() : 0;
 }
 
 static bool filter_cpu(struct perf_sample *sample)
@@ -2794,20 +2909,7 @@ static int process_sample_event(const struct perf_tool *tool,
 		goto out_put;
 	}
 
-	if (scripting_ops) {
-		struct addr_location *addr_al_ptr = NULL;
-
-		if ((evsel->core.attr.sample_type & PERF_SAMPLE_ADDR) &&
-		    sample_addr_correlates_sym(&evsel->core.attr)) {
-			if (!addr_al.thread)
-				thread__resolve(al.thread, &addr_al, sample);
-			addr_al_ptr = &addr_al;
-		}
-		scripting_ops->process_event(event, sample, &al, addr_al_ptr);
-	} else {
-		process_event(scr, sample, &al, &addr_al, machine);
-	}
-
+	process_event(scr, sample, &al, &addr_al, machine);
 out_put:
 	addr_location__exit(&addr_al);
 	addr_location__exit(&al);
@@ -3119,9 +3221,6 @@ static int process_switch_event(const struct perf_tool *tool,
 	if (perf_event__process_switch(tool, event, sample, machine) < 0)
 		return -1;
 
-	if (scripting_ops && scripting_ops->process_switch && !filter_cpu(sample))
-		scripting_ops->process_switch(event, sample, machine);
-
 	if (!script->show_switch_events)
 		return 0;
 
@@ -3129,18 +3228,6 @@ static int process_switch_event(const struct perf_tool *tool,
 			   sample->tid);
 }
 
-static int process_auxtrace_error(const struct perf_tool *tool,
-				  struct perf_session *session,
-				  union perf_event *event)
-{
-	if (scripting_ops && scripting_ops->process_auxtrace_error) {
-		scripting_ops->process_auxtrace_error(session, event);
-		return 0;
-	}
-
-	return perf_event__process_auxtrace_error(tool, session, event);
-}
-
 static int
 process_lost_event(const struct perf_tool *tool,
 		   union perf_event *event,
@@ -3153,12 +3240,11 @@ process_lost_event(const struct perf_tool *tool,
 
 static int
 process_throttle_event(const struct perf_tool *tool __maybe_unused,
-		       union perf_event *event,
-		       struct perf_sample *sample,
-		       struct machine *machine)
+		       union perf_event *event __maybe_unused,
+		       struct perf_sample *sample __maybe_unused,
+		       struct machine *machine __maybe_unused)
 {
-	if (scripting_ops && scripting_ops->process_throttle)
-		scripting_ops->process_throttle(event, sample, machine);
+
 	return 0;
 }
 
@@ -3301,10 +3387,9 @@ static int __cmd_script(struct perf_script *script)
 		script->tool.mmap = process_mmap_event;
 		script->tool.mmap2 = process_mmap2_event;
 	}
-	if (script->show_switch_events || (scripting_ops && scripting_ops->process_switch))
+	if (script->show_switch_events)
 		script->tool.context_switch = process_switch_event;
-	if (scripting_ops && scripting_ops->process_auxtrace_error)
-		script->tool.auxtrace_error = process_auxtrace_error;
+	script->tool.auxtrace_error = perf_event__process_auxtrace_error;
 	if (script->show_namespace_events)
 		script->tool.namespaces = process_namespaces_event;
 	if (script->show_cgroup_events)
@@ -3341,96 +3426,48 @@ static int __cmd_script(struct perf_script *script)
 	return ret;
 }
 
-static int list_available_languages_cb(struct scripting_ops *ops, const char *spec)
-{
-	fprintf(stderr, "  %-42s [%s]\n", spec, ops->name);
-	return 0;
-}
-
-static void list_available_languages(void)
-{
-	fprintf(stderr, "\n");
-	fprintf(stderr, "Scripting language extensions (used in "
-		"perf script -s [spec:]script.[spec]):\n\n");
-	script_spec__for_each(&list_available_languages_cb);
-	fprintf(stderr, "\n");
-}
-
 /* Find script file relative to current directory or exec path */
 static char *find_script(const char *script)
 {
 	char path[PATH_MAX];
+	char *exec_path;
 
-	if (!scripting_ops) {
-		const char *ext = strrchr(script, '.');
+	if (strchr(script, '/') && access(script, R_OK) == 0)
+		return strdup(script);
 
-		if (!ext)
-			return NULL;
+	exec_path = get_argv_exec_path();
+	if (exec_path) {
+		snprintf(path, sizeof(path), "%s/python/%s", exec_path, script);
+		if (access(path, R_OK) == 0) {
+			free(exec_path);
+			return strdup(path);
+		}
 
-		scripting_ops = script_spec__lookup(++ext);
-		if (!scripting_ops)
-			return NULL;
+		snprintf(path, sizeof(path), "%s/python/%s.py", exec_path, script);
+		free(exec_path);
+		if (access(path, R_OK) == 0)
+			return strdup(path);
 	}
 
-	if (access(script, R_OK)) {
-		char *exec_path = get_argv_exec_path();
-
-		if (!exec_path)
-			return NULL;
-		snprintf(path, sizeof(path), "%s/scripts/%s/%s",
-			 exec_path, scripting_ops->dirname, script);
-		free(exec_path);
-		script = path;
-		if (access(script, R_OK))
-			return NULL;
+	if (access(script, R_OK) == 0) {
+		if (!strchr(script, '/')) {
+			snprintf(path, sizeof(path), "./%s", script);
+			return strdup(path);
+		}
+		return strdup(script);
 	}
-	return strdup(script);
+
+	/* Failure to find script. */
+	return NULL;
 }
 
 static int parse_scriptname(const struct option *opt __maybe_unused,
 			    const char *str, int unset __maybe_unused)
 {
-	char spec[PATH_MAX];
-	const char *script, *ext;
-	int len;
-
-	if (strcmp(str, "lang") == 0) {
-		list_available_languages();
-		exit(0);
-	}
-
-	script = strchr(str, ':');
-	if (script) {
-		len = script - str;
-		if (len >= PATH_MAX) {
-			fprintf(stderr, "invalid language specifier");
-			return -1;
-		}
-		strncpy(spec, str, len);
-		spec[len] = '\0';
-		scripting_ops = script_spec__lookup(spec);
-		if (!scripting_ops) {
-			fprintf(stderr, "invalid language specifier");
-			return -1;
-		}
-		script++;
-	} else {
-		script = str;
-		ext = strrchr(script, '.');
-		if (!ext) {
-			fprintf(stderr, "invalid script extension");
-			return -1;
-		}
-		scripting_ops = script_spec__lookup(++ext);
-		if (!scripting_ops) {
-			fprintf(stderr, "invalid script extension");
-			return -1;
-		}
-	}
-
-	script_name = find_script(script);
+	zfree(&script_name);
+	script_name = find_script(str);
 	if (!script_name)
-		script_name = strdup(script);
+		script_name = strdup(str);
 
 	return 0;
 }
@@ -3618,7 +3655,6 @@ static int parse_output_fields(const struct option *opt __maybe_unused,
 		    (script_dirent->d_type != DT_UNKNOWN ||		\
 		     !is_directory(lang_path, script_dirent)))
 
-
 #define RECORD_SUFFIX			"-record"
 #define REPORT_SUFFIX			"-report"
 
@@ -3626,7 +3662,6 @@ struct script_desc {
 	struct list_head	node;
 	char			*name;
 	char			*half_liner;
-	char			*args;
 };
 
 static LIST_HEAD(script_descs);
@@ -3641,16 +3676,16 @@ static struct script_desc *script_desc__new(const char *name)
 	return s;
 }
 
-static void script_desc__delete(struct script_desc *s)
-{
-	zfree(&s->name);
-	zfree(&s->half_liner);
-	zfree(&s->args);
-	free(s);
-}
-
 static void script_desc__add(struct script_desc *s)
 {
+	struct script_desc *pos;
+
+	list_for_each_entry(pos, &script_descs, node) {
+		if (s->name && pos->name && strcasecmp(s->name, pos->name) < 0) {
+			list_add_tail(&s->node, &pos->node);
+			return;
+		}
+	}
 	list_add_tail(&s->node, &script_descs);
 }
 
@@ -3698,15 +3733,65 @@ static int read_script_info(struct script_desc *desc, const char *filename)
 {
 	char line[BUFSIZ], *p;
 	FILE *fp;
+	bool in_docstring = false;
+	bool found_description = false;
 
 	fp = fopen(filename, "r");
 	if (!fp)
 		return -1;
 
 	while (fgets(line, sizeof(line), fp)) {
+		static const char * const triple_quote_str[] = {
+			"\"\"\"",
+			"'''",
+			"r\"\"\"",
+		};
 		p = skip_spaces(line);
 		if (strlen(p) == 0)
 			continue;
+
+		if (in_docstring) {
+			if (strlen(p) && p[strlen(p) - 1] == '\n')
+				p[strlen(p) - 1] = '\0';
+			zfree(&desc->half_liner);
+			desc->half_liner = strdup(skip_spaces(p));
+			in_docstring = false;
+			found_description = true;
+			break;
+		}
+
+			for (size_t i = 0; i < ARRAY_SIZE(triple_quote_str); i++) {
+				const char *quote = triple_quote_str[i];
+				const char *close_quote = quote;
+
+				if (quote[0] == 'r' || quote[0] == 'R')
+					close_quote++;
+
+				if (!strstarts(p, quote))
+					continue;
+
+				p += strlen(quote);
+				p = skip_spaces(p);
+				if (strlen(p) > 0) {
+					if (p[strlen(p) - 1] == '\n')
+						p[strlen(p) - 1] = '\0';
+					p = skip_spaces(p);
+					if (str_ends_with(p, close_quote))
+						p[strlen(p) - strlen(close_quote)] = '\0';
+					zfree(&desc->half_liner);
+					desc->half_liner = strdup(skip_spaces(p));
+					found_description = true;
+					break;
+				}
+				in_docstring = true;
+				break;
+		}
+		if (found_description)
+			break;
+
+		if (in_docstring)
+			continue;
+
 		if (*p != '#')
 			continue;
 		p++;
@@ -3719,14 +3804,17 @@ static int read_script_info(struct script_desc *desc, const char *filename)
 
 		if (!strncmp(p, "description:", strlen("description:"))) {
 			p += strlen("description:");
+			zfree(&desc->half_liner);
 			desc->half_liner = strdup(skip_spaces(p));
-			continue;
+			found_description = true;
+			break;
 		}
 
-		if (!strncmp(p, "args:", strlen("args:"))) {
-			p += strlen("args:");
-			desc->args = strdup(skip_spaces(p));
-			continue;
+		if (!found_description && strlen(p) > 0 &&
+		    strncmp(p, "SPDX-License-Identifier", 23)) {
+			if (!desc->half_liner)
+				desc->half_liner = strdup(p);
+			// Don't set found_description, maybe we find a better "description:" later!
 		}
 	}
 
@@ -3757,23 +3845,21 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
 				  const char *s __maybe_unused,
 				  int unset __maybe_unused)
 {
-	struct dirent *script_dirent, *lang_dirent;
-	char *buf, *scripts_path, *script_path, *lang_path, *first_half;
-	DIR *scripts_dir, *lang_dir;
+	struct dirent *script_dirent;
+	char *buf, *scripts_path, *script_path;
+	DIR *scripts_dir;
 	struct script_desc *desc;
 	char *script_root;
 
-	buf = malloc(3 * MAXPATHLEN + BUFSIZ);
+	buf = malloc(2 * MAXPATHLEN + BUFSIZ);
 	if (!buf) {
 		pr_err("malloc failed\n");
 		exit(-1);
 	}
 	scripts_path = buf;
 	script_path = buf + MAXPATHLEN;
-	lang_path = buf + 2 * MAXPATHLEN;
-	first_half = buf + 3 * MAXPATHLEN;
 
-	snprintf(scripts_path, MAXPATHLEN, "%s/scripts", get_argv_exec_path());
+	snprintf(scripts_path, MAXPATHLEN, "%s/python", get_argv_exec_path());
 
 	scripts_dir = opendir(scripts_path);
 	if (!scripts_dir) {
@@ -3785,30 +3871,26 @@ static int list_available_scripts(const struct option *opt __maybe_unused,
 		exit(-1);
 	}
 
-	for_each_lang(scripts_path, scripts_dir, lang_dirent) {
-		scnprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
-			  lang_dirent->d_name);
-		lang_dir = opendir(lang_path);
-		if (!lang_dir)
-			continue;
+	while ((script_dirent = readdir(scripts_dir)) != NULL) {
+		if (script_dirent->d_type != DT_DIR &&
+		    (script_dirent->d_type != DT_UNKNOWN ||
+		     !is_directory(scripts_path, script_dirent))) {
 
-		for_each_script(lang_path, lang_dir, script_dirent) {
-			script_root = get_script_root(script_dirent, REPORT_SUFFIX);
+			script_root = get_script_root(script_dirent, ".py");
 			if (script_root) {
 				desc = script_desc__findnew(script_root);
 				scnprintf(script_path, MAXPATHLEN, "%s/%s",
-					  lang_path, script_dirent->d_name);
+					  scripts_path, script_dirent->d_name);
 				read_script_info(desc, script_path);
 				free(script_root);
 			}
 		}
 	}
+	closedir(scripts_dir);
 
-	fprintf(stdout, "List of available trace scripts:\n");
+	fprintf(stdout, "List of available scripts:\n");
 	list_for_each_entry(desc, &script_descs, node) {
-		sprintf(first_half, "%s %s", desc->name,
-			desc->args ? desc->args : "");
-		fprintf(stdout, "  %-36s %s\n", first_half,
+		fprintf(stdout, "  %-36s %s\n", desc->name,
 			desc->half_liner ? desc->half_liner : "");
 	}
 
@@ -3844,94 +3926,6 @@ static void free_dlarg(void)
 	free(dlargv);
 }
 
-static char *get_script_path(const char *script_root, const char *suffix)
-{
-	struct dirent *script_dirent, *lang_dirent;
-	char scripts_path[MAXPATHLEN];
-	char script_path[MAXPATHLEN];
-	DIR *scripts_dir, *lang_dir;
-	char lang_path[MAXPATHLEN];
-	char *__script_root;
-
-	snprintf(scripts_path, MAXPATHLEN, "%s/scripts", get_argv_exec_path());
-
-	scripts_dir = opendir(scripts_path);
-	if (!scripts_dir)
-		return NULL;
-
-	for_each_lang(scripts_path, scripts_dir, lang_dirent) {
-		scnprintf(lang_path, MAXPATHLEN, "%s/%s/bin", scripts_path,
-			  lang_dirent->d_name);
-		lang_dir = opendir(lang_path);
-		if (!lang_dir)
-			continue;
-
-		for_each_script(lang_path, lang_dir, script_dirent) {
-			__script_root = get_script_root(script_dirent, suffix);
-			if (__script_root && !strcmp(script_root, __script_root)) {
-				free(__script_root);
-				closedir(scripts_dir);
-				scnprintf(script_path, MAXPATHLEN, "%s/%s",
-					  lang_path, script_dirent->d_name);
-				closedir(lang_dir);
-				return strdup(script_path);
-			}
-			free(__script_root);
-		}
-		closedir(lang_dir);
-	}
-	closedir(scripts_dir);
-
-	return NULL;
-}
-
-static bool is_top_script(const char *script_path)
-{
-	return ends_with(script_path, "top") != NULL;
-}
-
-static int has_required_arg(char *script_path)
-{
-	struct script_desc *desc;
-	int n_args = 0;
-	char *p;
-
-	desc = script_desc__new(NULL);
-
-	if (read_script_info(desc, script_path))
-		goto out;
-
-	if (!desc->args)
-		goto out;
-
-	for (p = desc->args; *p; p++)
-		if (*p == '<')
-			n_args++;
-out:
-	script_desc__delete(desc);
-
-	return n_args;
-}
-
-static int have_cmd(int argc, const char **argv)
-{
-	char **__argv = calloc(argc, sizeof(const char *));
-
-	if (!__argv) {
-		pr_err("malloc failed\n");
-		return -1;
-	}
-
-	memcpy(__argv, argv, sizeof(const char *) * argc);
-	argc = parse_options(argc, (const char **)__argv, record_options,
-			     NULL, PARSE_OPT_STOP_AT_NON_OPTION);
-	free(__argv);
-
-	system_wide = (argc == 0);
-
-	return 0;
-}
-
 static void script__setup_sample_type(struct perf_script *script)
 {
 	struct perf_session *session = script->session;
@@ -4055,6 +4049,14 @@ static int perf_script__process_auxtrace_info(const struct perf_tool *tool,
 	return ret;
 }
 
+static const char *script_itrace_opts;
+
+static int parse_script_itrace(const struct option *opt, const char *str, int unset)
+{
+	script_itrace_opts = unset ? "" : (str && *str ? str : "cepwx");
+	return itrace_parse_synth_opts(opt, str, unset);
+}
+
 static int parse_insn_trace(const struct option *opt __maybe_unused,
 			    const char *str, int unset __maybe_unused)
 {
@@ -4074,6 +4076,7 @@ static int parse_insn_trace(const struct option *opt __maybe_unused,
 	if (ret < 0)
 		return ret;
 
+	script_itrace_opts = "i0nse";
 	itrace_parse_synth_opts(opt, "i0nse", 0);
 	symbol_conf.nanosecs = true;
 	return 0;
@@ -4095,6 +4098,7 @@ static int parse_call_trace(const struct option *opt __maybe_unused,
 			    int unset __maybe_unused)
 {
 	parse_output_fields(NULL, "-ip,-addr,-event,-period,+callindent", 0);
+	script_itrace_opts = "cewp";
 	itrace_parse_synth_opts(opt, "cewp", 0);
 	symbol_conf.nanosecs = true;
 	symbol_conf.pad_output_len_dso = 50;
@@ -4106,27 +4110,102 @@ static int parse_callret_trace(const struct option *opt __maybe_unused,
 			    int unset __maybe_unused)
 {
 	parse_output_fields(NULL, "-ip,-addr,-event,-period,+callindent,+flags", 0);
+	script_itrace_opts = "crewp";
 	itrace_parse_synth_opts(opt, "crewp", 0);
 	symbol_conf.nanosecs = true;
 	return 0;
 }
 
+/*
+ * Detect scripts written for the removed legacy embedded Python scripting API.
+ *
+ * Without an embedded interpreter invoking trace_begin()/process_event()/trace_end(),
+ * executing a callback-only legacy script directly under `python3` would simply
+ * define top-level functions and silently exit with status 0 without processing
+ * any events.
+ *
+ * Note on ordering and heuristics:
+ * 1) "perf_trace_context" and "Perf-Trace-Util" must be checked BEFORE
+ *    "import perf", because "import perf" is a substring prefix of
+ *    "import perf_trace_context".
+ * 2) Defining `def process_event(`, `def trace_begin(`, or `def trace_end(`
+ *    is only flagged as legacy when `!has_perf_import`, because standalone
+ *    `import perf` scripts commonly define a helper named `def process_event(sample):`
+ *    to pass as the `sample=` callback to `perf.session(...)`.
+ */
+static bool is_legacy_python_script(const char *path)
+{
+	struct stat st;
+	int fd;
+	FILE *fp;
+	char line[1024];
+	bool has_legacy_cb = false;
+	bool has_perf_import = false;
+
+	fd = open(path, O_RDONLY | O_NONBLOCK);
+	if (fd < 0)
+		return false;
+
+	if (fstat(fd, &st) < 0 || !S_ISREG(st.st_mode)) {
+		close(fd);
+		return false;
+	}
+
+	fp = fdopen(fd, "r");
+	if (!fp) {
+		close(fd);
+		return false;
+	}
+
+	while (fgets(line, sizeof(line), fp)) {
+		const char *p = skip_spaces(line);
+
+		if (*p == '#')
+			continue;
+		if ((strstr(p, "import perf") && !strstr(p, "import perf_trace_context")) ||
+		    strstr(p, "from perf ") ||
+		    strstr(p, "__main__"))
+			has_perf_import = true;
+		if (strstr(p, "perf_trace_context") ||
+		    strstr(p, "Perf-Trace-Util") ||
+		    strstr(p, "def process_event(") ||
+		    strstr(p, "def trace_begin(") ||
+		    strstr(p, "def trace_end("))
+			has_legacy_cb = true;
+	}
+	fclose(fp);
+	return has_legacy_cb && !has_perf_import;
+}
+
+static volatile sig_atomic_t script_child_pid;
+
+static void forward_script_sig(int sig, siginfo_t *info, void *ucontext __maybe_unused)
+{
+	/*
+	 * Terminal-generated signals (Ctrl-C / Ctrl-\) have si_code > 0
+	 * (SI_KERNEL) and are already delivered by the TTY driver to the
+	 * entire foreground process group, including the child script.
+	 * Signals sent directly to the perf process via kill(2) / sigqueue(3)
+	 * have si_code <= 0 (SI_USER, SI_QUEUE, etc.) and must be forwarded
+	 * to the child script so it can catch KeyboardInterrupt / SIGTERM
+	 * and flush its output before exiting.
+	 */
+	if (script_child_pid > 0 && (sig == SIGTERM || !info || info->si_code <= 0))
+		kill(script_child_pid, sig);
+}
+
 int cmd_script(int argc, const char **argv)
 {
 	bool show_full_info = false;
 	bool header = false;
 	bool header_only = false;
-	bool script_started = false;
 	bool unsorted_dump = false;
 	bool merge_deferred_callchains = true;
-	char *rec_script_path = NULL;
-	char *rep_script_path = NULL;
 	struct perf_session *session;
 	struct itrace_synth_opts itrace_synth_opts = {
 		.set = false,
 		.default_no_sample = true,
 	};
-	char *script_path = NULL;
 	const char *dlfilter_file = NULL;
 	const char **__argv;
 	int i, j, err = 0;
@@ -4147,11 +4226,10 @@ int cmd_script(int argc, const char **argv)
 			   list_available_scripts),
 	OPT_CALLBACK_NOOPT(0, "list-dlfilters", NULL, NULL, "list available dlfilters",
 			   list_available_dlfilters),
-	OPT_CALLBACK('s', "script", NULL, "name",
-		     "script file name (lang:script name, script name, or *)",
-		     parse_scriptname),
-	OPT_STRING('g', "gen-script", &generate_script_lang, "lang",
-		   "generate perf-script.xx script in specified language"),
+	{ .type = OPTION_CALLBACK, .short_name = 's', .long_name = "script",
+	  .value = NULL, .argh = "name",
+	  .help = "script file name (lang:script name, script name, or *)",
+	  .callback = parse_scriptname, .flags = PARSE_OPT_HIDDEN },
 	OPT_STRING(0, "dlfilter", &dlfilter_file, "file", "filter .so file name"),
 	OPT_CALLBACK(0, "dlarg", NULL, "argument", "filter argument",
 		     add_dlarg),
@@ -4180,8 +4258,6 @@ int cmd_script(int argc, const char **argv)
 		     "code_page_size,ins_lat,machine_pid,vcpu,cgroup,retire_lat,"
 		     "brcntr",
 		     parse_output_fields),
-	OPT_BOOLEAN('a', "all-cpus", &system_wide,
-		    "system-wide collection from all CPUs"),
 	OPT_STRING(0, "dsos", &symbol_conf.dso_list_str, "dso[,dso...]",
 		   "only consider symbols in these DSOs"),
 	OPT_STRING('S', "symbols", &symbol_conf.sym_list_str, "symbol[,symbol...]",
@@ -4244,7 +4320,7 @@ int cmd_script(int argc, const char **argv)
 		    "Use 9 decimal places when displaying time"),
 	OPT_CALLBACK_OPTARG(0, "itrace", &itrace_synth_opts, NULL, "opts",
 			    "Instruction Tracing options\n" ITRACE_HELP,
-			    itrace_parse_synth_opts),
+			    parse_script_itrace),
 	OPT_BOOLEAN(0, "full-source-path", &srcline_full_filename,
 			"Show full source file name path for source lines"),
 	OPT_BOOLEAN(0, "demangle", &symbol_conf.demangle,
@@ -4278,22 +4354,16 @@ int cmd_script(int argc, const char **argv)
 	OPTS_EVSWITCH(&script.evswitch),
 	OPT_END()
 	};
-	const char * const script_subcommands[] = { "record", "report", NULL };
 	const char *script_usage[] = {
 		"perf script [<options>]",
-		"perf script [<options>] record <script> [<record-options>] <command>",
-		"perf script [<options>] report <script> [script-args]",
-		"perf script [<options>] <script> [<record-options>] <command>",
-		"perf script [<options>] <top-script> [script-args]",
+		"perf script [<options>] <script> [script-args]",
 		NULL
 	};
 	struct perf_env *env;
 
 	perf_set_singlethreaded();
 
-	setup_scripting();
-
-	argc = parse_options_subcommand(argc, argv, options, script_subcommands, script_usage,
+	argc = parse_options_subcommand(argc, argv, options, NULL, script_usage,
 			     PARSE_OPT_STOP_AT_NON_OPTION);
 
 	if (symbol_conf.guestmount ||
@@ -4316,22 +4386,6 @@ int cmd_script(int argc, const char **argv)
 	if (symbol__validate_sym_arguments())
 		return -1;
 
-	if (argc > 1 && strlen(argv[0]) > 2 && strstarts("record", argv[0])) {
-		rec_script_path = get_script_path(argv[1], RECORD_SUFFIX);
-		if (!rec_script_path)
-			return cmd_record(argc, argv);
-	}
-
-	if (argc > 1 && strlen(argv[0]) > 2 && strstarts("report", argv[0])) {
-		rep_script_path = get_script_path(argv[1], REPORT_SUFFIX);
-		if (!rep_script_path) {
-			fprintf(stderr,
-				"Please specify a valid report script"
-				"(see 'perf script -l' for listing)\n");
-			return -1;
-		}
-	}
-
 	if (reltime && deltatime) {
 		fprintf(stderr,
 			"reltime and deltatime - the two don't get along well. "
@@ -4346,149 +4400,194 @@ int cmd_script(int argc, const char **argv)
 	/* make sure PERF_EXEC_PATH is set for scripts */
 	set_argv_exec_path(get_argv_exec_path());
 
-	if (argc && !script_name && !rec_script_path && !rep_script_path) {
-		int live_pipe[2];
-		int rep_args;
-		pid_t pid;
-
-		rec_script_path = get_script_path(argv[0], RECORD_SUFFIX);
-		rep_script_path = get_script_path(argv[0], REPORT_SUFFIX);
-
-		if (!rec_script_path && !rep_script_path) {
-			script_name = find_script(argv[0]);
-			if (script_name) {
+	if (argc && !script_name) {
+		if (!strcmp(argv[0], "record") || !strcmp(argv[0], "report")) {
+			fprintf(stderr,
+				"The '%s' subcommand is no longer supported.\n",
+				argv[0]);
+			fprintf(stderr,
+				"Run 'perf script <script> [args]' directly.\n");
+			err = -1;
+			goto out;
+		}
+		script_name = find_script(argv[0]);
+		if (script_name) {
+			argc -= 1;
+			argv += 1;
+			if (argc && !strcmp(argv[0], "--")) {
 				argc -= 1;
 				argv += 1;
-				goto script_found;
 			}
-			usage_with_options_msg(script_usage, options,
-				"Couldn't find script `%s'\n\n See perf"
-				" script -l for available scripts.\n", argv[0]);
+			goto script_found;
 		}
+		usage_with_options_msg(script_usage, options,
+			"Couldn't find script `%s'\n\n"
+			" See perf script -l for available scripts.\n", argv[0]);
+	}
+script_found:
 
-		if (is_top_script(argv[0])) {
-			rep_args = argc - 1;
-		} else {
-			int rec_args;
-
-			rep_args = has_required_arg(rep_script_path);
-			rec_args = (argc - 1) - rep_args;
-			if (rec_args < 0) {
-				usage_with_options_msg(script_usage, options,
-					"`%s' script requires options."
-					"\n\n See perf script -l for available "
-					"scripts and options.\n", argv[0]);
-			}
-		}
+	if (script_name) {
+		pid_t pid;
+		bool is_python = str_ends_with(script_name, ".py");
+		struct sigaction forward_sa = {
+			.sa_sigaction = forward_script_sig,
+			.sa_flags = SA_SIGINFO,
+		};
+		struct sigaction old_int, old_quit, old_term;
+		sigset_t block_mask, old_mask;
 
-		if (pipe(live_pipe) < 0) {
-			perror("failed to create pipe");
-			return -1;
+		if (is_python && is_legacy_python_script(script_name)) {
+			pr_err("Error: '%s' uses the removed legacy embedded Python scripting API.\n"
+			       "Please port it to a standalone script using 'import perf' (see 'man perf-script-python').\n",
+			       script_name);
+			err = -EINVAL;
+			goto out;
 		}
 
+		if (cpu_list || symbol_conf.comm_list_str ||
+		    symbol_conf.pid_list_str || symbol_conf.tid_list_str ||
+		    script.time_str || dlfilter_file || dlargc > 0) {
+			pr_warning("Warning: Filtering options (-C, -c, --pid, --tid, --time, --dlfilter, --dlarg) are ignored for standalone scripts.\n");
+		}
+		/*
+		 * Install forward_script_sig for SIGINT, SIGQUIT, and SIGTERM
+		 * in the parent `perf` process while waiting for the child
+		 * script, and restore the original handlers and signal mask in
+		 * the child before execvp(). When the user presses Ctrl-C
+		 * during a live trace, the terminal delivers SIGINT (SI_KERNEL)
+		 * to the entire foreground process group; ignoring SI_KERNEL in
+		 * the parent prevents `perf` from terminating immediately and
+		 * allows the child Python script to catch KeyboardInterrupt,
+		 * print its summary/report, and finish cleanup before exiting.
+		 * When a signal is sent directly to `perf` via kill(2) (e.g.
+		 * from a backgrounded job in a non-interactive shell), si_code
+		 * is <= 0 (SI_USER) and forward_script_sig forwards it to the
+		 * child script.
+		 */
+		sigemptyset(&forward_sa.sa_mask);
+		sigemptyset(&block_mask);
+		sigaddset(&block_mask, SIGINT);
+		sigaddset(&block_mask, SIGQUIT);
+		sigaddset(&block_mask, SIGTERM);
+		sigprocmask(SIG_BLOCK, &block_mask, &old_mask);
+		sigaction(SIGINT, &forward_sa, &old_int);
+		sigaction(SIGQUIT, &forward_sa, &old_quit);
+		sigaction(SIGTERM, &forward_sa, &old_term);
 		pid = fork();
 		if (pid < 0) {
-			perror("failed to fork");
-			return -1;
+			err = -errno;
+			sigaction(SIGINT, &old_int, NULL);
+			sigaction(SIGQUIT, &old_quit, NULL);
+			sigaction(SIGTERM, &old_term, NULL);
+			sigprocmask(SIG_SETMASK, &old_mask, NULL);
+			pr_err("failed to fork\n");
+			goto out;
 		}
-
-		if (!pid) {
+		if (pid == 0) { /* child */
+			sigaction(SIGINT, &old_int, NULL);
+			sigaction(SIGQUIT, &old_quit, NULL);
+			sigaction(SIGTERM, &old_term, NULL);
+			sigprocmask(SIG_SETMASK, &old_mask, NULL);
+			__argv = calloc(argc + 6, sizeof(const char *));
 			j = 0;
+			if (!__argv)
+				_exit(127);
 
-			dup2(live_pipe[1], 1);
-			close(live_pipe[0]);
+			if (is_python) {
+				const char *python = getenv("PYTHON");
 
-			if (is_top_script(argv[0])) {
-				system_wide = true;
-			} else if (!system_wide) {
-				if (have_cmd(argc - rep_args, &argv[rep_args]) != 0) {
-					err = -1;
-					goto out;
-				}
+				if (!python || !*python)
+					python = "python3";
+				__argv[j++] = python;
+				__argv[j++] = "--";
+				__argv[j++] = script_name;
+			} else {
+				__argv[j++] = script_name;
 			}
-
-			__argv = calloc(argc + 6, sizeof(const char *));
-			if (!__argv) {
-				pr_err("malloc failed\n");
-				err = -ENOMEM;
-				goto out;
+			if (input_name) {
+				__argv[j++] = "-i";
+				__argv[j++] = input_name;
+			} else {
+				struct stat st;
+				bool has_input_arg = false;
+
+				for (i = 0; i < argc; i++) {
+					if (!strcmp(argv[i], "-i") ||
+					    strstarts(argv[i], "--input")) {
+						has_input_arg = true;
+						break;
+					}
+				}
+				if (!has_input_arg &&
+				    fstat(STDIN_FILENO, &st) == 0 &&
+				    S_ISFIFO(st.st_mode)) {
+					__argv[j++] = "-i";
+					__argv[j++] = "-";
+				}
 			}
-
-			__argv[j++] = "/bin/sh";
-			__argv[j++] = rec_script_path;
-			if (system_wide)
-				__argv[j++] = "-a";
-			__argv[j++] = "-q";
-			__argv[j++] = "-o";
-			__argv[j++] = "-";
-			for (i = rep_args + 1; i < argc; i++)
+			for (i = 0; i < argc; i++)
 				__argv[j++] = argv[i];
 			__argv[j++] = NULL;
 
-			execvp("/bin/sh", (char **)__argv);
-			free(__argv);
-			exit(-1);
-		}
-
-		dup2(live_pipe[0], 0);
-		close(live_pipe[1]);
-
-		__argv = calloc(argc + 4, sizeof(const char *));
-		if (!__argv) {
-			pr_err("malloc failed\n");
-			err = -ENOMEM;
-			goto out;
-		}
+			if (symbol_conf.vmlinux_name)
+				setenv("PERF_SYMBOL_VMLINUX", symbol_conf.vmlinux_name, 1);
+			if (symbol_conf.kallsyms_name)
+				setenv("PERF_SYMBOL_KALLSYMS", symbol_conf.kallsyms_name, 1);
+			if (symbol_conf.symfs && symbol_conf.symfs[0])
+				setenv("PERF_SYMBOL_SYMFS", symbol_conf.symfs, 1);
+			if (script_itrace_opts)
+				setenv("PERF_ITRACE", script_itrace_opts, 1);
+
+			execvp(__argv[0], (char **)__argv);
+			{
+				int err_code = errno;
+
+				pr_err("failed to execute script '%s': %s\n",
+				       script_name, strerror(err_code));
+				_exit(err_code);
+			}
+		} else { /* parent */
+			siginfo_t info;
+			int status = 0;
 
-		j = 0;
-		__argv[j++] = "/bin/sh";
-		__argv[j++] = rep_script_path;
-		for (i = 1; i < rep_args + 1; i++)
-			__argv[j++] = argv[i];
-		__argv[j++] = "-i";
-		__argv[j++] = "-";
-		__argv[j++] = NULL;
-
-		execvp("/bin/sh", (char **)__argv);
-		free(__argv);
-		exit(-1);
-	}
-script_found:
-	if (rec_script_path)
-		script_path = rec_script_path;
-	if (rep_script_path)
-		script_path = rep_script_path;
-
-	if (script_path) {
-		j = 0;
-
-		if (!rec_script_path)
-			system_wide = false;
-		else if (!system_wide) {
-			if (have_cmd(argc - 1, &argv[1]) != 0) {
-				err = -1;
+			script_child_pid = pid;
+			sigprocmask(SIG_SETMASK, &old_mask, NULL);
+			/*
+			 * Wait with WNOWAIT first so the child remains a
+			 * zombie (preventing PID reuse by the kernel) until
+			 * script_child_pid is cleared and signal handlers are
+			 * restored, then reap the zombie with waitpid().
+			 */
+			while (waitid(P_PID, pid, &info, WEXITED | WNOWAIT) < 0) {
+				if (errno == EINTR)
+					continue;
+				pr_err("failed to wait for script '%s': %s\n",
+				       script_name, strerror(errno));
+				err = -errno;
+				script_child_pid = 0;
+				sigaction(SIGINT, &old_int, NULL);
+				sigaction(SIGQUIT, &old_quit, NULL);
+				sigaction(SIGTERM, &old_term, NULL);
 				goto out;
 			}
-		}
-
-		__argv = calloc(argc + 2, sizeof(const char *));
-		if (!__argv) {
-			pr_err("malloc failed\n");
-			err = -ENOMEM;
+			script_child_pid = 0;
+			sigaction(SIGINT, &old_int, NULL);
+			sigaction(SIGQUIT, &old_quit, NULL);
+			sigaction(SIGTERM, &old_term, NULL);
+			while (waitpid(pid, &status, 0) != pid) {
+				if (errno == EINTR)
+					continue;
+				err = -errno;
+				goto out;
+			}
+			if (WIFEXITED(status))
+				err = WEXITSTATUS(status);
+			else if (WIFSIGNALED(status))
+				err = 128 + WTERMSIG(status);
+			else
+				err = -1;
 			goto out;
 		}
-
-		__argv[j++] = "/bin/sh";
-		__argv[j++] = script_path;
-		if (system_wide)
-			__argv[j++] = "-a";
-		for (i = 2; i < argc; i++)
-			__argv[j++] = argv[i];
-		__argv[j++] = NULL;
-
-		execvp("/bin/sh", (char **)__argv);
-		free(__argv);
-		exit(-1);
 	}
 
 	if (dlfilter_file) {
@@ -4580,79 +4679,11 @@ int cmd_script(int argc, const char **argv)
 		goto out_delete;
 	}
 #endif
-	if (generate_script_lang) {
-		struct stat perf_stat;
-		int input;
-		char *filename = strdup("perf-script");
-
-		if (output_set_by_user()) {
-			fprintf(stderr,
-				"custom fields not supported for generated scripts");
-			err = -EINVAL;
-			goto out_delete;
-		}
-
-		input = open(data.path, O_RDONLY);	/* input_name */
-		if (input < 0) {
-			err = -errno;
-			perror("failed to open file");
-			goto out_delete;
-		}
-
-		err = fstat(input, &perf_stat);
-		if (err < 0) {
-			perror("failed to stat file");
-			goto out_delete;
-		}
-
-		if (!perf_stat.st_size) {
-			fprintf(stderr, "zero-sized file, nothing to do!\n");
-			goto out_delete;
-		}
-
-		scripting_ops = script_spec__lookup(generate_script_lang);
-		if (!scripting_ops && ends_with(generate_script_lang, ".py")) {
-			scripting_ops = script_spec__lookup("python");
-			free(filename);
-			filename = strdup(generate_script_lang);
-			filename[strlen(filename) - 3] = '\0';
-		} else if (!scripting_ops && ends_with(generate_script_lang, ".pl")) {
-			scripting_ops = script_spec__lookup("perl");
-			free(filename);
-			filename = strdup(generate_script_lang);
-			filename[strlen(filename) - 3] = '\0';
-		}
-		if (!scripting_ops) {
-			fprintf(stderr, "invalid language specifier '%s'\n", generate_script_lang);
-			err = -ENOENT;
-			goto out_delete;
-		}
-		if (!filename) {
-			err = -ENOMEM;
-			goto out_delete;
-		}
-#ifdef HAVE_LIBTRACEEVENT
-		err = scripting_ops->generate_script(session->tevent.pevent, filename);
-#else
-		err = scripting_ops->generate_script(NULL, filename);
-#endif
-		free(filename);
-		goto out_delete;
-	}
 
 	err = dlfilter__start(dlfilter, session);
 	if (err)
 		goto out_delete;
 
-	if (script_name) {
-		err = scripting_ops->start_script(script_name, argc, argv, session);
-		if (err)
-			goto out_delete;
-		pr_debug("perf script started with script %s\n\n", script_name);
-		script_started = true;
-	}
-
-
 	err = perf_session__check_output_opt(session);
 	if (err < 0)
 		goto out_delete;
@@ -4680,8 +4711,6 @@ int cmd_script(int argc, const char **argv)
 
 	err = __cmd_script(&script);
 
-	flush_scripting();
-
 	if (verbose > 2 || debug_kmaps)
 		perf_session__dump_kmaps(session);
 
@@ -4696,10 +4725,9 @@ int cmd_script(int argc, const char **argv)
 	perf_session__delete(session);
 	perf_script__exit(&script);
 
-	if (script_started)
-		cleanup_scripting();
+out:
+	zfree(&script_name);
 	dlfilter__cleanup(dlfilter);
 	free_dlarg();
-out:
 	return err;
 }
tools/perf/scripts/Build deleted +0 -3
deleted file mode 100644
index fbeab8fff88b..000000000000
@@ -1,3 +0,0 @@
-ifeq ($(CONFIG_LIBTRACEEVENT),y)
-  perf-util-$(CONFIG_LIBPERL)   += perl/Perf-Trace-Util/
-endif
tools/perf/scripts/perl/Perf-Trace-Util/Build deleted +0 -9
deleted file mode 100644
index 01a1a0ed51ae..000000000000
@@ -1,9 +0,0 @@
-perf-util-y += Context.o
-
-CFLAGS_Context.o += $(PERL_EMBED_CCOPTS) -Wno-redundant-decls -Wno-strict-prototypes -Wno-bad-function-cast -Wno-declaration-after-statement -Wno-switch-enum
-CFLAGS_Context.o += -Wno-unused-parameter -Wno-nested-externs -Wno-undef
-CFLAGS_Context.o += -Wno-switch-default -Wno-shadow -Wno-thread-safety-analysis
-
-ifeq ($(CC_NO_CLANG), 1)
-  CFLAGS_Context.o += -Wno-unused-command-line-argument
-endif
tools/perf/scripts/perl/Perf-Trace-Util/Context.c deleted +0 -122
deleted file mode 100644
index 25c47d23a130..000000000000
@@ -1,122 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0-or-later
-/*
- * This file was generated automatically by ExtUtils::ParseXS version 2.18_02 from the
- * contents of Context.xs. Do not edit this file, edit Context.xs instead.
- *
- *	ANY CHANGES MADE HERE WILL BE LOST! 
- */
-#include <stdbool.h>
-#ifndef HAS_BOOL
-# define HAS_BOOL 1
-#endif
-#line 1 "Context.xs"
-/*
- * Context.xs.  XS interfaces for perf script.
- *
- * Copyright (C) 2009 Tom Zanussi <[email protected]>
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-#include "../../../util/trace-event.h"
-
-#ifndef PERL_UNUSED_VAR
-#  define PERL_UNUSED_VAR(var) if (0) var = var
-#endif
-
-#line 42 "Context.c"
-
-XS(XS_Perf__Trace__Context_common_pc); /* prototype to pass -Wmissing-prototypes */
-XS(XS_Perf__Trace__Context_common_pc)
-{
-#ifdef dVAR
-    dVAR; dXSARGS;
-#else
-    dXSARGS;
-#endif
-    if (items != 1)
-       Perl_croak(aTHX_ "Usage: %s(%s)", "Perf::Trace::Context::common_pc", "context");
-    PERL_UNUSED_VAR(cv); /* -W */
-    {
-	struct scripting_context *	context = INT2PTR(struct scripting_context *,SvIV(ST(0)));
-	int	RETVAL;
-	dXSTARG;
-
-	RETVAL = common_pc(context);
-	XSprePUSH; PUSHi((IV)RETVAL);
-    }
-    XSRETURN(1);
-}
-
-
-XS(XS_Perf__Trace__Context_common_flags); /* prototype to pass -Wmissing-prototypes */
-XS(XS_Perf__Trace__Context_common_flags)
-{
-#ifdef dVAR
-    dVAR; dXSARGS;
-#else
-    dXSARGS;
-#endif
-    if (items != 1)
-       Perl_croak(aTHX_ "Usage: %s(%s)", "Perf::Trace::Context::common_flags", "context");
-    PERL_UNUSED_VAR(cv); /* -W */
-    {
-	struct scripting_context *	context = INT2PTR(struct scripting_context *,SvIV(ST(0)));
-	int	RETVAL;
-	dXSTARG;
-
-	RETVAL = common_flags(context);
-	XSprePUSH; PUSHi((IV)RETVAL);
-    }
-    XSRETURN(1);
-}
-
-
-XS(XS_Perf__Trace__Context_common_lock_depth); /* prototype to pass -Wmissing-prototypes */
-XS(XS_Perf__Trace__Context_common_lock_depth)
-{
-#ifdef dVAR
-    dVAR; dXSARGS;
-#else
-    dXSARGS;
-#endif
-    if (items != 1)
-       Perl_croak(aTHX_ "Usage: %s(%s)", "Perf::Trace::Context::common_lock_depth", "context");
-    PERL_UNUSED_VAR(cv); /* -W */
-    {
-	struct scripting_context *	context = INT2PTR(struct scripting_context *,SvIV(ST(0)));
-	int	RETVAL;
-	dXSTARG;
-
-	RETVAL = common_lock_depth(context);
-	XSprePUSH; PUSHi((IV)RETVAL);
-    }
-    XSRETURN(1);
-}
-
-#ifdef __cplusplus
-extern "C"
-#endif
-XS(boot_Perf__Trace__Context); /* prototype to pass -Wmissing-prototypes */
-XS(boot_Perf__Trace__Context)
-{
-#ifdef dVAR
-    dVAR; dXSARGS;
-#else
-    dXSARGS;
-#endif
-    const char* file = __FILE__;
-
-    PERL_UNUSED_VAR(cv); /* -W */
-    PERL_UNUSED_VAR(items); /* -W */
-    XS_VERSION_BOOTCHECK ;
-
-        newXSproto("Perf::Trace::Context::common_pc", XS_Perf__Trace__Context_common_pc, file, "$");
-        newXSproto("Perf::Trace::Context::common_flags", XS_Perf__Trace__Context_common_flags, file, "$");
-        newXSproto("Perf::Trace::Context::common_lock_depth", XS_Perf__Trace__Context_common_lock_depth, file, "$");
-    if (PL_unitcheckav)
-         call_list(PL_scopestack_ix, PL_unitcheckav);
-    XSRETURN_YES;
-}
-
tools/perf/scripts/perl/Perf-Trace-Util/Context.xs deleted +0 -42
deleted file mode 100644
index 8c7ea42444d1..000000000000
@@ -1,42 +0,0 @@
-/*
- * Context.xs.  XS interfaces for perf script.
- *
- * Copyright (C) 2009 Tom Zanussi <[email protected]>
- *
- *  This program is free software; you can redistribute it and/or modify
- *  it under the terms of the GNU General Public License as published by
- *  the Free Software Foundation; either version 2 of the License, or
- *  (at your option) any later version.
- *
- *  This program is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- *  GNU General Public License for more details.
- *
- *  You should have received a copy of the GNU General Public License
- *  along with this program; if not, write to the Free Software
- *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
- *
- */
-
-#include "EXTERN.h"
-#include "perl.h"
-#include "XSUB.h"
-#include "../../../perf.h"
-#include "../../../util/trace-event.h"
-
-MODULE = Perf::Trace::Context		PACKAGE = Perf::Trace::Context
-PROTOTYPES: ENABLE
-
-int
-common_pc(context)
-	struct scripting_context * context
-
-int
-common_flags(context)
-	struct scripting_context * context
-
-int
-common_lock_depth(context)
-	struct scripting_context * context
-
tools/perf/scripts/perl/Perf-Trace-Util/Makefile.PL deleted +0 -18
deleted file mode 100644
index e8994332d7dc..000000000000
@@ -1,18 +0,0 @@
-# SPDX-License-Identifier: GPL-2.0
-use 5.010000;
-use ExtUtils::MakeMaker;
-# See lib/ExtUtils/MakeMaker.pm for details of how to influence
-# the contents of the Makefile that is written.
-WriteMakefile(
-    NAME              => 'Perf::Trace::Context',
-    VERSION_FROM      => 'lib/Perf/Trace/Context.pm', # finds $VERSION
-    PREREQ_PM         => {}, # e.g., Module::Name => 1.1
-    ($] >= 5.005 ?     ## Add these new keywords supported since 5.005
-      (ABSTRACT_FROM  => 'lib/Perf/Trace/Context.pm', # retrieve abstract from module
-       AUTHOR         => 'Tom Zanussi <[email protected]>') : ()),
-    LIBS              => [''], # e.g., '-lm'
-    DEFINE            => '-I ../..', # e.g., '-DHAVE_SOMETHING'
-    INC               => '-I.', # e.g., '-I. -I/usr/include/other'
-	# Un-comment this if you add C files to link with later:
-    OBJECT            => 'Context.o', # link all the C files too
-);
tools/perf/scripts/perl/Perf-Trace-Util/README deleted +0 -59
deleted file mode 100644
index 2f0c7f3043ee..000000000000
@@ -1,59 +0,0 @@
-Perf-Trace-Util version 0.01
-============================
-
-This module contains utility functions for use with perf script.
-
-Core.pm and Util.pm are pure Perl modules; Core.pm contains routines
-that the core perf support for Perl calls on and should always be
-'used', while Util.pm contains useful but optional utility functions
-that scripts may want to use.  Context.pm contains the Perl->C
-interface that allows scripts to access data in the embedding perf
-executable; scripts wishing to do that should 'use Context.pm'.
-
-The Perl->C perf interface is completely driven by Context.xs.  If you
-want to add new Perl functions that end up accessing C data in the
-perf executable, you add desciptions of the new functions here.
-scripting_context is a pointer to the perf data in the perf executable
-that you want to access - it's passed as the second parameter,
-$context, to all handler functions.
-
-After you do that:
-
-  perl Makefile.PL   # to create a Makefile for the next step
-  make               # to create Context.c
-
-  edit Context.c to add const to the char* file = __FILE__ line in
-  XS(boot_Perf__Trace__Context) to silence a warning/error.
-
-  You can delete the Makefile, object files and anything else that was
-  generated e.g. blib and shared library, etc, except for of course
-  Context.c
-
-  You should then be able to run the normal perf make as usual.
-
-INSTALLATION
-
-Building perf with perf script Perl scripting should install this
-module in the right place.
-
-You should make sure libperl and ExtUtils/Embed.pm are installed first
-e.g. apt-get install libperl-dev or yum install perl-ExtUtils-Embed.
-
-DEPENDENCIES
-
-This module requires these other modules and libraries:
-
-  None
-
-COPYRIGHT AND LICENCE
-
-Copyright (C) 2009 by Tom Zanussi <[email protected]>
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself, either Perl version 5.10.0 or,
-at your option, any later version of Perl 5 you may have available.
-
-Alternatively, this software may be distributed under the terms of the
-GNU General Public License ("GPL") version 2 as published by the Free
-Software Foundation.
-
tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Context.pm deleted +0 -55
deleted file mode 100644
index 4e2f6039ac92..000000000000
@@ -1,55 +0,0 @@
-package Perf::Trace::Context;
-
-use 5.010000;
-use strict;
-use warnings;
-
-require Exporter;
-
-our @ISA = qw(Exporter);
-
-our %EXPORT_TAGS = ( 'all' => [ qw(
-) ] );
-
-our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
-
-our @EXPORT = qw(
-	common_pc common_flags common_lock_depth
-);
-
-our $VERSION = '0.01';
-
-require XSLoader;
-XSLoader::load('Perf::Trace::Context', $VERSION);
-
-1;
-__END__
-=head1 NAME
-
-Perf::Trace::Context - Perl extension for accessing functions in perf.
-
-=head1 SYNOPSIS
-
-  use Perf::Trace::Context;
-
-=head1 SEE ALSO
-
-Perf (script) documentation
-
-=head1 AUTHOR
-
-Tom Zanussi, E<lt>[email protected]<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (C) 2009 by Tom Zanussi
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself, either Perl version 5.10.0 or,
-at your option, any later version of Perl 5 you may have available.
-
-Alternatively, this software may be distributed under the terms of the
-GNU General Public License ("GPL") version 2 as published by the Free
-Software Foundation.
-
-=cut
tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Core.pm deleted +0 -192
deleted file mode 100644
index 9158458d3eeb..000000000000
@@ -1,192 +0,0 @@
-package Perf::Trace::Core;
-
-use 5.010000;
-use strict;
-use warnings;
-
-require Exporter;
-
-our @ISA = qw(Exporter);
-
-our %EXPORT_TAGS = ( 'all' => [ qw(
-) ] );
-
-our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
-
-our @EXPORT = qw(
-define_flag_field define_flag_value flag_str dump_flag_fields
-define_symbolic_field define_symbolic_value symbol_str dump_symbolic_fields
-trace_flag_str
-);
-
-our $VERSION = '0.01';
-
-my %trace_flags = (0x00 => "NONE",
-		   0x01 => "IRQS_OFF",
-		   0x02 => "IRQS_NOSUPPORT",
-		   0x04 => "NEED_RESCHED",
-		   0x08 => "HARDIRQ",
-		   0x10 => "SOFTIRQ");
-
-sub trace_flag_str
-{
-    my ($value) = @_;
-
-    my $string;
-
-    my $print_delim = 0;
-
-    foreach my $idx (sort {$a <=> $b} keys %trace_flags) {
-	if (!$value && !$idx) {
-	    $string .= "NONE";
-	    last;
-	}
-
-	if ($idx && ($value & $idx) == $idx) {
-	    if ($print_delim) {
-		$string .= " | ";
-	    }
-	    $string .= "$trace_flags{$idx}";
-	    $print_delim = 1;
-	    $value &= ~$idx;
-	}
-    }
-
-    return $string;
-}
-
-my %flag_fields;
-my %symbolic_fields;
-
-sub flag_str
-{
-    my ($event_name, $field_name, $value) = @_;
-
-    my $string;
-
-    if ($flag_fields{$event_name}{$field_name}) {
-	my $print_delim = 0;
-	foreach my $idx (sort {$a <=> $b} keys %{$flag_fields{$event_name}{$field_name}{"values"}}) {
-	    if (!$value && !$idx) {
-		$string .= "$flag_fields{$event_name}{$field_name}{'values'}{$idx}";
-		last;
-	    }
-	    if ($idx && ($value & $idx) == $idx) {
-		if ($print_delim && $flag_fields{$event_name}{$field_name}{'delim'}) {
-		    $string .= " $flag_fields{$event_name}{$field_name}{'delim'} ";
-		}
-		$string .= "$flag_fields{$event_name}{$field_name}{'values'}{$idx}";
-		$print_delim = 1;
-		$value &= ~$idx;
-	    }
-	}
-    }
-
-    return $string;
-}
-
-sub define_flag_field
-{
-    my ($event_name, $field_name, $delim) = @_;
-
-    $flag_fields{$event_name}{$field_name}{"delim"} = $delim;
-}
-
-sub define_flag_value
-{
-    my ($event_name, $field_name, $value, $field_str) = @_;
-
-    $flag_fields{$event_name}{$field_name}{"values"}{$value} = $field_str;
-}
-
-sub dump_flag_fields
-{
-    for my $event (keys %flag_fields) {
-	print "event $event:\n";
-	for my $field (keys %{$flag_fields{$event}}) {
-	    print "    field: $field:\n";
-	    print "        delim: $flag_fields{$event}{$field}{'delim'}\n";
-	    foreach my $idx (sort {$a <=> $b} keys %{$flag_fields{$event}{$field}{"values"}}) {
-		print "        value $idx: $flag_fields{$event}{$field}{'values'}{$idx}\n";
-	    }
-	}
-    }
-}
-
-sub symbol_str
-{
-    my ($event_name, $field_name, $value) = @_;
-
-    if ($symbolic_fields{$event_name}{$field_name}) {
-	foreach my $idx (sort {$a <=> $b} keys %{$symbolic_fields{$event_name}{$field_name}{"values"}}) {
-	    if (!$value && !$idx) {
-		return "$symbolic_fields{$event_name}{$field_name}{'values'}{$idx}";
-		last;
-	    }
-	    if ($value == $idx) {
-		return "$symbolic_fields{$event_name}{$field_name}{'values'}{$idx}";
-	    }
-	}
-    }
-
-    return undef;
-}
-
-sub define_symbolic_field
-{
-    my ($event_name, $field_name) = @_;
-
-    # nothing to do, really
-}
-
-sub define_symbolic_value
-{
-    my ($event_name, $field_name, $value, $field_str) = @_;
-
-    $symbolic_fields{$event_name}{$field_name}{"values"}{$value} = $field_str;
-}
-
-sub dump_symbolic_fields
-{
-    for my $event (keys %symbolic_fields) {
-	print "event $event:\n";
-	for my $field (keys %{$symbolic_fields{$event}}) {
-	    print "    field: $field:\n";
-	    foreach my $idx (sort {$a <=> $b} keys %{$symbolic_fields{$event}{$field}{"values"}}) {
-		print "        value $idx: $symbolic_fields{$event}{$field}{'values'}{$idx}\n";
-	    }
-	}
-    }
-}
-
-1;
-__END__
-=head1 NAME
-
-Perf::Trace::Core - Perl extension for perf script
-
-=head1 SYNOPSIS
-
-  use Perf::Trace::Core
-
-=head1 SEE ALSO
-
-Perf (script) documentation
-
-=head1 AUTHOR
-
-Tom Zanussi, E<lt>[email protected]<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (C) 2009 by Tom Zanussi
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself, either Perl version 5.10.0 or,
-at your option, any later version of Perl 5 you may have available.
-
-Alternatively, this software may be distributed under the terms of the
-GNU General Public License ("GPL") version 2 as published by the Free
-Software Foundation.
-
-=cut
tools/perf/scripts/perl/Perf-Trace-Util/lib/Perf/Trace/Util.pm deleted +0 -94
deleted file mode 100644
index 053500114625..000000000000
@@ -1,94 +0,0 @@
-package Perf::Trace::Util;
-
-use 5.010000;
-use strict;
-use warnings;
-
-require Exporter;
-
-our @ISA = qw(Exporter);
-
-our %EXPORT_TAGS = ( 'all' => [ qw(
-) ] );
-
-our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
-
-our @EXPORT = qw(
-avg nsecs nsecs_secs nsecs_nsecs nsecs_usecs print_nsecs
-clear_term
-);
-
-our $VERSION = '0.01';
-
-sub avg
-{
-    my ($total, $n) = @_;
-
-    return $total / $n;
-}
-
-my $NSECS_PER_SEC    = 1000000000;
-
-sub nsecs
-{
-    my ($secs, $nsecs) = @_;
-
-    return $secs * $NSECS_PER_SEC + $nsecs;
-}
-
-sub nsecs_secs {
-    my ($nsecs) = @_;
-
-    return $nsecs / $NSECS_PER_SEC;
-}
-
-sub nsecs_nsecs {
-    my ($nsecs) = @_;
-
-    return $nsecs % $NSECS_PER_SEC;
-}
-
-sub nsecs_str {
-    my ($nsecs) = @_;
-
-    my $str = sprintf("%5u.%09u", nsecs_secs($nsecs), nsecs_nsecs($nsecs));
-
-    return $str;
-}
-
-sub clear_term
-{
-    print "\x1b[H\x1b[2J";
-}
-
-1;
-__END__
-=head1 NAME
-
-Perf::Trace::Util - Perl extension for perf script
-
-=head1 SYNOPSIS
-
-  use Perf::Trace::Util;
-
-=head1 SEE ALSO
-
-Perf (script) documentation
-
-=head1 AUTHOR
-
-Tom Zanussi, E<lt>[email protected]<gt>
-
-=head1 COPYRIGHT AND LICENSE
-
-Copyright (C) 2009 by Tom Zanussi
-
-This library is free software; you can redistribute it and/or modify
-it under the same terms as Perl itself, either Perl version 5.10.0 or,
-at your option, any later version of Perl 5 you may have available.
-
-Alternatively, this software may be distributed under the terms of the
-GNU General Public License ("GPL") version 2 as published by the Free
-Software Foundation.
-
-=cut
tools/perf/scripts/perl/Perf-Trace-Util/typemap deleted +0 -1
deleted file mode 100644
index 840836804aa7..000000000000
@@ -1 +0,0 @@
-struct scripting_context * T_PTR
tools/perf/scripts/perl/bin/check-perf-trace-record deleted +0 -2
deleted file mode 100644
index 423ad6aed056..000000000000
@@ -1,2 +0,0 @@
-#!/bin/bash
-perf record -a -e kmem:kmalloc -e irq:softirq_entry -e kmem:kfree
tools/perf/scripts/perl/bin/failed-syscalls-record deleted +0 -3
deleted file mode 100644
index 74685f318379..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-(perf record -e raw_syscalls:sys_exit $@ || \
- perf record -e syscalls:sys_exit $@) 2> /dev/null
tools/perf/scripts/perl/bin/failed-syscalls-report deleted +0 -10
deleted file mode 100644
index 9f83cc1ad8ba..000000000000
@@ -1,10 +0,0 @@
-#!/bin/bash
-# description: system-wide failed syscalls
-# args: [comm]
-if [ $# -gt 0 ] ; then
-    if ! expr match "$1" "-" > /dev/null ; then
-	comm=$1
-	shift
-    fi
-fi
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/perl/failed-syscalls.pl $comm
tools/perf/scripts/perl/bin/rw-by-file-record deleted +0 -3
deleted file mode 100644
index 33efc8673aae..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-perf record -e syscalls:sys_enter_read -e syscalls:sys_enter_write $@
-
tools/perf/scripts/perl/bin/rw-by-file-report deleted +0 -10
deleted file mode 100644
index 77200b3f3100..000000000000
@@ -1,10 +0,0 @@
-#!/bin/bash
-# description: r/w activity for a program, by file
-# args: <comm>
-if [ $# -lt 1 ] ; then
-    echo "usage: rw-by-file <comm>"
-    exit
-fi
-comm=$1
-shift
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/perl/rw-by-file.pl $comm
tools/perf/scripts/perl/bin/rw-by-pid-record deleted +0 -2
deleted file mode 100644
index 7cb9db230448..000000000000
@@ -1,2 +0,0 @@
-#!/bin/bash
-perf record -e syscalls:sys_enter_read -e syscalls:sys_exit_read -e syscalls:sys_enter_write -e syscalls:sys_exit_write $@
tools/perf/scripts/perl/bin/rw-by-pid-report deleted +0 -3
deleted file mode 100644
index a27b9f311f95..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-# description: system-wide r/w activity
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/perl/rw-by-pid.pl
tools/perf/scripts/perl/bin/rwtop-record deleted +0 -2
deleted file mode 100644
index 7cb9db230448..000000000000
@@ -1,2 +0,0 @@
-#!/bin/bash
-perf record -e syscalls:sys_enter_read -e syscalls:sys_exit_read -e syscalls:sys_enter_write -e syscalls:sys_exit_write $@
tools/perf/scripts/perl/bin/rwtop-report deleted +0 -20
deleted file mode 100644
index 83e11ec2e190..000000000000
@@ -1,20 +0,0 @@
-#!/bin/bash
-# description: system-wide r/w top
-# args: [interval]
-n_args=0
-for i in "$@"
-do
-    if expr match "$i" "-" > /dev/null ; then
-	break
-    fi
-    n_args=$(( $n_args + 1 ))
-done
-if [ "$n_args" -gt 1 ] ; then
-    echo "usage: rwtop-report [interval]"
-    exit
-fi
-if [ "$n_args" -gt 0 ] ; then
-    interval=$1
-    shift
-fi
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/perl/rwtop.pl $interval
tools/perf/scripts/perl/bin/wakeup-latency-record deleted +0 -6
deleted file mode 100644
index 464251a1bd7e..000000000000
@@ -1,6 +0,0 @@
-#!/bin/bash
-perf record -e sched:sched_switch -e sched:sched_wakeup $@
-
-
-
-
tools/perf/scripts/perl/bin/wakeup-latency-report deleted +0 -3
deleted file mode 100644
index 889e8130cca5..000000000000
@@ -1,3 +0,0 @@
-#!/bin/bash
-# description: system-wide min/max/avg wakeup latency
-perf script $@ -s "$PERF_EXEC_PATH"/scripts/perl/wakeup-latency.pl
tools/perf/scripts/perl/check-perf-trace.pl deleted +0 -106
deleted file mode 100644
index d307ce8fd6ed..000000000000
@@ -1,106 +0,0 @@
-# perf script event handlers, generated by perf script -g perl
-# (c) 2009, Tom Zanussi <[email protected]>
-# Licensed under the terms of the GNU GPL License version 2
-
-# This script tests basic functionality such as flag and symbol
-# strings, common_xxx() calls back into perf, begin, end, unhandled
-# events, etc.  Basically, if this script runs successfully and
-# displays expected results, perl scripting support should be ok.
-
-use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib";
-use lib "./Perf-Trace-Util/lib";
-use Perf::Trace::Core;
-use Perf::Trace::Context;
-use Perf::Trace::Util;
-
-sub trace_begin
-{
-    print "trace_begin\n";
-}
-
-sub trace_end
-{
-    print "trace_end\n";
-
-    print_unhandled();
-}
-
-sub irq::softirq_entry
-{
-	my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	    $common_pid, $common_comm, $common_callchain,
-	    $vec) = @_;
-
-	print_header($event_name, $common_cpu, $common_secs, $common_nsecs,
-		     $common_pid, $common_comm);
-
-	print_uncommon($context);
-
-	printf("vec=%s\n",
-	       symbol_str("irq::softirq_entry", "vec", $vec));
-}
-
-sub kmem::kmalloc
-{
-	my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	    $common_pid, $common_comm, $common_callchain,
-	    $call_site, $ptr, $bytes_req, $bytes_alloc,
-	    $gfp_flags) = @_;
-
-	print_header($event_name, $common_cpu, $common_secs, $common_nsecs,
-		     $common_pid, $common_comm);
-
-	print_uncommon($context);
-
-	printf("call_site=%p, ptr=%p, bytes_req=%u, bytes_alloc=%u, ".
-	       "gfp_flags=%s\n",
-	       $call_site, $ptr, $bytes_req, $bytes_alloc,
-
-	       flag_str("kmem::kmalloc", "gfp_flags", $gfp_flags));
-}
-
-# print trace fields not included in handler args
-sub print_uncommon
-{
-    my ($context) = @_;
-
-    printf("common_preempt_count=%d, common_flags=%s, common_lock_depth=%d, ",
-	   common_pc($context), trace_flag_str(common_flags($context)),
-	   common_lock_depth($context));
-
-}
-
-my %unhandled;
-
-sub print_unhandled
-{
-    if ((scalar keys %unhandled) == 0) {
-	return;
-    }
-
-    print "\nunhandled events:\n\n";
-
-    printf("%-40s  %10s\n", "event", "count");
-    printf("%-40s  %10s\n", "----------------------------------------",
-	   "-----------");
-
-    foreach my $event_name (keys %unhandled) {
-	printf("%-40s  %10d\n", $event_name, $unhandled{$event_name});
-    }
-}
-
-sub trace_unhandled
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain) = @_;
-
-    $unhandled{$event_name}++;
-}
-
-sub print_header
-{
-	my ($event_name, $cpu, $secs, $nsecs, $pid, $comm) = @_;
-
-	printf("%-20s %5u %05u.%09u %8u %-20s ",
-	       $event_name, $cpu, $secs, $nsecs, $pid, $comm);
-}
tools/perf/scripts/perl/failed-syscalls.pl deleted +0 -47
deleted file mode 100644
index 05954a8f363a..000000000000
@@ -1,47 +0,0 @@
-# failed system call counts
-# (c) 2010, Tom Zanussi <[email protected]>
-# Licensed under the terms of the GNU GPL License version 2
-#
-# Displays system-wide failed system call totals
-# If a [comm] arg is specified, only syscalls called by [comm] are displayed.
-
-use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib";
-use lib "./Perf-Trace-Util/lib";
-use Perf::Trace::Core;
-use Perf::Trace::Context;
-use Perf::Trace::Util;
-
-my $for_comm = shift;
-
-my %failed_syscalls;
-
-sub raw_syscalls::sys_exit
-{
-	my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	    $common_pid, $common_comm, $common_callchain,
-	    $id, $ret) = @_;
-
-	if ($ret < 0) {
-	    $failed_syscalls{$common_comm}++;
-	}
-}
-
-sub syscalls::sys_exit
-{
-	raw_syscalls::sys_exit(@_)
-}
-
-sub trace_end
-{
-    printf("\nfailed syscalls by comm:\n\n");
-
-    printf("%-20s  %10s\n", "comm", "# errors");
-    printf("%-20s  %6s  %10s\n", "--------------------", "----------");
-
-    foreach my $comm (sort {$failed_syscalls{$b} <=> $failed_syscalls{$a}}
-		      keys %failed_syscalls) {
-	next if ($for_comm && $comm ne $for_comm);
-
-	printf("%-20s  %10s\n", $comm, $failed_syscalls{$comm});
-    }
-}
tools/perf/scripts/perl/rw-by-file.pl deleted +0 -106
deleted file mode 100644
index 92a750b8552b..000000000000
@@ -1,106 +0,0 @@
-#!/usr/bin/perl -w
-# SPDX-License-Identifier: GPL-2.0-only
-# (c) 2009, Tom Zanussi <[email protected]>
-
-# Display r/w activity for files read/written to for a given program
-
-# The common_* event handler fields are the most useful fields common to
-# all events.  They don't necessarily correspond to the 'common_*' fields
-# in the status files.  Those fields not available as handler params can
-# be retrieved via script functions of the form get_common_*().
-
-use 5.010000;
-use strict;
-use warnings;
-
-use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib";
-use lib "./Perf-Trace-Util/lib";
-use Perf::Trace::Core;
-use Perf::Trace::Util;
-
-my $usage = "perf script -s rw-by-file.pl <comm>\n";
-
-my $for_comm = shift or die $usage;
-
-my %reads;
-my %writes;
-
-sub syscalls::sys_enter_read
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain, $nr, $fd, $buf, $count) = @_;
-
-    if ($common_comm eq $for_comm) {
-	$reads{$fd}{bytes_requested} += $count;
-	$reads{$fd}{total_reads}++;
-    }
-}
-
-sub syscalls::sys_enter_write
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain, $nr, $fd, $buf, $count) = @_;
-
-    if ($common_comm eq $for_comm) {
-	$writes{$fd}{bytes_written} += $count;
-	$writes{$fd}{total_writes}++;
-    }
-}
-
-sub trace_end
-{
-    printf("file read counts for $for_comm:\n\n");
-
-    printf("%6s  %10s  %10s\n", "fd", "# reads", "bytes_requested");
-    printf("%6s  %10s  %10s\n", "------", "----------", "-----------");
-
-    foreach my $fd (sort {$reads{$b}{bytes_requested} <=>
-			      $reads{$a}{bytes_requested}} keys %reads) {
-	my $total_reads = $reads{$fd}{total_reads};
-	my $bytes_requested = $reads{$fd}{bytes_requested};
-	printf("%6u  %10u  %10u\n", $fd, $total_reads, $bytes_requested);
-    }
-
-    printf("\nfile write counts for $for_comm:\n\n");
-
-    printf("%6s  %10s  %10s\n", "fd", "# writes", "bytes_written");
-    printf("%6s  %10s  %10s\n", "------", "----------", "-----------");
-
-    foreach my $fd (sort {$writes{$b}{bytes_written} <=>
-			      $writes{$a}{bytes_written}} keys %writes) {
-	my $total_writes = $writes{$fd}{total_writes};
-	my $bytes_written = $writes{$fd}{bytes_written};
-	printf("%6u  %10u  %10u\n", $fd, $total_writes, $bytes_written);
-    }
-
-    print_unhandled();
-}
-
-my %unhandled;
-
-sub print_unhandled
-{
-    if ((scalar keys %unhandled) == 0) {
-	return;
-    }
-
-    print "\nunhandled events:\n\n";
-
-    printf("%-40s  %10s\n", "event", "count");
-    printf("%-40s  %10s\n", "----------------------------------------",
-	   "-----------");
-
-    foreach my $event_name (keys %unhandled) {
-	printf("%-40s  %10d\n", $event_name, $unhandled{$event_name});
-    }
-}
-
-sub trace_unhandled
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain) = @_;
-
-    $unhandled{$event_name}++;
-}
-
-
tools/perf/scripts/perl/rw-by-pid.pl deleted +0 -184
deleted file mode 100644
index d789fe39caab..000000000000
@@ -1,184 +0,0 @@
-#!/usr/bin/perl -w
-# SPDX-License-Identifier: GPL-2.0-only
-# (c) 2009, Tom Zanussi <[email protected]>
-
-# Display r/w activity for all processes
-
-# The common_* event handler fields are the most useful fields common to
-# all events.  They don't necessarily correspond to the 'common_*' fields
-# in the status files.  Those fields not available as handler params can
-# be retrieved via script functions of the form get_common_*().
-
-use 5.010000;
-use strict;
-use warnings;
-
-use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib";
-use lib "./Perf-Trace-Util/lib";
-use Perf::Trace::Core;
-use Perf::Trace::Util;
-
-my %reads;
-my %writes;
-
-sub syscalls::sys_exit_read
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain,
-	$nr, $ret) = @_;
-
-    if ($ret > 0) {
-	$reads{$common_pid}{bytes_read} += $ret;
-    } else {
-	if (!defined ($reads{$common_pid}{bytes_read})) {
-	    $reads{$common_pid}{bytes_read} = 0;
-	}
-	$reads{$common_pid}{errors}{$ret}++;
-    }
-}
-
-sub syscalls::sys_enter_read
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain,
-	$nr, $fd, $buf, $count) = @_;
-
-    $reads{$common_pid}{bytes_requested} += $count;
-    $reads{$common_pid}{total_reads}++;
-    $reads{$common_pid}{comm} = $common_comm;
-}
-
-sub syscalls::sys_exit_write
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain,
-	$nr, $ret) = @_;
-
-    if ($ret <= 0) {
-	$writes{$common_pid}{errors}{$ret}++;
-    }
-}
-
-sub syscalls::sys_enter_write
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain,
-	$nr, $fd, $buf, $count) = @_;
-
-    $writes{$common_pid}{bytes_written} += $count;
-    $writes{$common_pid}{total_writes}++;
-    $writes{$common_pid}{comm} = $common_comm;
-}
-
-sub trace_end
-{
-    printf("read counts by pid:\n\n");
-
-    printf("%6s  %20s  %10s  %10s  %10s\n", "pid", "comm",
-	   "# reads", "bytes_requested", "bytes_read");
-    printf("%6s  %-20s  %10s  %10s  %10s\n", "------", "--------------------",
-	   "-----------", "----------", "----------");
-
-    foreach my $pid (sort { ($reads{$b}{bytes_read} || 0) <=>
-				($reads{$a}{bytes_read} || 0) } keys %reads) {
-	my $comm = $reads{$pid}{comm} || "";
-	my $total_reads = $reads{$pid}{total_reads} || 0;
-	my $bytes_requested = $reads{$pid}{bytes_requested} || 0;
-	my $bytes_read = $reads{$pid}{bytes_read} || 0;
-
-	printf("%6s  %-20s  %10s  %10s  %10s\n", $pid, $comm,
-	       $total_reads, $bytes_requested, $bytes_read);
-    }
-
-    printf("\nfailed reads by pid:\n\n");
-
-    printf("%6s  %20s  %6s  %10s\n", "pid", "comm", "error #", "# errors");
-    printf("%6s  %20s  %6s  %10s\n", "------", "--------------------",
-	   "------", "----------");
-
-    my @errcounts = ();
-
-    foreach my $pid (keys %reads) {
-	foreach my $error (keys %{$reads{$pid}{errors}}) {
-	    my $comm = $reads{$pid}{comm} || "";
-	    my $errcount = $reads{$pid}{errors}{$error} || 0;
-	    push @errcounts, [$pid, $comm, $error, $errcount];
-	}
-    }
-
-    @errcounts = sort { $b->[3] <=> $a->[3] } @errcounts;
-
-    for my $i (0 .. $#errcounts) {
-	printf("%6d  %-20s  %6d  %10s\n", $errcounts[$i][0],
-	       $errcounts[$i][1], $errcounts[$i][2], $errcounts[$i][3]);
-    }
-
-    printf("\nwrite counts by pid:\n\n");
-
-    printf("%6s  %20s  %10s  %10s\n", "pid", "comm",
-	   "# writes", "bytes_written");
-    printf("%6s  %-20s  %10s  %10s\n", "------", "--------------------",
-	   "-----------", "----------");
-
-    foreach my $pid (sort { ($writes{$b}{bytes_written} || 0) <=>
-			($writes{$a}{bytes_written} || 0)} keys %writes) {
-	my $comm = $writes{$pid}{comm} || "";
-	my $total_writes = $writes{$pid}{total_writes} || 0;
-	my $bytes_written = $writes{$pid}{bytes_written} || 0;
-
-	printf("%6s  %-20s  %10s  %10s\n", $pid, $comm,
-	       $total_writes, $bytes_written);
-    }
-
-    printf("\nfailed writes by pid:\n\n");
-
-    printf("%6s  %20s  %6s  %10s\n", "pid", "comm", "error #", "# errors");
-    printf("%6s  %20s  %6s  %10s\n", "------", "--------------------",
-	   "------", "----------");
-
-    @errcounts = ();
-
-    foreach my $pid (keys %writes) {
-	foreach my $error (keys %{$writes{$pid}{errors}}) {
-	    my $comm = $writes{$pid}{comm} || "";
-	    my $errcount = $writes{$pid}{errors}{$error} || 0;
-	    push @errcounts, [$pid, $comm, $error, $errcount];
-	}
-    }
-
-    @errcounts = sort { $b->[3] <=> $a->[3] } @errcounts;
-
-    for my $i (0 .. $#errcounts) {
-	printf("%6d  %-20s  %6d  %10s\n", $errcounts[$i][0],
-	       $errcounts[$i][1], $errcounts[$i][2], $errcounts[$i][3]);
-    }
-
-    print_unhandled();
-}
-
-my %unhandled;
-
-sub print_unhandled
-{
-    if ((scalar keys %unhandled) == 0) {
-	return;
-    }
-
-    print "\nunhandled events:\n\n";
-
-    printf("%-40s  %10s\n", "event", "count");
-    printf("%-40s  %10s\n", "----------------------------------------",
-	   "-----------");
-
-    foreach my $event_name (keys %unhandled) {
-	printf("%-40s  %10d\n", $event_name, $unhandled{$event_name});
-    }
-}
-
-sub trace_unhandled
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain) = @_;
-
-    $unhandled{$event_name}++;
-}
tools/perf/scripts/perl/rwtop.pl deleted +0 -203
deleted file mode 100644
index eba4df67af6b..000000000000
@@ -1,203 +0,0 @@
-#!/usr/bin/perl -w
-# SPDX-License-Identifier: GPL-2.0-only
-# (c) 2010, Tom Zanussi <[email protected]>
-
-# read/write top
-#
-# Periodically displays system-wide r/w call activity, broken down by
-# pid.  If an [interval] arg is specified, the display will be
-# refreshed every [interval] seconds.  The default interval is 3
-# seconds.
-
-use 5.010000;
-use strict;
-use warnings;
-
-use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib";
-use lib "./Perf-Trace-Util/lib";
-use Perf::Trace::Core;
-use Perf::Trace::Util;
-use POSIX qw/SIGALRM SA_RESTART/;
-
-my $default_interval = 3;
-my $nlines = 20;
-my $print_thread;
-my $print_pending = 0;
-
-my %reads;
-my %writes;
-
-my $interval = shift;
-if (!$interval) {
-    $interval = $default_interval;
-}
-
-sub syscalls::sys_exit_read
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain,
-	$nr, $ret) = @_;
-
-    print_check();
-
-    if ($ret > 0) {
-	$reads{$common_pid}{bytes_read} += $ret;
-    } else {
-	if (!defined ($reads{$common_pid}{bytes_read})) {
-	    $reads{$common_pid}{bytes_read} = 0;
-	}
-	$reads{$common_pid}{errors}{$ret}++;
-    }
-}
-
-sub syscalls::sys_enter_read
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain,
-	$nr, $fd, $buf, $count) = @_;
-
-    print_check();
-
-    $reads{$common_pid}{bytes_requested} += $count;
-    $reads{$common_pid}{total_reads}++;
-    $reads{$common_pid}{comm} = $common_comm;
-}
-
-sub syscalls::sys_exit_write
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain,
-	$nr, $ret) = @_;
-
-    print_check();
-
-    if ($ret <= 0) {
-	$writes{$common_pid}{errors}{$ret}++;
-    }
-}
-
-sub syscalls::sys_enter_write
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain,
-	$nr, $fd, $buf, $count) = @_;
-
-    print_check();
-
-    $writes{$common_pid}{bytes_written} += $count;
-    $writes{$common_pid}{total_writes}++;
-    $writes{$common_pid}{comm} = $common_comm;
-}
-
-sub trace_begin
-{
-    my $sa = POSIX::SigAction->new(\&set_print_pending);
-    $sa->flags(SA_RESTART);
-    $sa->safe(1);
-    POSIX::sigaction(SIGALRM, $sa) or die "Can't set SIGALRM handler: $!\n";
-    alarm 1;
-}
-
-sub trace_end
-{
-    print_unhandled();
-    print_totals();
-}
-
-sub print_check()
-{
-    if ($print_pending == 1) {
-	$print_pending = 0;
-	print_totals();
-    }
-}
-
-sub set_print_pending()
-{
-    $print_pending = 1;
-    alarm $interval;
-}
-
-sub print_totals
-{
-    my $count;
-
-    $count = 0;
-
-    clear_term();
-
-    printf("\nread counts by pid:\n\n");
-
-    printf("%6s  %20s  %10s  %10s  %10s\n", "pid", "comm",
-	   "# reads", "bytes_req", "bytes_read");
-    printf("%6s  %-20s  %10s  %10s  %10s\n", "------", "--------------------",
-	   "----------", "----------", "----------");
-
-    foreach my $pid (sort { ($reads{$b}{bytes_read} || 0) <=>
-			       ($reads{$a}{bytes_read} || 0) } keys %reads) {
-	my $comm = $reads{$pid}{comm} || "";
-	my $total_reads = $reads{$pid}{total_reads} || 0;
-	my $bytes_requested = $reads{$pid}{bytes_requested} || 0;
-	my $bytes_read = $reads{$pid}{bytes_read} || 0;
-
-	printf("%6s  %-20s  %10s  %10s  %10s\n", $pid, $comm,
-	       $total_reads, $bytes_requested, $bytes_read);
-
-	if (++$count == $nlines) {
-	    last;
-	}
-    }
-
-    $count = 0;
-
-    printf("\nwrite counts by pid:\n\n");
-
-    printf("%6s  %20s  %10s  %13s\n", "pid", "comm",
-	   "# writes", "bytes_written");
-    printf("%6s  %-20s  %10s  %13s\n", "------", "--------------------",
-	   "----------", "-------------");
-
-    foreach my $pid (sort { ($writes{$b}{bytes_written} || 0) <=>
-			($writes{$a}{bytes_written} || 0)} keys %writes) {
-	my $comm = $writes{$pid}{comm} || "";
-	my $total_writes = $writes{$pid}{total_writes} || 0;
-	my $bytes_written = $writes{$pid}{bytes_written} || 0;
-
-	printf("%6s  %-20s  %10s  %13s\n", $pid, $comm,
-	       $total_writes, $bytes_written);
-
-	if (++$count == $nlines) {
-	    last;
-	}
-    }
-
-    %reads = ();
-    %writes = ();
-}
-
-my %unhandled;
-
-sub print_unhandled
-{
-    if ((scalar keys %unhandled) == 0) {
-	return;
-    }
-
-    print "\nunhandled events:\n\n";
-
-    printf("%-40s  %10s\n", "event", "count");
-    printf("%-40s  %10s\n", "----------------------------------------",
-	   "-----------");
-
-    foreach my $event_name (keys %unhandled) {
-	printf("%-40s  %10d\n", $event_name, $unhandled{$event_name});
-    }
-}
-
-sub trace_unhandled
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain) = @_;
-
-    $unhandled{$event_name}++;
-}
tools/perf/scripts/perl/wakeup-latency.pl deleted +0 -107
deleted file mode 100644
index 53444ff4ec7f..000000000000
@@ -1,107 +0,0 @@
-#!/usr/bin/perl -w
-# SPDX-License-Identifier: GPL-2.0-only
-# (c) 2009, Tom Zanussi <[email protected]>
-
-# Display avg/min/max wakeup latency
-
-# The common_* event handler fields are the most useful fields common to
-# all events.  They don't necessarily correspond to the 'common_*' fields
-# in the status files.  Those fields not available as handler params can
-# be retrieved via script functions of the form get_common_*().
-
-use 5.010000;
-use strict;
-use warnings;
-
-use lib "$ENV{'PERF_EXEC_PATH'}/scripts/perl/Perf-Trace-Util/lib";
-use lib "./Perf-Trace-Util/lib";
-use Perf::Trace::Core;
-use Perf::Trace::Util;
-
-my %last_wakeup;
-
-my $max_wakeup_latency;
-my $min_wakeup_latency;
-my $total_wakeup_latency = 0;
-my $total_wakeups = 0;
-
-sub sched::sched_switch
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain,
-	$prev_comm, $prev_pid, $prev_prio, $prev_state, $next_comm, $next_pid,
-	$next_prio) = @_;
-
-    my $wakeup_ts = $last_wakeup{$common_cpu}{ts};
-    if ($wakeup_ts) {
-	my $switch_ts = nsecs($common_secs, $common_nsecs);
-	my $wakeup_latency = $switch_ts - $wakeup_ts;
-	if ($wakeup_latency > $max_wakeup_latency) {
-	    $max_wakeup_latency = $wakeup_latency;
-	}
-	if ($wakeup_latency < $min_wakeup_latency) {
-	    $min_wakeup_latency = $wakeup_latency;
-	}
-	$total_wakeup_latency += $wakeup_latency;
-	$total_wakeups++;
-    }
-    $last_wakeup{$common_cpu}{ts} = 0;
-}
-
-sub sched::sched_wakeup
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain,
-	$comm, $pid, $prio, $success, $target_cpu) = @_;
-
-    $last_wakeup{$target_cpu}{ts} = nsecs($common_secs, $common_nsecs);
-}
-
-sub trace_begin
-{
-    $min_wakeup_latency = 1000000000;
-    $max_wakeup_latency = 0;
-}
-
-sub trace_end
-{
-    printf("wakeup_latency stats:\n\n");
-    print "total_wakeups: $total_wakeups\n";
-    if ($total_wakeups) {
-	printf("avg_wakeup_latency (ns): %u\n",
-	       avg($total_wakeup_latency, $total_wakeups));
-    } else {
-	printf("avg_wakeup_latency (ns): N/A\n");
-    }
-    printf("min_wakeup_latency (ns): %u\n", $min_wakeup_latency);
-    printf("max_wakeup_latency (ns): %u\n", $max_wakeup_latency);
-
-    print_unhandled();
-}
-
-my %unhandled;
-
-sub print_unhandled
-{
-    if ((scalar keys %unhandled) == 0) {
-	return;
-    }
-
-    print "\nunhandled events:\n\n";
-
-    printf("%-40s  %10s\n", "event", "count");
-    printf("%-40s  %10s\n", "----------------------------------------",
-	   "-----------");
-
-    foreach my $event_name (keys %unhandled) {
-	printf("%-40s  %10d\n", $event_name, $unhandled{$event_name});
-    }
-}
-
-sub trace_unhandled
-{
-    my ($event_name, $context, $common_cpu, $common_secs, $common_nsecs,
-	$common_pid, $common_comm, $common_callchain) = @_;
-
-    $unhandled{$event_name}++;
-}
tools/perf/tests/make +0 -2
index cf9d4b5d3153..7524de522802 100644
@@ -79,7 +79,6 @@ make_no_jevents     := NO_JEVENTS=1
 make_jevents_all    := JEVENTS_ARCH=all
 make_no_bpf_skel    := BUILD_BPF_SKEL=0
 make_gen_vmlinux_h  := GEN_VMLINUX_H=1
-make_libperl        := LIBPERL=1
 make_no_python_module := NO_PYTHON_MODULE=1
 make_no_scripts     := NO_PYTHON_MODULE=1
 make_no_slang       := NO_SLANG=1
@@ -175,7 +174,6 @@ run += make_no_jevents
 run += make_jevents_all
 run += make_no_bpf_skel
 run += make_gen_vmlinux_h
-run += make_libperl
 run += make_no_python_module
 run += make_no_scripts
 run += make_no_slang
tools/perf/tests/shell/coresight/test_arm_coresight_disasm.sh +4 -10
index 82cdb1762285..d298b18154b2 100755
@@ -20,13 +20,6 @@ skip_if_no_cs_etm_event || exit 2
 set -e
 glb_err=1
 
-# Relative path works whether it's installed or running from repo
-if [ -n "$PERF_EXEC_PATH" ] && [ -e "$PERF_EXEC_PATH/python/arm-cs-trace-disasm.py" ]; then
-	script_path="$PERF_EXEC_PATH/python/arm-cs-trace-disasm.py"
-else
-	script_path=$(dirname "$0")/../../../python/arm-cs-trace-disasm.py
-fi
-
 # shellcheck source=lib/setup_python.sh
 . "$(dirname "$0")"/../lib/setup_python.sh
 $PYTHON -c "import perf" 2>/dev/null || {
@@ -56,8 +49,8 @@ branch_search='[[:space:]](bl|b(\.(eq|ne|cs|cc|mi|pl|vs|vc|hi|ls|ge|lt|gt|le|al)
 if [ "$(id -u)" == 0 ] && [ -e /proc/kcore ]; then
 	echo "Testing kernel disassembly"
 	perf record -o ${perfdata} -e cs_etm//k --kcore -Se -m,64K -- touch $file > /dev/null 2>&1
-	$PYTHON ${script_path} -i ${perfdata} -d --stop-sample=2 \
-		-k ${perfdata}/kcore_dir/kcore 2> /dev/null > ${file}
+	perf script -i ${perfdata} arm-cs-trace-disasm -- \
+		-d --stop-sample=2 -k ${perfdata}/kcore_dir/kcore 2> /dev/null > ${file}
 	grep -q -E ${branch_search} ${file}
 	echo "Found kernel branches"
 else
@@ -68,7 +61,8 @@ fi
 ## Test user ##
 echo "Testing userspace disassembly"
 perf record -o ${perfdata} -e cs_etm//u -Se -m,64K -- touch $file > /dev/null 2>&1
-$PYTHON ${script_path} -i ${perfdata} -d --stop-sample=2 2> /dev/null > ${file}
+perf script -i ${perfdata} arm-cs-trace-disasm -- \
+	-d --stop-sample=2 2> /dev/null > ${file}
 grep -q -E ${branch_search} ${file}
 echo "Found userspace branches"
 
tools/perf/tests/shell/script_perl.sh deleted +0 -102
deleted file mode 100755
index b6d65b6fbda1..000000000000
@@ -1,102 +0,0 @@
-#!/bin/bash
-# perf script perl tests
-# SPDX-License-Identifier: GPL-2.0
-
-set -e
-
-# set PERF_EXEC_PATH to find scripts in the source directory
-perfdir=$(dirname "$0")/../..
-if [ -e "$perfdir/scripts/perl/Perf-Trace-Util" ]; then
-  export PERF_EXEC_PATH=$perfdir
-fi
-
-
-perfdata=$(mktemp /tmp/__perf_test_script_perl.perf.data.XXXXX)
-generated_script=$(mktemp /tmp/__perf_test_script.XXXXX.pl)
-
-cleanup() {
-  rm -f "${perfdata}"
-  rm -f "${generated_script}"
-  trap - EXIT TERM INT
-}
-
-trap_cleanup() {
-  echo "Unexpected signal in ${FUNCNAME[1]}"
-  cleanup
-  exit 1
-}
-trap trap_cleanup TERM INT
-trap cleanup EXIT
-
-check_perl_support() {
-	if perf check feature -q libperl; then
-		return 0
-	fi
-	echo "perf script perl test [Skipped: no libperl support]"
-	return 2
-}
-
-test_script() {
-	local event_name=$1
-	local expected_output=$2
-	local record_opts=$3
-
-	echo "Testing event: $event_name"
-
-	# Try to record. If this fails, it might be permissions or lack of support.
-	# We return 2 to indicate "skip this event" rather than "fail test".
-	if ! perf record -o "${perfdata}" -e "$event_name" $record_opts -- perf test -w thloop > /dev/null 2>&1; then
-		echo "perf script perl test [Skipped: failed to record $event_name]"
-		return 2
-	fi
-
-	echo "Generating perl script..."
-	if ! perf script -i "${perfdata}" -g "${generated_script}"; then
-		echo "perf script perl test [Failed: script generation for $event_name]"
-		return 1
-	fi
-
-	if [ ! -f "${generated_script}" ]; then
-		echo "perf script perl test [Failed: script not generated for $event_name]"
-		return 1
-	fi
-
-	echo "Executing perl script..."
-	output=$(perf script -i "${perfdata}" -s "${generated_script}" 2>&1)
-
-	if echo "$output" | grep -q "$expected_output"; then
-		echo "perf script perl test [Success: $event_name triggered $expected_output]"
-		return 0
-	else
-		echo "perf script perl test [Failed: $event_name did not trigger $expected_output]"
-		echo "Output was:"
-		echo "$output" | head -n 20
-		return 1
-	fi
-}
-
-check_perl_support || exit 2
-
-# Try tracepoint first
-test_script "sched:sched_switch" "sched::sched_switch" "-c 1" && res=0 || res=$?
-
-if [ $res -eq 0 ]; then
-	exit 0
-elif [ $res -eq 1 ]; then
-	exit 1
-fi
-
-# If tracepoint skipped (res=2), try task-clock
-# For generic events like task-clock, the generated script uses process_event()
-# which dumps data using Data::Dumper. We check for "$VAR1" which is standard Dumper output.
-test_script "task-clock" "\$VAR1" "-c 100" && res=0 || res=$?
-
-if [ $res -eq 0 ]; then
[… more lines in the raw message]

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_check_perf_trace_python.sh +1 -1
index a346e45eb18c..92cc7b1f0033 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_compaction_times_python.sh +3 -3
index ad950f3602b5..50397afaafed 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_event_analyzing_sample_python.sh +2 -1
index 4678edfd9e5b..a7a8ded003db 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_export_to_postgresql_python.sh +5 -3
index ce13a1aa7cd7..350813466700 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_export_to_sqlite_python.sh +2 -2
index 59280d372399..d3c5e22a0754 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_failed_syscalls_by_pid_python.sh +4 -3
index 5bbd1a0adb1e..215372d4e1c5 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_failed_syscalls_python.sh +1 -1
index 0cabb127d7e9..861c2ba71c0a 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_flamegraph_python.sh +4 -4
index c6f5cf80b79f..86313c72f53e 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_futex_contention_python.sh +1 -1
index 26b13d263d20..a8846ed68ac2 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_gecko_python.sh +1 -1
index eac9b2f8e3c7..de1d7fcf88b7 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_intel_pt_events_python.sh +1 -1
index 0d397792ced8..b5c3173fa2db 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_mem_phys_addr_python.sh +2 -1
index d094a0611a24..451692d5e089 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_net_dropmonitor_python.sh +1 -1
index d00be255d259..05056a897bc9 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_netdev_times_python.sh +1 -1
index bb0f8c30207f..393bf446efb2 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_powerpc_hcalls_python.sh +1 -1
index 5316c28f243f..19569c6d3613 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_rw_by_file_python.sh +1 -1
index 98218bf8a39e..f121597f418f 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_rw_by_pid_python.sh +1 -1
index da8b065d43de..41eaa29097a2 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_rwtop_python.sh +1 -1
index 062fca2dad14..05897e384702 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_sched_migration_python.sh +1 -1
index f243e86c6700..75465bcd3791 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_sctop_python.sh +2 -2
index cd38cdd4794c..007f2584cce6 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_stackcollapse_python.sh +3 -3
index a3b6c917e842..ce0f80407eec 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_stat_cpi_python.sh +2 -2
index 0960afa4c797..fe7562307634 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_syscall_counts_by_pid_python.sh +4 -3
index 9f2ad27751a2..45bbdc554c8f 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_syscall_counts_python.sh +2 -2
index 0c4b75499209..310e05d399f9 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_task_analyzer.sh +24 -34
index 3a97d58eec74..f99a637a6099 100755

Lines of this file are not shown. View the raw message.

tools/perf/tests/shell/test_wakeup_latency_python.sh +2 -2
index fc39ac117609..cb2571449168 100755

Lines of this file are not shown. View the raw message.

tools/perf/ui/browsers/scripts.c +7 -154
index b8a3383ec02a..d6d09b4a348c 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/Build +0 -3
index afcf98dc5006..512f2ca0cd1a 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/scripting-engines/Build deleted +0 -5
deleted file mode 100644
index 3f1dc10526f8..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/util/scripting-engines/trace-event-perl.c deleted +0 -770
deleted file mode 100644
index 410dc4cd0600..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/util/trace-event-parse.c +0 -65
index 9c015fc2bcfb..374cf82fd86e 100644

Lines of this file are not shown. View the raw message.

tools/perf/util/trace-event-scripting.c deleted +0 -398
deleted file mode 100644
index c78b317978dd..000000000000

Lines of this file are not shown. View the raw message.

tools/perf/util/trace-event.h +1 -71
index 1c342fce36bb..fa3824cf39fa 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.56.0.rc1.315.gc6ed9934b7-goog

Part of the diff is not shown here. View the raw message.

#407 lore raw
In reply to Ian Rogers
Quoted 10 lines · Ian Rogers

The perf script command has historically supported running Python and Perl scripts by embedding libpython and libperl. That approach has several drawbacks:
- high overhead from constructing Python dictionaries for every event (whether used by the script or not),
- complex build dependencies on specific Python/Perl libraries,
- threading and interpreter lifecycle complications from embedding the interpreter inside perf,
- no unified model for standalone scripts such as ilist.py, treport.py, tracepoint.py, and twatch.py.

So I applied it and tested on the containers, make -C tools/perf build-test and 'perf test', that has some flakiness running the new tests for these python scripts in parallel, nothing that prevents it from being merged now tho:

=== Test Summary ===
Passed main tests : 146
Passed subtests : 156
Skipped tests : 28
Failed tests : 13
List of failed tests:
72: Test dwarf unwind
88: daemon operations
101: perf kvm tests
111: perf record tests
112: perf record sample filtering (by BPF) tests 117: perf sched tests
137: check-perf-trace python test
138: compaction-times python test
141: failed-syscalls-by-pid python test 142: failed-syscalls python test
144: futex-contention python test
157: sctop python test
159: stat-cpi python test

root@x2:~# perf test 72
 72: Test dwarf unwind                                                                                         : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0

root@x2:~# perf test 88
 88: daemon operations                                                                                         : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0

root@x2:~# perf test 101
101: perf kvm tests                                                                                            : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0

root@x2:~# perf test 112 ; perf test 117 ; perf test 137 ; perf test 141 ; perf test 142 ; perf test 144 ; perf test 157; perf test 159
112: perf record sample filtering (by BPF) tests                                                               : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
117: perf sched tests : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
137: check-perf-trace python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
141: failed-syscalls-by-pid python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
142: failed-syscalls python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
144: futex-contention python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
157: sctop python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
159: stat-cpi python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0

root@x2:~# uname -a
Linux x2 7.2.5-200.fc44.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Sep 11 15:11:05 UTC 2026 x86_64 GNU/Linux
root@x2:~# cat /etc/os-release
NAME="Fedora Linux"
VERSION="44 (Workstation Edition)"
RELEASE_TYPE=stable
ID=fedora
VERSION_ID=44
VERSION_CODENAME=""
PRETTY_NAME="Fedora Linux 44 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:44"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f44/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=44
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=44
SUPPORT_END=2027-05-19
VARIANT="Workstation Edition"
VARIANT_ID=workstation
root@x2:~#
author reviewer
#408 lore raw
Quoted 136 lines · Arnaldo Carvalho de Melo
Quoted 10 lines · Ian Rogers

The perf script command has historically supported running Python and Perl scripts by embedding libpython and libperl. That approach has several drawbacks:
- high overhead from constructing Python dictionaries for every event (whether used by the script or not),
- complex build dependencies on specific Python/Perl libraries,
- threading and interpreter lifecycle complications from embedding the interpreter inside perf,
- no unified model for standalone scripts such as ilist.py, treport.py, tracepoint.py, and twatch.py.

So I applied it and tested on the containers, make -C tools/perf build-test and 'perf test', that has some flakiness running the new tests for these python scripts in parallel, nothing that prevents it from being merged now tho:

=== Test Summary ===
Passed main tests : 146
Passed subtests : 156
Skipped tests : 28
Failed tests : 13
List of failed tests:
72: Test dwarf unwind
88: daemon operations
101: perf kvm tests
111: perf record tests
112: perf record sample filtering (by BPF) tests 117: perf sched tests
137: check-perf-trace python test
138: compaction-times python test
141: failed-syscalls-by-pid python test 142: failed-syscalls python test
144: futex-contention python test
157: sctop python test
159: stat-cpi python test

root@x2:~# perf test 72
 72: Test dwarf unwind                                                                                         : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0

root@x2:~# perf test 88
 88: daemon operations                                                                                         : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0

root@x2:~# perf test 101
101: perf kvm tests                                                                                            : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0

root@x2:~# perf test 112 ; perf test 117 ; perf test 137 ; perf test 141 ; perf test 142 ; perf test 144 ; perf test 157; perf test 159
112: perf record sample filtering (by BPF) tests                                                               : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
117: perf sched tests : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
137: check-perf-trace python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
141: failed-syscalls-by-pid python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
142: failed-syscalls python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
144: futex-contention python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
157: sctop python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
159: stat-cpi python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0

root@x2:~# uname -a
Linux x2 7.2.5-200.fc44.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Sep 11 15:11:05 UTC 2026 x86_64 GNU/Linux
root@x2:~# cat /etc/os-release
NAME="Fedora Linux"
VERSION="44 (Workstation Edition)"
RELEASE_TYPE=stable
ID=fedora
VERSION_ID=44
VERSION_CODENAME=""
PRETTY_NAME="Fedora Linux 44 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:44"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f44/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
Quoted 8 lines
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=44
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=44
SUPPORT_END=2027-05-19
VARIANT="Workstation Edition"
VARIANT_ID=workstation
root@x2:~#

That's great! I'll dig into the flakes.

Thanks!
Ian

author reviewer
#409 lore raw
Quoted 148 lines · Ian Rogers
Quoted 136 lines · Arnaldo Carvalho de Melo
Quoted 10 lines · Ian Rogers

The perf script command has historically supported running Python and Perl scripts by embedding libpython and libperl. That approach has several drawbacks:
- high overhead from constructing Python dictionaries for every event (whether used by the script or not),
- complex build dependencies on specific Python/Perl libraries,
- threading and interpreter lifecycle complications from embedding the interpreter inside perf,
- no unified model for standalone scripts such as ilist.py, treport.py, tracepoint.py, and twatch.py.

So I applied it and tested on the containers, make -C tools/perf build-test and 'perf test', that has some flakiness running the new tests for these python scripts in parallel, nothing that prevents it from being merged now tho:

=== Test Summary ===
Passed main tests : 146
Passed subtests : 156
Skipped tests : 28
Failed tests : 13
List of failed tests:
72: Test dwarf unwind
88: daemon operations
101: perf kvm tests
111: perf record tests
112: perf record sample filtering (by BPF) tests 117: perf sched tests
137: check-perf-trace python test
138: compaction-times python test
141: failed-syscalls-by-pid python test 142: failed-syscalls python test
144: futex-contention python test
157: sctop python test
159: stat-cpi python test

root@x2:~# perf test 72
 72: Test dwarf unwind                                                                                         : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0

root@x2:~# perf test 88
 88: daemon operations                                                                                         : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0

root@x2:~# perf test 101
101: perf kvm tests                                                                                            : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0

root@x2:~# perf test 112 ; perf test 117 ; perf test 137 ; perf test 141 ; perf test 142 ; perf test 144 ; perf test 157; perf test 159
112: perf record sample filtering (by BPF) tests                                                               : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
117: perf sched tests : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
137: check-perf-trace python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
141: failed-syscalls-by-pid python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
142: failed-syscalls python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
144: futex-contention python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
157: sctop python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0
159: stat-cpi python test : Ok

=== Test Summary ===
Passed main tests : 1
Passed subtests : 0
Skipped tests : 0
Failed tests : 0

root@x2:~# uname -a
Linux x2 7.2.5-200.fc44.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Sep 11 15:11:05 UTC 2026 x86_64 GNU/Linux
root@x2:~# cat /etc/os-release
NAME="Fedora Linux"
VERSION="44 (Workstation Edition)"
RELEASE_TYPE=stable
ID=fedora
VERSION_ID=44
VERSION_CODENAME=""
PRETTY_NAME="Fedora Linux 44 (Workstation Edition)"
ANSI_COLOR="0;38;2;60;110;180"
LOGO=fedora-logo-icon
CPE_NAME="cpe:/o:fedoraproject:fedora:44"
DEFAULT_HOSTNAME="fedora"
HOME_URL="https://fedoraproject.org/"
DOCUMENTATION_URL="https://docs.fedoraproject.org/en-US/fedora/f44/"
SUPPORT_URL="https://ask.fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
Quoted 8 lines
REDHAT_BUGZILLA_PRODUCT="Fedora"
REDHAT_BUGZILLA_PRODUCT_VERSION=44
REDHAT_SUPPORT_PRODUCT="Fedora"
REDHAT_SUPPORT_PRODUCT_VERSION=44
SUPPORT_END=2027-05-19
VARIANT="Workstation Edition"
VARIANT_ID=workstation
root@x2:~#
Quoted 1 line

That's great! I'll dig into the flakes.

Just to add, testing with perf-tools-next:

```
$ make -C tools/perf O=/tmp/perf DESTDIR=/tmp/perf-install DEBUG=1 install
...
$ PERF_EXEC_PATH=/tmp/perf-install/libexec/perf-core
/tmp/perf-install/bin/perf script -l
List of available scripts:
  arm-cs-trace-disasm                  arm-cs-trace-disasm.py: ARM
CoreSight Trace Dump With Disassembler
  check-perf-trace                     Basic test of Python scripting
support for perf.
  compaction-times                     Report time spent in memory compaction.
  counting                             Example for counting perf events.
  event_analyzing_sample               General event handler in
Python, using SQLite to analyze events.
  export-to-postgresql                 Export perf data to a
postgresql database.
  export-to-sqlite                     Export perf data to a sqlite3 database.
  exported-sql-viewer                  exported-sql-viewer.py: view
data from sql database.
  failed-syscalls                      Failed system call counts.
  failed-syscalls-by-pid               Displays system-wide failed
system call totals, broken down by pid.
  flamegraph                           flamegraph.py - create flame
graphs from perf samples using perf python module
  futex-contention                     Measures futex contention.
  gecko                                gecko.py - Convert perf record
output to Firefox's gecko profile format
  ilist                                Interactive perf list.
  intel-pt-events                      Print Intel PT Events including
Power Events and PTWRITE.
  libxed                               Python wrapper for libxed.so
  mem-phys-addr                        mem-phys-addr.py: Resolve
physical address samples
  net_dropmonitor                      Monitor the system for dropped
packets and produce a report of drop locations and counts.
  netdev-times                         Display a process of packets
and processed time.
  parallel-perf                        Parallel perf script.
  perf_live                            Live event session helper using
perf.evlist.
  powerpc-hcalls                       Hypervisor call statistics
  rw-by-file                           Display r/w activity for files
read/written to for a given program.
  rw-by-pid                            Display r/w activity for all processes.
  rwtop                                Periodically displays
system-wide r/w call activity, broken down by pid.
  sched-migration                      Cpu task migration overview toy
  SchedGui                             SchedGui.py - Python extension
for perf script, basic GUI code for traces drawing and overview.
  sctop                                System call top
  stackcollapse                        stackcollapse.py - format perf
samples with one line per distinct call stack
  stat-cpi                             Calculate CPI from perf stat
data or live.
  syscall-counts                       Displays system-wide system
call totals, broken down by syscall.
  syscall-counts-by-pid                Displays system-wide system
call totals, broken down by syscall.
  task-analyzer                        Comprehensive perf tasks analysis.
  tracepoint                           Example showing how to enable a
tracepoint and access its fields.
  treport                              treport.py - perf report like
tool written using textual.
  twatch                               Example to show how to enable a
software event and track context switches.
  wakeup-latency                       Display avg/min/max wakeup latency.
$ sudo bash -c "PERF_EXEC_PATH=/tmp/perf-install/libexec/perf-core
/tmp/perf-install/bin/perf script ilist"
...
```

:-D

Thanks!
Ian