LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Virtualization and Cloud (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/)
-   -   sharing the same cpu between VMs (https://www.linuxquestions.org/questions/linux-virtualization-and-cloud-90/sharing-the-same-cpu-between-vms-4175431560/)

sanaz 10-10-2012 05:47 PM

sharing the same cpu between VMs
 
Hi all,

I have 3 virtual machines created with KVM. How can I check whether they are sharing the same cpu or not.

Any help is appreciated,

Sanaz

JaseP 10-10-2012 06:02 PM

It doesn't work like that... The VM cores are virtual (obviously?!). What is happening is that the scheduler for kernel on the host is breaking up processing jobs between the machines on the next available processor thread... It is possible to "overbook" the CPUs when setting up VMs and running many at the same time. Luckily, for VM hosts, most computers spend the majority of their CPU time idle. It's part of what makes virtualization of servers so attractive.

sanaz 10-16-2012 03:36 PM

What if, the host has for e.g. 5 core and it has 2 VM. So it will allocates a core to each VM?

JaseP 10-16-2012 05:07 PM

Don't get caught up thinking that a core is actually sidelined for the virtual machine. Pretty much all the hardware on the virtual machine is "virtual." The VM's "cores" are just time slices on the host's cores... If a server's cores are loaded at 40% capacity, you can get twice that machine's number of virtual CPUs running, without breaking a sweat, as long as your peak use doesn't spike all at once. RAM is a bit different.

sanaz 10-16-2012 08:06 PM

Actually my host has 32 cpu and each 8 cores. I really wanna be sure my two VM are sharing exactly the same core(out of 256 available cores). I understand what you mean, but it's possible that OS schedules VM's jobs on different cores(isn't it?). I want to be sure they are always running on the same core.

dyasny 10-17-2012 07:52 AM

man taskset

sanaz 10-17-2012 11:02 AM

I can do the following find out pid of all the process which I want to be executed on same core (with other VM's core) and do the following:
taskset -c -p preferred_core pid

and do exactly the same thing on the other VM(with the same core id), is it right?

Now my question:
is it possible that core id(which I'm using) are actually pointing to different physical core? If so, still I can't be sure they are sharing the same core.

Slax-Dude 10-17-2012 01:55 PM

You can either use taskset, as dyasny suggested, or use the pining setting in virt-manager (if you use it).

JaseP 10-17-2012 01:56 PM

May I ask why it's so critical that they are executed on a particular core?

Benchmarking? Real time kernels running? Looking to implement a separation kernel for high security reasons? Under ordinary conditions, the scheduler can anticipate loads just fine. Real time systems should ideally use their own hardware. Separation kernels are military grade type stuff...

The only way to get what I assume you are asking for is with a separation kernel on the host/hypervisor.

sanaz 10-17-2012 04:54 PM

Because I want to do benchmarking.

And could you please explain about pinning in virt-manager?
should I assign only one core to all virtual machines by
Code:

virsh vcpupin vm1 0 4
virsh vcpupin vm1 1 4
virsh vcpupin vm1 2 4
...
virsh vcpupin vm2 0 4
virsh vcpupin vm2 1 4
virsh vcpupin vm2 2 4
....


JaseP 10-17-2012 06:40 PM

It doesn't do exactly what you want,...

See here;
http://frankdenneman.nl/cpu/beating-...-cpu-affinity/
... Second paragraph spells it out ...

What you are looking for is a Separation Kernel...

sanaz 10-17-2012 09:19 PM

I did not get the point.
let me elaborate what I want. I don't care if the core is not dedicated to my VM. The only thing that I do care is two VM are running on the same core(even if some other vm or processes are also using that core and I don't care about performance etc.)
So does the aforementioned code help? or there is another problem which I did not get it.

Quote:

Originally Posted by JaseP (Post 4808578)
It doesn't do exactly what you want,...

See here;
http://frankdenneman.nl/cpu/beating-...-cpu-affinity/
... Second paragraph spells it out ...

What you are looking for is a Separation Kernel...


JaseP 10-17-2012 10:44 PM

Here's the issue... You can't contain the host's use of that same CPU space, including allocation of it to competing VMs. If this is for balance testing, ... That's OK. But be concerned if you are basing billing on these data points... Your clients may have grounds for a false billing practice action against you. If you are trying to obtain data to justify throttling, ... OK. But,are sure that whatever you are doing has a rational relationship to the client VM's use of the CPU and IO, vs others... Or, if this is all internal, that you are use-justifying any policy changes, make sure to cover your bases.

What I am essentially saying is that you cannot base any policy decisions on this so-called empirical data... Nada, ... nill,... It's like the Linux users' (market share) statistics or US unemployment statistics ...

Slax-Dude 10-19-2012 06:06 AM

1 Attachment(s)
@sanaz: Yes, you can use virsh to do it, or use virt-manager (it's just a GUI for virsh) as the attached screen-shot.

@JaseP: It doesn't matter what the OP's reasons for doing that... he just wants to do it.
He may not want to explain why he needs to do such a thing.
It only needs make sense to him, not the rest of us ;)


All times are GMT -5. The time now is 12:02 AM.