虚拟化 cpu虚拟化_谁在偷虚拟CPU时间?

虚拟化 cpu虚拟化

Hi! In this article, I want to explain, in layman’s terms, how steal appears in VMs and tell you about some of the less-than-obvious artifacts that we found during research on the topic that I was involved in as CTO of the Mail.ru Cloud Solutions platform. The platform runs KVM.

嗨! 在本文中,我想以通俗易懂的方式来解释窃取如何在虚拟机中出现,并向您介绍在我作为邮件的 CTO参与主题研究期间发现的一些不太明显的工件。 ru云解决方案平台。 该平台运行KVM。

CPU steal time is the time during which a VM doesn’t receive the necessary resources to operate. This time can only be calculated in a guest OS in virtualization environments. It is extremely unclear where the allocated resources are lost, just like in real life situations. However, we decided to figure it out, and we even performed a series of tests to do so. That is not to say that we know everything about steal, but there are some fascinating things that we would like to share with you.

CPU窃取时间是指VM无法接收到所需的资源以进行操作的时间。 此时间只能在虚拟化环境中的来宾OS中计算。 就像在现实生活中一样,目前还不清楚分配的资源在哪里丢失。 但是,我们决定解决这个问题,我们甚至进行了一系列测试。 这并不是说我们对盗窃一无所知但我们希望与您分享一些有趣的事情。

1.什么是偷窃(1. What is steal?)

Steal is a metric that indicates a lack of CPU time for VM processes. As described in the 窃取是一种指标,表明VM进程缺少CPU时间。 如 KVM kernel patch, KVM内核补丁中所述steal is the time that a hypervisor spends running other processes in a host OS, while VM process is in a run queue. In other words, 窃取是虚拟机管理程序花时间在VM进程处于运行队列中时在主机OS中运行其他进程的时间。 换句话说, steal is calculated as the difference between the moment when a process is ready to run and the moment when CPU time is allocated to the process. 窃取被计算为进程准备运行的时刻与为该进程分配CPU时间之间的差。

The VM kernel gets the steal metric from the hypervisor. The hypervisor doesn’t specify which processes it is running. It just says: «I’m busy, and can’t allocate any time to you.» In a KVM, steal calculation is supported in patches. There are two main points regarding this:

VM内核从管理程序获取窃取指标。 系统管理程序未指定其正在运行的进程。 它只是说:“我很忙,无法给您分配任何时间。” 在KVM中, 补丁程序支持窃取计算。 关于此点有两个要点:

  • A VM learns about steal from the hypervisor. This means that in terms of losses, steal is an indirect measurement that can be distorted in several ways.

    VM从管理程序了解窃取 。 这意味着就损失而言, 窃取是一种间接测量,可以通过多种方式进行失真。

  • The hypervisor doesn’t share with the VM information regarding what it is occupied with. The most crucial point is that it doesn’t allocate time to it. The VM itself, therefore, cannot detect distortions in the steal metric, which could be estimated by the nature of the competing processes.

    系统管理程序不会与VM共享有关其占用的信息。 最关键的一点是它没有分配时间。 因此,VM本身无法检测到窃取度量标准中的失真这可以通过竞争进程的性质来估计。

2.什么会影响盗窃(2. What affects steal?)

2.1。 计算盗窃 (2.1. Calculating steal)

Essentially, steal is calculated in more or less the same way as CPU utilization time. There isn’t a great deal of information regarding how utilization is calculated. That’s probably because most professionals think it’s obvious. However, there are some pitfalls. The process is described in an article by Brendann Gregg. He discusses a whole host of nuances regarding how to calculate utilization and scenarios in which the calculation will be wrong:

本质上, 窃取的计算方式与CPU利用率时间大致相同。 关于如何计算利用率的信息不多。 这可能是因为大多数专业人士认为这很明显。 但是,有一些陷阱。 Brendann Gregg一篇文章中描述了该过程。 他讨论了有关如何计算利用率以及计算错误的方案的许多细微差别:

  • CPU overheating and throttling.

    CPU过热和节流。

  • Turning Turbo Boost on/off, resulting in a change in CPU clock rate.

    打开/关闭Turbo Boost,导致CPU时钟速率改变。
  • The time slice change that occurs when CPU power-saving technologies, e.g. SpeedStep, are used.

    使用CPU节电技术(例如SpeedStep)时发生的时间片更改。

  • Problems related to calculating averages: measuring utilization for one minute at 80% power could hide a short-term 100 % boost.

    与计算平均值有关的问题:以80%的功率测量一分钟的利用率可能会在短期内隐藏100%的提升。

  • A spinlock that results in a scenario whereby the processor is utilized, but the user process doesn’t progress. As a result, the calculated CPU utilization will be 100%, but the process will not actually consume CPU time.

    自旋锁导致使用处理器但用户进程无法进行的情况。 结果,计算出的CPU利用率将为100%,但是该进程实际上不会消耗CPU时间。

I haven’t come across any articles describing such calculations of st

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值