4

To find the number of cores available to you in Termux you run:

grep Cpus_allowed /proc/self/status

This number of cores is limited in a similar way to running taskset on GNU/Linux.

I am trying to be able to predict what that will return.

According to the app CPU-Z my phone (Huawei Smart P) has 1 HiSilicon Kirin 659 with 8 cores. According to the app CPU Info 4 cores are running the same speed (480-1709Mhz) and 4 cores are running the same speed (1402-2362Mhz).

After booting the phone and waiting 5 minutes to make sure all startup tasks have been started/completed I started Termux, login through ssh and got:

Cpus_allowed_list:       0-7

Which is exactly what I expect.

But if I press the home key, I get:

Cpus_allowed_list:      2-3

I thought this might have to do with how hard the cores are loaded, so I switched to Termux again, started 16 bzip2s. This does not change the number of cores I get immediately. But after 30s I get 4 cores:

Cpus_allowed_list:     0-3

And yet later I get bumped back to 2 cores:

Cpus_allowed_list:      2-3

This behaviour happens through ssh whether Termux is in the foreground or background.

The effect of the home key is only when running Termux: If I run CPU Info, then press home and then start Termux, then Termux still has 8 cores:

Cpus_allowed_list:       0-7

Only when I switch away from Termux using the home key, the app-list key, or the back key does the number of CPUs change.

Software controlled big.LITTLE could explain going from 8 to 4 cores if the limit was not enforced immediately after boot, but only activated later. Since the limit is not activated 5 minutes after boot, I think it is safe to reject this as the explanation. Also it does not explain limiting to 2 cores some of the time when running 16 bzip2s.

What is causing the phone to limit me from using 8 cores? How can I tell the phone not to do so? What is causing the limit to jump between 2 and 4 cores at seemingly random intervals?

(On top of this I had expected the cores to run at 100% speed which also does not happen).

The limitation does not happen if not run through ssh or if run in a tmux session where the tmux session is started.

  • The CPU is an Octa core with BIG-little concept. Therefore this answer also applies to your CPU. – Robert Mar 3 at 12:06
  • @Robert IF it was a big.LITTLE CPU why do I get 0-7 after boot? It stays that way if I do not press home. top clearly shows 8 CPUs running 100%. Also that would not explain why I am limited to only 2 cores some of the time. – Ole Tange Mar 3 at 12:47
  • I would assume that the device starts without specific CPU assignments. This also makes the boot as fast as possible. Afterwards (may be by the start of a special service) it applies the power configuration to limit the power consumption. New processes start with 2 cores and after 30 seconds of high cpu usage all 4 fast cores are allowed. Keep in mind that Smartphones are optimized for UI responsiveness, not for max CPU throughput. – Robert Mar 3 at 12:54
  • @Robert I have updated the question. The big.LITTLE explanation does not seem to fit the evidence. – Ole Tange Mar 3 at 14:11
-2

Summary: the more cores you use the more battery you consume so CPU hotplugging turns off the other cores, and the others do the work which makes them at 100% CPU usage, which also give the best performance and the most balanced one.

It's CPU hotplug It turns on and off the cores when needed or not.

It's running 100% CPU usage because it's like this. Imagine, there's a 4 car, and let's assume the drivers are the cores. You have four lanes and 4 cars of course. Each one of them will take 100 pizzas. You can let one core to do all the work and that's what hot plugging do. Knowing that a car with 50 pizzas consumes a lot less fuel than a car with 100 pizzas you can now see how we can have the same performance and save on fuel: load two cars with 50 pizzas and let them accelerate as quickly as possible to the destination (performance governor). They will get there as quickly as one car with 100 pizzas (same performance), but burn less fuel (battery saving).

If you want to make your phone run at 8 cores then you need to install a custom kernel, use an other CPU governor, use a custom CPU hotplugging, or without installing a custom kernel use an interactive governor, then tweak its parameters. You can search on XDA for Advance Interactive governor tweaks.

  • 1
    Further, what do you think gives "best balance performance" on high load? Certainly not disabling cores. And 16 bzip2 processes certainly need more than 3 cores for "good performance". So could you please explain – and back your claim? – Izzy Mar 2 at 18:13
  • Use an interactive governor then tune its parameters – Sean Mar 2 at 18:18
  • Its the way your kernel turn on and off the cores if its needed or not in the bootup all cores are on because android bootup are sometimes slow so developers try to turn on all the cores to make it boot faster – Sean Mar 2 at 18:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.