[4.1.0.24][Xperia 10 II] Unknown memory level reported by MCE

REPRODUCIBILITY: always
OS VERSION: 4.1.0.24
HARDWARE: Xperia 10 II
UI LANGUAGE: cz
REGRESSION: no (on this device)

DESCRIPTION:

I am using memory level reported by MCE daemon for controlling application caches to avoid attention low-memory-killer. But on Xperia X II, MCE always reports “unknown” level. By wiki page https://sailfishos.org/wiki/Mce , it may happen when kernel subsystem memnotify is missing. It is correct, device /dev/memnotify is not present on the device (but it exists on old Jolla 1).

Would be possible to include memnotify in next release? Or kernel is provided by Sony and it is out of Jolla control?

STEPS TO REPRODUCE:

[defaultuser@Xperia ~]$ dbus-send --system --type=method_call --print-reply --dest=com.nokia.mce /com/nokia/mce/request  com.nokia.mce.request.get_memory_level
method return time=1623344738.268430 sender=:1.1 -> destination=:1.189 serial=423 reply_serial=2
   string "unknown"

[defaultuser@Xperia ~]$ ls -alh /dev/memnotify
ls: /dev/memnotify: No such file or directory

EXPECTED RESULT:

on Jolla 1:

[nemo@Sailfish ~]$ dbus-send --system --type=method_call --print-reply --dest=com.nokia.mce /com/nokia/mce/request  com.nokia.mce.request.get_memory_level
method return time=1623345782.652745 sender=:1.1 -> destination=:1.397 serial=3547 reply_serial=2
   string "normal"

[nemo@Sailfish ~]$ ls -alh /dev/memnotify
crw-rw-rw-    1 root     root       10,  31 Jun 10 13:09 /dev/memnotify
1 Like

Sounds similar?

Memnotify kernel patch and related mce configuration files are handled at Jolla.
Apparently this was not done for Xperia 10 II → I filed an internal ticket about this.

3 Likes

It is not just the Xperia 10 II, my Xperia XA2 Plus has the same issue.

Jolla 1 and Jolla tablet are okay indeed.

The device is also not present on Xperia 10 (one) under SFOS 4.0 Koli.

The device is also not present on Gemini PDA x27 under SFOS 4.1 Kvarken.

Device /dev/memnotify is not present on Sony Xperia XA2 Ultra under SFOS 4.1 Kvarken either, and I can also confirm that it isn’t on Sony Xperia 10 II with Kvarken.

Does this “unknown” memory level also cause Android subsystem to self-report isLowRamDevice()?

Does’t exist on Sony Xperia XA2 Dual-SIM with version 3.4.0.24 either and dbus command returns “Unknown” as well.

Good news, this may be fixed in the next release, according to:

https://irclogs.sailfishos.org/meetings/sailfishos-meeting/2021/sailfishos-meeting.2021-08-05-07.00.log.html

Hopefully. I also saw some tuning of low-memory-killer limits, that should improve Alien Dalvik behaviour, that is using lmkd daemon (if I am not mistaken) and I hope even native applications, that are killed by lowmemorykiller kernel module. I hope that together with memnotify subsystem it will bring less force-stops.

At least native browser and OSM Scout should listen to mce notifications :wink: Not sure if some other native apps are using it.

In SFOS 4.2.0.19 (early access) MCE memory level works:

[defaultuser@Xperia ~]$ dbus-send --system --type=method_call --print-reply --dest=com.nokia.mce /com/nokia/mce/request  com.nokia.mce.request.get_memory_level
method return time=1630478890.332339 sender=:1.1 -> destination=:1.401 serial=4470 reply_serial=2
   string "normal"

It is interesting, that /dev/memnotify doesn’t exists. Kernel interface of memnotify was changed? Or MCE is using different api now?

1 Like

Hmm, I am not able to get different memory level than “normal”, even when open many applications and lowmemory killer (kernel module) starts killing the apps :frowning: It doesn’t looks tuned properly on Xperia 10 II.

1 Like

As an enabler mce can now get memory pressure information also via cgroups kernel interface. (In older devices that already have memnotify available and configured, it is still used.)

As configuration was done en masse for a bunch of devices, further tuning might be needed.

… you can also make an attempt to tweak these yourself, e.g.

# show current state
mcetool | grep "Memory use"
# set new values
mcetool --set-memuse-warning-used=3210M --set-memuse-critical-used=3456M
# back to defaults
mcetool --reset-settings=/system/osso/dsm/memnotify/

Also: the effect this has depends on co-operation from applications, so the biggest impact comes from e.g. getting browser to flush background tabs on low memory conditions.

1 Like

Thank you @spiiroin for your reply! I was not aware that it is possible to tune MCE memory limits at runtime. It is also good to know how it works on the background. I understand that lowmemorykiller and mce are two separate components, so it is tricky to find the balanced configuration.

Btw, as Android 11 abandon lowmemorykiller kernel module and move its responsibility to user-space daemon (because better flexibility), it is planned something similar in SFOS in the future?

Cool.

On pre-4.2 versions, should that be possible as well?

I tried a modified version of the commands above, but apparently mcetool wants page count (int) instead of megabytes + “M”.

Yes, but it only makes sense in devices that have memnotify in kernel.

In earlier versions (mce < 1.107.0) the value needs to be integer page count. Possibility to use more human readable values was added along with cgroup based memory use support.

1 Like

Just loaded SFOS 4.3.0.12 (Suomenlinna) to my Xperia 10 II and the device still doesn’t exist, however the dbus command seems to return a correct value:

[defaultuser@Xperia10II-DualSIM ~]$ ls -l /dev/memnotify
ls: /dev/memnotify: No such file or directory
[defaultuser@Xperia10II-DualSIM ~]$ dbus-send --system --type=method_call --print-reply --dest=com.nokia.mce /com/nokia/mce/request  com.nokia.mce.request.get_m
emory_level
method return time=1635937375.319857 sender=:1.1 -> destination=:1.288 serial=1102 reply_serial=2
   string "normal"

As @spiiroin wrote, mce is using cgroups API (similarly as Android lmkd service) on newer kernels, not memnotify anymore.

1 Like

Hi @spiiroin , I made deeper look on memory configuration (low-memory killer, mce) on Xperia 10 II and believe that current mce/mempressure implementation cannot work properly. Because cgroup’s usage_in_bytes counts cache memory, that may be reclaimed and ignores kernel memory. It is absolutely different metric than low-memory killer is using…

I wrote details as blog post: Sailfish OS and memory :: karry.cz

I would appreciate your comments when you will have some time.

5 Likes