Tuning Kernel: Difference between revisions

From KVM
No edit summary
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 8: Line 8:


The host is the system that runs QEMU / KVM, it hosts the guest systems.
The host is the system that runs QEMU / KVM, it hosts the guest systems.


=== The kernel needs to be configured with ===
=== The kernel needs to be configured with ===


- VIRTUALIZATION
- VIRTUALIZATION  


Options for Linux host to run other operating systems inside virtual machines (guests)
Options for Linux host to run other operating systems inside virtual machines (guests)


- KVM (Location : Virtualization)
- KVM (Location : Virtualization)
Support hosting fully virtualized guest machines using hardware virtualization extensions
Support hosting fully virtualized guest machines using hardware virtualization extensions


- KVM_INTEL (Location : Virtualization)
- KVM_INTEL (Location : Virtualization)
Support for Intel processors with VT-x virtualization support (Vanderpool), CPU flag : vmx
Support for Intel processors with VT-x virtualization support (Vanderpool), CPU flag : vmx


- KVM_AMD (Location : Virtualization)


- KVM_AMD (Location : Virtualization)
Support for AMD processors with AMD-V virtualization support (Pacifica), CPU flag : svm
Support for AMD processors with AMD-V virtualization support (Pacifica), CPU flag : svm


=== Useful options for the kernel of the host ===
=== Useful options for the kernel of the host ===


- VHOST_NET (Location : Virtualization)


- VHOST_NET (Location : Virtualization)
Driver for host kernel to accelerate guest networking with virtio_net (guest drive).
Driver for host kernel to accelerate guest networking with virtio_net (guest drive).


- HIGH_RES_TIMER (Location : Processor type and features)


- HIGH_RES_TIMER (Location : Processor type and features)
High Resolution Timer Support
High Resolution Timer Support


- HPET (Location : Device Drivers -> Character devices)


- HPET (Location : Device Drivers -> Character devices)
High Precision Event Timer
High Precision Event Timer


- COMPACTION (Location : Processor type and features)


- COMPACTION (Location : Processor type and features)
Allows the compaction of memory for the allocation of huge pages
Allows the compaction of memory for the allocation of huge pages


- MIGRATION (Location : Processor type and features)


- MIGRATION (Location : Processor type and features)
Allows the migration of the physical location of pages of processes while the virtual addresses are not changed. This is useful when allocating huge pages as migration can relocate pages to satisfy a huge page allocation instead of reclaiming.
Allows the migration of the physical location of pages of processes while the virtual addresses are not changed. This is useful when allocating huge pages as migration can relocate pages to satisfy a huge page allocation instead of reclaiming.


- KSM (Location : Processor type and features)


- KSM (Location : Processor type and features)
Enable Kernel Samepage Merging: KSM periodically scans those areas of an application's address space that an app has advised may be mergeable. When it finds pages of identical content, it replaces the many instances by a single page with that content, so saving memory until one or another app needs to modify the content. KSM is inactive until a program has madvised that an area is MADV_MERGEABLE, and root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).
Enable Kernel Samepage Merging: KSM periodically scans those areas of an application's address space that an app has advised may be mergeable. When it finds pages of identical content, it replaces the many instances by a single page with that content, so saving memory until one or another app needs to modify the content. KSM is inactive until a program has madvised that an area is MADV_MERGEABLE, and root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).


A daemon as "ksmtuned" can be used to tuning KSM.
A daemon as "ksmtuned" can be used to tuning KSM.


- TRANSPARENT_HUGEPAGE (Location : Processor type and features)


- TRANSPARENT_HUGEPAGE (Location : Processor type and features)
Transparent Hugepages allows the kernel to use huge pages and huge tlb transparently to the applications whenever possible. This feature can improve computing performance to certain applications by speeding up page faults during memory allocation, by reducing the number of tlb misses and by speeding up the pagetable walking.                   
Transparent Hugepages allows the kernel to use huge pages and huge tlb transparently to the applications whenever possible. This feature can improve computing performance to certain applications by speeding up page faults during memory allocation, by reducing the number of tlb misses and by speeding up the pagetable walking.                   


- CGROUPS (Location : General setup)


- CGROUPS (Location : General setup)
The cgroup allow you to control the distribution of resources (processors, cores, memory, IO) at different VM.
The cgroup allow you to control the distribution of resources (processors, cores, memory, IO) at different VM.


== Kernel for guest with paravirtualization ==
== Kernel for guest with paravirtualization ==


- VIRTIO


- VIRTIO
Selected by VIRTIO_PCI or VIRTIO_BALLOON
Selected by VIRTIO_PCI or VIRTIO_BALLOON


- VIRTIO_NET (Location : Device Drivers -> Network device support)


- VIRTIO_NET (Location : Device Drivers -> Network device support)
The virtual network driver for virtio : Paravirtualized Network Device.
The virtual network driver for virtio : Paravirtualized Network Device.


- VIRTIO_BLK (Location : Device Drivers -> Block devices)


- VIRTIO_BLK (Location : Device Drivers -> Block devices)
The virtual block driver for virtio : Paravirtualized Block Device.
The virtual block driver for virtio : Paravirtualized Block Device.


- VIRTIO_PCI (Location : Virtualization)


- VIRTIO_PCI (Location : Virtualization)
This drivers provides support for virtio based paravirtual device drivers over PCI.  This requires that your VMM has appropriate PCI virtio backends.  
This drivers provides support for virtio based paravirtual device drivers over PCI.  This requires that your VMM has appropriate PCI virtio backends.  


- VIRTIO_BALLOON (Location : Virtualization)


- VIRTIO_BALLOON (Location : Virtualization)
This driver supports increasing and decreasing the amount of memory within a KVM guest.
This driver supports increasing and decreasing the amount of memory within a KVM guest.


- VIRTIO_RING


- VIRTIO_RING
Selected by VIRTIO_PCI or VIRTIO_BALLOON
Selected by VIRTIO_PCI or VIRTIO_BALLOON


- VIRTIO_CONSOLE (Location :  Device Drivers -> Character devices)


- VIRTIO_CONSOLE (Location :  Device Drivers -> Character devices)
Serves as a general-purpose serial device for data transfer between the guest and host. Character devices at /dev/vportNpn will be created when corresponding ports are found, where N is the device number and n is the port number within that device. If specified by the host, a sysfs attribute called 'name' will be populated with a name for the port which can be used by udev scripts to create a symlink to the device.     
Serves as a general-purpose serial device for data transfer between the guest and host. Character devices at /dev/vportNpn will be created when corresponding ports are found, where N is the device number and n is the port number within that device. If specified by the host, a sysfs attribute called 'name' will be populated with a name for the port which can be used by udev scripts to create a symlink to the device.     


- HW_RANDOM_VIRTIO (Location : Device Drivers -> Character devices -> Hardware Random Number Generator Core support)


- HW_RANDOM_VIRTIO (Location : Device Drivers -> Character devices -> Hardware Random Number Generator Core support)
This driver provides kernel-side support for the virtual Random Number Generator hardware.
This driver provides kernel-side support for the virtual Random Number Generator hardware.


- PCI_MSI (Location :  Bus options (PCI etc.))
- PCI_MSI (Location :  Bus options (PCI etc.))
This allows device drivers to enable MSI (Message SignaledInterrupts). Message Signaled Interrupts enable a device togenerate an interrupt using an inbound Memory Write on its PCI bus instead of asserting a device IRQ pin.
This allows device drivers to enable MSI (Message SignaledInterrupts). Message Signaled Interrupts enable a device togenerate an interrupt using an inbound Memory Write on its PCI bus instead of asserting a device IRQ pin.


- PARAVIRT_GUEST (Location : Processor type and features)


- PARAVIRT_GUEST (Location : Processor type and features)
Options for paravirtualized Linux guest  
Options for paravirtualized Linux guest  


- KVM_CLOCK (Location : Processor type and features-> Paravirtualized guest support)


- KVM_CLOCK (Location : Processor type and features-> Paravirtualized guest support)
Instead of relying on a PIT (or probably other) emulation by the underlying device model, the host provides the guest with timing infrastructure such as time of day, and system time   
Instead of relying on a PIT (or probably other) emulation by the underlying device model, the host provides the guest with timing infrastructure such as time of day, and system time   


- KVM_GUEST (Location : Processor type and features-> Paravirtualized guest support)


- KVM_GUEST (Location : Processor type and features-> Paravirtualized guest support)
This option enables various optimizations for running under the KVM hypervisor.
This option enables various optimizations for running under the KVM hypervisor.


- PARAVIRT (Location : Processor type and features-> Paravirtualized guest support)


- PARAVIRT (Location : Processor type and features-> Paravirtualized guest support)
This changes the kernel so it can modify itself when it is run under a hypervisor, potentially improving performance significantly over full virtualization. However, when run without a hypervisor the kernel is theoretically slower and slightly larger.  
This changes the kernel so it can modify itself when it is run under a hypervisor, potentially improving performance significantly over full virtualization. However, when run without a hypervisor the kernel is theoretically slower and slightly larger.  


- MEMORY_HOTPLUG (Location : Processor type and features)
- MEMORY_HOTPLUG (Location : Processor type and features)
Line 127: Line 122:


- PROCESSOR_FAMILY (Location : Processor type and features)
- PROCESSOR_FAMILY (Location : Processor type and features)
Core2 ou generic_x86_64 ?
Core2 ou generic_x86_64 ?
This may depend on how we run qemu : qemu -cpu host
This may depend on how we run qemu : qemu -cpu host
http://www.linux-kvm.org/page/Tuning_KVM
http://www.linux-kvm.org/page/Tuning_KVM


- ACPIPHP


- ACPIPHP
- PCI_HOTPLUG
- PCI_HOTPLUG


PCI Hotplug support for the guest, to add a disk or a network card on the fly.
PCI Hotplug support for the guest, to add a disk or a network card on the fly.


For http://www.linux-kvm.org/page/Hotadd_pci_devices
http://www.linux-kvm.org/page/Hotadd_pci_devices

Latest revision as of 12:36, 13 June 2011

How tuning the kernel

What are the kernel options necessary or useful to use KVM, how to optimize or tune the kernel for the host or the guest ?

In the case of paravirtualization, virtio is used as a driver of the guest kernel, and a QEMU / KVM backend of the host.

Kernel for host

The host is the system that runs QEMU / KVM, it hosts the guest systems.

The kernel needs to be configured with

- VIRTUALIZATION

Options for Linux host to run other operating systems inside virtual machines (guests)

- KVM (Location : Virtualization)

Support hosting fully virtualized guest machines using hardware virtualization extensions

- KVM_INTEL (Location : Virtualization)

Support for Intel processors with VT-x virtualization support (Vanderpool), CPU flag : vmx

- KVM_AMD (Location : Virtualization)

Support for AMD processors with AMD-V virtualization support (Pacifica), CPU flag : svm

Useful options for the kernel of the host

- VHOST_NET (Location : Virtualization)

Driver for host kernel to accelerate guest networking with virtio_net (guest drive).

- HIGH_RES_TIMER (Location : Processor type and features)

High Resolution Timer Support

- HPET (Location : Device Drivers -> Character devices)

High Precision Event Timer

- COMPACTION (Location : Processor type and features)

Allows the compaction of memory for the allocation of huge pages

- MIGRATION (Location : Processor type and features)

Allows the migration of the physical location of pages of processes while the virtual addresses are not changed. This is useful when allocating huge pages as migration can relocate pages to satisfy a huge page allocation instead of reclaiming.

- KSM (Location : Processor type and features)

Enable Kernel Samepage Merging: KSM periodically scans those areas of an application's address space that an app has advised may be mergeable. When it finds pages of identical content, it replaces the many instances by a single page with that content, so saving memory until one or another app needs to modify the content. KSM is inactive until a program has madvised that an area is MADV_MERGEABLE, and root has set /sys/kernel/mm/ksm/run to 1 (if CONFIG_SYSFS is set).

A daemon as "ksmtuned" can be used to tuning KSM.

- TRANSPARENT_HUGEPAGE (Location : Processor type and features)

Transparent Hugepages allows the kernel to use huge pages and huge tlb transparently to the applications whenever possible. This feature can improve computing performance to certain applications by speeding up page faults during memory allocation, by reducing the number of tlb misses and by speeding up the pagetable walking.

- CGROUPS (Location : General setup)

The cgroup allow you to control the distribution of resources (processors, cores, memory, IO) at different VM.

Kernel for guest with paravirtualization

- VIRTIO

Selected by VIRTIO_PCI or VIRTIO_BALLOON

- VIRTIO_NET (Location : Device Drivers -> Network device support)

The virtual network driver for virtio : Paravirtualized Network Device.

- VIRTIO_BLK (Location : Device Drivers -> Block devices)

The virtual block driver for virtio : Paravirtualized Block Device.

- VIRTIO_PCI (Location : Virtualization)

This drivers provides support for virtio based paravirtual device drivers over PCI. This requires that your VMM has appropriate PCI virtio backends.

- VIRTIO_BALLOON (Location : Virtualization)

This driver supports increasing and decreasing the amount of memory within a KVM guest.

- VIRTIO_RING

Selected by VIRTIO_PCI or VIRTIO_BALLOON

- VIRTIO_CONSOLE (Location : Device Drivers -> Character devices)

Serves as a general-purpose serial device for data transfer between the guest and host. Character devices at /dev/vportNpn will be created when corresponding ports are found, where N is the device number and n is the port number within that device. If specified by the host, a sysfs attribute called 'name' will be populated with a name for the port which can be used by udev scripts to create a symlink to the device.

- HW_RANDOM_VIRTIO (Location : Device Drivers -> Character devices -> Hardware Random Number Generator Core support)

This driver provides kernel-side support for the virtual Random Number Generator hardware.

- PCI_MSI (Location : Bus options (PCI etc.))

This allows device drivers to enable MSI (Message SignaledInterrupts). Message Signaled Interrupts enable a device togenerate an interrupt using an inbound Memory Write on its PCI bus instead of asserting a device IRQ pin.

- PARAVIRT_GUEST (Location : Processor type and features)

Options for paravirtualized Linux guest

- KVM_CLOCK (Location : Processor type and features-> Paravirtualized guest support)

Instead of relying on a PIT (or probably other) emulation by the underlying device model, the host provides the guest with timing infrastructure such as time of day, and system time

- KVM_GUEST (Location : Processor type and features-> Paravirtualized guest support)

This option enables various optimizations for running under the KVM hypervisor.

- PARAVIRT (Location : Processor type and features-> Paravirtualized guest support)

This changes the kernel so it can modify itself when it is run under a hypervisor, potentially improving performance significantly over full virtualization. However, when run without a hypervisor the kernel is theoretically slower and slightly larger.

- MEMORY_HOTPLUG (Location : Processor type and features)

- MEMORY_HOTREMOVE (Location : Processor type and features -> Allow for memory hot-add)

- PROCESSOR_FAMILY (Location : Processor type and features)

Core2 ou generic_x86_64 ?

This may depend on how we run qemu : qemu -cpu host

http://www.linux-kvm.org/page/Tuning_KVM

- ACPIPHP

- PCI_HOTPLUG

PCI Hotplug support for the guest, to add a disk or a network card on the fly.

http://www.linux-kvm.org/page/Hotadd_pci_devices