Bug 251134 - [WPE] Linux memory pressure for swap memory
Summary: [WPE] Linux memory pressure for swap memory
Status: REOPENED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WPE WebKit (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Linux
: P2 Major
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-24 21:42 PST by Donghwa Kim
Modified: 2023-01-25 03:50 PST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Donghwa Kim 2023-01-24 21:42:01 PST
Hi,

I am using webkit browser for my embedded linux platform with memory swap.

However, when I check the source code, I can see that MemoryPressureHandlerLinux.cpp does not consider swap memory.

Looking inside the MemoryUsagePoller function, we are only monitoring the VmRSS value.
So, in the Linux environment using memory swap (HDD swap, etc.), I confirmed that memory clear (garbage collection) is not done at the time I expect.

This will result in OOM of the platform in severe cases.
I'd suggest that not only the VmRSS values should be monitored, but also the VmSwap as well.
Comment 1 Donghwa Kim 2023-01-24 21:54:07 PST
This is my suggetion :

diff --git a/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp b/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp
index fb86ee9d996d..674ff297837c 100644
--- a/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp
+++ b/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp
@@ -248,13 +248,14 @@ MemoryPressureHandler::MemoryUsagePoller::MemoryUsagePoller()
             bool critical = false;
             bool synchronous = false;
             size_t value = 0;
+            size_t value_swap = 0;

             if (s_pollMaximumProcessMemoryCriticalLimit) {
-                if (readToken(s_processStatus, "VmRSS:", KB, value)) {
-                    if (value > s_pollMaximumProcessMemoryNonCriticalLimit) {
+                if (readToken(s_processStatus, "VmRSS:", KB, value) && readToken(s_processStatus, "VmSwap:", KB, value_swap)) {
+                    if (value + value_swap > s_pollMaximumProcessMemoryNonCriticalLimit) {
                         underMemoryPressure = true;
-                        critical = value > s_pollMaximumProcessMemoryCriticalLimit;
-                        synchronous = value > s_pollMaximumProcessMemoryCriticalLimit * 1.05;
+                        critical = value + value_swap > s_pollMaximumProcessMemoryCriticalLimit;
+                        synchronous = value + value_swap > s_pollMaximumProcessMemoryCriticalLimit * 1.05;
                     }
                 }
             }
Comment 2 Donghwa Kim 2023-01-24 23:37:39 PST
Sorry. I should report this issue to the WPEWebkit project.
I will closed it.
Comment 3 Adrian Perez 2023-01-25 02:54:48 PST
(In reply to Donghwa Kim from comment #2)
> Sorry. I should report this issue to the WPEWebkit project.
> I will closed it.

Hi Donghwa! You have reported your bug correctly... this Bugzilla is
for all the WebKit ports, including WPE =)

Let's reopen this, I am CC'ing a coouple of developers who may have
a better idea than me about this topic.
Comment 4 Miguel Gomez 2023-01-25 03:30:08 PST
While the upstream version of WPE has the same problem, the code Donghwa is referring to belongs to the WebPlatformForEmbedded version of WPE.
Comment 5 Donghwa Kim 2023-01-25 03:50:05 PST
Here is my WPEWebkit pull request link :

https://github.com/WebPlatformForEmbedded/WPEWebKit/pull/1017