analyzing dpdk applications with ebpf · analyzing dpdk applications with ebpf sharpening the...

60
Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1

Upload: others

Post on 20-May-2020

51 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Analyzing DPDK applications with eBPFSharpening the toolset

Stephen HemmingerFosdem, February 1, 2020

Microsoft

1

Page 2: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Table of Contents

Introduction

Packet Capture

Tracing

Lttng

Bpftrace

Performance

Conclusion

2

Page 3: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Introduction

Page 4: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Ancient wisdom

French proverbMauvés ovriers ne trovera ja bon hostillBad workers will never find a good tool

Chinese proverbTo do a good job, a craftsman must sharpen his tools.

3

Page 5: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Ancient wisdom

French proverbMauvés ovriers ne trovera ja bon hostillBad workers will never find a good tool

Chinese proverbTo do a good job, a craftsman must sharpen his tools.

3

Page 6: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Methodology

• Don’t focus on a tool set

• Problem statement• Workload Characterization• USE

• Utilization• Saturation• Errors

See Linux tracing talks (Brendan Gregg et al)

4

Page 7: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Methodology

• Don’t focus on a tool set• Problem statement

• Workload Characterization• USE

• Utilization• Saturation• Errors

See Linux tracing talks (Brendan Gregg et al)

4

Page 8: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Methodology

• Don’t focus on a tool set• Problem statement• Workload Characterization

• USE• Utilization• Saturation• Errors

See Linux tracing talks (Brendan Gregg et al)

4

Page 9: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Methodology

• Don’t focus on a tool set• Problem statement• Workload Characterization• USE

• Utilization• Saturation• Errors

See Linux tracing talks (Brendan Gregg et al)

4

Page 10: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Methodology

• Don’t focus on a tool set• Problem statement• Workload Characterization• USE

• Utilization• Saturation• Errors

See Linux tracing talks (Brendan Gregg et al)

4

Page 11: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Capture vs Tracing

DPDKApplication

pdump

tcpdump

Tracer

send

receive

ring

Capture

Tracing

5

Page 12: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Packet Capture

Page 13: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

DPDK pdump

DPDK Primary Application

dpdk-pdumptool

PCAP PMD

dpdk_port0

librte_pdump

capture.pcapTraffic Generator

• Packet copied and queuedto ring

• Secondary process sends tolibpcap

• Packets recorded in pcapformat

6

Page 14: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Pdump limitations

• No metadata (vlan, offload, ...)

• Inaccurate timestamp• No direction information• Single port only• No filtering• Poor performance

7

Page 15: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Pdump limitations

• No metadata (vlan, offload, ...)• Inaccurate timestamp

• No direction information• Single port only• No filtering• Poor performance

7

Page 16: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Pdump limitations

• No metadata (vlan, offload, ...)• Inaccurate timestamp• No direction information

• Single port only• No filtering• Poor performance

7

Page 17: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Pdump limitations

• No metadata (vlan, offload, ...)• Inaccurate timestamp• No direction information• Single port only

• No filtering• Poor performance

7

Page 18: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Pdump limitations

• No metadata (vlan, offload, ...)• Inaccurate timestamp• No direction information• Single port only• No filtering

• Poor performance

7

Page 19: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Pdump limitations

• No metadata (vlan, offload, ...)• Inaccurate timestamp• No direction information• Single port only• No filtering• Poor performance

7

Page 20: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

PCAP Next Generation

• Nanosecond resolution timestamp

• System and Interface metadata• Multiple interfaces• Flags (direction, hash, ...)• Comments

8

Page 21: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

PCAP Next Generation

• Nanosecond resolution timestamp• System and Interface metadata

• Multiple interfaces• Flags (direction, hash, ...)• Comments

8

Page 22: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

PCAP Next Generation

• Nanosecond resolution timestamp• System and Interface metadata• Multiple interfaces

• Flags (direction, hash, ...)• Comments

8

Page 23: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

PCAP Next Generation

• Nanosecond resolution timestamp• System and Interface metadata• Multiple interfaces• Flags (direction, hash, ...)

• Comments

8

Page 24: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

PCAP Next Generation

• Nanosecond resolution timestamp• System and Interface metadata• Multiple interfaces• Flags (direction, hash, ...)• Comments

8

Page 25: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Packet filtering with libpcap

PCAP filter string: ip dst fosdem.org

cBPF program (6 insns):(000) ldh [12](001) jeq #0x800 jt 2 jf 5(002) ld [30](003) jeq #0x1f16168c jt 4 jf 5(004) ret #65535(005) ret #0

9

Page 26: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Packet filtering cBPF

Translated to eBPF

eBPF program (11 insns):L0: xor r0, r0L1: xor r7, r7L2: mov r6, r1L3: ldh r0, [12]L4: jne r0, #0x800, L9L5: ldw r0, [30]L6: jne r0, #0x1f16168c, L9L7: mov32 r0, #0xffffL8: exitL9: mov32 r0, #0x1L10: exit

10

Page 27: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Tracing

Page 28: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Linux Trace toolkit

• Easy to use

• User Defined Trace Points• Filtering• Common Trace Format• High performance

11

Page 29: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Linux Trace toolkit

• Easy to use• User Defined Trace Points

• Filtering• Common Trace Format• High performance

11

Page 30: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Linux Trace toolkit

• Easy to use• User Defined Trace Points• Filtering

• Common Trace Format• High performance

11

Page 31: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Linux Trace toolkit

• Easy to use• User Defined Trace Points• Filtering• Common Trace Format

• High performance

11

Page 32: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Linux Trace toolkit

• Easy to use• User Defined Trace Points• Filtering• Common Trace Format• High performance

11

Page 33: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Adding lttng tracepoint

/∗ Send burs t of packets on an output i n t e r f a c e ∗/s t a t i c i n l i n e i n tsend_burst ( s t ruc t l core_conf ∗qconf , uint16_t n , uint16_t port ){

s t ruc t rte_mbuf ∗∗m_table = qconf−>tx_mbufs [ port ] . m_table ;uint16_t queueid = qconf−>tx_queue_id [ port ] ;i n t r e t ;

r e t = rte_eth_tx_burst ( port , queueid , m_table , n ) ;t r a cepo in t ( l3fwd , tx_burst , port , queueid , n , r e t ) ;i f ( u n l i k e l y ( r e t < n ))^^ Irte_pktmbuf_free_bulk(&m_table [ r e t ] , n − r e t ) ;return 0 ;

}

12

Page 34: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Using eBPF from userspace

• Origin: dtrace

• Adds NOP locations and ELF section• Run code at tracepoint• Prerequisites

uprobe Linux 3.14 (or later) kernelsys/sdt.h systemtap-std-dev

13

Page 35: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Using eBPF from userspace

• Origin: dtrace• Adds NOP locations and ELF section

• Run code at tracepoint• Prerequisites

uprobe Linux 3.14 (or later) kernelsys/sdt.h systemtap-std-dev

13

Page 36: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Using eBPF from userspace

• Origin: dtrace• Adds NOP locations and ELF section• Run code at tracepoint

• Prerequisitesuprobe Linux 3.14 (or later) kernel

sys/sdt.h systemtap-std-dev

13

Page 37: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Using eBPF from userspace

• Origin: dtrace• Adds NOP locations and ELF section• Run code at tracepoint• Prerequisites

uprobe Linux 3.14 (or later) kernel

sys/sdt.h systemtap-std-dev

13

Page 38: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Using eBPF from userspace

• Origin: dtrace• Adds NOP locations and ELF section• Run code at tracepoint• Prerequisites

uprobe Linux 3.14 (or later) kernelsys/sdt.h systemtap-std-dev

13

Page 39: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Using eBPF from userspace

• Origin: dtrace• Adds NOP locations and ELF section• Run code at tracepoint• Prerequisites

uprobe Linux 3.14 (or later) kernelsys/sdt.h systemtap-std-dev

13

Page 40: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Adding DTRACE probes

s t a t i c voidpkt_burst_rece ive ( s t ruc t fwd_stream ∗ f s ){

s t ruc t rte_mbuf ∗ pkts_burst [MAX_PKT_BURST] ;uint16_t i , nb_rx ;

/∗ Receive a burs t of packets . ∗/nb_rx = rte_eth_rx_burst ( f s−>rx_port , f s−>rx_queue ,^^ I ^^ I ^^ I pkts_burst , nb_pkt_per_burst ) ;

DTRACE_PROBE1( testpmd , rx_burst , nb_rx ) ;

i f ( u n l i k e l y ( nb_rx == 0))^^ I ^^ I r e t u r n ;

14

Page 41: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Looking for USDT

Use bpftrace to look for tracepoints in application

$ sudo bpftrace -l "usdt:./build/app/testpmd"usdt:./build/app/testpmd:testpmd:rx_burst

15

Page 42: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Running bpftrace

Build a histogram of the number of packets per loop

$ sudo bpftrace -e 'usdt:./build/app/testpmd:rx_burst { @ = hist(arg0); }'Attaching 1 probe...^C

@:[0] 16001930 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|[1] 0 | |[2, 4) 0 | |[4, 8) 0 | |[8, 16) 0 | |[16, 32) 0 | |[32, 64) 5333977 |@@@@@@@@@@@@@@@@@ |

16

Page 43: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Performance

Page 44: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Caveats

• Limited hardware - x85 with 25G NIC

• One off test• Untuned• Limited scope

• Testpmd - 64 byte packets• Immediate drop• Current DPDK 19.11• Single queue active

17

Page 45: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Caveats

• Limited hardware - x85 with 25G NIC• One off test

• Untuned• Limited scope

• Testpmd - 64 byte packets• Immediate drop• Current DPDK 19.11• Single queue active

17

Page 46: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Caveats

• Limited hardware - x85 with 25G NIC• One off test• Untuned

• Limited scope• Testpmd - 64 byte packets• Immediate drop• Current DPDK 19.11• Single queue active

17

Page 47: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Caveats

• Limited hardware - x85 with 25G NIC• One off test• Untuned• Limited scope

• Testpmd - 64 byte packets

• Immediate drop• Current DPDK 19.11• Single queue active

17

Page 48: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Caveats

• Limited hardware - x85 with 25G NIC• One off test• Untuned• Limited scope

• Testpmd - 64 byte packets• Immediate drop

• Current DPDK 19.11• Single queue active

17

Page 49: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Caveats

• Limited hardware - x85 with 25G NIC• One off test• Untuned• Limited scope

• Testpmd - 64 byte packets• Immediate drop• Current DPDK 19.11

• Single queue active

17

Page 50: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Caveats

• Limited hardware - x85 with 25G NIC• One off test• Untuned• Limited scope

• Testpmd - 64 byte packets• Immediate drop• Current DPDK 19.11• Single queue active

17

Page 51: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Test configuration

Testpmdtx_only

Testpmdrx_only

• Sender tx-only• Receiver rx-only• Observe Receive packets/sec

18

Page 52: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Capture and Tracing Performance

Test Disabled EnabledPdump 0 -36.85Pdump + eBPF 0 0Lttng -0.42 -0.02bpftrace -0.01 -56.72

19

Page 53: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Conclusion

Page 54: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Ongoing work

• DPDK packet capture

• Pcapng support• capture filter• dumpcap (tshark) syntax

• DPDK trace points

20

Page 55: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Ongoing work

• DPDK packet capture• Pcapng support

• capture filter• dumpcap (tshark) syntax

• DPDK trace points

20

Page 56: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Ongoing work

• DPDK packet capture• Pcapng support• capture filter

• dumpcap (tshark) syntax

• DPDK trace points

20

Page 57: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Ongoing work

• DPDK packet capture• Pcapng support• capture filter• dumpcap (tshark) syntax

• DPDK trace points

20

Page 58: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Ongoing work

• DPDK packet capture• Pcapng support• capture filter• dumpcap (tshark) syntax

• DPDK trace points

20

Page 59: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Ongoing work

• DPDK packet capture• Pcapng support• capture filter• dumpcap (tshark) syntax

• DPDK trace points

20

Page 60: Analyzing DPDK applications with eBPF · Analyzing DPDK applications with eBPF Sharpening the toolset Stephen Hemminger Fosdem, February 1, 2020 Microsoft 1. Table of Contents Introduction

Thank you

• Questions• Thanks

• DPDK community• LTTng• eBPF developers

[email protected]@networkplumber

21