LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud
User Name
Password
Linux - Virtualization and Cloud This forum is for the discussion of all topics relating to Linux Virtualization and Linux Cloud platforms. Xen, KVM, OpenVZ, VirtualBox, VMware, Linux-VServer and all other Linux Virtualization platforms are welcome. OpenStack, CloudStack, ownCloud, Cloud Foundry, Eucalyptus, Nimbus, OpenNebula and all other Linux Cloud platforms are welcome. Note that questions relating solely to non-Linux OS's should be asked in the General forum.

Notices


Reply
  Search this Thread
Old 10-10-2012, 05:47 PM   #1
sanaz
Member
 
Registered: Aug 2012
Posts: 76

Rep: Reputation: Disabled
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
 
Old 10-10-2012, 06:02 PM   #2
JaseP
Senior Member
 
Registered: Jun 2002
Location: Eastern PA, USA
Distribution: K/Ubuntu 18.04-14.04, Scientific Linux 6.3-6.4, Android-x86, Pretty much all distros at one point...
Posts: 1,802

Rep: Reputation: 157Reputation: 157
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.
 
1 members found this post helpful.
Old 10-16-2012, 03:36 PM   #3
sanaz
Member
 
Registered: Aug 2012
Posts: 76

Original Poster
Rep: Reputation: Disabled
What if, the host has for e.g. 5 core and it has 2 VM. So it will allocates a core to each VM?
 
Old 10-16-2012, 05:07 PM   #4
JaseP
Senior Member
 
Registered: Jun 2002
Location: Eastern PA, USA
Distribution: K/Ubuntu 18.04-14.04, Scientific Linux 6.3-6.4, Android-x86, Pretty much all distros at one point...
Posts: 1,802

Rep: Reputation: 157Reputation: 157
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.
 
Old 10-16-2012, 08:06 PM   #5
sanaz
Member
 
Registered: Aug 2012
Posts: 76

Original Poster
Rep: Reputation: Disabled
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.
 
Old 10-17-2012, 07:52 AM   #6
dyasny
Member
 
Registered: Dec 2007
Location: Canada
Distribution: RHEL,Fedora
Posts: 995

Rep: Reputation: 115Reputation: 115
man taskset
 
Old 10-17-2012, 11:02 AM   #7
sanaz
Member
 
Registered: Aug 2012
Posts: 76

Original Poster
Rep: Reputation: Disabled
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.
 
Old 10-17-2012, 01:55 PM   #8
Slax-Dude
Member
 
Registered: Mar 2006
Location: Valadares, V.N.Gaia, Portugal
Distribution: Slackware
Posts: 528

Rep: Reputation: 272Reputation: 272Reputation: 272
You can either use taskset, as dyasny suggested, or use the pining setting in virt-manager (if you use it).
 
Old 10-17-2012, 01:56 PM   #9
JaseP
Senior Member
 
Registered: Jun 2002
Location: Eastern PA, USA
Distribution: K/Ubuntu 18.04-14.04, Scientific Linux 6.3-6.4, Android-x86, Pretty much all distros at one point...
Posts: 1,802

Rep: Reputation: 157Reputation: 157
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.
 
Old 10-17-2012, 04:54 PM   #10
sanaz
Member
 
Registered: Aug 2012
Posts: 76

Original Poster
Rep: Reputation: Disabled
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
....

Last edited by sanaz; 10-17-2012 at 05:12 PM.
 
Old 10-17-2012, 06:40 PM   #11
JaseP
Senior Member
 
Registered: Jun 2002
Location: Eastern PA, USA
Distribution: K/Ubuntu 18.04-14.04, Scientific Linux 6.3-6.4, Android-x86, Pretty much all distros at one point...
Posts: 1,802

Rep: Reputation: 157Reputation: 157
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...
 
Old 10-17-2012, 09:19 PM   #12
sanaz
Member
 
Registered: Aug 2012
Posts: 76

Original Poster
Rep: Reputation: Disabled
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 View Post
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...
 
Old 10-17-2012, 10:44 PM   #13
JaseP
Senior Member
 
Registered: Jun 2002
Location: Eastern PA, USA
Distribution: K/Ubuntu 18.04-14.04, Scientific Linux 6.3-6.4, Android-x86, Pretty much all distros at one point...
Posts: 1,802

Rep: Reputation: 157Reputation: 157
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 ...

Last edited by JaseP; 10-18-2012 at 07:40 AM.
 
Old 10-19-2012, 06:06 AM   #14
Slax-Dude
Member
 
Registered: Mar 2006
Location: Valadares, V.N.Gaia, Portugal
Distribution: Slackware
Posts: 528

Rep: Reputation: 272Reputation: 272Reputation: 272
@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
Attached Thumbnails
Click image for larger version

Name:	snapshot.png
Views:	21
Size:	100.8 KB
ID:	11005  
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[Tcptraceroute/Traceroute/Ping] Windows VMs & Linux VMs BiFo Linux - Networking 0 08-24-2010 02:07 PM
CPU sharing over LAN. dragos240 Linux - Hardware 6 06-10-2010 08:37 AM
LXer: Using Xen With LVM-Based VMs Instead Of Image-Based VMs (Debian Etch) LXer Syndicated Linux News 0 01-14-2009 08:20 PM
Join PCs for sharing CPU manolakis Linux - Hardware 3 05-12-2007 12:23 PM
Sharing one monitor with 2 CPU's ninadb Linux - General 4 04-04-2005 06:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Virtualization and Cloud

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration