# 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])) 'linux-4.6.y'>linux-4.6.y Hosts the 0x221E linux distro kernel.Ubuntu
summaryrefslogtreecommitdiff
AgeCommit message (Expand)Author
2022-12-02vfio-iommufd: Support iommufd for physical VFIO devicesJason Gunthorpe
2022-09-21vfio/pci: Use the new device life cycle helpersYi Liu
2022-09-01vfio/pci: Split linux/vfio_pci_core.hJason Gunthorpe
2022-05-13Merge remote-tracking branch 'iommu/vfio-notifier-fix' into v5.19/vfio/nextAlex Williamson
2022-05-11vfio/pci: Remove vfio_device_get_from_dev()Jason Gunthorpe
2022-05-11vfio/pci: Have all VFIO PCI drivers store the vfio_pci_core_device in drvdataJason Gunthorpe
2022-04-28vfio: Set DMA ownership for VFIO devicesLu Baolu
2022-03-03vfio: Have the core code decode the VFIO_DEVICE_FEATURE ioctlJason Gunthorpe
2021-08-26vfio/pci: Introduce vfio_pci_core.koMax Gurtovoy
2021-08-26PCI / VFIO: Add 'override_only' support for VFIO PCI sub systemMax Gurtovoy
2021-08-26vfio/pci: Move module parameters to vfio_pci.cYishai Hadas
2021-08-26vfio/pci: Move igd initialization to vfio_pci.cMax Gurtovoy
2021-08-26vfio/pci: Split the pci_driver code out of vfio_pci_core.cMax Gurtovoy
2021-08-26vfio/pci: Rename vfio_pci.c to vfio_pci_core.cMax Gurtovoy
2021-08-11vfio/pci: Reorganize VFIO_DEVICE_PCI_HOT_RESET to use the device setJason Gunthorpe
2021-08-11vfio/pci: Change vfio_pci_try_bus_reset() to use the dev_setJason Gunthorpe
2021-08-11vfio/pci: Move to the device set infrastructureYishai Hadas
2021-08-11vfio: Introduce a vfio_uninit_group_dev() API callMax Gurtovoy
2021-06-30vfio/pci: Handle concurrent vma faultsAlex Williamson
2021-06-24vfio: use the new pci_dev_trylock() helper to simplify try lockLuis Chamberlain
2021-06-15vfio: centralize module refcount in subsystem layerMax Gurtovoy
2021-04-28Merge tag 'vfio-v5.13-rc1' of git://github.com/awilliam/linux-vfioLinus Torvalds
2021-04-13vfio/pci: Add missing range check in vfio_pci_mmapChristian A. Ehrhardt
2021-04-06Merge branches 'v5.13/vfio/embed-vfio_device', 'v5.13/vfio/misc' and 'v5.13/v...Alex Williamson
2021-04-06vfio: Remove device_data from the vfio bus driver APIJason Gunthorpe
2021-04-06vfio/pci: Replace uses of vfio_device_data() with container_ofJason Gunthorpe
2021-04-06vfio: Make vfio_device_ops pass a 'struct vfio_device *' instead of 'void *'Jason Gunthorpe
2021-04-06vfio/pci: Use vfio_init/register/unregister_group_devJason Gunthorpe
2021-04-06vfio/pci: Re-order vfio_pci_probe()Jason Gunthorpe
2021-04-06vfio/pci: Move VGA and VF initialization to functionsJason Gunthorpe
2021-04-06vfio/pci: remove vfio_pci_nvlink2Christoph Hellwig
2021-04-06vfio/pci: Remove an unnecessary blank line in vfio_pci_enableZhou Wang
2021-04-06vfio: pci: Spello fix in the file vfio_pci.cBhaskar Chowdhury
2021-02-19vfio/pci: remove CONFIG_VFIO_PCI_ZDEV from KconfigMax Gurtovoy
2020-12-02vfio-pci: Use io_remap_pfn_range() for PCI IO memoryJason Gunthorpe
2020-12-02vfio/pci: Move dummy_resources_list init in vfio_pci_probe()Eric Auger
2020-11-03vfio/pci: Bypass IGD init in case of -ENODEVFred Gao
2020-10-22Merge tag 'vfio-v5.10-rc1' of git://github.com/awilliam/linux-vfioLinus Torvalds
2020-10-16mm: remove the now-unnecessary mmget_still_valid() hackJann Horn
2020-10-12Merge branches 'v5.10/vfio/fsl-mc-v6' and 'v5.10/vfio/zpci-info-v3' into v5.1...Alex Williamson
2020-10-12vfio-pci/zdev: Add zPCI capabilities to VFIO_DEVICE_GET_INFOMatthew Rosato
2020-09-21vfio/pci: Remove redundant declaration of vfio_pci_driverZenghui Yu
2020-08-23treewide: Use fallthrough pseudo-keywordGustavo A. R. Silva