notes
perf stat -a sleep 10
perf stat -e cycles,instructions,cache-references,cache-misses,bus-cycles -a sleep 10
perf stat -e L1-dcache-loads,L1-dcache-load-misses,L1-dcache-stores -a sleep 10
perf stat -e dTLB-loads,dTLB-load-misses,dTLB-prefetch-misses -a sleep 10
perf stat -e LLC-loads,LLC-load-misses,LLC-stores,LLC-prefetches -a sleep 10
perf stat -e 'syscalls:sys_enter_*' -a sleep 10
perf stat -e 'vmscan:*' -a sleep 10
# CPU counter statistics for the specified command:
perf stat command
# Detailed CPU counter statistics (includes extras) for the specified command:
perf stat -d command
# CPU counter statistics for the specified PID, until Ctrl-C:
perf stat -p PID
# CPU counter statistics for the entire system, for 5 seconds:
perf stat -a sleep 5
# Various basic CPU statistics, system wide, for 10 seconds:
perf stat -e cycles,instructions,cache-references,cache-misses,bus-cycles -a sleep 10
# Various CPU level 1 data cache statistics for the specified command:
perf stat -e L1-dcache-loads,L1-dcache-load-misses,L1-dcache-stores command
# Various CPU data TLB statistics for the specified command:
perf stat -e dTLB-loads,dTLB-load-misses,dTLB-prefetch-misses command
# Various CPU last level cache statistics for the specified command:
perf stat -e LLC-loads,LLC-load-misses,LLC-stores,LLC-prefetches command
# Using raw PMC counters, eg, counting unhalted core cycles:
perf stat -e r003c -a sleep 5
# PMCs: counting cycles and frontend stalls via raw specification:
perf stat -e cycles -e cpu/event=0x0e,umask=0x01,inv,cmask=0x01/ -a sleep 5
# Count syscalls per-second system-wide:
perf stat -e raw_syscalls:sys_enter -I 1000 -a
# Count system calls by type for the specified PID, until Ctrl-C:
perf stat -e 'syscalls:sys_enter_*' -p PID
# Count system calls by type for the entire system, for 5 seconds:
perf stat -e 'syscalls:sys_enter_*' -a sleep 5
# Count scheduler events for the specified PID, until Ctrl-C:
perf stat -e 'sched:*' -p PID
# Count scheduler events for the specified PID, for 10 seconds:
perf stat -e 'sched:*' -p PID sleep 10
# Count ext4 events for the entire system, for 10 seconds:
perf stat -e 'ext4:*' -a sleep 10
# Count block device I/O events for the entire system, for 10 seconds:
perf stat -e 'block:*' -a sleep 10
# Count all vmscan events, printing a report every second:
perf stat -e 'vmscan:*' -a -I 1000# ftrace 记录上下文切换事件,结合kernelshark实用最佳
trace-cmd record -F -b 100000 -e 'sched_wakeup*' -e sched_switch -e 'sched_migrate*' ./cmd
# ftrace 记录函数调用,单位us
trace-cmd record -F -M 5 -c -p function_graph ./cmd
# perf kvm事件
perf kvm stat -e kvm0:kvm_exit -e kvm0:kvm_entry -e kvm0:kvm_cpuid -e kvm0:kvm_msr -e kvm0:kvm_apic_ipi -e kvm0:kvm_apic_accept_irq -e kvm0:kvm_ple_window -e kvm0:kvm_fpu -a sleep 10
# perf 火焰图流程,注意频率对结果的影响
perf record -F 999 -a -g ./cmd
perf script > out.perf
/root/FlameGraph-master/stackcollapse-perf.pl out.perf > out.folded
/root/FlameGraph-master/flamegraph.pl out.folded > result.svg
# 抓包,1G缓冲不丢包,按主机IP,不切割结果
tcpdump -ttt -n -i eth0 -s 0 -B 1048576 ip host xxx and yyy -w s.pcap
# 抓包,2G缓冲不丢包,按端口,自动切割结果
tcpdump -ttt -n -i eth0 -s 0 -B 2097151 tcp port xxx -G 10 -W 1 -w s.pcap