CPU Configuration in KVM

Source: Internet
Author: User

In QEMU/KVM, QEMU provides a simulation of the CPU, showing a certain number of CPUs and CPU characteristics of the client, and in the case of KVM Open, the execution of CPU instruction in the client has the hardware processor's virtualization function to assist the execution, which is very effective.

QEMU/KVM provides the client with a complete set of hardware system environments, which the client sees as having a CPU that is the Vcpus (virtual CPU). In a KVM environment, each client is a standard Linux process (QEMU process), and each vcpus is a normal thread derived from the QEMU process in the host.

In a normal Linux system, the process typically has two execution modes: kernel mode and user mode. In the KVM environment, a third mode is added: Customer mode.

    • User mode

The main processing I/O simulation and management, implemented by QEMU's code.

    • Kernel modes (Kernel mode)

Primary processing requires high performance and security-related directives, such as processing client-mode to kernel-mode conversions, handling the I/O instructions in customer mode or other privileged instructions due to exit (Vm-exit), and Processing Shadow memory management (Shadow MMU).

    • Customer model (Guest mode)

The main execution of most of the commands in guest, except I/O and some privileged instructions (they will cause vm-exit, intercepted and simulated by hypervisor).

(We've been stressing a problem) a client in KVM is running as a user-space process (QEMU-KVM), which is scheduled by the kernel to run on the physical CPU just like any other normal user process, but it is controlled by the KVM module and can run in the three execution modes above.

Multiple clients are multiple QEMU processes in a host, and multiple Vcpus of one client are multiple threads in a QEMU process.

In the client system, the client's kernel and the client's user-space application are also run separately.

    • SMP in the KVM environment

SMP, symmetric multiprocessor, can be implemented in a virtual machine environment in two ways (personally, it is the same)

1 for the physical hardware non-SMP environment, set the virtual machine to SMP, multiple Vcpus on the host hardware time-sharing scheduling.

2 for the physical hardware for the SMP environment, set the virtual machine to SMP, and multiple Vcpus are assigned to multiple CPUs on the host and executed concurrently.

In the QEMU-KVM command, the "-SMP" parameter is configured to configure the client's SMP system,

  -SMP N[,maxcpus=cpus][,cores=cores][,threads=threads][,sockets=sockets]

Maxcpus the maximum number of vcpus that can be used by a virtual machine, which is used to dynamically add Vcpus and requires virtual machine support. (in rhel6.5 beta, the test is perfect, accelerating the guest-set-cpus of Qemu-ga, which can smoothly control the resources of the virtual machine)

Questions:

The architecture of the SMP in the KVM environment is how to deal with time limits, that is, cores * 2,socket * 2, Threads * 2 and Cores * 1,socket * 8,thread * 1 What are the essential differences?

Because the vcpus that provide the compute for the virtual machine are actually a thread on the host, there is no clear distinction between cores, sockets, or threads on the thread, that is, the overall settings 2*2*2 and 1*8*1.

within a virtual machine, however, there may be systems that tend to have multiple physical slots, or multiple physical cores, that are (the server's level of setting). (previously encountered WIN2K8 (non-datacenter) is not able to identify more than 8 Vcpus, but set to 2*6*1 to achieve 12 Vcpus of the server )

    • CPU overload usage in a KVM environment

The overloaded use of CPUs and the overload of memory are two different uses. CPU is the compute resource of the server, if no application uses CPU, it will be idel by the system. Allocating CPU resources is also not to say I assign 20% or 30%, but rather to adjust the priority.

CPU overload simple understanding is that Vcpus is always larger than the number of physical server CPU, when the virtual machine is not full CPU, it will not affect the overall performance. Because the number of processes in our system itself is much larger than the number of CPUs, and the client process is no different from the normal process, it is just a thread with multiple Vcpus.

!!! Strongly deprecated: The Vcpus of a single client are always greater than the number of host CPUs. Performance can be severely impacted.

Of course, because any function on the server is CPU-bound, (memory allocation, I/O, etc.), I am not recommending that the virtual machine run computationally intensive applications or centralized running-intensive applications (that is, most VMs are computational).

    • CPU model

Each VMM (Virtual machine Monitor) defines its own policy, giving the customer and appearing to have a default CPU model. (Some of the features of the CPU are still very vague, like the model I still do not know what the role of)

Some hypervisor will simply pass the type and characteristics of the CPU in the host to the client using

QEMU/KVM, by default, provides a basic CPU model called Qemu64 and qemu32 by the client. This strategy of QEMU/KVM brings some benefits, such as the ability to provide some advanced filtering capabilities for CPU features, and the ability to group physical platforms based on the basic CPU models provided. This makes dynamic migration of clients on the same set of hardware platforms smoother and more secure. (one of the previous moves is to migrate the virtual machine to another machine, but it cannot be migrated back because the CPU instruction set is missing)

Can I use only qemu-kvm-cpu? View

    • Processor affinity of the process and the binding of the Vcpus

What is process affinity: a simple sentence is how many CPUs can I load balance on the Linux process.

The KVM virtual machine is a normal Linux process, and the Vcpus is a thread that we can bind to the specified CPU on the host for the Vcpus thread's corresponding tid.

  taskset-p [mask] pid

Binding the Vcpus to the specified CPU does improve performance because there are some necessary data structure initialization (vmlaunch) relative to Vm-entry when the Vcpus thread is doing load balancing on the physical CPU, plus the cache hit, Performance is bound to improve, but it destroys load balancing. When the two vcpus on the same CPU are bound to high loads at the same time, performance is compromised and other CPUs are not fully utilized.

In a KVM environment, it is generally not recommended to manually set the processor affinity of the QEMU process to bind Vcpus, but, based on a good understanding of the hardware architecture of the system, it can be bound to a specific CPU based on the actual application requirements. This improves CPU execution efficiency in the client or enables exclusive isolation of CPU resources.


This article is from the "8176010" blog, please be sure to keep this source http://8186010.blog.51cto.com/8176010/1585780

CPU Configuration in KVM

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.