summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python/stackcollapse.py
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-10-30 21:54:38 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2026-10-30 21:54:38 -0700
commitdd384658c738d15783a786d3af2851e02490f171 (patch)
tree63b96f8ba0e7b33ddc8d44506dce5ac39fed77aa /tools/perf/scripts/python/stackcollapse.py
parent60aba79a50127e92d8c4a663d35b855e52a9da01 (diff)
parent4626d370ae89b8af4d46a45372b269f926ec662d (diff)
Merge tag 'perf-tools-for-v7.4-1-2026-10-30' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next
Pull perf tool updates from Arnaldo Carvalho de Melo: - Support instruction tracking on arm64 for data type profiling, resolving stack, global, per-CPU and 'current' variable accesses, so that 'perf annotate --data-type' resolves types on arm64 the way it does on x86. - Port the Python scripts to the perf module and standalone execution, and improve the module: lazy sample callchains and event copies, GIL handling, better session/thread lookup, new treport, flamegraph and sqlite/postgres exporters. - Reenable and fix the attribute expectation test suite: per-PMU bit masks, other core PMUs' events, dummy tracking events, group checks and spelled out skip reasons. - perf trace: filter the target's tasks in BPF, open the BPF output event on every CPU, add an option to disable syscall augmentation and raise TRACE_AUG_MAX_BUF. - perf jitdump: harden record parsing, validating unwinding sizes and symbol names, byte-swapping debug entries via safe accessors and fixing frees on error paths. - perf annotate-data fixes: bound the member nesting recursion, resolve type DIEs in the debug file they came from, adjust the offset for flex-arrays and show the sample count in the data-type browser. - perf symbol and debug info: try linked debug files for DSOs, avoid repeated failing searches, set binary/symtab types for split kallsyms, JIT maps and the build-id cache, fix libbfd symbol loading. - perf config: serialize config file access with a mutex, add the DEFINE_MUTEX() and DO_ONCE() primitives and a robust process shared mutex, add the core.hybrid-merge option. - perf report: add --progress and --no-progress options. - perf mem: add a false sharing workload to 'perf test', request PERF_SAMPLE_CPU by default, use the IBS swfilt filter when available and decode L0 in the memory level. - perf test: take turns using the perf mlock budget in the mmaping tests, add the 'needs_mlock' suite flag, scope the probe based tests to their PID and make more tests non-exclusive. - perf vendor events intel: update events and metrics to TMA 5.2, refresh the event tables and fix umask encodings. - perf build: run shellcheck, mypy and pylint in parallel, make pylint opt-out with NO_PYLINT=1, fix clean and install dependencies. - Add a script and a 'make sync-headers' target to sync the tools/ copies of kernel headers with the kernel sources, plus the resulting syncs of the cpufeatures, KVM, fs, mount, fcntl, socket, rtnetlink, if_addr and sound headers. - Fix cs-etm HW_ID mapping synthesis for raw trace, queue teardown leaks and duplicate v0 global mappings. - Add a 'perf bench atomic' benchmark for atomic operations. - Filter events before creating lock_stat in 'perf lock contention'. - Add a 'perf test' case for events re-armed with PERF_EVENT_IOC_REFRESH. - Fix memory leaks on 'perf c2c' output fields and add function view stdio coverage to its test. - Fix a NULL dereference resolving callchains in 'perf machine'. - Optimize the libdw fallback when DWARF is missing and try the symbol file first when checking for debuginfo. - Don't call eprintf() in pr_debugN() when not verbose. - Don't delete cumulative caller entries before the stat_acc decays in 'perf report'. - Fix ring buffer cursor handling: keep the consumed cursor in forward mode and use the head selected by read_init. - Fix 'perf test mmap-basic' user rdpmc detection and only test userspace reading on supported platforms. - Build fixes: include sys/types.h for ssize_t, errno.h before kernel headers and fix jevents.py type annotations for mypy 2.x. * tag 'perf-tools-for-v7.4-1-2026-10-30' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools-next: (425 commits) perf machine: Fix NULL deref in thread__resolve_callchain_sample() perf pmu-events: Fix jevents.py type annotations for mypy 2.x perf parse-events: Include errno.h before kernel headers perf print_insn: Include sys/types.h for ssize_t perf tests mmap-basic: Fix user rdpmc detection logic perf tests mmap-basic: Only test userspace reading on supported platforms perf mmap: Preserve the consumed cursor in forward mode perf mmap: Use the head selected by read_init perf hist: Do not delete cumulative caller entries before stat_acc decays perf debug: Avoid calling eprintf() in pr_debugN() when verbose < n perf libdw: Optimize fallback logic for missing DWARF tools headers: Sync KVM headers with the kernel sources tools headers: Sync UAPI sound/asound.h with the kernel sources tools headers: Sync UAPI linux/mount.h with the kernel sources tools headers: Sync UAPI linux/fs.h with the kernel sources tools headers: Sync UAPI linux/fcntl.h with the kernel sources tools headers: Sync linux/socket.h with the kernel sources tools arch x86: Sync the cpufeatures.h copy with the kernel sources tools headers UAPI: Sync linux/rtnetlink.h with the kernel sources tools headers UAPI: Sync linux/if_addr.h with the kernel sources ...
Diffstat (limited to 'tools/perf/scripts/python/stackcollapse.py')
-rwxr-xr-xtools/perf/scripts/python/stackcollapse.py127
1 files changed, 0 insertions, 127 deletions
diff --git a/tools/perf/scripts/python/stackcollapse.py b/tools/perf/scripts/python/stackcollapse.py
deleted file mode 100755
index b1c4def1410a..000000000000
--- a/tools/perf/scripts/python/stackcollapse.py
+++ /dev/null
@@ -1,127 +0,0 @@
-# stackcollapse.py - format perf samples with one line per distinct call stack
-# SPDX-License-Identifier: GPL-2.0
-#
-# This script's output has two space-separated fields. The first is a semicolon
-# separated stack including the program name (from the "comm" field) and the
-# function names from the call stack. The second is a count:
-#
-# swapper;start_kernel;rest_init;cpu_idle;default_idle;native_safe_halt 2
-#
-# The file is sorted according to the first field.
-#
-# Input may be created and processed using:
-#
-# perf record -a -g -F 99 sleep 60
-# perf script report stackcollapse > out.stacks-folded
-#
-# (perf script record stackcollapse works too).
-#
-# Written by Paolo Bonzini <pbonzini@redhat.com>
-# Based on Brendan Gregg's stackcollapse-perf.pl script.
-
-from __future__ import print_function
-
-import os
-import sys
-from collections import defaultdict
-from optparse import OptionParser, make_option
-
-sys.path.append(os.environ['PERF_EXEC_PATH'] + \
- '/scripts/python/Perf-Trace-Util/lib/Perf/Trace')
-
-from perf_trace_context import *
-from Core import *
-from EventClass import *
-
-# command line parsing
-
-option_list = [
- # formatting options for the bottom entry of the stack
- make_option("--include-tid", dest="include_tid",
- action="store_true", default=False,
- help="include thread id in stack"),
- make_option("--include-pid", dest="include_pid",
- action="store_true", default=False,
- help="include process id in stack"),
- make_option("--no-comm", dest="include_comm",
- action="store_false", default=True,
- help="do not separate stacks according to comm"),
- make_option("--tidy-java", dest="tidy_java",
- action="store_true", default=False,
- help="beautify Java signatures"),
- make_option("--kernel", dest="annotate_kernel",
- action="store_true", default=False,
- help="annotate kernel functions with _[k]")
-]
-
-parser = OptionParser(option_list=option_list)
-(opts, args) = parser.parse_args()
-
-if len(args) != 0:
- parser.error("unexpected command line argument")
-if opts.include_tid and not opts.include_comm:
- parser.error("requesting tid but not comm is invalid")
-if opts.include_pid and not opts.include_comm:
- parser.error("requesting pid but not comm is invalid")
-
-# event handlers
-
-lines = defaultdict(lambda: 0)
-
-def process_event(param_dict):
- def tidy_function_name(sym, dso):
- if sym is None:
- sym = '[unknown]'
-
- sym = sym.replace(';', ':')
- if opts.tidy_java:
- # the original stackcollapse-perf.pl script gives the
- # example of converting this:
- # Lorg/mozilla/javascript/MemberBox;.<init>(Ljava/lang/reflect/Method;)V
- # to this:
- # org/mozilla/javascript/MemberBox:.init
- sym = sym.replace('<', '')
- sym = sym.replace('>', '')
- if sym[0] == 'L' and sym.find('/'):
- sym = sym[1:]
- try:
- sym = sym[:sym.index('(')]
- except ValueError:
- pass
-
- if opts.annotate_kernel and dso == '[kernel.kallsyms]':
- return sym + '_[k]'
- else:
- return sym
-
- stack = list()
- if 'callchain' in param_dict:
- for entry in param_dict['callchain']:
- entry.setdefault('sym', dict())
- entry['sym'].setdefault('name', None)
- entry.setdefault('dso', None)
- stack.append(tidy_function_name(entry['sym']['name'],
- entry['dso']))
- else:
- param_dict.setdefault('symbol', None)
- param_dict.setdefault('dso', None)
- stack.append(tidy_function_name(param_dict['symbol'],
- param_dict['dso']))
-
- if opts.include_comm:
- comm = param_dict["comm"].replace(' ', '_')
- sep = "-"
- if opts.include_pid:
- comm = comm + sep + str(param_dict['sample']['pid'])
- sep = "/"
- if opts.include_tid:
- comm = comm + sep + str(param_dict['sample']['tid'])
- stack.append(comm)
-
- stack_string = ';'.join(reversed(stack))
- lines[stack_string] = lines[stack_string] + 1
-
-def trace_end():
- list = sorted(lines)
- for stack in list:
- print("%s %d" % (stack, lines[stack]))