MMEMORY LAB / GPU BALLOON
BILINGUAL READING / 逐段对照

gBalloon:全 GPU 虚拟化环境中的图形内存空间气球机制

Ballooning Graphics Memory Space in Full GPU Virtualization Environments

Scientific Programming · 2019-04-23 · DOI 10.1155/2019/5240956

原文作者与署名

Younghun Park; Minwoo Gu; Sungyong Park

AI逐段译稿/第一轮文本与结构核对,非人工终审、非作者官方译本,未复现实验。正文、附录、声明逐段对照;算法附中文说明,图内英文、参考文献、模型和代码名保留原文。阅读解读与原文疑点。

固定原文 ↗ · CC BY 4.0 与版本台账 · 下载对照文本

101个对照单元
“两个 VM 为什么能用同一个槽?”先看可点击的地址/GTT/数据示意:分清原版 gVirt、gScale 扩展与 gBalloon,再继续读正文。

Abstract摘要

001

Advances in virtualization technology have enabled multiple virtual machines (VMs) to share resources in a physical machine (PM). With the widespread use of graphics-intensive applications, such as two-dimensional (2D) or 3D rendering, many graphics processing unit (GPU) virtualization solutions have been proposed to provide high-performance GPU services in a virtualized environment. Although elasticity is one of the major benefits in this environment, the allocation of GPU memory is still static in the sense that after the GPU memory is allocated to a VM, it is not possible to change the memory size at runtime. This causes underutilization of GPU memory or performance degradation of a GPU application due to the lack of GPU memory when an application requires a large amount of GPU memory. In this paper, we propose a GPU memory ballooning solution called gBalloon that dynamically adjusts the GPU memory size at runtime according to the GPU memory requirement of each VM and the GPU memory sharing overhead. The gBalloon extends the GPU memory size of a VM by detecting performance degradation due to the lack of GPU memory. The gBalloon also reduces the GPU memory size when the overcommitted or underutilized GPU memory of a VM creates additional overhead for the GPU context switch or the CPU load due to GPU memory sharing among the VMs. We implemented the gBalloon by modifying the gVirt, a full GPU virtualization solution for Intel’s integrated GPUs. Benchmarking results show that the gBalloon dynamically adjusts the GPU memory size at runtime, which improves the performance by up to 8% against the gVirt with 384 MB of high global graphics memory and 32% against the gVirt with 1024 MB of high global graphics memory.

虚拟化技术的进步使多个虚拟机(VM)能够共享一台物理机(PM)的资源。随着二维(2D)和三维(3D)渲染等图形密集型应用的广泛使用,研究者提出了许多 GPU 虚拟化方案,以在虚拟化环境中提供高性能 GPU 服务。虽然弹性是这种环境的主要优势之一,但 GPU 内存仍采用静态分配:一旦分配给某个 VM,便无法在运行时改变容量。这会造成 GPU 内存利用不足,或使需要大量 GPU 内存的应用因容量不足而性能下降。本文提出名为 gBalloon 的 GPU 内存气球方案,根据每个 VM 的 GPU 内存需求及共享开销,在运行时动态调整容量。gBalloon 检测由 GPU 内存不足引起的性能下降,进而扩大该 VM 的 GPU 内存;当过量分配或利用不足的内存因 VM 间共享而增加 GPU 上下文切换开销或 CPU 负载时,它也会缩小 GPU 内存。我们修改了 Intel 集成 GPU 全虚拟化方案 gVirt,实现 gBalloon。基准测试表明,gBalloon 能动态调整容量,相比高位全局图形内存为 384 MB 的 gVirt,性能最高提高 8%;相比配置为 1024 MB 的 gVirt,最高提高 32%。

1. Introduction1 引言

002

Running graphics-intensive applications that include three-dimensional (3D) visualization and rendering in a virtualized environment creates a new challenge for high-performance graphics processing unit (GPU) virtualization solutions. GPU virtualization is a technique that allows multiple virtual machines (VMs) to share a physical GPU and run high-performance graphics applications with performance guarantees.

在虚拟化环境中运行三维可视化、渲染等图形密集型应用,对高性能 GPU 虚拟化方案提出了新挑战。GPU 虚拟化让多个 VM 共享一块物理 GPU,并在提供性能保障的情况下运行高性能图形应用。
003

Among a wide range of GPU virtualization techniques, application programming interface (API) remoting [1–11] is a method of intercepting API calls and passing them to the host. This method is easy to implement, but requires modification every time the version of the API library or GPU driver changes. This method also cannot provide all GPU functions. Direct pass-through [12, 13] allocates a GPU exclusively to a single VM and allows it to directly use the GPU with no intervention by the hypervisor. This method provides a high performance that is similar to the native environment, but GPU sharing among VMs is impossible. Currently, AWS [14] and Azure [15] provide GPU services to VMs through the direct pass-through method or through the NVIDIA GRID [16] which is a GPU virtualization solution at the hardware level.

在众多 GPU 虚拟化技术中,API 远程调用 [1–11] 会截获 API 调用并交由宿主处理。该方法容易实现,但每次 API 库或 GPU 驱动版本变化都要修改,而且不能提供全部 GPU 功能。直接透传 [12,13] 则将一块 GPU 独占分配给一个 VM,使其不经 hypervisor 干预而直接使用 GPU。它具有接近原生环境的高性能,却无法在 VM 间共享 GPU。论文写作时,AWS [14] 和 Azure [15] 通过直接透传或硬件级 GPU 虚拟化方案 NVIDIA GRID [16] 向 VM 提供 GPU 服务。
004

To solve the problems of the approaches mentioned above, GPU virtualization solutions at the hypervisor level, such as gVirt [17], GPUvm [18], and VMCG [19], have been proposed. The gVirt is a full GPU virtualization technology for Intel’s integrated GPUs. Unlike dedicated or discrete GPUs in which dedicated graphic cards have independent graphics memory, integrated GPUs share a portion of the system RAM for graphics memory (or GPU memory). The original gVirt divides the graphics memory into chunks and allocates them exclusively to each VM. As a result, a single host could create up to only a maximum of three VMs. The gScale [20, 21] solved this scalability problem by dividing the graphics memory into multiple small slots and letting VMs share the slots. Private and physical graphics translation tables (GTTs) are used to translate the virtual address generated by each VM into the physical address for the graphics memory. When a VM is scheduled to run, the private GTT entries of the corresponding VM are copied to the physical GTT. Every time entries are updated in the physical GTT, the modified contents are synchronized with the private GTT that each VM has.

为解决上述问题,研究者提出了 gVirt [17]、GPUvm [18]、VMCG [19] 等 hypervisor 级 GPU 虚拟化方案。gVirt 是 Intel 集成 GPU 的全虚拟化技术。独立 GPU 拥有专用图形内存,而集成 GPU 使用部分系统 RAM 作为图形内存(GPU 内存)。原版 gVirt 将图形内存分块,并把块独占分配给各 VM,因此一台主机最多只能创建三个 VM。gScale [20,21] 将图形内存分成多个小槽位,让 VM 共享槽位,解决了扩展性问题。私有和物理图形转换表(GTT)把每个 VM 产生的虚拟地址转换为图形内存的物理地址。调度某 VM 运行时,其私有 GTT 表项被复制到物理 GTT;物理 GTT 表项每次更新后,修改内容也同步至该 VM 的私有 GTT。
005

However, the GPU memory size, which is set during the initial creation of the VM, cannot be changed dynamically. This causes the following problems. First, a VM must be restarted to change the allocated GPU memory size. The user must restart the VM to execute the GPU application that requires GPU memory larger than the current setting. As a result, the VM stops, and the service interruption is expectable. Second, the VM that occupies GPU memory larger than necessary can degrade the performance of other CPU and GPU applications running on other VMs. Whenever a GPU context switch occurs, the CPU copies the private GTT entries to a physical GTT, which also takes up the CPU time of other VMs. If the memory utilization is low, this unnecessary copying overhead may degrade the performance of other VMs. In addition, the GPU context switch time increases as the GPU memory size of each VM gets larger [22]. Third, as we reported in a previous study [22], small GPU memory size affects the performance of GPU workload, especially when VMs run with graphics operations for rendering or high-resolution display environments.

然而,VM 创建时设定的 GPU 内存容量无法动态更改,导致三个问题。首先,更改容量必须重启 VM;运行需要超过现有容量的 GPU 应用时,用户必须重启,造成 VM 停机和服务中断。其次,占用超过实际需要的 GPU 内存的 VM,可能拖慢其他 VM 中的 CPU、GPU 应用。每次 GPU 上下文切换,CPU 都要把私有 GTT 表项复制到物理 GTT,占用本可供其他 VM 使用的 CPU 时间。利用率较低时,这些无谓复制会降低其他 VM 的性能;而且每个 VM 的 GPU 内存越大,上下文切换时间也越长 [22]。最后,我们此前的研究 [22] 表明,GPU 内存过小会影响 GPU 工作负载,尤其是渲染或高分辨率显示环境。
006

Although several studies [23–29] dynamically adjusted the memory allocation of existing VMs, in these studies, memory was taken from a specific VM and allocated to another VM when the physical memory was insufficient. As these approaches assume an environment in which each VM has an independent virtual address space, it is difficult to apply those techniques directly to the full GPU virtualization environment in which the same virtual GPU memory space is shared.

虽然一些研究 [23–29] 能动态调整已有 VM 的内存分配,但它们是在物理内存不足时,从某个 VM 回收内存并分给另一个 VM。这些方法假定每个 VM 都有独立的虚拟地址空间,因此难以直接用于共享同一虚拟 GPU 内存空间的全 GPU 虚拟化环境。
007

In this paper, we propose a dynamic GPU memory ballooning scheme called gBalloon which dynamically increases or decreases the GPU memory size allocated to each VM at runtime. The gBalloon detects performance degradation due to the lack of GPU memory and increases the GPU memory size allocated to each VM. In addition, the GPU memory size of each VM can be reduced when the overcommitted or underutilized GPU memory of a VM creates additional overhead for the GPU context switch or the CPU load due to GPU memory sharing among the VMs. We implement the gBalloon using the 2016Q4 version of gVirt. As the gScale’s GPU memory-sharing technique is also implemented, the gBalloon can scale up to 15 Linux VMs. Using various CPU and GPU benchmarks, we also show that the gBalloon dynamically adjusts the GPU memory size at runtime and outperforms the gVirt (modified gVirt in which the gScale’s features are added) by up to 8% against the gVirt with 384 MB of high global graphics memory and 32% against the gVirt with 1024 MB of high global graphics memory.

本文提出动态 GPU 内存气球方案 gBalloon,在运行时增减每个 VM 的 GPU 内存容量。它检测内存不足造成的性能下降,给相应 VM 增加容量;当过量分配或利用不足的内存因 VM 间共享而带来额外的 GPU 上下文切换开销或 CPU 负载时,也会缩减容量。我们以 gVirt 2016Q4 为基础实现,并加入 gScale 的 GPU 内存共享技术,最多支持 15 个 Linux VM。通过多种 CPU、GPU 基准测试,我们表明 gBalloon 能动态调整容量,相比加入 gScale 功能的修改版 gVirt,在 384 MB 高位全局图形内存配置下最高提升 8%,在 1024 MB 配置下最高提升 32%。
008

Although current gBalloon is mainly targeted at Intel’s integrated GPU, its design principle can be applied to other architectures as well. For example, the proposed idea can be easily applied to other integrated GPUs from AMD and Samsung, where the system memory is used as GPU memory. In addition, we believe that other discrete GPUs with dedicated memory such as NVIDIA can benefit from the gBalloon since they also use graphics translation table for address translation. However, special care has to be taken to reduce the memory copy overhead across the system bus if the gBalloon is implemented over discrete GPUs. As the gVirt is open source and the access to the source codes for the NVIDIA driver and runtime is limited, we decided to use the gVirt as a software platform to verify our proposed idea.

虽然当前 gBalloon 主要面向 Intel 集成 GPU,但其设计原则也可用于其他架构。例如,对同样以系统内存作为 GPU 内存的 AMD、Samsung 集成 GPU,作者认为该思路容易应用。作者也认为,NVIDIA 等具有专用内存的独立 GPU 同样使用图形转换表做地址转换,因此可能受益。不过,若在独立 GPU 上实现,就必须特别注意降低跨系统总线复制内存的开销。由于 gVirt 开源,而 NVIDIA 驱动、运行时的源码访问受限,我们选择 gVirt 作为验证平台。
009

The rest of the paper is organized as follows. In Section 2, we outline the structure of gVirt and present the motivations behind the design of gBalloon. In Section 3, we explain the design and implementation issues of gBalloon. In Section 4, we evaluate the performance of gBalloon and compare it with that of gVirt using various configurations. In Section 5, we discuss related works, and in Section 6, we conclude with suggestions for future work.

本文其余部分如下:第2节介绍 gVirt 结构及 gBalloon 的设计动机;第3节说明设计与实现问题;第4节在不同配置下比较 gBalloon 和 gVirt 的性能;第5节讨论相关工作;第6节总结并提出未来研究方向。

2. Background and Motivation2 背景与动机

010

In this section, we provide an overview of the gVirt and discuss the motivations for the proposed approach.

本节概述 gVirt,并讨论本文方案的动机。

2.1. Overview of gVirt2.1 gVirt 概述

011

The gVirt is a high-performance GPU virtualization solution that provides mediated pass-through capability [17]. The gVirt allows VMs to directly access resources that have a large effect on performance and make other privileged operations be intervened through a hypervisor. Due to the restriction on the number of simultaneous VMs in the gVirt, we modified the original gVirt over Xen hypervisor (XenGT) and added the gScale’s scalability features [20]. Throughout this paper, we consider the modified gVirt as gVirt.

gVirt 是提供 mediated pass-through(中介式透传)能力的高性能 GPU 虚拟化方案 [17]。VM 可直接访问对性能影响很大的资源,其余特权操作则由 hypervisor 介入。由于原版 gVirt 同时支持的 VM 数量受限,我们在 Xen hypervisor(XenGT)上的 gVirt 中加入 gScale 的扩展性功能 [20]。本文下文所称的 gVirt,均指这一修改版。
012

In the gVirt, the mediator located in Dom0 emulates the virtual GPU (vGPU) for each VM. The mediator schedules the vGPU in a round-robin fashion for fair scheduling among the VMs. Considering the high cost of the GPU context switch, each vGPU is switched at approximately 16 ms interval, which is a speed at which people cannot recognize an image change [17]. When the time quantum allocated to each vGPU is fully used, the mediator saves the registers and memory information of the corresponding vGPU and restores the GPU state for the next vGPU. Because the gVirt does not support preemption (although NVIDIA starts to provide preemption capability at the hardware level from Pascal architecture, the feature is not exposed to user’s control at the time of this writing) at the time of this writing, it traces the submitted GPU commands and waits for the results until each vGPU can finish its jobs. For example, if a vGPU executes GPU kernels longer than 16 ms, it runs without preemption. To prevent each vGPU from overusing the time quantum, the gVirt places a limit on the number of GPU kernels a vGPU is allowed to run within the time quantum.

gVirt 在 Dom0 中设置 mediator,为每个 VM 模拟一个虚拟 GPU(vGPU),并以轮转方式公平调度。考虑 GPU 上下文切换的高成本,每个 vGPU 约每 16 ms 切换一次,文中称这是人眼难以察觉图像变化的时间尺度 [17]。时间片耗尽时,mediator 保存当前 vGPU 的寄存器和内存信息,再恢复下一 vGPU 的状态。论文写作时 gVirt 不支持抢占,因此会跟踪提交的 GPU 命令,等到该 vGPU 的任务完成;例如运行超过 16 ms 的 kernel 不会被抢占。论文指出 NVIDIA 从 Pascal 起提供硬件抢占,但当时未向用户开放控制。为避免 vGPU 过度使用时间片,gVirt 限制其在一个时间片内可运行的 kernel 数量。
013

Intel’s global graphics memory is divided into two parts as shown in Figure 1: low global graphics memory and high global graphics memory. Only the GPU can access high global graphics memory, but the CPU and the GPU can access low global graphics memory. The CPU can access low global graphics memory through the aperture mapped to the GPU memory. Thus, the amount of low global graphics memory that can be accessed depends on the aperture size. The maximum aperture size currently supported by the motherboard is 512 kB, which is mapped up to 512 MB of the low global graphics memory.

如图1,Intel 全局图形内存分为低位和高位两部分。只有 GPU 能访问高位全局图形内存,而 CPU、GPU 均可访问低位部分。CPU 通过映射到 GPU 内存的 aperture(孔径窗口)访问低位部分,因此可访问的容量取决于 aperture 大小。原文写道,主板当前支持的最大 aperture 为 512 kB,可映射最多 512 MB 的低位全局图形内存。【译注:这里的 kB 与 MB 对应关系存在疑点,按原文保留,不擅自改成硬件规格。】
Details are in the caption following the image
Figure 1 · Global graphics memory structure of gVirt .
图1:gVirt 的全局图形内存结构。
014

Figure 1 shows the memory mapping and management structure between global graphics memory and system memory. In the gVirt (modified gVirt in which the gScale’s features are added), part of the low global graphics memory is shared by all vGPUs, and the high global graphics memory is divided into 64 MB slots that can also be shared among the vGPUs. The virtual address of the global graphics memory is converted into a physical address through the physical GTT. Each vGPU has a private GTT, which is a copy of the physical GTT corresponding to the allocated low global graphics memory and high global graphics memory. The private GTT entries of the vGPU are synchronized every time each vGPU modifies the physical GTT entries. To activate the vGPU in a GPU context switch, if the entry does not exist in the physical GTT, the state is restored by copying the private GTT to the physical GTT. However, if the vGPU is scheduled out, the CPU cannot access the vGPU through aperture. To solve this problem, the gScale allows the CPU to access the vGPU space at all times through the fence memory space pool, which ensures the proper operation of ladder mapping for mapping the guest physical address to the host physical address [20].

图1展示全局图形内存与系统内存之间的映射、管理结构。在加入 gScale 功能的 gVirt 中,所有 vGPU 共享部分低位全局图形内存;高位部分被分成 64 MB 槽位,也可在 vGPU 之间共享。物理 GTT 把全局图形内存虚拟地址转换为物理地址。每个 vGPU 有一份私有 GTT,是与其已分配低位、高位区域对应的物理 GTT 副本。该 vGPU 每次修改物理 GTT 表项,都会同步更新私有 GTT。上下文切换时,为激活某 vGPU,若物理 GTT 中缺少其表项,就把私有 GTT 复制过去以恢复状态。但是 vGPU 被切出后,CPU 无法经 aperture 访问其空间。gScale 使用 fence memory space pool(围栏内存空间池)让 CPU 始终能够访问该 vGPU 空间,保证把来宾物理地址映射至宿主物理地址的 ladder mapping 正常工作 [20]。
015

The gVirt framework focuses on the acceleration of graphics-intensive applications such as 2D or 3D rendering over a virtualized environment, rather than general-purpose computing on graphics processing units (GPGPU) computing over clouds.

gVirt 主要加速虚拟化环境中的 2D、3D 渲染等图形密集型应用,而非云端通用 GPU 计算(GPGPU)。

2.2. Motivation2.2 研究动机

016

In current gVirt, 64 MB low global graphics memory and 384 MB high global graphics memory are recommended for Linux VM [20] because those memory sizes are enough to support most GPU workloads without performance degradation and crash from the experiments. However, we showed in a previous study [22] that large high global graphics memory can sometimes increase the performance of GPU workloads. We also observed in the study that large high global graphics memory can increase the possibility of overlapping address spaces, which may incur large overhead in a GPU context switch and thus degrade the performance of other VMs. Furthermore, in an environment where the VMs require large global graphics memory, it is highly likely that their GTT entries do not exist in the physical GTT in a GPU context switch because the GPU memory space is shared among the VMs. If a large amount of GPU memory is allocated although it is not fully utilized, unnecessary copies of the GTT entries can occur in a GPU context switch. This increases the time for the GPU context switch, which also decreases the time for each vGPU to occupy the GPU per unit time. As a result, not only the performance of the GPU applications running on all VMs is degraded but also the time for the CPU to copy the GTT entries increases. Therefore, the performance of the CPU applications running on the VMs can be degraded as well.

当前 gVirt 建议 Linux VM 使用 64 MB 低位、384 MB 高位全局图形内存 [20],因为实验显示这足以使多数 GPU 工作负载避免性能下降和崩溃。但我们此前的研究 [22] 发现,更大的高位容量有时能提高 GPU 工作负载性能,同时也更可能使地址空间重叠,增加上下文切换开销,拖慢其他 VM。VM 需要大容量时,由于共享同一 GPU 内存空间,切换时其 GTT 表项更可能不在物理 GTT 中。若分配很大却未充分使用,会在切换时无谓复制 GTT 表项,使切换更慢、每个 vGPU 单位时间内实际使用 GPU 的时间更少。因此,所有 VM 的 GPU 应用会变慢,CPU 复制表项的时间也增加,还会拖慢 CPU 应用。
017

To confirm this, we conducted two experiments to investigate the effects of copying GTT entries on the performance of GPU application due to excessive occupation of high global graphics memory. For the two experiments, 384 MB and 1024 MB are used for the high global graphics memory size. It is possible to use other configurations as long as it is bigger than 384 MB and smaller than the size of physical GPU memory. Furthermore, the size should be multiple of slot size. Figure 2 shows the sum of the frames per second (FPS) for each VM by executing Nexuiz 3D benchmarks from Phoronix Test Suite [30] as we increase the number of VMs from 3 to 15. As shown in Figure 2, when the size of the high global graphics memory is small (384 MB), the VMs start to share the GPU memory from the point when the number of VMs reaches around 10. Then, the performance of the VMs degrades as we increase the number of VMs to 12 or 15. However, when the size of the high global graphics memory is large (1024 MB), the VMs start to share GPU memory from the relatively small number of VMs. This means that the copying of the GTT entries in the GPU context switch causes a very large performance degradation. When the number of VMs is 6 or 9, the performance at 1024 MB degraded by approximately 3.5 times compared with the performance at 384 MB.

我们做了两组实验,考察过度占用高位全局图形内存而复制 GTT 表项,对 GPU 应用性能的影响。容量分别设为 384 MB、1024 MB;也可采用大于 384 MB、小于物理 GPU 内存且为槽位大小整数倍的其他配置。图2中,VM 数量从3增加至15,运行 Phoronix Test Suite [30] 的 Nexuiz 3D 基准,以各 VM 的每秒帧数(FPS)之和衡量性能。384 MB 配置在约10个 VM 时才开始共享 GPU 内存,增加至12、15个后性能下降;1024 MB 配置在 VM 更少时就开始共享,表明上下文切换中的 GTT 表项复制可造成显著性能损失。原文称,在6或9个 VM 时,1024 MB 配置相比 384 MB 配置性能“下降约3.5倍”。【译注:按原文倍率表述保留,不能改写为下降350%。】
Details are in the caption following the image
Figure 2 · Performance degradation due to GPU memory sharing.
图2:GPU 内存共享引起的性能下降。
018

Overall, the performance of the VMs is highly affected by the size of the GPU memory allocated to each VM, and the memory size must be adjusted at runtime to optimize the performance.

总体而言,分给每个 VM 的 GPU 内存容量会显著影响性能,需要在运行时调整以优化性能。

3. Design of gBalloon3 gBalloon 的设计

019

In this section, we describe the design and implementation of the gBalloon that adjusts the GPU memory size of VMs at runtime. As we identified in the previous section, the performance of a GPU application can be degraded due to the static allocation of GPU memory. The gBalloon monitors the lack of GPU memory in VMs and then allocates the required amount of GPU memory to the corresponding VM. Furthermore, the gBalloon also checks the performance of CPU and GPU applications and decreases the GPU memory size when the performance of each VM degrades due to the GPU memory sharing among the VMs. The gBalloon is implemented by modifying the gVirt 2016Q4 release [31]. In the following, we present the GPU memory expansion and reduction strategies implemented in the gBalloon in detail.

本节介绍 gBalloon 的设计与实现,它在运行时调整 VM 的 GPU 内存容量。前节指出,静态分配会使 GPU 应用性能下降。gBalloon 监测 VM 的 GPU 内存不足,并给对应 VM 增配所需容量;它也检查 CPU、GPU 应用的性能,若 VM 间共享 GPU 内存造成性能下降,就缩小容量。实现基于修改的 gVirt 2016Q4 发布版 [31]。下文详述扩容与缩容策略。

3.1. GPU Memory Expansion Strategy3.1 GPU 内存扩容策略

020

When a VM is created, the GPU driver of the VM obtains the available range of GPU memory from the GPU driver in Dom0 and balloons the requested memory area excluding the space that has been allocated to the VM. Then, the GPU driver of the VM searches for memory space excluding the ballooned area when allocating a new memory object. If the space for allocating an object is insufficient, the GPU driver creates an empty space by returning the existing memory objects. As a result, the performance of a GPU application that requires graphics-intensive operations, such as rendering operations, is degraded because the same objects are frequently returned. To reduce this overhead, the gBalloon detects the VMs’ lack of GPU memory by tracing the number of memory object returns at runtime and reduces the ballooned area of other VMs for the required amount of memory space so that the VM with the lack of memory can use additional GPU memory.

VM 创建时,来宾 GPU 驱动从 Dom0 的 GPU 驱动取得可用 GPU 内存范围,并将其中未分给该 VM 的区域用气球占位排除。分配新内存对象时,来宾驱动只搜索气球区域以外的空间。若空间不足,就通过回收已有内存对象腾出空间。对渲染等图形密集型应用,反复回收相同对象会造成性能下降。为减少开销,gBalloon 在运行时跟踪内存对象回收次数,检测 VM 是否缺少 GPU 内存,并相应缩减其他 VM 的气球区域,使缺少内存的 VM 能使用额外空间。【译注:本段“其他 VM”按原文保留;具体扩容步骤在下一段明确为缩减请求来宾自己的气球占位。】
021

Figure 3 shows the process in which the gBalloon allocates additional GPU memory to the guest. When a guest GPU driver must return an existing object due to the lack of GPU memory, the following four steps take place. Step 1: the guest requests additional GPU memory space from the host. Step 2: to expand the GPU memory space with the requested size, the host chooses the optimal strategy that can minimize the GPU memory-sharing overhead based on the GPU memory adjustment algorithm which will be explained later. Step 3: based on the results of the GPU memory adjustment algorithm, the size of the guest’s private GTT is increased. Step 4: finally, the guest receives information about the GPU memory expansion from the host and shrinks the existing ballooned area so that it can be used to allocate objects. For example, as shown in Figure 3, the high global graphics memory area of vGPU1 is expanded to the right, and the shared memory areas of vGPU1 and vGPU3 are increased accordingly.

图3展示给来宾增配 GPU 内存的过程。来宾驱动因容量不足而必须回收旧对象时,执行四步:①来宾向宿主请求更多 GPU 内存;②宿主根据下文的调整算法选择共享开销最小的扩容方式;③据此增加来宾私有 GTT 的大小;④来宾收到扩容通知,缩小既有气球区域,使该区域可分配对象。例如图3中,vGPU1 的高位全局图形内存向右扩大,它与 vGPU3 的共享区域也相应增加。
Details are in the caption following the image
Figure 3 · GPU memory expansion process.
图3:GPU 内存扩容过程。

3.2. GPU Memory Reduction Strategy3.2 GPU 内存缩减策略

022

As the GPU memory is expanded by the GPU memory expansion request of a VM, the size of the GPU memory shared among the VMs can also be increased. Consequently, the probability that the entry will not exist in the physical GTT during the GPU context switch is increased, resulting in more GTT entry copies. This degrades the performance of the GPU application. In addition, as the number of entries to be copied is also increased, the CPU consumes more time copying the GTT entries, thus degrading the performance of the CPU application.

VM 请求扩容后,VM 之间共享的 GPU 内存范围也可能增大。上下文切换时物理 GTT 缺少相应表项的概率随之上升,需要复制更多 GTT 表项,拖慢 GPU 应用。同时,由于复制的表项变多,CPU 花在复制上的时间也增加,CPU 应用性能也会下降。
099
The gBalloon monitors the CPU cycles consumed for copying GTT entries during the GPU context switch to check the performance degradation of the GPU application. Profiling is performed at every t cycles. When N is the number of CPUs in the host and C is the CPU cycles consumed for copying GTT entries, the rate of time Rcopy consumed by the CPU to copy the GTT entries for unit time t can be expressed as follows:
R_copy=C/(t×N)×100% (1)
为检查 GPU 应用性能下降,gBalloon 监测上下文切换时复制 GTT 表项所消耗的 CPU 周期,每 t 个周期采样一次。令 N 为宿主 CPU 数量,C 为复制表项消耗的 CPU 周期,则单位时间 t 内,CPU 用于复制的时间比例 R_copy 如公式(1)。
023

Because one CPU processes the copying of the GTT entries, a total of N CPUs consume the cycles for the unit time. Thus, the number of CPUs must be reflected in Rcopy.

由于复制 GTT 表项由一个 CPU 处理,而单位时间内共有 N 个 CPU 消耗周期,因此 R_copy 必须计入 CPU 数量。
100
To check the performance degradation of the CPU application due to the competition among the vCPUs, the gBalloon uses the steal time. The steal time is the time when the vCPU of a VM exists in the ready queue. Assume that wij is the steal time of the vCPUj of VMi and sij is the time when the vCPUj of VMi exists in other queues. Then, the rate W of the steal times in all VMs can be expressed as follows:
W=Σ_iΣ_j w_ij/(w_ij+s_ij) (%) (2)
为检查 vCPU 竞争导致的 CPU 应用性能下降,gBalloon 使用 steal time,即某 VM 的 vCPU 在就绪队列中等待的时间。令 w_ij 为 VM_i 的 vCPU_j 的 steal time,s_ij 为其处于其他队列中的时间,则所有 VM 的 steal time 比例 W 如公式(2)。
024

A large value of W means that there is severe competition among the VMs. Therefore, the state of a physical machine (PM) can be defined by the values of W and Rcopy. If both W and Rcopy are large, then the performance of the CPU application is being degraded by the copying of the GTT entries. In this case, the host must prevent the performance degradation of the CPU and GPU applications by rejecting the GPU memory expansion requests of the VMs and reducing the GPU memory sharing among the VMs. Whereas, if W is large, but Rcopy is small, although there is severe competition among the VMs, it is not caused by the copying of the GTT entries. In this case, the performance of the CPU application could be degraded due to the increase in Rcopy. Thus, the GTT size should be reduced if possible. However, if W is small, but Rcopy is large, there is no competition among the VMs, but many copies of the GTT entries are occurring. In this case, if the VMs perform CPU applications, then the competition among the vCPUs can become more severe due to the copies of the GTT entries, and thus, the performance of the CPU application can degrade. Therefore, the host should try to reduce the sharing of GPU memory as much as possible. Finally, if both W and Rcopy are small, there is no overhead in the current PM, and the host does not need to take any action.

W 较大意味着 VM 之间竞争激烈。因此,可用 W 和 R_copy 描述物理机状态。两者均大时,复制 GTT 表项正在拖慢 CPU 应用,宿主应拒绝扩容并减少共享,以防 CPU、GPU 应用进一步退化。若 W 大而 R_copy 小,竞争虽激烈,但并非主要由复制引起;此时若 R_copy 增大仍可能拖慢 CPU 应用,所以应尽可能缩小 GTT。若 W 小而 R_copy 大,当前没有明显 VM 竞争,但复制很多;一旦 VM 开始执行 CPU 应用,复制会加剧 vCPU 竞争,因此宿主也应尽可能减少共享。两者均小时,当前物理机无此类开销,无须采取行动。
101
Based on the implications described above, the gBalloon identifies the degree of overhead in the host using the values of W and Rcopy. f(W, Rcopy), which represents the degree of overhead incurred due to the copying of the GTT entries, can be expressed as follows:
f(W,R_copy)=α×W+β×R_copy (3)
where α and β are the reciprocals of maximum W and Rcopy. Those parameters normalize the overall value by giving the same weight to W and Rcopy. The maximum W and Rcopy are dependent upon a particular hardware platform and are generally determined through experiments.
根据上述分析,gBalloon 使用 W、R_copy 判断宿主开销程度。由 GTT 表项复制造成的开销函数 f(W,R_copy) 如公式(3)。其中 α、β 分别是 W 与 R_copy 最大值的倒数,使二者归一化并获得相同权重;最大值依赖具体硬件平台,通常通过实验确定。
025

The gBalloon calculates f(W, Rcopy) every 0.5 seconds and classifies the value with two thresholds Thresholdlow and Thresholdhigh. Based on the classification, the gBalloon applies different GPU memory policies. The threshold values are experimentally determined from 0 to 2 as the value of f(W, Rcopy) ranges from 0 to 2. For the experiments, we use 0.5 (25% of the maximum value) and 1 (50% of the maximum value) for Thresholdlow and Thresholdhigh, respectively. If f(W, Rcopy) is smaller than Thresholdlow, the gBalloon approves all requests for GPU memory expansion and does not reduce the GPU memory of the VMs. If f(W, Rcopy) is larger than Thresholdlow, the gBalloon starts to decrease the size of the GPU memory allocated to each VM to reduce the overhead of the GPU memory sharing among the VMs. Instead of reducing the GPU memory of all VMs, the gBalloon reduces the GPU memory of the VM that occupies a large amount of GPU memory and has the lowest GPU memory utilization. If f(W, Rcopy) is larger than Thresholdhigh, the gBalloon rejects all requests for GPU memory expansion from the VMs and reduces a space corresponding to two 64 MB slots regardless of the GPU memory usage of each VM. The method for reducing GPU memory is to minimize the GPU memory sharing by using Algorithm 1 described in the next subsection.

gBalloon 每 0.5 秒计算 f(W,R_copy),按低、高两个阈值分类并采取不同策略。f 范围为0至2,实验选取低阈值0.5(最大值的25%)和高阈值1(50%)。低于低阈值时,批准所有 GPU 内存扩容请求,不缩减 VM 内存。高于低阈值时,开始缩减容量,以降低共享开销;不是缩减所有 VM,而是选择占用容量大且利用率最低的 VM。高于高阈值时,拒绝所有扩容请求,并且无论各 VM 的利用率如何,都缩减相当于两个 64 MB 槽位的空间。具体缩减方式采用下一小节算法1,以尽量减少共享。
    Algorithm 1: GPU memory adjustment algorithm.
  •  
    026

    Require:

    输入要求:
  •  
    027

     M: the total number of slots in high global graphics memory

    M:高位全局图形内存的总槽位数。
  •  
    028

     N: the number of vGPUs

    N:vGPU 数量。
  •  
    029

     V = {V0, V1,…, VN−1}: a set of vGPUs

    V={V_0,V_1,…,V_(N−1)}:vGPU 集合。
  •  
    030

     S = {S0, S1,…, SN−1}: a set of the number of occupied slots by vGPUs

    S={S_0,S_1,…,S_(N−1)}:各 vGPU 占用槽位数量的集合。
  •  
    031

     P = {P0, P1,…, PN−1}: a set of start slot index of vGPUs

    P={P_0,P_1,…,P_(N−1)}:各 vGPU 起始槽位下标的集合。
  •  
    032

     Q: the number of requested slots to expand/reduce

    Q:请求扩展/缩减的槽位数。
  •  
    033

     K: vGPU number that initiated memory expansion request

    K:发起内存扩容请求的 vGPU 编号。
  •  
    034

    Ensure:

    输出保证:
  •  
    035

     L, R: the number of slots to expand/reduce to the left side and the right side

    L、R:分别向左、向右扩展/缩减的槽位数量。
  •  
    036

     

    (原文空行)
  •  
    037

    procedure Expansion

    过程 Expansion(扩容):
  • (1)
    038

    ifSK + Q > M then return ERROR

    若 S_K+Q>M,则返回 ERROR。
  • (2)
    039

    minimum ⟵ ∞

    minimum ← ∞。
  • (3)
    040

    for i ⟵ Q-min(Q, M − PK − SK) to min(Q, PK) step 1 do

    i 从 Q−min(Q,M−P_K−S_K) 遍历至 min(Q,P_K),步长为1:
  • (4)
    041

     count ⟵ 0

    count ← 0。
  • (5)
    042

     for j ⟵ 0 to N − 1 step 1 do

    j 从0遍历至 N−1,步长为1:
  • (6)
    043

      Lcount ⟵ the number of occupied slots from PK − i to PK − 1 by Vj

    Lcount ← 在 P_K−i 至 P_K−1 范围内被 V_j 占用的槽位数。
  • (7)
    044

      Rcount ⟵ the number of occupied slots from PK + SK to PK + SK + Q − i − 1 by Vj

    Rcount ← 在 P_K+S_K 至 P_K+S_K+Q−i−1 范围内被 V_j 占用的槽位数。
  • (8)
    045

      count ⟵ count + Lcount + Rcount

    count ← count+Lcount+Rcount。
  • (9)
    046

     end for

    结束内层 for 循环。
  • (10)
    047

     if minimum > count then

    若 minimum>count:
  • (11)
    048

      minimum ⟵ count;

    minimum ← count。
  • (12)
    049

      L ⟵ i

    L ← i。
  • (13)
    050

     end if

    结束 if。
  • (14)
    051

    end for

    结束外层 for 循环。
  • (15)
    052

    R ⟵ Q − L

    R ← Q−L。
  • (16)
    053

    return L, R

    返回 L、R。
  •  
    054

    end procedure

    结束扩容过程。
  •  
    055

     

    (原文空行)
  •  
    056

    procedure Reduction

    过程 Reduction(缩容):
  • (1)
    057

    ifSK < Q then return ERROR

    若 S_K<Q,则返回 ERROR。
  • (2)
    058

    maximum ⟵ −1

    maximum ← −1。
  • (3)
    059

    for i ⟵ 0 to Q step 1 do

    i 从0遍历至 Q,步长为1:
  • (4)
    060

     count ⟵ 0

    count ← 0。
  • (5)
    061

     for j ⟵ 0 to N − 1 step 1 do

    j 从0遍历至 N−1,步长为1:
  • (6)
    062

      if j != K then

    若 j≠K:
  • (7)
    063

       Lcount ⟵ the number of occupied slots from PK to PK + i − 1 by Vj

    Lcount ← 在 P_K 至 P_K+i−1 范围内被 V_j 占用的槽位数。
  • (8)
    064

       Rcount ⟵ the number of occupied slots from PK + SK + i − Q to PK + SK − 1 by Vj

    Rcount ← 在 P_K+S_K+i−Q 至 P_K+S_K−1 范围内被 V_j 占用的槽位数。
  • (9)
    065

       count ⟵ count + Lcount + Rcount

    count ← count+Lcount+Rcount。
  • (10)
    066

      end if

    结束 if。
  • (11)
    067

     end for

    结束内层 for 循环。
  • (12)
    068

     if maximum < count then

    若 maximum<count:
  • (13)
    069

      maximum ⟵ count

    maximum ← count。
  • (14)
    070

      L ⟵ i

    L ← i。
  • (15)
    071

     end if

    结束 if。
  • (16)
    072

    end for

    结束外层 for 循环。
  • (17)
    073

    R ⟵ Q − L

    R ← Q−L。
  • (18)
    074

    return L, R

    返回 L、R。
  •  
    075

    end procedure

    结束缩容过程。

3.3. GPU Memory Adjustment Algorithm3.3 GPU 内存调整算法

076

The GPU memory is adjusted to minimize the GPU memory sharing with the existing VMs. When the gBalloon decides the number of GPU memory slots and the target vGPU to adjust based on the GPU memory expansion and reduction strategies discussed earlier, the spaces at both sides of the GPU memory space allocated to VMs are increased or decreased.

调整 GPU 内存的目标,是尽量减少与已有 VM 的共享。根据前述扩缩容策略,gBalloon 决定要调整的槽位数和目标 vGPU 后,就在该 VM 已分配 GPU 内存空间的左右两端增减空间。
077

For example, let us assume that vGPU4 initiated a GPU memory expansion request for two slots when there are four vGPUs from vGPU1 to vGPU4 that require two, two, two, and one slots, respectively. Also assume that there are five slots, and the GPU memory size of the host is 320 MB as shown in Figure 4. In this case, there are three possible methods for expanding the two slots as requested by vGPU4: (1) expanding two slots to the left side, (2) expanding one slot each to the left and right sides, and (3) expanding two slots to the right side. In the first case, vGPU4 shares slots 1 and 2 with vGPU1, resulting in two shared slots in total. In the second case, vGPU4 shares slot 2 with vGPU1 and slot 4 with vGPU2 and vGPU3, resulting in three shared slots in total. In the third case, vGPU4 shares slot 4 with vGPU2 and vGPU3 and slot 5 with vGPU3, resulting in three shared slots in total. Therefore, a strategy of expanding two slots to the left minimizes the number of shared slots. The gBalloon measures the number of shared slots and expands the GPU memory allocated to the VM to minimize the sharing overhead among the VMs.

例如图4,假设 vGPU1至vGPU4 分别需要2、2、2、1个槽位,总共5个槽位,宿主 GPU 内存为320 MB,vGPU4 请求再扩2槽。可选择:①向左扩2槽;②左右各扩1槽;③向右扩2槽。第一种与 vGPU1 共享槽1、2,共计2次槽位共享;第二种在槽2与 vGPU1 共享、槽4与 vGPU2及vGPU3 共享,共计3次;第三种在槽4与 vGPU2及vGPU3 共享、槽5与 vGPU3 共享,也共计3次。所以向左扩2槽最能减少共享。gBalloon 衡量共享槽位数,据此扩容,使 VM 间共享开销最小。
Details are in the caption following the image
Figure 4 · Example of GPU memory expansion.
图4:GPU 内存扩容示例。
078

The method for reducing GPU memory is the same as that for expanding it. In Figure 4, when the GPU memory of vGPU3 should be reduced by one slot, reducing slot 4 rather than slot 5 can minimize the GPU memory sharing among the VMs. Thus, the policy for minimizing the GPU memory sharing can maximize the effect of the predictive-copy technique [21] that copies the GTT entries in advance by predicting the next scheduled vGPU before the GPU context switch. The detailed algorithms for memory expansion and reduction are presented below.

缩容与扩容采用相同思路。图4中,若 vGPU3 要缩1槽,回收槽4比槽5更能减少共享。这种最小化共享的策略,也能最大化 predictive-copy(预测复制)技术 [21] 的效果:它预测下一个被调度的 vGPU,并在上下文切换前预先复制 GTT 表项。下文给出扩缩容的详细算法。

4. Performance Evaluation4 性能评估

079

In this section, we compare the performance of the gBalloon with that of the gVirt using various workloads. Table 1 shows the experimental environment for the performance evaluation. The global graphics memory size of the host is set to 4 GB, which consists of 256 MB of low global graphics memory and 3840 MB of high global graphics memory. Dom0 does not share the global graphics memory with other domains, but other guest VMs share 64 MB of the low global graphics memory and 3456 MB of the high global graphics memory excluding the Dom0 area. The low global graphics memory size of every guest VM is set to 64 MB as recommended in [20], whereas the high global graphics memory size is set differently depending on the experiments.

本节用多种工作负载比较 gBalloon 和 gVirt。实验环境见表1。宿主全局图形内存设置为4 GB,其中低位256 MB、高位3840 MB。Dom0 不与其他域共享全局图形内存;扣除 Dom0 区域后,其他来宾 VM 共享64 MB低位、3456 MB高位内存。依照文献 [20],每个来宾的低位容量均设64 MB,高位容量则随实验变化。
Table 1. Evaluation environment.
Host physical machine宿主物理机
Processor处理器 Intel core i7-6700 3.40 GHz (8 cores)/Intel HD Graphics 530
Memory内存 48 GB
Disk磁盘 Samsung SSD 850 PRO 256 GB ∗ 3
Host virtual machine (Dom0)宿主虚拟机(Dom0)
vCPU 8
Memory内存 4096 MB
Hypervisor虚拟机监控器 Xen version 4.6.0
OS操作系统 Ubuntu 16.04.1 (kernel version 4.3.0)
Low/high global graphics memory低位/高位全局图形内存 64 MB/384 MB
Guest virtual machine来宾虚拟机
vCPU 2
Memory内存 2560 MB
OS操作系统 Ubuntu 16.04 (kernel version 4.3.0)
Low global graphics memory低位全局图形内存 64 MB
080

The experiments use four 3D benchmarks and four 2D benchmarks. To measure the 3D performance, Lightsmark, Openarena, Nexuiz, and Urbanterror of Phoronix Test Suite [30] and Unigine Valley (valley) [32] that requires many rendering operations are used. To measure the 2D performance, Firefox-asteroids (Firefox-ast), Firefox-scrolling (Firefox-scr), gnome-system-monitor (gnome), and Midori of Cairo-perf-trace [33] are used. The performance of the 3D benchmarks is measured by the average number of FPS, and the performance of the 2D benchmarks is measured by the execution time. Furthermore, the NAS Parallel Benchmark (NPB) [34] is used to measure the overhead for the CPU due to the GPU context switch.

原文称实验使用四个3D与四个2D基准。3D测试列出 Phoronix Test Suite [30] 的 Lightsmark、Openarena、Nexuiz、Urbanterror,以及需要大量渲染操作的 Unigine Valley(valley)[32];2D测试使用 Cairo-perf-trace [33] 的 Firefox-asteroids(Firefox-ast)、Firefox-scrolling(Firefox-scr)、gnome-system-monitor(gnome)、Midori。3D性能以平均 FPS 衡量,2D性能以执行时间衡量。另外,用 NAS Parallel Benchmark(NPB)[34] 测量 GPU 上下文切换带给 CPU 的开销。【译注:原文“四个3D”与列出的五个名称不一致,保留这一疑点。】

4.1. Performance Comparison Using a Single GPU Application4.1 使用单一 GPU 应用的性能比较

081

In this subsection, the performance of the gVirt and the gBalloon is compared when valley that requires many rendering operations is executed by multiple VMs. For the gVirt, the gVirt-384 (a gVirt version with the high global graphics memory set to 384 MB) and the gVirt-1024 (a gVirt version with the high global graphics memory set to 1024 MB) are used for the performance comparison. For the 2D and 3D benchmarks that do not demand many rendering operations, additional GPU memory is not allocated because they require a small amount of high global graphics memory. Therefore, valley is used to compare the performance of the dynamic GPU memory expansion policy of the gBalloon with that of the gVirt. To observe the performance variations due to the increase in the number of VMs and the change in the degree of GPU memory sharing, experiments were performed in which the number of VMs was increased by three.

本小节让多个 VM 执行渲染密集的 valley,比较 gVirt 与 gBalloon。对照组为高位容量固定384 MB的 gVirt-384,以及固定1024 MB的 gVirt-1024。那些渲染需求较少的2D、3D基准只需较小高位容量,不会分配额外 GPU 内存,因此选 valley 比较动态扩容策略。为观察 VM 数量及共享程度变化的影响,每次将 VM 数量增加3个。
082

Figure 5 depicts the performance of the gVirt-384, the gVirt-1024, and the gBalloon normalized to the performance of the gVirt-384 by the sum of the FPS values of all VMs when there are 3, 6, 9, 12, or 15 VMs. When the number of VMs is six or fewer, the gVirt-1024 shows better performance than the gVirt-384 because the overhead from the GPU memory sharing is small. The gBalloon also shows a similar performance as the gVirt-1024 because the gBalloon allocates the required amount of GPU memory to VMs. In particular, as the number of VMs is increased, the performance of the gVirt-1024 and the gBalloon becomes more similar because the effect of overhead on the performance degradation becomes small, and the effect of performance degradation due to the GPU memory sharing becomes large. For this reason, all implementations show similar performance when the number of VMs is nine or higher.

图5展示3、6、9、12、15个 VM 的 FPS 总和,以 gVirt-384 归一化。当 VM 不超过6个时,共享开销较小,gVirt-1024 比 gVirt-384 更快;gBalloon 按需分配,性能也接近 gVirt-1024。原文进一步指出,随着 VM 增多,gVirt-1024 与 gBalloon 的性能更接近,因为一般开销所带来的性能影响变小,而共享造成的性能下降影响变大。因此,9个及更多 VM 时,各实现性能相近。
Details are in the caption following the image
Figure 5 · Performance of a single GPU benchmark.
图5:单一 GPU 基准的性能。

4.2. Performance Comparison Using Multiple GPU Applications4.2 使用多种 GPU 应用的性能比较

083

In this subsection, the performance of gVirt-384, gVirt-1024, and gBalloon is compared by running various types of GPU applications on 15 VMs. As shown in Table 2, 15 VMs run randomly selected 2D and 3D benchmarks. Because various benchmarks are mixed, it is possible to compare the degree of the performance degradation of the GPU applications due to the GPU memory-sharing overhead that may occur as the requirements for the GPU memory change.

本小节在15个 VM 上运行不同 GPU 应用,比较 gVirt-384、gVirt-1024、gBalloon。如表2,每个 VM 执行随机选择的2D、3D基准。混合多种基准,可在 GPU 内存需求变化时比较共享开销引起的性能下降。
Table 2. The benchmark sequence that each VM performs.
  Benchmark 1基准1 Benchmark 2基准2 Benchmark 3基准3
VM1 Gnome Openarena Valley
VM2 Valley Firefox-ast Urbanterror
VM3 Midori Valley Nexuiz
VM4 Valley Firefox-scr Urbanterror
VM5 Valley Firefox-scr Lightsmark
VM6 Lightsmark Gnome Valley
VM7 Gnome Valley Openarena
VM8 Urbanterror Valley Firefox-scr
VM9 Midori Nexuiz Valley
VM10 Valley Lightsmark Firefox-scr
VM11 Gnome Openarena Valley
VM12 Nexuiz Firefox-ast Valley
VM13 Valley Openarena Firefox-ast
VM14 Midori Valley Lightsmark
VM15 Valley Nexuiz Firefox-ast
084

Figure 6 shows the performance comparison when the randomly selected 2D and 3D benchmarks shown in Table 2 are executed by 15 VMs. All performance values are normalized to that of the gVirt-384. Strangely, valley in the gVirt-1024 shows a better performance than the gVirt-384 although the overhead is large due to the GPU memory sharing. However, the performance of the other 3D benchmarks is decreased by 50% or higher and the performance of the 2D benchmarks by 25%. Thus, the performance of the total VMs drops by 24%, on average, compared with that of the gVirt-384. In the case of the gBalloon, the performance of valley is guaranteed because the GPU memory size of each VM expands as the required amount of GPU memory increases. Moreover, the gBalloon minimizes the overhead due to the GPU memory sharing by dynamically adjusting the GPU memory size according to the GPU memory usage. As a result, the GPU context switch time is decreased, and the performance of valley is increased by up to 28%. The performance of the other benchmarks is similar to that of the gVirt-384. Figure 7 shows a summary of the performance in all benchmarks. The performance of the gBalloon is higher by 8% than that of the gVirt-384 and higher by 32% than that of the gVirt-1024.

图6比较15个 VM 执行表2中随机2D、3D基准的结果,均以 gVirt-384 归一化。值得注意的是,虽然 gVirt-1024 的共享开销很大,valley 仍比 gVirt-384 更快;但其他3D基准的性能下降50%或更多,2D基准下降25%,总体平均下降24%。gBalloon 则随需求增加而扩容,保障 valley 的性能,又根据使用情况动态调整容量、尽量降低共享开销,使上下文切换时间减少,valley 性能最高提升28%;其他基准与 gVirt-384 相近。图7汇总所有基准:gBalloon 比 gVirt-384 高8%,比 gVirt-1024 高32%。
Details are in the caption following the image
Figure 6 · Performance of each GPU benchmark.
图6:各 GPU 基准的性能。
Details are in the caption following the image
Figure 7 · Performance summary of all benchmarks.
图7:全部基准的性能汇总。

4.3. Performance Comparison Using CPU and GPU Applications4.3 混合 CPU 与 GPU 应用的性能比较

085

In this subsection, the effect of performance degradation in CPU applications caused by the copying of the private GTT entries is analyzed. Among the 15 VMs, 7 VMs run with CPU workloads, whereas the remaining 8 VMs run with GPU workloads. The CPU workload uses cg of the NPB benchmark, which is a workload to find the smallest eigenvalue of the matrix using the conjugate gradient method.

本小节分析复制私有 GTT 表项对 CPU 应用的性能影响。15个 VM 中,7个执行 CPU 工作负载,其余8个执行 GPU 工作负载。CPU测试采用 NPB 中的 cg,用共轭梯度法求矩阵的最小特征值。
086

Figure 8 shows the performance of the CPU and GPU benchmarks normalized to that of the gVirt-384. In the case of the gVirt-1024, the performance of cg is decreased by 19% compared with that of the gVirt-384. This is because the CPU consumes a great deal of time copying the private GTT entries due to the large amount of GPU memory shared among the VMs. Furthermore, the performance of valley is increased slightly by approximately 4% due to this overhead. In contrast, the gBalloon limits the increase in the GPU memory size of the VMs by detecting the overhead of the CPU and the overhead due to the copying of the GTT entries. As a result, the performance of cg is decreased by approximately 1.5%, and the performance of valley is increased by approximately 2% compared with that of gVirt-384.

图8将 CPU、GPU 基准结果相对 gVirt-384 归一化。gVirt-1024 中,cg 性能下降19%,因为 VM 间共享大量 GPU 内存,CPU 花费很多时间复制私有 GTT 表项;valley 性能仅提高约4%。gBalloon 检测 CPU 开销和 GTT 复制开销,限制 VM 的 GPU 内存增长。结果,相比 gVirt-384,cg 性能约下降1.5%,valley 约提升2%。
Details are in the caption following the image
Figure 8 · Performance when CPU and GPU benchmarks are performed at the same time.
图8:同时运行 CPU、GPU 基准时的性能。

4.4. Overhead and Sensitivity Analysis4.4 开销与敏感性分析

087

In this subsection, the performance of the gBalloon and the gVirt in a single VM environment is compared. High global graphics memory sizes of 384 MB and 1024 MB are set for the VMs of the gBalloon and the gVirt, respectively. Figure 9 shows the adaptive behavior in the GPU memory slots of the VMs over time when valley is performed with the dynamic GPU memory expansion policy of the gBalloon. Valley is composed of 18 scenes in total, and the amount of GPU memory required is different for each scene. When valley is executed first, the required amount of GPU memory is increased sharply, and the gBalloon expands three slots in 2 second intervals. Then, one slot is expanded for several scenes. The number of slots is increased up to 13, and the size of the high global graphics memory of the VMs is increased to 832 MB.

本小节比较单 VM 环境下的 gBalloon 和 gVirt,初始高位容量分别设为384 MB、1024 MB。图9展示 valley 执行时 gBalloon 动态扩容造成的槽位变化。Valley 有18个场景,各场景需求不同。开始运行时需求陡增,gBalloon 以2秒间隔扩展三个槽位;之后若干场景再逐次扩一个。槽位最多增加至13个,高位容量增至832 MB。
Details are in the caption following the image
Figure 9 · Changes in GPU memory size allocated to VMs when GPU benchmarking requiring a lot of GPU memory is executed.
图9:执行需要大量 GPU 内存的基准时,VM 获配 GPU 内存容量的变化。
088

Figure 10 shows the performance of gBalloon for each scene and the overall performance, which is normalized to that of the gVirt. As shown in Figure 10, the overall performance of the gBalloon is lower by approximately 1.9% than that of the gVirt. This is because the slots are increased one by one, resulting in performance degradation due to the temporary lack of GPU memory despite the sharp increase in the amount of GPU memory required in the first scene. However, this performance degradation is negligible. From the 10th scene when the number of slots becomes 12, the performance degradation disappears due to the frequent expansion requests and the lack of GPU memory. Thus, the FPS values of the gVirt and the gBalloon are similar.

图10展示各场景及总体性能,以 gVirt 归一化。gBalloon 总体约低1.9%,因为第一个场景需求突增,而槽位逐个增加,暂时容量不足,导致性能下降。作者认为该损失很小。从第10场景、槽位数达到12开始,频繁扩容请求和容量不足导致的性能损失消失,两者 FPS 相近。
Details are in the caption following the image
Figure 10 · Performance comparison of VMs when GPU benchmarking requiring a lot of GPU memory is executed.
图10:执行需要大量 GPU 内存的基准时的 VM 性能比较。

5. Related Works5 相关工作

089

Kato et al. [35], Wang et al. [36], Ji et al. [37], and Becchi et al. [38] proposed technologies for solving the problem of insufficient GPU memory when compute unified device architecture (CUDA) is performed in the NVIDIA GPU environment. When the amount of GPU memory is insufficient, the data in the GPU memory are moved to the system memory to secure space in the GPU memory, which is allocated to the applications. However, this copy operation has large overhead when performed at runtime, and the user must use a modified API.

Kato等 [35]、Wang等 [36]、Ji等 [37]、Becchi等 [38] 针对 NVIDIA GPU 运行 CUDA 时内存不足提出了技术:把 GPU 数据移至系统内存,腾出 GPU 空间给应用。然而运行时复制开销较大,而且用户必须使用修改后的 API。
090

Kehne et al. [39] and Kehne et al. [40] proposed a swap policy for reducing the overhead at runtime and improving the resource fairness among GPU applications and the utilization of GPU memory. GPUswap divides the buffer into chunks of a fixed size, randomly selects the chunk of an application that occupies the largest amount of GPU memory, and moves the chunk to the system memory when the GPU memory is insufficient. GPUswap randomly selects chunks from applications that occupy the largest amount of memory. However, because the chunk to be removed from the system memory is randomly selected, the performance of the corresponding applications may be degraded if highly reusable data are removed from the GPU memory. To reduce this overhead, GPrioSwap determines the priorities of the chunks by profiling the GPU memory access counts of the GPU applications and moves the chunk with the lowest priority when the GPU memory is insufficient.

Kehne等 [39,40] 提出交换策略,以降低运行时开销、改善 GPU 应用间的资源公平性和利用率。GPUswap 将缓冲区分成固定大小的块,在 GPU 内存不足时,从占用最多的应用中随机选择一个块移至系统内存。然而若随机移出的恰好是重用率高的数据,应用性能会下降。GPrioSwap 则分析 GPU 内存访问次数,确定块优先级,并在容量不足时移出优先级最低的块,以降低开销。【译注:原文一处写“从系统内存移除”,与前后描述不一致,此处按机制上下文表达,英文对照保留原句。】
091

Studies have also been conducted to prevent program crashes when the GPU is shared between containers. Kang et al. [41] proposed a solution that proposes the amount of GPU memory that can be allocated to each container. When a container asks to use more than the limited GPU memory size, ConVGPU rejects the request. In contrast, when the GPU memory is insufficient, ConVGPU lets the container wait until GPU memory becomes available even if the requested amount of memory is less than the limited memory size. However, these studies were targeted at discrete GPUs whose data are transferred through PCIe bus and cannot be directly applied to the heterogeneous system architecture. In this architecture, the system memory is used as the GPU memory, and the data copying between the CPU and the GPU is carried out through a zero-copy buffer.

还有研究防止多个容器共享 GPU 时程序崩溃。Kang等 [41] 的 ConVGPU 为每个容器规定可分配 GPU 内存上限;申请超过上限就拒绝。若申请未超上限但当前空闲不足,则让容器等待。上述研究面向经 PCIe 传输数据的独立 GPU,不能直接用于异构系统架构;在后者中,系统内存被用作 GPU 内存,CPU、GPU 的数据访问通过零复制缓冲区完成。
092

To improve the memory efficiency in the hypervisor environment, the memory overcommitment technique that decreases or increases the memory allocated to VMs is used. Waldspurger [23], Zhou et al. [24], Zhao et al. [25], Guo [26], Kim et al. [27], and Lu and Shen [28] periodically profiled the access frequencies of pages by nullifying the translation look-aside buffer (TLB) entries of randomly selected pages. Based on this, the least accessed pages are returned when the amount of memory is insufficient. However, this method has a problem because performance degradation may occur due to the nullification of the TLB entries. Furthermore, in [26], [27], [28], and [29], the problem of an inability to respond to sudden changes in VMs’ memory demands due to the cyclic overcommitment exists. To solve this problem, the memory pressure aware (MPA) ballooning [27] applies different memory return policies by distinguishing the degree of memory pressure between an anonymous page and a file page. The MPA reduces the performance degradation caused by page return by setting the page with a high probability of becoming the least accessed as the object of return using Linux active and inactive lists. Furthermore, the MPA responds to the VMs’ unexpected memory requests by immediately reallocating the memory to sudden memory requests and returning the memory slowly.

为提高 hypervisor 环境的内存效率,可用内存超额分配技术增减 VM 内存。Waldspurger [23]、Zhou等 [24]、Zhao等 [25]、Guo [26]、Kim等 [27]、Lu和Shen [28] 通过让随机页面的 TLB 表项失效,周期性分析页访问频率,并在内存不足时回收最少访问的页。但 TLB 失效本身可能降低性能。此外,[26–29] 的周期性调整不能及时应对 VM 需求突变。内存压力感知气球(MPA)[27] 区分匿名页和文件页的压力,采用不同回收策略;利用 Linux 活跃/非活跃链表,把更可能成为低访问页的页作为回收对象,减少性能损失。面对意外的内存突增,MPA 立即重新分配内存,而缓慢回收,以及时响应。【译注:这是本文对相关工作的概括,不表示每篇被引论文都使用完全相同的 TLB 技术。】
093

Recently, Park et al. [22] proposed a dynamic memory management technique for Intel’s integrated GPU called DymGPU that provides two memory allocation policies: size- and utilization-based algorithms. Although DymGPU improves the performance of VMs by minimizing the overlap of the graphics memory space among VMs and thus reduces the context switch overhead, DymGPU’s allocation is still static, and the memory size cannot be changed at runtime.

近期 Park等 [22] 提出面向 Intel 集成 GPU 的 DymGPU,提供基于容量、基于利用率的两种分配策略。它通过减少 VM 间图形地址空间重叠,降低上下文切换开销并提升性能;但分配仍是静态的,不能在运行时改变容量。

6. Conclusion and Future Works6 结论与未来工作

094

In GPU virtualization, due to the static allocation of GPU memory, the performance of VMs that require more GPU memory can be degraded or the GPU application can crash. The gBalloon, proposed in this paper, improves the performance of VMs due to the lack of GPU memory by dynamically adjusting the GPU memory size allocated to each VM. Moreover, the gBalloon detects the increase in overhead due to GPU memory sharing and reduces the GPU memory size of the VMs that unnecessarily occupy a large amount of GPU memory. Consequently, the GPU context switch time is decreased, and the performance of the GPU applications is increased. Furthermore, the performance of the CPU applications is also guaranteed because the CPU load is reduced. The study demonstrated through experiments that the performance of the gBalloon improved by up to 32% when compared with the performance of gVirt with 1024 MB of high global graphics memory.

GPU 虚拟化中的静态容量可能使需要更多内存的 VM 性能下降,甚至使 GPU 应用崩溃。gBalloon 在运行时动态调整各 VM 的容量,改善由容量不足引起的性能问题;也检测共享开销上升,缩减无谓占用大容量的 VM,减少上下文切换时间,提高 GPU 应用性能。同时 CPU 负载减少,也能保障 CPU 应用性能。实验表明,相比高位容量1024 MB的 gVirt,gBalloon 性能最高提升32%。
095

Currently, the gBalloon increases or decreases only the spaces at both sides to adjust the GPU memory space allocated to VMs. This problem can be solved by allocating non-consecutive spaces of small slot units rather than consecutive GPU memory spaces to VMs. We are currently investigating this issue.

当前 gBalloon 只在 VM 已分配空间的两端增减。将来可把分配单位改为不连续的小槽位,而不要求连续 GPU 内存空间,从而解决这一限制。作者正在研究该问题。

Conflicts of Interest利益冲突声明

096

The authors declare that there are no conflicts of interest regarding the publication of this paper.

作者声明,本文发表不存在利益冲突。

Acknowledgments致谢

097

This research was supported by the Next-Generation Information Computing Development Program through the National Research Foundation of Korea (NRF) funded by the Ministry of Science, ICT (2017M3C4A7080245).

本研究由韩国国家研究基金会(NRF)的下一代信息计算开发计划支持,资助来自科学与信息通信技术部,项目编号2017M3C4A7080245。

    Data Availability数据可用性

    098

    The data used to support the findings of this study are included within the article.

    支持本研究结论的数据包含于本文之中。

    References参考文献(保留英文)

    • 1 Reaño C., Silla F., Shainer G., and Schultz S., Local and remote GPUs perform similar with EDR 100G InfiniBand, Proceedings of the Industrial Track of the 16th International Middleware Conference, December 2015, Vancouver, BC, Canada.
    • 2 Duato J., Pena A. J., Silla F., Mayo R., and Quintana-Orti E. S., rCUDA: reducing the number of GPU-based accelerators in high performance clusters, Proceedings of International Conference on High Performance Computing & Simulation, June 2010, Caen, France.
    • 3 Shi L., Chen H., Sun J., and Li K., vCUDA: GPU-accelerated high-performance computing in virtual machines, IEEE Transactions on Computers. (2012) 61, no. 6, 804–816, https://doi.org/10.1109/tc.2011.112, 2-s2.0-84860524424.
    • 4 Qi Z., Yao J., Zhang C., Yu M., Yang Z., and Guan H., VGRIS: virtualized GPU resource isolation and scheduling in cloud gaming, ACM Transactions on Architecture and Code Optimization (TACO). (2014) 11, no. 2, 1–25, https://doi.org/10.1145/2632216, 2-s2.0-84907339380.
    • 5 Jang S. M., Choi W., and Kim W. Y., Client rendering method for desktop virtualization services, ETRI Journal. (2013) 35, no. 2, 348–351, https://doi.org/10.4218/etrij.13.0212.0213, 2-s2.0-84878588753.
    • 6 Giunta G., Montella R., Agrillo G., and Coviello G., A GPGPU transparent virtualization component for high performance computing clouds, European Conference on Parallel Processing, 2010, Berlin, Heidelberg, Springer.
    • 7 Montella R., Giunta G., and Laccetti G., Virtualizing high-end GPGPUs on ARM clusters for the next generation of high performance cloud computing, Cluster Computing. (2014) 17, no. 1, 139–152, https://doi.org/10.1007/s10586-013-0341-0, 2-s2.0-84896394744.
    • 8 Montella R., Giunta G., Laccetti G. et al., On the virtualization of CUDA based GPU remoting on ARM and X86 machines in the GVirtuS framework, International Journal of Parallel Programming. (2017) 45, no. 5, 1142–1163, https://doi.org/10.1007/s10766-016-0462-1, 2-s2.0-84991112040.
    • 9 Xiao S., Balaji P., Zhu Q. et al., VOCL: an optimized environment for transparent virtualization of graphics processing units, Proceedings of Innovative Parallel Computing (InPar), May 2012, San Jose, CA, USA.
    • 10 Zhang C., Yao J., Qi Z., Yu M., and Guan H., vGASA: adaptive scheduling algorithm of virtualized GPU resource in cloud gaming, IEEE Transactions on Parallel and Distributed Systems. (2014) 25, no. 11, 3036–3045, https://doi.org/10.1109/tpds.2013.288, 2-s2.0-84904498998.
    • 11 Lee C., Kim S.-W., and Yoo C., VADI: GPU virtualization for an automotive platform, IEEE Transactions on Industrial Informatics. (2016) 12, no. 1, 277–290.
    • 12 Abramson D., Intel virtualization technology for directed I/O, Intel Technology Journal. (2006) 10, no. 3, https://doi.org/10.1535/itj.1003.02.
    • 13 Yang C.-T., Liu J.-C., Wang H.-Y., and Hsu C.-H., Implementation of GPU virtualization using PCI pass-through mechanism, Journal of Supercomputing. (2014) 68, no. 1, 183–213, https://doi.org/10.1007/s11227-013-1034-4, 2-s2.0-84898061475.
    • 14 Amazon high performance computing cloud using GPU, http://aws.amazon.com/hpc/.
    • 15 Jennings R., Cloud Computing with the Windows Azure Platform, 2010, John Wiley & Sons, Hoboken, NJ, USA.
    • 16 Herrera A., NVIDIA GRID: Graphics Accelerated VDI with the Visual Performance of a Workstation, 2014, Nvidia Corp, Santa Clara, CA, USA.
    • 17 Tian K., Dong Y., and Cowperthwaite D., A full GPU virtualization solution with mediated pass-through, Proceedings of USENIX Annual Technical Conference (USENIX ATC 14), June 2014, Philadelphia, PA, USA.
    • 18 Suzuki Y., Kato S., Yamada H., and Kono K., GPUvm: why not virtualizing GPUs at the hypervisor?, Proceedings of 2014 USENIX Annual Technical Conference (USENIX ATC 14), June 2014, Philadelphia, PA, USA.
    • 19 Tan H., Tan Y., He X., Li K., and Li K., A virtual multi-channel GPU fair scheduling method for virtual machines, IEEE Transactions on Parallel and Distributed Systems. (2019) 30, no. 2, 257–270, https://doi.org/10.1109/tpds.2018.2865341, 2-s2.0-85051674686.
    • 20 Xue M., gScale: scaling up GPU virtualization with dynamic sharing of graphics memory space, Proceedings of 2016 USENIX Annual Technical Conference (USENIX ATC 16), June 2016, Denver, CO, USA.
    • 21 Xue M., Ma J., Li W. et al., Scalable GPU virtualization with dynamic sharing of graphics memory space, IEEE Transactions on Parallel and Distributed Systems. (2018) 29, no. 8, 1823–1836, https://doi.org/10.1109/tpds.2018.2789883, 2-s2.0-85041173169.
    • 22 Park Y., Gu M., Yoo S., Kim Y., and Park S., DymGPU: dynamic memory management for sharing GPUs in virtualized clouds, Proceedings of 2018 IEEE 3rd International Workshops on Foundations and Applications of Self∗ Systems (FAS∗W), September 2018, Trento, Italy.
    • 23 Waldspurger C. A, Memory resource management in VMware ESX server, ACM SIGOPS Operating Systems Review. (2002) 36, 181–194, https://doi.org/10.1145/844128.844146, 2-s2.0-84978382687.
    • 24 Zhou P., Pandey V., Sundaresan J., Raghuraman A., Zhou Y., and Kumar S., Dynamic tracking of page miss ratio curve for memory management, ACM SIGOPS Operating Systems Review. (2004) 38, no. 5, https://doi.org/10.1145/1037949.1024415, 2-s2.0-33845412281.
    • 25 Zhao W., Wang Z., and Luo Y., Dynamic memory balancing for virtual machines, ACM SIGOPS Operating Systems Review. (2009) 43, no. 3, 37–47, https://doi.org/10.1145/1618525.1618530, 2-s2.0-77952254745.
    • 26 Guo F., Understanding Memory Resource Management in VMware vSphere 5.0, 2011, VMware, Inc., Palo Alto, California, USA.
    • 27 Kim J., Fedorov V., Gratz P. V., and Narasimha Reddy A. L., Dynamic memory pressure aware ballooning, Proceedings of the 2015 International Symposium on Memory Systems, October 2015, Washington DC, USA.
    • 28 Lu P. and Shen K., Virtual machine memory access tracing with hypervisor exclusive cache, Proceedings of Usenix Annual Technical Conference, June 2007, Santa Clara, CA, USA.
    • 29 Magenheimer D., Mason C., McCracken D. et al., Transcendent memory and linux, Proceedings of the Linux Symposium, July 2009, Montreal, QC, Canada.
    • 30 Phoronix Test Suite, http://phoronix-test-suite.com.
    • 31 Intel GVT-G (XENGT) public release-Q4’2016, https://01.org/igvt-g/blogs/wangbo85/2017/intel-gvt-g-xengt-public-release-q42016.
    • 32 UNIGINE valley, https://benchmark.unigine.com/valley.
    • 33 Cairo-perf-trace, http://www.cairographics.org.
    • 34 Bailey D. H., Barszcz E., Barton J. T. et al., The nas parallel benchmarks, International Journal of Supercomputing Applications. (1991) 5, no. 3, 63–73, https://doi.org/10.1177/109434209100500306, 2-s2.0-84973836157.
    • 35 Kato S., McThrow M., Maltzahn C., and Brandt S. A., Gdev: first-class GPU resource management in the operating system, Proceedings of 2012 USENIX Annual Technical Conference (USENIX ATC 12), June 2012, Boston, MA, USA.
    • 36 Wang K., Ding X., Lee R., Kato S., and Zhang X., GDM, ACM SIGMETRICS Performance Evaluation Review. (2014) 42, no. 1, 533–545, https://doi.org/10.1145/2637364.2592002.
    • 37 Ji F., Lin H., and Ma X., RSVM: a region-based software virtual memory for GPU, Proceedings of the 22nd International Conference on Parallel Architectures and Compilation Techniques, 2013, Edinburgh, UK.
    • 38 Becchi M., Sajjapongse K., Graves I., Procter A., Ravi V., and Chakradhar S., A virtual memory based runtime to support multi-tenancy in clusters with GPUs, Proceedings of the 21st International Symposium on High-Performance Parallel and Distributed Computing, June 2012, Delft, Netherlands.
    • 39 Kehne J., Metter J., and Frank B., GPUswap: enabling oversubscription of GPU memory through transparent swapping, ACM SIGPLAN Notices. (2015) 50, no. 7, ACM, 65–77, https://doi.org/10.1145/2817817.2731192.
    • 40 Kehne J., Hillenbrand M., Metter J., Gottschlag M., Merkel M., and Bellosa F., GPrioSwap: towards a swapping policy for GPUs, Proceedings of the 10th ACM International Systems and Storage Conference, May 2017, Haifa, Israel.
    • 41 Kang D., Jun T. J., Kim D., Kim J., and Kim D., ConVGPU: GPU management middleware in container based virtualized environment, Proceedings of 2017 IEEE International Conference on Cluster Computing (CLUSTER), September 2017, Honolulu, HI, USA.
    原文:Younghun Park; Minwoo Gu; Sungyong Park,Ballooning Graphics Memory Space in Full GPU Virtualization Environments。原文链接 · CC BY 4.0。本页对原文进行了中文翻译、结构化、图像本地化及译注添加,原作者未背书本译稿;图内英文及参考文献保留原样。
    ↑