Firstly, it seems like this is not possible, here is some information on this:
We will use the Samsung Exynos 5 Octa CPU as an example for this thread, but generally any ARM processor will work the same.
The Samsung Exynos 5 Octa CPU has 8 CPU cores. but in reality it has two processes with 4 cores each. This is called big.LITTLE. You have 1 fast processor and 1 power efficient processor.
Within the Exynos 5 CPU it has two different CPUs in built, a Cortex a15 and a Cortex a7...
Within big.LITTLE both CPUs cannot run at the same time, only one CPU can be active at any given time...
But there is also something called "big.LITTLE mp" in which both CPU's can be active at the same time, but here is the catch (again!) Only FOUR cores can be active to the software at any given time. Here is an image to explain this a bit better:

Now as you can see, a single CPU core is used from the more powerful processor here and then the other four cores are active from the more energy efficient a7 CPU cluster.
You can read more about the big.LITTLE architecture here :
http://www.arm.com/products/processors/technologies/biglittleprocessing.php
You can read more about the big.LITTLE mp architecture here:
http://www.arm.com/products/processors/technologies/biglittleprocessing.php
What you want to find out now, is if it is possible to know if the CPU architecture is Big.LITTLE or BIG.LITTLE mp. Then see if you can directly find out the CPU count from each individual CPU, but I cannot find any relevant code. There is a lot of documentation on ARMs website, but I am not too sure if it is possible to get this information. Either way though, only 4 CPU cores can be used therefor the code you have is technically correct as that is the number of useable cores.
I hope this helped, if you have any questions or want anything clearing up then let me know. There is a lot of information out there