VB understates cpu core count

This is for discussing general topics about how to use VirtualBox.
Post Reply
hohon
Posts: 1
Joined: 3. Jan 2021, 00:12

VB understates cpu core count

Post by hohon »

I lost the count of how many times I created bug reports for this same issue that keeps creeping in with every new version, every different CPU.
It goes back almost a decade, and every time we hear the same excuses from the devs, and they escalate into accusations of users being liars. Yes, I heard all kinds of insults for saying that VB incorrectly understates the CPU count.

Today I replaced A6-3670 with 4x cores in my system for A5-5400K with 2x cores. VB incorrectly detects A6-5400K as a single-core CPU.
My own software has no issues detecting the CPU count under any OS imaginable. I do it for a living, and my software runs on Linux, FreeBSD, Solaris, Windows, and some other OSs. It is a system call, for crying out loud, but VB has its own opinion and it is always different.

Can you just get it right, once in a lifetime, and correctly detect AMD-V and core count? I am so sick of this. Needless to say, VMWare player detects it correctly. Boo-hoo!
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: VB understates cpu core count

Post by scottgus1 »

I have not run into this issue on any of my hosts, mostly Intel, also a couple AMD, in the 12 years that I have run Virtualbox. I did run across a poster within the last month that had an AMD that was being mis-reported in Virtualbox, and needed drivers from AMD for the host OS. Once those drivers were installed, the CPU count was properly reported.

AMD-V can be 'mis-reported' if it's a Windows 10/2019 host and Hyper-V is enabled, or some other AMD-V user has grabbed it first.

Please check with your CPU's provider for any chipset or CPU drivers needed, then try any VM, even with no OS installed, and post a zipped vbox.log using the forum's Upload Attachment tab.

One other thing: I detect a bit of rant in your (first and only :shock: ) post. A bit of rant helps at times. But please remember we are all non-employee volunteer posters and fellow Virtualbox users here on this forum, and we hope for a calm and polite conversation after the rantino particles have been purged. :D
z hopa
Posts: 17
Joined: 8. Dec 2013, 17:29

Re: VB understates cpu core count

Post by z hopa »

Same problem here. Perpetually understated CPU core count is driving me nuts for as long as I remember VirtualBox.
Do we run VirtualBox under Hyper-X or Qemu? Well, no, we are intelligent enough not to sandwich virtualization.
Why coming up with excuses when you can simply trust the OS to report the core count?

5 min of google-fu:

Code: Select all

#if defined (__linux__) || defined (_AIX) || defined (macintosh) || defined (__sun)
		cores = sysconf( _SC_NPROCESSORS_ONLN );
#endif

#if defined (__FreeBSD__) || defined (__NetBSD__) || defined (__OpenBSD__) || defined (__bsdi__)
		int mib[4];
		size_t len = sizeof(cores);

		mib[0] = CTL_HW;
		mib[1] = HW_AVAILCPU;  // alternatively, try HW_NCPU;

		sysctl(mib, 2, &cores, &len, NULL, 0);

		if( cores < 1 )
		{
			 mib[1] = HW_NCPU;
			 sysctl( mib, 2, &cores, &len, NULL, 0 );

			 if( cores < 1 )
			 {
				  cores = 1;
			 }
		}
#endif

#if defined (_hpux) || defined (hpux) || defined (__hpux)
		cores = mpctl(MPC_GETNUMSPUS, NULL, NULL);
#endif

#if defined (__sgi) or defined (sgi)
		cores = sysconf( _SC_NPROC_ONLN );
#endif
    }
Too hard?
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: VB understates cpu core count

Post by scottgus1 »

I guess the rantino particles haven't dispersed enough....
z hopa wrote:Do we run VirtualBox under Hyper-XV or Qemu? Well, no, we are intelligent enough not to sandwich virtualization.
A. Nested Virtualization is a thing now, and folks are trying it. Certain quid pro quos apply.
B. How does this fit with the apparent 'understating' of CPU count?
z hopa wrote:Why coming up with excuses
Whose 'excuses' are you referring to? Quotes are used to clarify such misunderstandings.

I'm not certain what the code snippet is supposed to show? And as to the hardness of it:
scottgus1 wrote:we are all non-employee volunteer posters and fellow Virtualbox users here on this forum
We on the forum have no control of Virtualbox's source code. Users can contribute code, the devs look it over when they get time.

Neither questioner in this topic has posted a vbox.log, so their assertions are so far just assertions with no evidence, and therefore not investigatable. Hint, hint...
z hopa
Posts: 17
Joined: 8. Dec 2013, 17:29

Re: VB understates cpu core count

Post by z hopa »

scottgus1 wrote:I'm not certain what the code snippet is supposed to show?
It shows how to detect CPU counts on various OSs.
scottgus1 wrote:Neither questioner in this topic has posted a vbox.log, so their assertions are so far just assertions with no evidence, and therefore not investigatable. Hint, hint...
I come here, again, because on yet another system, each version of VB since 5.2.8 and up till the currentmost 6.1 fail to detect CPU count.

Logs attached.
Attachments
Dreaded screenshot
Dreaded screenshot
Capture.PNG (30.45 KiB) Viewed 2565 times
VBox.zip
Coveted logs
(34.63 KiB) Downloaded 5 times
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: VB understates cpu core count

Post by scottgus1 »

Thanks for the screenshot and vbox.log!

The rantino particles seem to still be influencing your posting:
Dreaded screenshot
Coveted logs
You might want to look into that. Personally I can't see how we could dig through this issue without some solid evidence like a screenshot or a log. So these would be more like 'necessary screenshot' and 'required log'.

The CPU-Z screenshot reports 4 cores 4 threads. The vbox.log reports:
00:00:02.461482 CPUM: Logical host processors: 4 present, 4 max, 4 online, online mask: 000000000000000f
00:00:02.461483 CPUM: Physical host cores: 2
AMD reports:
https://www.amd.com/en/support/apu/amd- ... n-hd-8670d
# of CPU Cores 4
# of Threads 4
Seems the vbox.log is reporting logical cores correctly. I don't know how reliable "notebookcheck.net' is, but they say:
https://www.notebookcheck.net/AMD-A-Ser ... 620.0.html
The AMD A10-6800K is ... 2 modules with 4 CPU cores
'cpubenchmark.net' reports:
https://www.cpubenchmark.net/cpu.php?cp ... PU&id=1935
Cores: 4 (in 2 physical modules)
Both of these look a lot like the vbox.log: 2 physical devices, 4 total cores. So far I'm not seeing a discrepancy.

If you're referring to an apparent difference in the "number of processors" slider in the VM's settings, I have seen that over-provision the count. My 4-core not-hyperthreaded Core i5-750 shows 8 processors total in that slider. We had a discussion on that last year viewtopic.php?f=8&t=98388 Please follow that through, and if you have any other non-rantino-influenced questions or comments we'll be happy to help.
Post Reply