SlideShare a Scribd company logo
BPF Performance Tools
chapter 4 - bcc
Viller Hsiao
Feb. 17, 2020
What’s in Chapter 4
BPF Compiler Collection (BCC)
BCC is a toolkit for creating efficient kernel tracing and manipulation programs, and
includes several useful tools and examples. It makes use of extended BPF (Berkeley
Packet Filters), formally known as eBPF, a new feature that was first added to Linux 3.15.
Much of what BCC uses requires Linux 4.1 and above. (4.9 and up is better)
Overview (1/3)
● Use bcc
○ How to install bcc
■ with man page
■ example files
○ Tools overview
● Develop bcc program
○ bcc internals
○ debugging bcc
Overview (2/3)
● Use bcc
○ How to install bcc
○ Tools overview
● Develop bcc program
○ bcc internals
○ debugging bcc
Overview (3/3)
● Use bcc
○ How to install bcc
○ Tools overview
● Develop bcc program
○ bcc internals
○ debugging bcc
Example
bcc/examples/tracing/task_switch.py
task_switch.py
[/path/to/bcc/examples/tracing]% sudo python task_switch.py
task_switch[ 0-> 2520]=10
task_switch[14980-> 0]=1
task_switch[ 1096-> 0]=1
task_switch[19347->14055]=1
task_switch[14423-> 0]=1
task_switch[ 0-> 53]=1
task_switch[ 0->28879]=60
At First Glance
https://vignette.wikia.nocookie.net/pttpedia/images/4/48/File
_52cb83b426b60.jpg/revision/latest/scale-to-width-down/34
0?cb=20180122134757&path-prefix=zh
Main Parts
1. BPF program to run in
kernel
2. Kernel tracing tool to use
3. Retrieve data and
do some post processing
What’s the Program Do?
Translation
When kernel run to <target>,
use <tracing mechanism> to execute <handler>.
The handler record some <statistics> or do <something>.
(Like a function decorator in Python)
Actions
When kernel run to finish_task_switch,
use kprobe to execute cond_sched.
The handler store counts of task switch as hash map,
which is indexed by (prev_pid, curr_pid) pairs.
static struct rq * finish_task_switch(struct task_struct *prev)
BPF helper
Recorded Data Manipulation
When kernel run to finish_task_switch,
use kprobe to execute cond_sched.
The handler store counts of task switch as hash map,
which is indexed by (prev_pid, curr_pid) pairs.
翻訳コンニャク
When kernel run to finish_task_switch,
use kprobe to execute cond_sched.
The handler store counts of task switch as hash map,
which is indexed by (prev_pid, curr_pid) pairs.
Resources for bcc Programming
● bcc Reference Guide
○ BPF C
○ bcc Python
● bpftrace -l
Other resources
● If it’s hard to use bpftrace on your machine ...
● /sys/kernel/tracing
○ available_events
■ tracepoint
○ tracepoint format
■ /sys/kernel/tracing/<type>/<event>/format
■ e.g. events/irq/softirq_entry/format
○ available_filter_functions
■ kprobe on function entry
● “perf list”
○ pmu events
Alternative Tools
Alternative Profiling Tools
● bpftrace
● ftrace / perf
○ perf-tools, by Brendan Gregg, before bcc
○ iosnoop vs biosnoop-bpfcc
● Other frontends
○ systemtap, LTTng and so on
Q & A

More Related Content

PDF
Spying on the Linux kernel for fun and profit
ODP
Linux kernel tracing superpowers in the cloud
PDF
eBPF Trace from Kernel to Userspace
PDF
BPF Internals (eBPF)
PDF
eBPF Perf Tools 2019
PPTX
Understanding eBPF in a Hurry!
PPTX
eBPF Basics
PDF
Linux 4.x Tracing: Performance Analysis with bcc/BPF
Spying on the Linux kernel for fun and profit
Linux kernel tracing superpowers in the cloud
eBPF Trace from Kernel to Userspace
BPF Internals (eBPF)
eBPF Perf Tools 2019
Understanding eBPF in a Hurry!
eBPF Basics
Linux 4.x Tracing: Performance Analysis with bcc/BPF

What's hot (20)

PDF
Performance Analysis Tools for Linux Kernel
PDF
bcc/BPF tools - Strategy, current tools, future challenges
PDF
Linux 4.x Tracing Tools: Using BPF Superpowers
PDF
LPC2019 BPF Tracing Tools
PDF
UM2019 Extended BPF: A New Type of Software
PDF
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021
PDF
Security Monitoring with eBPF
PDF
Low Overhead System Tracing with eBPF
PDF
Building Network Functions with eBPF & BCC
PPTX
eBPF Workshop
POTX
Performance Tuning EC2 Instances
PDF
netfilter and iptables
PDF
BPF / XDP 8월 세미나 KossLab
ODP
eBPF maps 101
PDF
Performance Wins with BPF: Getting Started
PPTX
Staring into the eBPF Abyss
PDF
Kernel development
PDF
New Ways to Find Latency in Linux Using Tracing
PDF
Yet another introduction to Linux RCU
PPTX
Berkeley Packet Filters
Performance Analysis Tools for Linux Kernel
bcc/BPF tools - Strategy, current tools, future challenges
Linux 4.x Tracing Tools: Using BPF Superpowers
LPC2019 BPF Tracing Tools
UM2019 Extended BPF: A New Type of Software
Tracing MariaDB server with bpftrace - MariaDB Server Fest 2021
Security Monitoring with eBPF
Low Overhead System Tracing with eBPF
Building Network Functions with eBPF & BCC
eBPF Workshop
Performance Tuning EC2 Instances
netfilter and iptables
BPF / XDP 8월 세미나 KossLab
eBPF maps 101
Performance Wins with BPF: Getting Started
Staring into the eBPF Abyss
Kernel development
New Ways to Find Latency in Linux Using Tracing
Yet another introduction to Linux RCU
Berkeley Packet Filters
Ad

Similar to Bpf performance tools chapter 4 bcc (20)

PDF
Systems@Scale 2021 BPF Performance Getting Started
PDF
Performance Wins with eBPF: Getting Started (2021)
PDF
Efficient System Monitoring in Cloud Native Environments
PDF
Kernel bug hunting
PPT
Turbo C
PDF
ebpf and IO Visor: The What, how, and what next!
PDF
Using eBPF to Measure the k8s Cluster Health
PDF
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
PDF
eBPF Debugging Infrastructure - Current Techniques
PDF
[KubeCon EU 2020] containerd Deep Dive
PDF
Shifter singularity - june 7, 2018 - bw symposium
PDF
Not breaking userspace: the evolving Linux ABI
PDF
Differences of Deep Learning Frameworks
PPTX
Using R on High Performance Computers
PPTX
Measurement .Net Performance with BenchmarkDotNet
PPTX
Talk Python To Me: Stream Processing in your favourite Language with Beam on ...
PDF
Fast federated SQL with Apache Calcite
PDF
workshop_8_c__.pdf
PDF
Introduction to eBPF and XDP
PDF
FIFODC
Systems@Scale 2021 BPF Performance Getting Started
Performance Wins with eBPF: Getting Started (2021)
Efficient System Monitoring in Cloud Native Environments
Kernel bug hunting
Turbo C
ebpf and IO Visor: The What, how, and what next!
Using eBPF to Measure the k8s Cluster Health
Dynamic tracing of MariaDB on Linux - problems and solutions (MariaDB Server ...
eBPF Debugging Infrastructure - Current Techniques
[KubeCon EU 2020] containerd Deep Dive
Shifter singularity - june 7, 2018 - bw symposium
Not breaking userspace: the evolving Linux ABI
Differences of Deep Learning Frameworks
Using R on High Performance Computers
Measurement .Net Performance with BenchmarkDotNet
Talk Python To Me: Stream Processing in your favourite Language with Beam on ...
Fast federated SQL with Apache Calcite
workshop_8_c__.pdf
Introduction to eBPF and XDP
FIFODC
Ad

More from Viller Hsiao (9)

PDF
Prerequisite knowledge for shared memory concurrency
PDF
twlkh-linux-vsyscall-and-vdso
PDF
Linux kernel tracing
PDF
Meet cute-between-ebpf-and-tracing
PDF
mbed-os 3.0 modules dependency graph
PDF
Introduction to ARM mbed-OS 3.0 uvisor
PDF
My first-crawler-in-python
PDF
Trace kernel code tips
PDF
f9-microkernel-ktimer
Prerequisite knowledge for shared memory concurrency
twlkh-linux-vsyscall-and-vdso
Linux kernel tracing
Meet cute-between-ebpf-and-tracing
mbed-os 3.0 modules dependency graph
Introduction to ARM mbed-OS 3.0 uvisor
My first-crawler-in-python
Trace kernel code tips
f9-microkernel-ktimer

Recently uploaded (20)

PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PPTX
Welding lecture in detail for understanding
PPTX
UNIT-1 - COAL BASED THERMAL POWER PLANTS
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PPTX
bas. eng. economics group 4 presentation 1.pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
Sustainable Sites - Green Building Construction
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
Well-logging-methods_new................
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PDF
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
DOCX
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
PPTX
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
PPTX
Internet of Things (IOT) - A guide to understanding
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Welding lecture in detail for understanding
UNIT-1 - COAL BASED THERMAL POWER PLANTS
Embodied AI: Ushering in the Next Era of Intelligent Systems
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
bas. eng. economics group 4 presentation 1.pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Sustainable Sites - Green Building Construction
CH1 Production IntroductoryConcepts.pptx
Well-logging-methods_new................
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
Operating System & Kernel Study Guide-1 - converted.pdf
Mohammad Mahdi Farshadian CV - Prospective PhD Student 2026
ASol_English-Language-Literature-Set-1-27-02-2023-converted.docx
MCN 401 KTU-2019-PPE KITS-MODULE 2.pptx
Internet of Things (IOT) - A guide to understanding
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx

Bpf performance tools chapter 4 bcc