How to assign logical host CPUs available to a guest?
How to assign logical host CPUs available to a guest?
The new Intel 13900K has 32 logical cpus. The first 16 are pairs of threads on the 8 performance cores, and the last 16 are efficiency cores. The performance cores are faster.
How do I configure a virtualbox machine definition file for the guest to limit the guest virtual cpus to a subset of the available logical host cpus? For example, perhaps I want to make logical cores 0,2,4,6,8,10,12, an 14 available only. That will assign the guest virtual cpus to performance cores, but disallow two virtual cpus going to the same core.
Can't do it in Window task manager, as I hit an "access is denied," probably due to the "hardening" crap. Is there any way to do this? I really don't want to argue about why I want to do it. I just want to know how to do it.
How do I configure a virtualbox machine definition file for the guest to limit the guest virtual cpus to a subset of the available logical host cpus? For example, perhaps I want to make logical cores 0,2,4,6,8,10,12, an 14 available only. That will assign the guest virtual cpus to performance cores, but disallow two virtual cpus going to the same core.
Can't do it in Window task manager, as I hit an "access is denied," probably due to the "hardening" crap. Is there any way to do this? I really don't want to argue about why I want to do it. I just want to know how to do it.
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: How to assign logical host CPUs available to a guest?
I am not aware of any technology called a "logical CPU".
The i9-13900K has 24 cores, we don't care about threads.
The maximum number of cores you should assign to any VM is 12, but in fact unless you are doing a huge amount of parallel work inside the VM then I would stick with 2 cores. The host OS will generally choose which cores are assigned.
The i9-13900K has 24 cores, we don't care about threads.
The maximum number of cores you should assign to any VM is 12, but in fact unless you are doing a huge amount of parallel work inside the VM then I would stick with 2 cores. The host OS will generally choose which cores are assigned.
-
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: How to assign logical host CPUs available to a guest?
I think what you are trying to do is "set affinity". Virtualbox doesn't appear to have any mechanisms for setting affinity for the VMs, and there is no mention of "affinity" in the manual.
I suspect that this is something the host OS would have to handle. Keep in mind that the actual process running the VM is VirtualboxVM.exe, and three VirtualboxVM.exe's are launched to run each VM.
I'd lean away from Virtualbox Hardening being the cause of the access denied in Task Manager. Setting affinity in TM is a host OS setting that occurs to control where the process code runs, and Hardening isn't actually executig util it gets a core to execute on. I may be wrong....
I too have been curious about running Virtualbox on those new-fangled performance/efficiency CPU's, wondering if the VM would stay on performance cores, sometimes lose the lottery and end up on the efficiency cores and get slower, or bounce back and forth as the load changes.
I think the only way to tell would be to run various real-world loads in the VM then check completion speeds, or possibly which host cores the VM processes are executing on over time if such is possible.
I suspect that this is something the host OS would have to handle. Keep in mind that the actual process running the VM is VirtualboxVM.exe, and three VirtualboxVM.exe's are launched to run each VM.
I'd lean away from Virtualbox Hardening being the cause of the access denied in Task Manager. Setting affinity in TM is a host OS setting that occurs to control where the process code runs, and Hardening isn't actually executig util it gets a core to execute on. I may be wrong....
I too have been curious about running Virtualbox on those new-fangled performance/efficiency CPU's, wondering if the VM would stay on performance cores, sometimes lose the lottery and end up on the efficiency cores and get slower, or bounce back and forth as the load changes.
I think the only way to tell would be to run various real-world loads in the VM then check completion speeds, or possibly which host cores the VM processes are executing on over time if such is possible.
-
- Volunteer
- Posts: 5677
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: How to assign logical host CPUs available to a guest?
You cannot do that, because there is no configuration item in VirtualBox VM definitions for that.ThomasF wrote:How do I configure a virtualbox machine definition file for the guest to limit the guest virtual cpus to a subset of the available logical host cpus?
Yes, I'm afraid you're right. On Linux hosts, you can set the affinity AFAIK.ThomasF wrote:Can't do it in Window task manager, as I hit an "access is denied," probably due to the "hardening"
Not within VirtualBox. You can only use mechanisms provided by the host OS. But as far as I understood the technology so far, the basic idea is that the Intel Thread Director (embedded microcontroller hardware) collects and provides the data to the OS scheduler, so manually setting the affinity could be counter-productive.ThomasF wrote:Is there any way to do this?
BTW, you might stumble upon one of the real reasons why Windows 11 had to be named Windows 11.
Re: How to assign logical host CPUs available to a guest?
I've attached a screenshot from Windows 10 task manager. You can see that the "performance" tab of the task manager is being shown, with the view set to "logical processors." At the top, in a big font, is the word "CPU" and a grid of 32 utilization charts is shown, one per logical CPU. So it is official terminology from Microsoft.mpack wrote:I am not aware of any technology called a "logical CPU".
The i9-13900K has 24 cores, we don't care about threads.
The maximum number of cores you should assign to any VM is 12, but in fact unless you are doing a huge amount of parallel work inside the VM then I would stick with 2 cores. The host OS will generally choose which cores are assigned.
I'm not running Windows 11, and don't plan to soon, and so I don't think I can count on Windows to assign performance cores to the VirtualBox virtual cpus. That's why I was asking whether VB has the config option.
VMware has such an config option in its vmx files, which at least shows that it's not a crazy idea, though so far, I haven't gotten it to work on my system.
Yeah, that's why I was asking. A web search wasn't turning up any way to do it.scottgus1 wrote:I think what you are trying to do is "set affinity". Virtualbox doesn't appear to have any mechanisms for setting affinity for the VMs, and there is no mention of "affinity" in the manual.
Well, I can set the affinity for the equivalent process for VMware, vmware-vmx.exe, from the Windows 10 task manager, and VMware doesn't have "hardening" like VirtualBox does (at least with regard to other areas, such as host driver signature checks), so the fact that it fails for VirtualBox and not other apps suggests to me that it's the hardening.I suspect that this is something the host OS would have to handle. Keep in mind that the actual process running the VM is VirtualboxVM.exe, and three VirtualboxVM.exe's are launched to run each VM.
I'd lean away from Virtualbox Hardening being the cause of the access denied in Task Manager. Setting affinity in TM is a host OS setting that occurs to control where the process code runs, and Hardening isn't actually executig util it gets a core to execute on. I may be wrong....
Note that VirtualBox also blocks me from changing the process priority with access denied as well, something else that you can do with no problem for VMware, though VMware will override the changed priority every few minutes with whatever you've configured in your vmx file.
I'm running Windows 10, not 11, so I don't think manually assigning CPU affinity, if I could do it,would clash with the OS. One option is an app called "Process Lasso", but I'm not sure without investigating whether it would be blocked from changing VirtualBox's process affinity, as I am directly from the Task Manager GUI.fth0 wrote: Not within VirtualBox. You can only use mechanisms provided by the host OS. But as far as I understood the technology so far, the basic idea is that the Intel Thread Director (embedded microcontroller hardware) collects and provides the data to the OS scheduler, so manually setting the affinity could be counter-productive.
BTW, you might stumble upon one of the real reasons why Windows 11 had to be named Windows 11.
- Attachments
-
- taskman-cpus.png (83.45 KiB) Viewed 6591 times
-
- Volunteer
- Posts: 5677
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: How to assign logical host CPUs available to a guest?
It doesn't really matter, but your argument is a little bit flawed:ThomasF wrote:I've attached a screenshot from Windows 10 task manager. You can see that the "performance" tab of the task manager is being shown, with the view set to "logical processors." At the top, in a big font, is the word "CPU" and a grid of 32 utilization charts is shown, one per logical CPU. So it is official terminology from Microsoft.
The Task Manager displays 1 CPU "13th Gen Intel(R) Core(TM) i9-13900K" with 24 32 logical processors. The term "logical processor" is official terminology from Intel; you'll find it hundreds of times in the Intel SDM, but you won't find the term "logical CPU" there even once. But you'll find the term "logical CPU" often on Google nonetheless, mostly from non-official sources.
Last edited by fth0 on 24. Feb 2023, 18:56, edited 1 time in total.
-
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: How to assign logical host CPUs available to a guest?
I think fth0 probably meant "24 cores", and there are 32 "logical processors", which is really market-speak for "24 cores and 8 of them are hyperthreaded". I surmise these are the 8 performance cores.fth0 wrote:The Task Manager displays 1 CPU "13th Gen Intel(R) Core(TM) i9-13900K" with 24 logical processors.
https://www.intel.com/content/www/us/en ... tions.html
Note that Virtualbox 4.3.12 was the last version that did not have hardening. You could try it and see if Task Manager lets you set affinity. 4.3.14 is the first version with hardening. If .12 lets affinity get set and .14 does not, then maybe hardening is a reasonable suspect. https://www.virtualbox.org/wiki/Download_Old_BuildsCPU Specifications
Total Cores 24
# of Performance-cores 8
# of Efficient-cores 16
Total Threads 32
Terminology and possible hardening interference aside, Virtualbox doesn't have a way to force a VM process onto a particular core. If VMware does, and you really need this function, then you'll have to use VMware.
-
- Volunteer
- Posts: 5677
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: How to assign logical host CPUs available to a guest?
Thanks for spotting my mistake, I shouldn't post when being in a hurry!scottgus1 wrote:I think fth0 probably meant "24 cores", and there are 32 "logical processors", which is really market-speak for "24 cores and 8 of them are hyperthreaded". I surmise these are the 8 performance cores.fth0 wrote: The Task Manager displays 1 CPU "13th Gen Intel(R) Core(TM) i9-13900K" with 24 logical processors.
I meant 32 logical processors, of course. But it's not market-speak, but rather technical correctness. A logical processor (*) is an entity on which the OS can schedule one of its threads. That logical processors share some physical hardware inside the CPU, influences their combined performance, but the OS can handle them as separate entities nonetheless.
(*) Introduction of the term "logical processor" in the Intel SDM:
Intel SDM, chapter 2.2.8 Intel Hyper-Threading Technology wrote:Architecturally, an IA-32 processor that supports Intel HT Technology consists of two or more logical processors, each of which has its own IA-32 architectural state. Each logical processor consists of a full set of IA-32 data registers, segment registers, control registers, debug registers, and most of the MSRs. Each also has its own advanced programmable interrupt controller (APIC).
Re: How to assign logical host CPUs available to a guest?
What does the "P" in CPU stand for? Processing. So I don't see much daylight between the two, especially since, as I pointed out, the word "CPU" is right there in the screen grab from the Windows 10 Task Manager showing 32 utilization charts. Does it only apply to the collective set of charts, or to each chart? How many angels can dance on the head of a pin?fth0 wrote: The Task Manager displays 1 CPU "13th Gen Intel(R) Core(TM) i9-13900K" with 24 32 logical processors. The term "logical processor" is official terminology from Intel; you'll find it hundreds of times in the Intel SDM, but you won't find the term "logical CPU" there even once. But you'll find the term "logical CPU" often on Google nonetheless, mostly from non-official sources.
I have both products installed and I'd like both of them to work.scottgus1 wrote: Note that Virtualbox 4.3.12 was the last version that did not have hardening. You could try it and see if Task Manager lets you set affinity. 4.3.14 is the first version with hardening. If .12 lets affinity get set and .14 does not, then maybe hardening is a reasonable suspect. https://www.virtualbox.org/wiki/Download_Old_Builds
Terminology and possible hardening interference aside, Virtualbox doesn't have a way to force a VM process onto a particular core. If VMware does, and you really need this function, then you'll have to use VMware.
As far as investigating old versions of VirtualBox, unfortunately you can't install multiple versions of VB, and even if you could, I don't think such an old version of VB would support a Windows 10 22H2 guest, which is what I'm running. So such an investigation would only serve to satisfy the intellectual curiosity of resolving the question, rather than practical value. I suppose I could build and maintain my own fork of VB from open source, but unfortunately I don't have huge quantities of time to burn.
If I find time to test Process Lasso on VirtualBox, I will report back here.
-
- Volunteer
- Posts: 5677
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: How to assign logical host CPUs available to a guest?
Thanks for teaching me an English proverb!ThomasF wrote:How many angels can dance on the head of a pin?
You can spare your precious time, if you believe me:ThomasF wrote:If I find time to test Process Lasso on VirtualBox
I just tried the free version of Process Lasso, and it could only change the CPU affinity (and priorities) for the first VirtualBoxVM.exe process (just as I would have expected). The same holds true for Sysinternals Process Monitor, BTW.
-
- Site Moderator
- Posts: 39134
- Joined: 4. Sep 2008, 17:09
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Mostly XP
Re: How to assign logical host CPUs available to a guest?
IMO, it would be highly risky to fiddle with processor affinity of a program that you did not develop. The program should signal its own affinity using an API call.
-
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: How to assign logical host CPUs available to a guest?
"CPU" only applies to the collective set. CPU refers to the large flat black IC with four hundred pins on it squeezed under he heatsink. Inside the CPU is a number of different cores, and some of those cores are hyperthreaded, and as fth0 points out above, each core or hyperthread gets displayed as a "logical processor".ThomasF wrote:the word "CPU" is right there in the screen grab from the Windows 10 Task Manager showing 32 utilization charts. Does it only apply to the collective set of charts, or to each chart?
Yes, 4.3.12/14 won't run Windows 10. And you can only have one version of Virtualbox installed at a time. So, you can install .12 and try an older Windows or Linux version, then try to set affinity on the VM. If it works, then try .14. If it does still, then hardening has nothing to do with blocking affinity setting. If neither affinity can be set, it also indicates hardening is not the problem.
-
- Volunteer
- Posts: 5677
- Joined: 14. Feb 2019, 03:06
- Primary OS: Mac OS X other
- VBox Version: PUEL
- Guest OSses: Linux, Windows 10, ...
- Location: Germany
Re: How to assign logical host CPUs available to a guest?
Your argumentation is flawed IMHO, because like many parts of VirtualBox, the VirtualBox hardening implementation has evolved from 4.3.14 up to 7.0.6 (obviously undocumented ), so it very well could be that blocking process affinity changes was introduced after 4.3.14.scottgus1 wrote:So, you can install .12 and try an older Windows or Linux version, then try to set affinity on the VM. If it works, then try .14. If it does still, then hardening has nothing to do with blocking affinity setting.
Other than that, the fact that you can change the affinity of the 1st VirtualBoxVM.exe child process, but not of the 2nd and 3rd child, already reveals that the VirtualBox hardening implementation is responsible.
-
- Posts: 231
- Joined: 1. Jan 2017, 09:16
- Primary OS: MS Windows 7
- VBox Version: PUEL
- Guest OSses: Ubuntu 16.04 x64, W7
Re: How to assign logical host CPUs available to a guest?
For general reference: though Lasso is more capable, start /affinity will usually get the job done.fth0 wrote:Process Lasso (snip)
AFAICT from a quick glance it works fine: I started a VM pinned to 2 cores, with another 4-core VM already running, stressed the second VM, and 100% of the load is on the two cores I assigned to it. So I don't understand what OP's problem is. Is it just that he'd like a GUI for it?
-
- Site Moderator
- Posts: 20945
- Joined: 30. Dec 2009, 20:14
- Primary OS: MS Windows 10
- VBox Version: PUEL
- Guest OSses: Windows, Linux
Re: How to assign logical host CPUs available to a guest?
Not a surprise here It was a shot in the dark. ThomasF, please consider this .12/.14 idea withdrawn.fth0 wrote:Your argumentation is flawed IMHOscottgus1 wrote:you can install .12 ... then try .14....
So that's what the three VirtualboxVM.exe processes are for!fth0 wrote:the fact that you can change the affinity of the 1st VirtualBoxVM.exe child process, but not of the 2nd and 3rd child, already reveals that the VirtualBox hardening implementation is responsible.