+ All Categories
Home > Documents > Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to...

Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to...

Date post: 13-Aug-2020
Category:
Upload: others
View: 2 times
Download: 0 times
Share this document with a friend
28
1 / 28 Vhost: Sharing is better Eyal Moscovici Partly sponsored by: Bandan Das
Transcript
Page 1: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

1 / 28

Vhost: Sharing is better

Eyal Moscovici, IBMBandan Das, Red Hat

Also funded by Mikelangelo (

Eyal Moscovici

Partly sponsored by:

Bandan Das

Page 2: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

2 / 28

What's it about ?

● Paravirtualization: Shared Responsibilities

● Vhost: How much can we stretch ?

● Design Ideas: Parallelization

● Design Ideas: Consolidation

● Vhost: ELVIS

● Upstreaming

● Results

● Wrap up and Questions

Page 3: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

3 / 28

Shared Responsibilities● From Virtualization to Paravirtualization

● Virtio – Host/Guest co-ordination

– - Standardized backend/frontend drivers

● Advantages

– - Host still has ultimate control (compared to hardware device assignment)

– - Security, Fault tolerance, SDN, file-based images, replication, snapshots, VM migration

● Disadvantages

– - Scalability Limitations

Page 4: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

4 / 28

Shared Responsibilities● Vhost kernel

– - Let's move things into the kernel (almost!)

– - Better userspace/kernel API

– - Avoids system calls, improves performance

– - And comes with all the advantages of virtio

vCPU

Vhost worker thread

ioeventfd

Network Stack

irqfd

Read/Write

Virtio buffers

Guest

KVM

Page 5: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

5 / 28

How much can we stretch ?● One worker thread per virtqueue pair

● More guests = more worker threads

– - But is it necessary ?

– - Can a worker share responsibilities ?

● Performance will improve (or at least stay the same)

– - Main objective: Scalable performance

● No userspace modifications should be necessary

Page 6: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

6 / 28

Parallelization (Pronunciation Challenge)

● A worker thread running on every CPU core.

● Guest/Thread mapping is decoupled.

● Guest serviced by a free worker thread with NUMA locality

● Presented by Shirley Ma at LPC 2012

CPU0

Guest Guest Guest Guest

CPU1 CPU2 CPU3

Vhost-1 Vhost-2 Vhost-3 Vhost-4

Numa-aware scheduling

Tx/Rx Tx/Rx Tx/Rx Tx/Rx

Page 7: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

7 / 28

Parallelization● But….

- Do we really need “always-on” threads ?

● - is it enough to create threads on demand ?

– - Scheduling more complicated when number of guests increase ?

● - Why not share a thread among multiple devices ?

Page 8: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

8 / 28

Consolidation - ELVIS (Not the singer)

Presented by Abel Gordon at KVM Forum 2013

● Divide the cores in the system into two group: VM cores and I/O cores.

● A vhost thread servicing multiple I/O devices from different guest

● has a dedicated CPU core

● A user configurable parameter determines how many.

● A dedicated I/O scheduler on the vhost thread

● Posted interrupts and polling included!

I/OCoreCore NCore 2Core 1Core 1I/O

Core

I/OVM1

Core N

VMiI/O

VM2

fine-grained I/O scheduling

Core 2

I/OVM2I/OVMi

thread-based scheduling

Exe

cutio

n T

ime

VMj

VMi

VM1VCPU1

I/OVM1

I/OVMj

I/OVM2

VM2VCPU2

I/OVM2I/OVMiE

xecu

tion

Tim

e

VM1VCPU2

VM2VCPU1

Page 9: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

9 / 28

ELVIS Polling Thread ● Single thread in a dedicated core monitors the activity of

each queue (VMs I/O)

● Balance between queues based on the I/O activity

● Decide which queue should be processed and for how long

● Balance between throughput and latency● No process/thread context switches for I/O

● Exitless communication (in the next slides)

Page 10: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

10 / 28

ELVIS Polling Thread

VCPUThread(Core X)

guest

hypervisor

(time)

I/OThread(Core Y) hypervisor

I/O notificationGuest-to-Host

I/O notificationHost-to-Guest

Process I/O Request

Complete I/O Request

ELVIS

VCPUThread(Core X)

(time)

I/OThread(Core Y)

I/O notificationGuest-to-Host

I/O notificationHost-to-Guest

Process I/O Request

Complete I/O Request

Traditional Paravirtual I/O

PollingExitless virtual interrupt

injection (via ELI)

guest

hypervisor

hypervisor

Page 11: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

11 / 28

ELVIS Exitless communication● Implemented software posted interrupt based on ELI

(Exitless interupts)

- ELI will be very hard to upstream

● Possible replacements

- KVM PV EOI introduced by Michael S. Tsirkin

– - INTEL VT-d Posted-interrupts (PI) which may be leveraged

Page 12: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

12 / 28

Upstreaming..● A lot of new ideas!

● First Step

– - Stabilize a next generation vhost design.

● The plan:

– - Introduce a shared vhost design and run benchmarks with different configurations

● - RFC posted upstream● - Initial test results favorable

● Later enhancements can be introduced gradually...

Page 13: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

13 / 28

Cgroups (Buzzwords, JK ;))

● Initial approach

– - Add a function to search all cgroups in all hierarchies for the new process.

– - Even a single mismatch => create a new vhost worker.

● But..

– - What happens when a VM process is migrated to a different cgroup ?

– - Can we optimize the cgroup search ?

– - What happens if use polling?

– - Rethink cgroups integration ?

Guest1Guest1

CG1 CG2 CG3

G1 G2 G3

WG3

WG3

WG3

WG1

WG1

WG1

WG2

WG2

WG2

WG3

WG1

WG3

Per Device Vhost Worker

Shared Vhost Worker

Page 14: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

14 / 28

Cgroups and polling● Can a vhost polling thread poll guests with missmatching

cgoups?

– - Yes, but it will require the polling thread to take into account cgroup state of the guest.

● Probably requires a deeper integration of vhost and cgroups

Page 15: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

15 / 28

Workqueues (cmwq) (Even more sharing!)

● Can we use concurrency managed workqueues ?

● NUMA awareness comes free!

● But wait, what about cgroups ?

– - No cgroups support (at least yet, WIP)

● Less code to manage, less bugs.

● Cons-

– - Minimal control once work enters the workqueue

– - Again, no cgroups support :(

Page 16: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

16 / 28

Results● ELVIS results

– - A little old but significant

– - Includes testing for Exit Less Interrupts, Polling

● - Valuable data for future work ● Setup

– - Linux Kernel 3.1

– - IBM System x3550 M4, two 8-cores sockets of Intel Xeon E5-2660, 2.2 GHz, 56GB RAM

– and with an Intel x520 dual port 10Gbps

– - QEMU 0.14

● Results showing the performance impact of the different components of ELVIS

– - Throughput: Netperf TCP stream w. 64 byte messages

– - Latency: Netperf UDP RR

Page 17: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

17 / 28

Results – Components of ELVIS

1 2 3 4 5 6 70.75

0.80

0.85

0.90

0.95

1.00

1.05

netperf udp rr

elvis

elvis-poll

elvis-poll-pi

# vmsre

lativ

e la

ten

cy

1 2 3 4 5 6 70.8

0.9

1.0

1.1

1.2

1.3

1.4

netperf tcp stream

elvis-poll-pi

elvis-poll

elvis

# VMs

Re

lativ

e th

rou

gh

pu

t

Page 18: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

18 / 28

Even more Results● New results with RFC patches

– - Two systems with Xeon E5-2640 v3

– - Point to point network connection

– - Netperf TCP throughput (STREAM & MAERTS)

– - Netperf TCP Request Response

Page 19: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

19 / 28

Results

Page 20: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

20 / 28

Results

Page 21: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

21 / 28

So, ship it ?!● Not yet :)

● Slowly making progress towards a acceptable solution

● Scope for a lot of interesting work

Questions/Comments/Suggestions ?

Page 22: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

22 / 28

Backup

Page 23: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

23 / 28

ELVIS missing piece● Polling on the physical NIC

- It may be possible to use low-latency Ethernet device polling introduced in kernel 3.11

● * I have an ELVIS version polling the physical NIC that is not using this patch

Page 24: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

24 / 28

Results – Performance (Netperf)

1 2 3 4 5 6 70

2

4

6

8

10

netperf tcp stream

elvis-poll-pi

elvis-poll

elvis

baseline

baseline-affinity

# VMs

Th

rou

gh

pu

t (G

bp

s)

1 2 3 4 5 6 70.00

10.00

20.00

30.00

40.00

50.00

60.00

70.00

80.00

netperf udp rr

baseline

elvis

elvis-poll

elvis-poll-pi

# vmsla

ten

cy (

mse

c)

Page 25: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

25 / 28

Results – Performance (Netperf)

● Different message sizes require different number of IO cores● Using sidecores is beneficial in a wide range of message sizes● The number of VMs “doesn't matter” for throughput

Page 26: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

26 / 28

Results – Performance (Netperf UDP RR)

● One I/O side core is not enough, two is needed● sidecore performs up to x1.5 better then Baseline

Page 27: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

27 / 28

Results – Performance (memcached)

● One I/O side core is not enough, two is needed● sidecore performs up to > x2 better then Baseline

Page 28: Vhost: Sharing is better - KVM...3 / 28 Shared Responsibilities From Virtualization to Paravirtualization Virtio – Host/Guest co-ordination – - Standardized backend/frontend drivers

28 / 28

Results – Performance (apachebench)

● One I/O side core is not enough, two is needed● sidecore performs up to x2 better then Baseline


Recommended