summaryrefslogtreecommitdiff
path: root/tools/perf/scripts/python
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-08-22 08:47:50 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2026-08-22 08:47:50 -0700
commit473f6c8f437b049f8ec015d57cd59bb983b1d85c (patch)
treeb06f7045dbd0fabfe6b26c523a1ffe30d5697a8c /tools/perf/scripts/python
parent47f05f71ad988c3180bdba807151e6e86ed75aa3 (diff)
parent9453bc6a69ef43755f1c28d5688cacdd69fa16bd (diff)
downloadlinux-473f6c8f437b049f8ec015d57cd59bb983b1d85c.tar.gz
linux-473f6c8f437b049f8ec015d57cd59bb983b1d85c.zip
Merge tag 'perf-tools-for-v7.3-2026-08-21' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools
Pull perf tools updates from Namhyung Kim: "perf c2c: - Add 'function view' in perf c2c report TUI (switched by pressing 'TAB' in the cacheline view) to organize samples around functions rather than cachelines in 3-level hierarchy: Level 1: Read-side function (sorted by estimated Cycles %) Level 2: Contending writer functions (sorted by Store count) Level 3: Shared cacheline addresses Users can navigate the entries and fold/unfold using 'e' key. An example output would look like below: Shared Data Functions Table (19 entries, sorted on Cycles %) Cycles Store % count Function / Contending function / Cacheline ---------------------------------------------------------------------- + 35.67% 876 + [k] cpupri_set + 24.31% 424 + [k] pull_rt_task - 16.53% 555 - [k] dequeue_pushable_task 145 - [k] pull_rt_task 145 0xff2d0082809da080 139 - [k] enqueue_pushable_task 70 0xff2d00a2071f9640 69 0xff2d0082809da000 python module support: - Extend "perf" python module so that it can be fully functional. The goal is to run scripts directly, not by 'perf script' command. This would give better performance as well as more control to build standalone programs with UI. - Add LiveSession helper (perf_live.py) to enable live event collection directly from Python using perf.evlist and perf.parse_events. perf stat: - Add --hide-zero-events option to suppress zero-count events - Reject conflicting --field-separator and --json-output options - Fix duplicate event output with --for-each-cgroup perf sched latency: - Add -H/--histogram and --hist-mode (log|linear) options to show scheduler wait latency histograms - Add --time option to filter analysis by time span in 'perf sched latency' ARM CoreSight: - Synthesize callchains for instruction samples from CoreSight trace using thread stack ('--itrace=g...') - Support call indentation ('perf script -F +callindent') to display call depth hierarchy on branch samples - Decode ETE (Embedded Trace Extension) exception packets Build system: - Add 'make install-build-deps' target to install required packages - Parallelize JSON and metric pre-computation in jevents.py for faster builds Vendor event/metric updates: - Add Intel Nova Lake events and update tables for existing models - Update AMD Zen 5 and Zen 6 core events - Update Arm64 Tegra410 metrics and PowerPC hcalls Internal changes and fixes: - Harden trace-event and synthetic event parsing against corrupted data - Fix unwinding of multi-threaded processes in libdw unwinder - Fix memory leaks in various commands and python bindings - Speed up 'perf test' shell tests" * tag 'perf-tools-for-v7.3-2026-08-21' of git://git.kernel.org/pub/scm/linux/kernel/git/perf/perf-tools: (232 commits) perf vendor events arm64: Fix Tegra410 Olympus event 0x0197 perf vendor events arm64: fix swapped MetricGroup for Tegra410 L1 prefetcher metrics perf evlist: Warn when 'sleep' workload is used without system-wide (-a) option perf c2c: document function view in perf-c2c man page perf c2c: add function view browser UI and cacheline detail perf c2c: build and finalize the function view hierarchy perf c2c: add function view hierarchy entry creation perf c2c: add function view stats merge and memory management perf c2c: add HPP list parsing for function view columns perf c2c: add column rendering for function view perf c2c: add function view model skeleton perf c2c: extract shared data structures into util/c2c.h perf test sample-parsing: Validate PERF_FORMAT_GROUP values without LOST perf dso: Replace assert with runtime check in dso__read_symbol() perf dso: Guard against cache underflow on short reads in dso_cache__memcpy() perf dso: Use stored fd error instead of stale errno in file_read() and file_size() perf dso: Guard close() against invalid fd in dso__decompress_kmodule_path() perf dso: Guard against errno==0 when dso__get_filename() returns NULL perf build: install-build-deps: add RHEL family devel package mapping perf build: Remove leftover feature tests for removed cxx and clang support ...
Diffstat (limited to 'tools/perf/scripts/python')
-rwxr-xr-xtools/perf/scripts/python/arm-cs-trace-disasm.py9
-rw-r--r--tools/perf/scripts/python/powerpc-hcalls.py137
2 files changed, 140 insertions, 6 deletions
diff --git a/tools/perf/scripts/python/arm-cs-trace-disasm.py b/tools/perf/scripts/python/arm-cs-trace-disasm.py
index 8f6fa4a007b4..42579f858684 100755
--- a/tools/perf/scripts/python/arm-cs-trace-disasm.py
+++ b/tools/perf/scripts/python/arm-cs-trace-disasm.py
@@ -31,18 +31,19 @@ from perf_trace_context import perf_sample_srccode, perf_config_get
#
# Output disassembly with objdump and auto detect vmlinux
# (when running on same machine.):
-# perf script -s scripts/python/arm-cs-trace-disasm.py -d
+# perf script --itrace=b -s scripts/python/arm-cs-trace-disasm.py \
+# -- -d
#
# Output disassembly with llvm-objdump:
-# perf script -s scripts/python/arm-cs-trace-disasm.py \
+# 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 -s scripts/python/arm-cs-trace-disasm.py \
+# 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 -s scripts/python/arm-cs-trace-disasm.py
+# perf script --itrace=b -s scripts/python/arm-cs-trace-disasm.py
def default_objdump():
config = perf_config_get("annotate.objdump")
diff --git a/tools/perf/scripts/python/powerpc-hcalls.py b/tools/perf/scripts/python/powerpc-hcalls.py
index 8b78dc790adb..fedce1b68cad 100644
--- a/tools/perf/scripts/python/powerpc-hcalls.py
+++ b/tools/perf/scripts/python/powerpc-hcalls.py
@@ -25,6 +25,7 @@ from Util import *
# } ...
# }
output = {}
+sort_key = 'count'
# d_enter: {
# cpu: {
@@ -112,15 +113,17 @@ hcall_table = {
420: 'H_CREATE_RPT',
424: 'H_REMOVE_RPT',
428: 'H_REGISTER_RPAGES',
- 432: 'H_DISABLE_AND_GETC',
+ 432: 'H_DISABLE_AND_GET',
436: 'H_ERROR_DATA',
440: 'H_GET_HCA_INFO',
444: 'H_GET_PERF_COUNT',
448: 'H_MANAGE_TRACE',
+ 456: 'H_GET_CPU_CHARACTERISTICS',
468: 'H_FREE_LOGICAL_LAN_BUFFER',
472: 'H_POLL_PENDING',
484: 'H_QUERY_INT_STATE',
580: 'H_ILLAN_ATTRIBUTES',
+ 584: 'H_ADD_LOGICAL_LAN_BUFFERS',
592: 'H_MODIFY_HEA_QP',
596: 'H_QUERY_HEA_QP',
600: 'H_QUERY_HEA',
@@ -135,11 +138,17 @@ hcall_table = {
644: 'H_ADD_CONN',
648: 'H_DEL_CONN',
664: 'H_JOIN',
+ 672: 'H_VASI_SIGNAL',
676: 'H_VASI_STATE',
+ 680: 'H_VIOCTL',
688: 'H_ENABLE_CRQ',
696: 'H_GET_EM_PARMS',
720: 'H_SET_MPP',
724: 'H_GET_MPP',
+ 732: 'H_REG_SUB_CRQ',
+ 736: 'H_FREE_SUB_CRQ',
+ 740: 'H_SEND_SUB_CRQ',
+ 744: 'H_SEND_SUB_CRQ_INDIRECT',
748: 'H_HOME_NODE_ASSOCIATIVITY',
756: 'H_BEST_ENERGY',
764: 'H_XIRR_X',
@@ -147,7 +156,88 @@ hcall_table = {
772: 'H_COP',
788: 'H_GET_MPP_X',
796: 'H_SET_MODE',
+ 808: 'H_BLOCK_REMOVE',
+ 856: 'H_CLEAR_HPT',
+ 864: 'H_REQUEST_VMC',
+ 876: 'H_RESIZE_HPT_PREPARE',
+ 880: 'H_RESIZE_HPT_COMMIT',
+ 892: 'H_REGISTER_PROC_TBL',
+ 896: 'H_SIGNAL_SYS_RESET',
+ 904: 'H_ALLOCATE_VAS_WINDOW',
+ 908: 'H_MODIFY_VAS_WINDOW',
+ 912: 'H_DEALLOCATE_VAS_WINDOW',
+ 916: 'H_QUERY_VAS_WINDOW',
+ 920: 'H_QUERY_VAS_CAPABILITIES',
+ 924: 'H_QUERY_NX_CAPABILITIES',
+ 928: 'H_GET_NX_FAULT',
+ 936: 'H_INT_GET_SOURCE_INFO',
+ 940: 'H_INT_SET_SOURCE_CONFIG',
+ 944: 'H_INT_GET_SOURCE_CONFIG',
+ 948: 'H_INT_GET_QUEUE_INFO',
+ 952: 'H_INT_SET_QUEUE_CONFIG',
+ 956: 'H_INT_GET_QUEUE_CONFIG',
+ 960: 'H_INT_SET_OS_REPORTING_LINE',
+ 964: 'H_INT_GET_OS_REPORTING_LINE',
+ 968: 'H_INT_ESB',
+ 972: 'H_INT_SYNC',
+ 976: 'H_INT_RESET',
+ 996: 'H_SCM_READ_METADATA',
+ 1000: 'H_SCM_WRITE_METADATA',
+ 1004: 'H_SCM_BIND_MEM',
+ 1008: 'H_SCM_UNBIND_MEM',
+ 1012: 'H_SCM_QUERY_BLOCK_MEM_BINDING',
+ 1016: 'H_SCM_QUERY_LOGICAL_MEM_BINDING',
+ 1020: 'H_SCM_UNBIND_ALL',
+ 1024: 'H_SCM_HEALTH',
+ 1048: 'H_SCM_PERFORMANCE_STATS',
+ 1052: 'H_PKS_GET_CONFIG',
+ 1056: 'H_PKS_SET_PASSWORD',
+ 1060: 'H_PKS_GEN_PASSWORD',
+ 1068: 'H_PKS_WRITE_OBJECT',
+ 1072: 'H_PKS_GEN_KEY',
+ 1076: 'H_PKS_READ_OBJECT',
+ 1080: 'H_PKS_REMOVE_OBJECT',
+ 1084: 'H_PKS_CONFIRM_OBJECT_FLUSHED',
+ 1096: 'H_RPT_INVALIDATE',
+ 1100: 'H_SCM_FLUSH',
+ 1104: 'H_GET_ENERGY_SCALE_INFO',
+ 1108: 'H_PKS_SIGNED_UPDATE',
+ 1112: 'H_HTM',
+ 1116: 'H_WATCHDOG',
+ # Platform specific hcalls used by KVM on PowerVM
+ 1120: 'H_GUEST_GET_CAPABILITIES',
+ 1124: 'H_GUEST_SET_CAPABILITIES',
+ 1136: 'H_GUEST_CREATE',
+ 1140: 'H_GUEST_CREATE_VCPU',
+ 1144: 'H_GUEST_GET_STATE',
+ 1148: 'H_GUEST_SET_STATE',
+ 1152: 'H_GUEST_RUN_VCPU',
+ 1156: 'H_GUEST_COPY_MEMORY',
+ 1160: 'H_GUEST_DELETE',
+ # Key wrapping hcalls
+ 1168: 'H_PKS_WRAP_OBJECT',
+ 1172: 'H_PKS_UNWRAP_OBJECT',
+ # Platform-specific hcalls used by the Ultravisor
+ 61184: 'H_SVM_PAGE_IN',
+ 61188: 'H_SVM_PAGE_OUT',
+ 61192: 'H_SVM_INIT_START',
+ 61196: 'H_SVM_INIT_DONE',
+ 61204: 'H_SVM_INIT_ABORT',
+ # Platform specific hcalls used by KVM
61440: 'H_RTAS',
+ # Platform specific hcalls used by QEMU/SLOF
+ 61441: 'H_LOGICAL_MEMOP',
+ 61442: 'H_CAS',
+ 61443: 'H_UPDATE_DT',
+ # Platform specific hcalls provided by PHYP
+ 61560: 'H_GET_24X7_CATALOG_PAGE',
+ 61564: 'H_GET_24X7_DATA',
+ 61568: 'H_GET_PERF_COUNTER_INFO',
+ # Platform-specific hcalls used for nested HV KVM
+ 63488: 'H_SET_PARTITION_TABLE',
+ 63492: 'H_ENTER_NESTED',
+ 63496: 'H_TLB_INVALIDATE',
+ 63500: 'H_COPY_TOFROM_GUEST',
}
def hcall_table_lookup(opcode):
@@ -158,10 +248,53 @@ def hcall_table_lookup(opcode):
print_ptrn = '%-28s%10s%10s%10s%10s'
+def sort_output(opcode):
+ stats = output[opcode]
+
+ if sort_key == 'min':
+ return stats['min']
+ if sort_key == 'max':
+ return stats['max']
+ if sort_key == 'avg':
+ return stats['time'] // stats['cnt']
+
+ return stats['cnt']
+
+def trace_begin():
+ global sort_key
+
+ valid_sort_keys = ['count', 'min', 'max', 'avg']
+
+ i = 1
+ while i < len(sys.argv):
+ arg = sys.argv[i]
+
+ if arg == '-s' or arg == '--sort':
+ if i + 1 >= len(sys.argv):
+ print("Error: -s/--sort requires a sort key argument")
+ sys.exit(1)
+ sort_key = sys.argv[i + 1]
+ i += 2
+ continue
+
+ if arg.startswith('--sort='):
+ sort_key = arg.split('=', 1)[1]
+ i += 1
+ continue
+
+ i += 1
+
+ if sort_key not in valid_sort_keys:
+ print(f"Error: Invalid sort key '{sort_key}'. Valid options are: {', '.join(valid_sort_keys)}")
+ sys.exit(1)
+
+ print("SORT KEY =", sort_key)
+
def trace_end():
print(print_ptrn % ('hcall', 'count', 'min(ns)', 'max(ns)', 'avg(ns)'))
print('-' * 68)
- for opcode in output:
+ for opcode in sorted(output, key = sort_output,
+ reverse=True):
h_name = hcall_table_lookup(opcode)
time = output[opcode]['time']
cnt = output[opcode]['cnt']