VMware Cloud Community
vm7user
Enthusiast
Enthusiast

How to see VM vCPU to Host CPU mapping?

Hello,

How to see VM's vCPU to Host physical/logical CPU mapping?

i.e. which VM vCPU is running on which physical/logical CPU?

Reply
0 Kudos
11 Replies
scott28tt
VMware Employee
VMware Employee

@vm7user 

It potentially is changing too frequently for any such tool to be really useful.

 

 


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
vm7user
Enthusiast
Enthusiast

No, i do not see changing

Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

@vm7user 

What do you see, and where do you see it?

How does that differ from what you expect or want to see?

 


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
vm7user
Enthusiast
Enthusiast

scott28tt

is changing too frequently

What is your proofs?

For example - if i have 32 cores host and 7 VM with 4 vcpu each, give at least one reason why "is changing too frequently"?

Reply
0 Kudos
scott28tt
VMware Employee
VMware Employee

@vm7user 

Do you have an understanding of how the CPU scheduler of ESXi functions? https://www.simongreaves.co.uk/cpu-optimisation/


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
Reply
0 Kudos
vm7user
Enthusiast
Enthusiast

you haven't answered the question - why will the scheduler change processors in my example?

Reply
0 Kudos
vbondzio
VMware Employee
VMware Employee

One method is via esxtop. In the CPU view (c), sort by GID (shift-n), show only VMs (shift-v), select fields (f), mark "summary stats" (i), expand (e) the GID of the VM you are interested in, check the CPU column for each vcpu world.

nachogonzalez
Commander
Commander

I think there was a missunderstanding here:
Scott was trying to illustrate that there is no such tool to show the mapping of vCPU to pCPU at runtime. (IE: which pCPU core is running which  vCPU thread) Because, as he correctly said the CPU scheduler changes at a really fast rate so it wouldn't be possible to keep track of. 

If what you want is to have a vCPU to pCPU operprovision (how much vCPUs am I using/can I use related to the pCPU's I have available) you can do it from some vROPs dashboards. 

Hope I have clarified the situation.

Reply
0 Kudos
vbondzio
VMware Employee
VMware Employee

That is only somewhat correct when taken literal. While it is more complicated (and fairly expensive) to track each and every individual migration (using schedtraces), you can definitely paint a picture, statistically speaking, by looking at esxtop. On a idle system with some vcpus at higher load, migrations (even intra LLC) might be fairly rare. You can look at MIG/s in esxtop (part of the "CPU Event Counts" fields).

There are reasons to be curious about this, not for capacity planning oe anything high level but esp. on AMD systems with multiple LLC domains per socket / NUMA node (depending on config) you might want to know where those vCPUs are when doing performance troubleshooting.

edit ~ two month later: just remembered that I updated a script that shows the placement and all affinity related information back then and forgot to add that. The caveat is that it is the vCPU/PCPU location at the time the vsi leaf was checked and depending on wakeup / switch / migrate rate, might not be very accurate: https://github.com/vbondzio/sowasvonunsupported/blob/master/vcpu_affinity_info.sh

Reply
0 Kudos
YongDong
VMware Employee
VMware Employee

Try below command:

# sched-stats -t cpu | grep vcpu

[root@esxi-16:~] sched-stats -t cpu | grep vcpu
vcpu vsmp type name uptime status usedsec syssec wait waitsec idlesec readysec min max units shares group emin cpu llc prio mode affinity
757179 757179 U vmx-vcpu-0:VM-03 74506.526 WAIT 818.815 0.000 IDLE 73630.596 71637.028 53.855 0 -1 pct 2000 vm.757166 1744 2 2 0 0 0-7
757181 757179 U vmx-vcpu-1:VM-03 74506.517 WAIT 897.525 0.000 IDLE 73535.015 72482.473 70.004 0 -1 pct 2000 vm.757166 1744 3 3 0 0 0-7
757364 757364 U vmx-vcpu-0:VM-06 74501.212 WAIT 568.980 0.000 IDLE 73834.234 73328.542 98.886 0 -1 pct 1000 vm.757269 497 2 2 0 0 0-7
1618850 1618850 U vmx-vcpu-0:vCLS-d68e9ed4-deab- 507.596 WAIT 20.893 0.000 IDLE 486.196 479.341 0.466 0 -1 pct 1000 vm.1618842 497 7 7 0 0 0-7

 

 

Reply
0 Kudos
ansarabass
Enthusiast
Enthusiast

Hey there!

Understanding the mapping of VM's vCPUs to the host's physical or logical CPUs can be quite valuable, especially when troubleshooting performance or fine-tuning your environment.

To see this mapping in ESXi:

ESXTOP: This is your go-to tool. Connect to your host using SSH and run esxtop.

Press c for the CPU view.
Identify your VM by its World ID.
The column PCPU USED% and PCPU UTIL% will tell you on which physical CPU the VM's vCPU is running.
vCenter Performance Charts:

Select the VM in question.
Navigate to the "Performance" tab and then to "Advanced".
Choose 'Chart Options' and under 'CPU', select the metric 'Core Utilization'. This will give you an idea of which core the vCPUs are utilizing.
However, do note that ESXi employs a CPU scheduler which dynamically schedules vCPUs to run on any available physical CPU (pCPU) core, depending on the current load and other factors. This means the mapping isn't static and can change over time as the scheduler deems necessary.

For in-depth examination or if you're looking into CPU affinity settings (which I'd advise caution with), VMware's official documentation or the VMware communities would be a great place to dive deeper.

Hope this gives you a good starting point!
Best,
Ansar

Reply
0 Kudos