-
Notifications
You must be signed in to change notification settings - Fork 891
Changed vm_mid_bits and VM_MID_BIT variable to 64 #141
Conversation
core/vm.c
Outdated
| static uint8_t vm_mid_bits = 0; | ||
| #define VM_MID_BIT 8 | ||
| static uint64_t vm_mid_bits = 0; | ||
| #define VM_MID_BIT 64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you please put this define into core/include/config.h?
I need it for the NetBSD backend. Also HAX_MAX_VCPUS is a little bit more verbose to me rather than cryptic VM_MID_BIT.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi. I changed HAX_MAX_VCPUS to 128 and put this define to config.h
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, now VM_MID_BIT is defined twice in two different files. The ideal solution is to define it once in one common header (config.h, or another one) and include that header in vm.c. Also, I agree with @krytarowski that we should take the chance to rename it to HAX_MAX_VMS (I believe HAX_MAX_VCPUS is a typo).
@insidiaGithub You could go ahead with the proper refactoring. Or, if you want this PR to focus on the original issue, that's also fine. Please keep only the first commit, and I'll approve it. @krytarowski If #137 can't handle 64 VMs, you can define a separate constant in a NetBSD header and limit it to 8.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please also fix your commit message:
- The format is a (concise) subject line, followed by a blank line, followed by a more detailed description.
Signed-off-by:(git commit -s) is required. See https://github.com/intel/haxm/blob/master/CONTRIBUTING.md
core/vm.c
Outdated
| static uint8_t vm_mid_bits = 0; | ||
| #define VM_MID_BIT 8 | ||
| static uint64_t vm_mid_bits = 0; | ||
| #define VM_MID_BIT 64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, now VM_MID_BIT is defined twice in two different files. The ideal solution is to define it once in one common header (config.h, or another one) and include that header in vm.c. Also, I agree with @krytarowski that we should take the chance to rename it to HAX_MAX_VMS (I believe HAX_MAX_VCPUS is a typo).
@insidiaGithub You could go ahead with the proper refactoring. Or, if you want this PR to focus on the original issue, that's also fine. Please keep only the first commit, and I'll approve it. @krytarowski If #137 can't handle 64 VMs, you can define a separate constant in a NetBSD header and limit it to 8.
core/include/config.h
Outdated
| }; | ||
|
|
||
| #define HAX_MAX_VCPUS 16 | ||
| #define HAX_MAX_VCPUS 128 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@insidiaGithub Do you need more than 16 vCPUs per VM? Have you tested this change? I just wonder if this is a step too far for this PR. Apparently, the underlying logic for limiting the number of vCPUs to 16 is very different from that for limiting the number of VMs, and I need more time to analyze the former and understand the ramifications of this change.
|
Hi @raphaelning ! Please check my сhanges again. Thank you) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing my previous comment! You've also renamed vm_mid_bits, which led me to an inspiration--sorry about that, but that should be the last change request for this PR.
core/vm.c
Outdated
|
|
||
| static uint8_t vm_mid_bits = 0; | ||
| #define VM_MID_BIT 8 | ||
| static uint64_t hax_max_vms_bits = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this variable is local to vm.c, we don't really have to rename it. If you don't like the old name, how about vm_mid_seed? It's based on the pattern of vm_t::vpid_seed (core/include/vm.h), and implies that it's used for generating VM IDs. Actually, we can follow vpid_seed's example and turn this variable into an array, which should be a better way to make a connection between it and HAX_MAX_VMS:
| static uint64_t hax_max_vms_bits = 0; | |
| static uint8_t vm_mid_seed[HAX_MAX_VMS / 8]; |
Note that we don't really need to initialize this array, since the default behavior is to fill it with zeros.
|
We are accessing this variable through an |
|
@krytarowski Good point. I did notice that |
|
@insidiaGithub Thanks for the update, but could you amend the first commit and revert the renaming of |
This change will allow running more than 8 virtual machines. uint8_t changed to uint64_t Signed-off-by: Pavel Sorokin <pavel@sorokin94.ru>
Done. thank you |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
|
I don't think that this looks sane, atomic operations behave well on registers, not arrays (for arrays we might want mutexes). I've noted this issue during my NetBSD porting effort, but rescheduled to be presented after merging my code. Thankfully it was fixed here indirectly. |
True. I was thinking about re-implementing them with the |
This change allows you to run more than 8 virtual machines.