ESXi

 View Only
Expand all | Collapse all

How to see VM vCPU to Host CPU mapping?

  • 1.  How to see VM vCPU to Host CPU mapping?

    Posted Dec 30, 2020 03:13 PM

    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?



  • 2.  RE: How to see VM vCPU to Host CPU mapping?

    Posted Dec 30, 2020 08:45 PM

     

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

     

     



  • 3.  RE: How to see VM vCPU to Host CPU mapping?

    Posted Dec 31, 2020 12:48 PM

    No, i do not see changing



  • 4.  RE: How to see VM vCPU to Host CPU mapping?

    Posted Dec 31, 2020 04:51 PM

     

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

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

     



  • 5.  RE: How to see VM vCPU to Host CPU mapping?

    Posted Jan 02, 2021 01:28 PM

    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"?



  • 6.  RE: How to see VM vCPU to Host CPU mapping?

    Posted Jan 02, 2021 03:56 PM

     

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



  • 7.  RE: How to see VM vCPU to Host CPU mapping?

    Posted Jan 02, 2021 06:05 PM

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



  • 8.  RE: How to see VM vCPU to Host CPU mapping?

    Posted Feb 04, 2021 12:09 PM

    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.



  • 9.  RE: How to see VM vCPU to Host CPU mapping?

    Broadcom Employee
    Posted Feb 04, 2021 01:43 PM

    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



  • 10.  RE: How to see VM vCPU to Host CPU mapping?

    Posted Aug 17, 2023 08:00 AM

    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



  • 11.  RE: How to see VM vCPU to Host CPU mapping?

    Broadcom Employee
    Posted Feb 04, 2021 11:08 AM

    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.



  • 12.  RE: How to see VM vCPU to Host CPU mapping?

    Broadcom Employee
    Posted Aug 17, 2023 06:01 AM

    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