# 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 # 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;.(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])) e='linux-4.5.y'>linux-4.5.y Hosts the 0x221E linux distro kernel.Ubuntu
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2022-06-17drm/i915: Improve user experience and driver robustness under SIGINT or similarTvrtko Ursulin
2022-05-06drm/i915: Don't use DRM_DEBUG_WARN_ON for ring unexpectedly not idleTvrtko Ursulin
2022-03-22drm/i915/gt: fix i915_reg_t initializationJani Nikula
2022-02-14drm/i915: don't include drm_cache.h in i915_drv.hJani Nikula
2022-02-11drm/i915: split out i915_gem_internal.h from i915_drv.hJani Nikula
2022-02-02drm/i915: Move GT registers to their own header fileMatt Roper
2022-01-31Merge drm/drm-next into drm-intel-nextRodrigo Vivi
2022-01-11drm/i915/gt: Move engine registers to their own headerMatt Roper
2022-01-11drm/i915: Use RING_PSMI_CTL rather than per-engine macrosMatt Roper
2021-11-19drm/i915: vma is always backed by an object.Maarten Lankhorst
2021-10-18drm/i915: Replace the unconditional clflush with drm_clflush_virt_range()Ville Syrjälä
2021-09-24drm/i915/gt: Register the migrate contexts with their enginesThomas Hellström
2021-08-25drm/i915: s/0/NULL/Ville Syrjälä
2021-07-27drm/i915/guc: Support request cancellationMatthew Brost
2021-07-27drm/i915/guc: Implement banned contexts for GuC submissionMatthew Brost
2021-07-27drm/i915: Move active request tracking to a vfuncMatthew Brost
2021-07-02drm/i915: Use the correct IRQ during resumeThomas Zimmermann
2021-06-18drm/i915: Move active tracking to i915_sched_engineMatthew Brost
2021-06-05drm/i915/gt: replace IS_GEN and friends with GRAPHICS_VERLucas De Marchi
2021-05-25drm/i915/gt: Move CS interrupt handler to the backendChris Wilson
2021-05-25drm/i915/gt: Move engine setup out of set_default_submissionChris Wilson
2021-04-08Merge tag 'drm-intel-gt-next-2021-04-06' of git://anongit.freedesktop.org/drm...Dave Airlie
2021-03-24drm/i915: Protect against request freeing during cancellation on wedgingChris Wilson
2021-03-24drm/i915/gt: Insert spaces into GEN3_L3LOG_SIZE/4Chris Wilson
2021-03-24drm/i915/gt: SPDX cleanupChris Wilson
2021-03-24drm/i915/gt: Call stop_ring() from ring resume, againChris Wilson
2021-03-24drm/i915: Make ring submission compatible with obj->mm.lock removal, v2.Maarten Lankhorst
2021-01-19drm/i915/gt: Pull ring submission resume under its caller forcewakeChris Wilson
2021-01-19drm/i915/gt: Disable the ring before resetting HEAD/TAILChris Wilson
2021-01-19drm/i915/gt: Lift stop_ring() to reset_prepareChris Wilson
2021-01-15drm/i915: Mark up protected uses of 'i915_request_completed'Chris Wilson
2021-01-14drm/i915/gt: Prune inlinesChris Wilson
2021-01-14drm/i915/gt: Reapply ppgtt enabling after engine resetsChris Wilson
2021-01-13drm/i915/gt: Replace open-coded intel_engine_stop_cs()Chris Wilson
2021-01-12drm/i915: Allow the sysadmin to override security mitigationsChris Wilson
2021-01-12drm/i915/gt: Restore clear-residual mitigations for Ivybridge, BaytrailChris Wilson
2021-01-09drm/i915: Refactor marking a request as EIOChris Wilson
2020-12-22drm/i915/gt: Track all timelines created using the HWSPChris Wilson
2020-12-10drm/i915/gt: Mark legacy ring context as lostChris Wilson
2020-11-13Merge tag 'drm-intel-gt-next-2020-11-12-1' of git://anongit.freedesktop.org/d...Dave Airlie
2020-09-30drm/i915/gt: Signal cancelled requestsChris Wilson
2020-09-09Merge tag 'drm-intel-gt-next-2020-09-07' of git://anongit.freedesktop.org/drm...Dave Airlie
2020-09-07drm/i915: Make sure execbuffer always passes ww state to i915_vma_pin.Maarten Lankhorst
2020-09-07drm/i915: Rework intel_context pinning to do everything outside of pin_mutexMaarten Lankhorst
2020-09-07drm/i915/gt: Switch to object allocations for page directoriesChris Wilson
2020-09-07drm/i915/gt: Distinguish the virtual breadcrumbs from the irq breadcrumbsChris Wilson