Sample Header Ad - 728x90

Why does the number of available CPU cores change when an app is closed?

7 votes
2 answers
2096 views
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 via the terminal on the phone.
Asked by Ole Tange (386 rep)
Mar 2, 2019, 04:13 PM
Last activity: May 25, 2022, 04:07 PM