1

I am looking at configuring a KVM hypervisor to have some virtual machines.

THe KVM hypervisor has 8 physical cores (16 with HyperThreading). I want to create 8 virtual machines on it but I am not able to understand what difference will cpu-pinning have on it.

What will be the difference when I pin each VM to a different core vs when I pin all the VMs to all the cores (by setting the affinity to cpu 0-15)

Will it have any performance benefits?

I guess I will have some caching benefits but will there be a difference if I want to run traffic to all the VMs?

Akshya11235
  • 133
  • 2
  • 5
  • Do you _really need_ to do CPU pinning? – Michael Hampton Aug 12 '14 at 01:51
  • I was trying to measure performance of httperf if my VM has the http server running. without pinning I was seeing the httperf using the full nic bandwidth. But with pinning I saw a drop in performance. I wanted to understand what difference did the pinning make – Akshya11235 Aug 13 '14 at 18:14

2 Answers2

2

CPU pinning ensures a VM will only get CPU time from a specific CPU or set of CPUs. Unless you have a very specific reason to pin, there usually is no need to do that.

dyasny
  • 18,482
  • 6
  • 48
  • 63
1

I'm sure you can have a performance gain if you pin each VM to specific CPU cores, as well as restrict the hypervisor to one or two other cores.

That would allow your VM's to optimally benefit from the L1 and L2 caches which are CPU specific and they won't be bothered by interrupts from NIC's and storage controllers.

On the other hand I expect the hypervisor already makes an effort to mostly direct CPU events of the same virtual CPU to the same physical core and I doubt it would be a significant performance gain if you manually force something more strict.

The disadvantages of that are pretty obvious too, when you assign more cores to virtual guests than available physical cores are present it is unlikely your manual CPU pinning does a better job than the hypervisor. It will also be hell when you use live migrations.

HBruijn
  • 72,524
  • 21
  • 127
  • 192