Userspace I/O와 VFIO

1.
이야기의 시작은 Cisco의 블로그입니다. 제가 자주 가서 눈 동냥을 하는 곳입니다. Cisco의 Jeff Squyres가 Cisco Blog – High Performance Computing Networking에 글을 올렸습니다.

Ain’t your father’s TCP

Jeff은 “20년전 TCP와 현재의 TCP의 기본원리는 같지만 많은 부분이 발전했다”고 주장합니다.

Van Jacobson’s “TCP in 30 [assembly] instructions” explanation. And I discovered that that explanation is from 1993.
Modern Ethernet NICs have quite a bit of acceleration built-in (lots of TCP offloading).
Operating system TCP protocol stacks are very highly optimized.

이런 결론 보다 관심을 끈 것은 첨부한 PDF입니다. 더불어 PDF에서 소개한 시험에 대한 자세한 내용은 아래를 참고하세요.

Cisco @ SC’12

Userpace NIC를 사용하고 있습니다. Kernel을 통하지 않고 Userpace에서 직접 I/O를 접근하려는 시도는 많았습니다. usNIC도 연장선인 듯 합니다. userspace NIC은 아니어도 Userspace를 통하여 Low Latency Networking을 하고자 하는 사례는 많습니다. 예전에 DIY Acceleration에서 소개한 Netmap이나 Solarflare의 OpenOnLoad도 Userspace Networking입니다. 이외에 PFQ: Accelerated Packet Capture Engine for Multi-core ArchitecturesPF_RING도 있습니다.

2.
Cisco는 Userspace NIC을 다음과 같이 정의합니다.

The short version is that we have implemented operating system bypass and NIC hardware offload via the Linux OpenFabrics verbs API stack. We call it “userspace NIC”, or “USNIC”.

RedHat과 함께 MRG에 적용한 usNIC의 개념도를 보면 VFIO라는 개념이 같이 등장합니다. VFIO=Virtual Function I/O입니다. VFIO는 Derivative of Userspace I/O라고 설명한 자료도 있습니다.

usnic userspace

VFIO와 Userspace I/O를 알아보죠. Userspace I/O는 Userspace Networking으로 유추해보면 이해가 쉽습니다. 위의 그림을 보면 직관적으로 이해할 수 있습니다. 다만 좀더 깊은 글을 보고 싶으면 아래를 읽어보시길 바랍니다.

UserSpace IO (UIO) Introduction

VFIO도 Usersapce I/O에 대한 이해에 Virtualization을 더하면 쉽게 이해할 수 있습니다. 아래 글중 IOMMU=Input/Output Memory Management Unit입니다.

VFIO – “Virtual Function I/O”

The VFIO driver is an IOMMU/device agnostic framework for exposing direct device access to userspace, in a secure, IOMMU protected environment. In other words, this allows safe, non-privileged, userspace drivers.

Why do we want that? Virtual machines often make use of direct device access (“device assignment”) when configured for the highest possible I/O performance. From a device and host perspective, this simply
turns the VM into a userspace driver, with the benefits of significantly reduced latency, higher bandwidth, and direct use of bare-metal device drivers.

그러면 SR-IOV와 어떻게 다를까요? SR-IOV와 IPC을 참조하면서 아래를 읽어보시길 바랍니다. PCI I/O가상화인 SR-IOV는 VM과 Device를 직접 연결해주는 기술이지만 VFIO는 Process와 Device를 연결해주는 기술이라고 합니다.

Recent hardware technologies – I/O MMUs and PCI I/O Virtualization – provide new hardware capabilities which the VFIO solution exploits to allow non-root user level drivers. The main role of the IOMMU is to ensure that DMA accesses from devices go only to the appropriate memory locations; this allows VFIO to ensure that user level drivers do not corrupt inappropriate memory.

PCI I/O virtualization (SR-IOV) was defined to allow “pass-through” of virtual devices to guest virtual machines. VFIO in essence implements pass-through of devices to user processes, not virtual machines.

SR-IOV devices implement a traditional PCI device (the physical function) and a dynamic number of special
PCI devices (virtual functions) whose feature set is somewhat restricted – in order to allow the operating system or virtual machine monitor to ensure the safe operation of the system.

이런 상상을 해보죠. SR-IOV를 채용한 이더넷카드와 VFIO를 채용한 이더넷카드중 어느 것이 더 Latency가 낮을까요? 시험 자료가 없으니까 확실하지 않지만 VFIO가 아닐까 추측해봅니다. Cisco의 usNIC을 설명한 자료를 보면 VMWARE의 Direct I/O와 비슷한 기능이라고 설명하고 있습니다.

VMware DirectPath I/O is a technology, available from vSphere 4.0 and higher that leverages hardware support (Intel VT-d and AMD-Vi) to allow guests to directly access hardware devices. In the case of networking, a VM with DirectPath I/O can directly access the physical NIC instead of using an emulated (vlance, e1000) or a para-virtualized (vmxnet, vmxnet3) device.
Performance and Use Cases of VMware DirectPath I/O for Networking중에서

3.
2011년 Nasdaq의 기술책임자가 한 발표를 소개한 NASDAQ이 바라보는 매칭기술의 미래을 보면 Userspace 프로그래밍을 강조하였습니다. Userspace I/O가 계속 발전하는 이유가 아닐까 합니다. VFIO도 Userspace I/O기술과 클라우드 컴퓨팅 기술이 발전하면서 나온 결과물이 아닐까 생각합니다.

제가 왜 이런 기술에 관심을 가졌을까요? 저는 클라우드방식의 DMA서비스를 통하여 투입 대비 효용성을 높혀야 한다고 생각합니다. 가상화가 아니면 리테일DMA를 위한 필요한 비용을 감당할 수 없습니다. 다만 가상화 DMA서비스라도 Low Latency를 제공하는 것은 중요하므로 VFIO와 관련한 기술이 매력적으로 보였습니다. 다만 시험을 해보지 않았으니 가설이 맞는지는 확인할 수 없네요.(^^)

참고로 I/O가상화와 관련한 기술을 집약적으로 소개한 자료를 올립니다. 이름은 “I/O仮想化最前線〜ネットワークI/Oを中心に〜(I/O기상화최전선 – 네트워크I/O를 중심으로”라는 자료입니다.

Leave a Comment

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

이 사이트는 스팸을 줄이는 아키스밋을 사용합니다. 댓글이 어떻게 처리되는지 알아보십시오.