HelloVolla / ubuntu-touch-beta-tests

Status overview and issues for beta tests of Ubuntu Touch on the Volla Phone
23 stars 1 forks source link

mtkfusionrild use always ~15% cpu #89

Closed manland closed 3 years ago

manland commented 3 years ago

Details about installed OS version Dev channel (before qt5.12 upgrade)

Describe the bug mtkfusionrild always use between 15% and 20% cpu. What is it purpose? Where is code to look at it? Is it normal?

Steps to reproduce the bug (The following is an example:)

  1. Enter top in terminal
  2. See mtkfusionrild at top

Screenshot screenshot20210121_235338295

Additional context Use my volla as main driver so I have sim inserted and wifi always on. But even in fly mode mtkfusiond run.

JamiKettunen commented 3 years ago

Hey @manland, mtkfusionrild is the Android vendor RIL implementation (some info here) used by the Volla Phone's Mediatek chipset, and as far as I know that CPU usage is normal (keep in mind it's 16% of a single core total and not 16% of all 8 cores, you can visualize this better by installing and using htop instead).

@NotKit could perhaps tell better, but I'm pretty much certain we aren't allowed to share the source code either for this daemon from the vendor BSP. Update: An issue has been identified in a RIL related library by natur, a fix may be issued at a later time after it has been tested more extensively by us.

natur-produkt commented 3 years ago

I'm figuring out how to deploy this fix to Ubuntu Touch

natur-produkt commented 3 years ago

The fix will be available in devel channel in 4-8 hours.

manland commented 3 years ago

Amazing :tada:

Just to be able to understand, can you share some links/repo/code please?

natur-produkt commented 3 years ago

Ok, sure.

As you know, on Ubuntu Touch we use Android blobs. MTK ril daemon (which is responsible for SIM connection) is a part of Android blob.

MTK ril daemon is responsible for not only taking API calls from Ubuntu Touch, but for configuring hardware as well.

There are multiple threads inside this process. I debugged 3 of them.

First one is the VoLTE thread, which waits for VoLTE clients (not present on Ubuntu Touch). The second thread is waiting for the first one to be fully initialized (VoLTE client to be connected). The third one tries to send data to the second thread.

The issue is, that there is no VoLTE client (application, which will configure VoLTE feature) in Ubuntu Touch. All 3 threads are sleeping for 200 microseconds. However, it means that 5000 times per second each thread is waken up. On Linux, it means, that this thread, which is woken up, gets very high priority in CPU scheduler. It means that waking up so many time (3 * 5000 times per second) causes huge CPU usage.

What is a solution?

  1. Long term - implement VoLTE client in Ubuntu Touch
  2. Short term - doesn't allow to wake up the threads so often.

I decided to imlement #2 solution.

natur-produkt commented 3 years ago

Solution number 2 is in proprietary Android blob - I can't share it.

manland commented 3 years ago

Thank you very much for all this details.

And thank you (I have spying on your activity) to show me how android proprietary blob work with open source project. You have the code and publish only the compilation.

natur-produkt commented 3 years ago

No problems.

The fix is present in devel channel - 326 is the first version, which includes the fix. @manland , could you please confirm, that bug is fixed?

manland commented 3 years ago

@natur-produkt yes I confirm, after a week-end of use, no more mtkfusionrild!

Thank you very much :tada: :rocket:

deprecated-dot commented 2 years ago

Is this fix portable to UBPorts on Cosmo Communicator? Running latest devel (805) shows the same behavior for mtkfusionrild -l libmtk-ril.so: two instances of the process each, consuming ~8% CPU. This has the effect of constantly draining the battery.