WebKit Bugzilla
Attachment 340167 Details for
Bug 184261
: [GTK][WPE] Memory pressure monitor doesn't reliable notify all the subprocesses
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
Patch
bug-184261-20180511060041.patch (text/plain), 28.97 KB, created by
Carlos Alberto Lopez Perez
on 2018-05-10 21:00:43 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Carlos Alberto Lopez Perez
Created:
2018-05-10 21:00:43 PDT
Size:
28.97 KB
patch
obsolete
>Subversion Revision: 231686 >diff --git a/Source/WTF/ChangeLog b/Source/WTF/ChangeLog >index 571658db3822b8b099d20b4c98e4ca34a8aba4b7..65e7c2851d39156b3d912d605ca1d0c1ef0683f3 100644 >--- a/Source/WTF/ChangeLog >+++ b/Source/WTF/ChangeLog >@@ -1,3 +1,24 @@ >+2018-05-10 Carlos Alberto Lopez Perez <clopez@igalia.com> >+ >+ [GTK][WPE] Memory pressure monitor doesn't reliable notify all the subprocesses >+ https://bugs.webkit.org/show_bug.cgi?id=184261 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Receive the memory pressure notifications from the UIProcess memory monitor via WebKit IPC. >+ If the memory cgroup (systemd) interface is available preffer and use it. >+ >+ * wtf/MemoryPressureHandler.h: >+ * wtf/linux/MemoryPressureHandlerLinux.cpp: >+ (WTF::isSystemdMemoryPressureMonitorAvailable): >+ (WTF::MemoryPressureHandler::EventFDPoller::EventFDPoller): >+ (WTF::MemoryPressureHandler::logErrorAndCloseFDs): >+ (WTF::MemoryPressureHandler::tryEnsureEventFD): >+ (WTF::MemoryPressureHandler::handleMemoryPressureEvent): >+ (WTF::MemoryPressureHandler::triggerMemoryPressureEventFromUIProcess): >+ (WTF::MemoryPressureHandler::install): >+ (WTF::MemoryPressureHandler::uninstall): >+ > 2018-05-10 Tim Horton <timothy_horton@apple.com> > > Fix the build after r231393 >diff --git a/Source/WebKit/ChangeLog b/Source/WebKit/ChangeLog >index 8adf65be887d46b2182087b4604c53e9a6cac6cb..0cca5cdcca78e2147c56d1b251ef7fb55f8fff9f 100644 >--- a/Source/WebKit/ChangeLog >+++ b/Source/WebKit/ChangeLog >@@ -1,3 +1,53 @@ >+2018-05-10 Carlos Alberto Lopez Perez <clopez@igalia.com> >+ >+ [GTK][WPE] Memory pressure monitor doesn't reliable notify all the subprocesses >+ https://bugs.webkit.org/show_bug.cgi?id=184261 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Instead of a shared eventfd file, use WebKit IPC to deliver the memory pressure events >+ from the UIProcess to the WebKit child processes, because the eventfd method is racy >+ and is not reliable with more than one WebKit child process. >+ >+ The thresolds for trigerring the event on the UIProcess memory monitor are lowered >+ a 5% to compensate that notifying the WebKit child process via WebKit IPC is a bit >+ slower than doing that via an eventfd. >+ >+ * NetworkProcess/NetworkProcess.cpp: >+ (WebKit::NetworkProcess::initializeNetworkProcess): >+ * NetworkProcess/NetworkProcessCreationParameters.cpp: >+ (WebKit::NetworkProcessCreationParameters::encode const): >+ (WebKit::NetworkProcessCreationParameters::decode): >+ * NetworkProcess/NetworkProcessCreationParameters.h: >+ * PluginProcess/PluginProcess.cpp: >+ (WebKit::PluginProcess::initializePluginProcess): >+ * Shared/ChildProcess.cpp: >+ (WebKit::ChildProcess::didReceiveMemoryPressureEvent): >+ * Shared/ChildProcess.h: >+ * Shared/ChildProcess.messages.in: >+ * Shared/Plugins/PluginProcessCreationParameters.cpp: >+ (WebKit::PluginProcessCreationParameters::encode const): >+ (WebKit::PluginProcessCreationParameters::decode): >+ * Shared/Plugins/PluginProcessCreationParameters.h: >+ * Shared/WebProcessCreationParameters.cpp: >+ (WebKit::WebProcessCreationParameters::encode const): >+ (WebKit::WebProcessCreationParameters::decode): >+ * Shared/WebProcessCreationParameters.h: >+ * UIProcess/Plugins/PluginProcessProxy.cpp: >+ (WebKit::PluginProcessProxy::didFinishLaunching): >+ * UIProcess/WebProcessPool.cpp: >+ (WebKit::WebProcessPool::sendMemoryPressureEvent): >+ (WebKit::WebProcessPool::ensureNetworkProcess): >+ (WebKit::WebProcessPool::initializeNewWebProcess): >+ * UIProcess/WebProcessPool.h: >+ * UIProcess/linux/MemoryPressureMonitor.cpp: >+ (WebKit::pollIntervalForUsedMemoryPercentage): Fix equation for calculating the interval percentage. >+ (WebKit::MemoryPressureMonitor::MemoryPressureMonitor): >+ (WebKit::MemoryPressureMonitor::setProcessPool): >+ * UIProcess/linux/MemoryPressureMonitor.h: >+ * WebProcess/WebProcess.cpp: >+ (WebKit::WebProcess::initializeWebProcess): >+ > 2018-05-10 John Wilander <wilander@apple.com> > > Storage Access API: Extend lifetime of cookies on successful user approval >diff --git a/Source/WTF/wtf/MemoryPressureHandler.h b/Source/WTF/wtf/MemoryPressureHandler.h >index 5d26356f3422b4c0a91183b8d62316c141b9790f..e3b89bfc992f24361e05d430d2cabb72c4b90cf1 100644 >--- a/Source/WTF/wtf/MemoryPressureHandler.h >+++ b/Source/WTF/wtf/MemoryPressureHandler.h >@@ -69,6 +69,10 @@ public: > > WTF_EXPORT_PRIVATE void setShouldUsePeriodicMemoryMonitor(bool); > >+#if OS(LINUX) >+ WTF_EXPORT_PRIVATE void triggerMemoryPressureEventFromUIProcess(); >+#endif >+ > void setMemoryKillCallback(WTF::Function<void()>&& function) { m_memoryKillCallback = WTFMove(function); } > void setMemoryPressureStatusChangedCallback(WTF::Function<void(bool)>&& function) { m_memoryPressureStatusChangedCallback = WTFMove(function); } > void setDidExceedInactiveLimitWhileActiveCallback(WTF::Function<void()>&& function) { m_didExceedInactiveLimitWhileActiveCallback = WTFMove(function); } >@@ -88,10 +92,6 @@ public: > } > void setUnderMemoryPressure(bool); > >-#if OS(LINUX) >- void setMemoryPressureMonitorHandle(int fd); >-#endif >- > class ReliefLogger { > public: > explicit ReliefLogger(const char *log) >@@ -220,6 +220,7 @@ private: > void holdOffTimerFired(); > void logErrorAndCloseFDs(const char* error); > bool tryEnsureEventFD(); >+ void handleMemoryPressureEvent(); > #endif > }; > >diff --git a/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp b/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp >index 8e85f58caf49df9f52da7ba3db1ac05b32a40bde..5c74fbc3092a767fbaf7f8ca2f6e665559cfe64f 100644 >--- a/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp >+++ b/Source/WTF/wtf/linux/MemoryPressureHandlerLinux.cpp >@@ -66,6 +66,24 @@ static const unsigned s_holdOffMultiplier = 20; > static const char* s_cgroupMemoryPressureLevel = "/sys/fs/cgroup/memory/memory.pressure_level"; > static const char* s_cgroupEventControl = "/sys/fs/cgroup/memory/cgroup.event_control"; > >+ >+static bool isSystemdMemoryPressureMonitorAvailable() >+{ >+ int fd = open(s_cgroupMemoryPressureLevel, O_CLOEXEC | O_RDONLY); >+ if (fd == -1) >+ return false; >+ close(fd); >+ >+ fd = open(s_cgroupEventControl, O_CLOEXEC | O_WRONLY); >+ if (fd == -1) >+ return false; >+ close(fd); >+ >+ return true; >+} >+ >+static const bool s_shouldUseSystemdMemoryPressureMonitor = isSystemdMemoryPressureMonitorAvailable(); >+ > #if USE(GLIB) > typedef struct { > GSource source; >@@ -171,10 +189,6 @@ inline void MemoryPressureHandler::logErrorAndCloseFDs(const char* log) > if (log) > LOG(MemoryPressure, "%s, error : %m", log); > >- if (m_eventFD) { >- close(m_eventFD.value()); >- m_eventFD = std::nullopt; >- } > if (m_pressureLevelFD) { > close(m_pressureLevelFD.value()); > m_pressureLevelFD = std::nullopt; >@@ -183,10 +197,6 @@ inline void MemoryPressureHandler::logErrorAndCloseFDs(const char* log) > > bool MemoryPressureHandler::tryEnsureEventFD() > { >- if (m_eventFD) >- return true; >- >- // Try to use cgroups instead. > int fd = eventfd(0, EFD_CLOEXEC); > if (fd == -1) { > LOG(MemoryPressure, "eventfd() failed: %m"); >@@ -219,33 +229,55 @@ bool MemoryPressureHandler::tryEnsureEventFD() > return true; > } > >-void MemoryPressureHandler::install() >+void MemoryPressureHandler::handleMemoryPressureEvent() > { >- if (m_installed || m_holdOffTimer.isActive()) >- return; >- >- if (!tryEnsureEventFD()) >- return; >- >- m_eventFDPoller = std::make_unique<EventFDPoller>(m_eventFD.value(), [this] { >- // FIXME: Current memcg does not provide any way for users to know how serious the memory pressure is. >- // So we assume all notifications from memcg are critical for now. If memcg had better inferfaces >- // to get a detailed memory pressure level in the future, we should update here accordingly. >- bool critical = true; >- if (ReliefLogger::loggingEnabled()) >- LOG(MemoryPressure, "Got memory pressure notification (%s)", critical ? "critical" : "non-critical"); >- >- setUnderMemoryPressure(critical); >- if (isMainThread()) >- respondToMemoryPressure(critical ? Critical::Yes : Critical::No); >- else >- RunLoop::main().dispatch([this, critical] { respondToMemoryPressure(critical ? Critical::Yes : Critical::No); }); >- }); >+ // FIXME: Current memcg does not provide any way for users to know how serious the memory pressure is. >+ // So we assume all notifications from memcg are critical for now. If memcg had better inferfaces >+ // to get a detailed memory pressure level in the future, we should update here accordingly. >+ bool critical = true; >+ if (ReliefLogger::loggingEnabled()) >+ LOG(MemoryPressure, "Got memory pressure notification (%s)", critical ? "critical" : "non-critical"); >+ >+ setUnderMemoryPressure(critical); >+ if (isMainThread()) >+ respondToMemoryPressure(critical ? Critical::Yes : Critical::No); >+ else >+ RunLoop::main().dispatch([this, critical] { respondToMemoryPressure(critical ? Critical::Yes : Critical::No); }); > > if (ReliefLogger::loggingEnabled() && isUnderMemoryPressure()) > LOG(MemoryPressure, "System is no longer under memory pressure."); > > setUnderMemoryPressure(false); >+} >+ >+void MemoryPressureHandler::triggerMemoryPressureEventFromUIProcess() >+{ >+ // corner case: it can happen that since the uiprocess was started >+ // something on the system made available the cgroup memory interface. >+ // So, when a new process is started (e.g.: new tab), this new process >+ // will use the systemd interface because its available now, but the >+ // memory pressure monitor from the uiprocess will continue to send >+ // events (because it only checks that at startup). >+ // So we simply ignore events from the uiprocess here if the systemd >+ // interface is available now. >+ if (s_shouldUseSystemdMemoryPressureMonitor) >+ return; >+ >+ if (m_installed) >+ handleMemoryPressureEvent(); >+} >+ >+void MemoryPressureHandler::install() >+{ >+ if (m_installed || m_holdOffTimer.isActive()) >+ return; >+ >+ if (s_shouldUseSystemdMemoryPressureMonitor) { >+ if (!tryEnsureEventFD()) >+ return; >+ m_eventFDPoller = std::make_unique<EventFDPoller>(m_eventFD.value(), [this] { handleMemoryPressureEvent(); }); >+ } >+ > m_installed = true; > } > >@@ -255,14 +287,13 @@ void MemoryPressureHandler::uninstall() > return; > > m_holdOffTimer.stop(); >- m_eventFDPoller = nullptr; > >- if (m_pressureLevelFD) { >- close(m_pressureLevelFD.value()); >- m_pressureLevelFD = std::nullopt; >+ if (s_shouldUseSystemdMemoryPressureMonitor) { >+ m_eventFDPoller = nullptr; >+ if (m_pressureLevelFD) { >+ close(m_pressureLevelFD.value()); >+ m_pressureLevelFD = std::nullopt; > >- // Only close the eventFD used for cgroups. >- if (m_eventFD) { > close(m_eventFD.value()); > m_eventFD = std::nullopt; > } >@@ -318,11 +349,6 @@ std::optional<MemoryPressureHandler::ReliefLogger::MemoryUsage> MemoryPressureHa > return MemoryUsage {processMemoryUsage(), physical}; > } > >-void MemoryPressureHandler::setMemoryPressureMonitorHandle(int fd) >-{ >- ASSERT(!m_eventFD); >- m_eventFD = fd; >-} > > } // namespace WTF > >diff --git a/Source/WebKit/NetworkProcess/NetworkProcess.cpp b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >index 9becb93c90b1a1be6a3620a8debedd5d1632f32c..141c77e9189409433e59ab09aa934c47d248260f 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcess.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkProcess.cpp >@@ -232,10 +232,6 @@ void NetworkProcess::initializeNetworkProcess(NetworkProcessCreationParameters&& > m_loadThrottleLatency = parameters.loadThrottleLatency; > if (!m_suppressMemoryPressureHandler) { > auto& memoryPressureHandler = MemoryPressureHandler::singleton(); >-#if OS(LINUX) >- if (parameters.memoryPressureMonitorHandle.fileDescriptor() != -1) >- memoryPressureHandler.setMemoryPressureMonitorHandle(parameters.memoryPressureMonitorHandle.releaseFileDescriptor()); >-#endif > memoryPressureHandler.setLowMemoryHandler([this] (Critical critical, Synchronous) { > lowMemoryHandler(critical); > }); >diff --git a/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp b/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp >index 3d24d23a4f5323e287022a1784dc3eecf1828341..ffc6decd56bdc4c0e1d82b17bd78c2d1bb3a256d 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp >+++ b/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.cpp >@@ -100,9 +100,6 @@ void NetworkProcessCreationParameters::encode(IPC::Encoder& encoder) const > #if HAVE(CFNETWORK_STORAGE_PARTITIONING) && !RELEASE_LOG_DISABLED > encoder << logCookieInformation; > #endif >-#if OS(LINUX) >- encoder << memoryPressureMonitorHandle; >-#endif > #if ENABLE(NETWORK_CAPTURE) > encoder << recordReplayMode; > encoder << recordReplayCacheLocation; >@@ -250,11 +247,6 @@ bool NetworkProcessCreationParameters::decode(IPC::Decoder& decoder, NetworkProc > return false; > #endif > >-#if OS(LINUX) >- if (!decoder.decode(result.memoryPressureMonitorHandle)) >- return false; >-#endif >- > #if ENABLE(NETWORK_CAPTURE) > if (!decoder.decode(result.recordReplayMode)) > return false; >diff --git a/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h b/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h >index d147533ba21ea987a7e989da018cee7d9977a518..3786234f0c657e6320a1ee06065ec324b1096dcd 100644 >--- a/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h >+++ b/Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h >@@ -25,7 +25,6 @@ > > #pragma once > >-#include "Attachment.h" > #include "CacheModel.h" > #include "NetworkSessionCreationParameters.h" > #include "SandboxExtension.h" >@@ -116,10 +115,6 @@ struct NetworkProcessCreationParameters { > bool logCookieInformation { false }; > #endif > >-#if OS(LINUX) >- IPC::Attachment memoryPressureMonitorHandle; >-#endif >- > #if ENABLE(NETWORK_CAPTURE) > String recordReplayMode; > String recordReplayCacheLocation; >diff --git a/Source/WebKit/PluginProcess/PluginProcess.cpp b/Source/WebKit/PluginProcess/PluginProcess.cpp >index 1cd3075b6bc27aa8257b43635a670238d6b8c93c..afff127b91f2b403ef7ccf8064122b1fa4fc8ecb 100644 >--- a/Source/WebKit/PluginProcess/PluginProcess.cpp >+++ b/Source/WebKit/PluginProcess/PluginProcess.cpp >@@ -124,10 +124,6 @@ void PluginProcess::initializePluginProcess(PluginProcessCreationParameters&& pa > ASSERT(!m_pluginModule); > > auto& memoryPressureHandler = MemoryPressureHandler::singleton(); >-#if OS(LINUX) >- if (parameters.memoryPressureMonitorHandle.fileDescriptor() != -1) >- memoryPressureHandler.setMemoryPressureMonitorHandle(parameters.memoryPressureMonitorHandle.releaseFileDescriptor()); >-#endif > memoryPressureHandler.setLowMemoryHandler([this] (Critical, Synchronous) { > if (shouldTerminate()) > terminate(); >diff --git a/Source/WebKit/Shared/ChildProcess.cpp b/Source/WebKit/Shared/ChildProcess.cpp >index 0b2cab7976967ab698ab1f9f666283fecdbc9997..1c923f90f0a144c10cad560ee338ad29af7c28ca 100644 >--- a/Source/WebKit/Shared/ChildProcess.cpp >+++ b/Source/WebKit/Shared/ChildProcess.cpp >@@ -35,6 +35,10 @@ > #include <unistd.h> > #endif > >+#if OS(LINUX) >+#include <wtf/MemoryPressureHandler.h> >+#endif >+ > using namespace WebCore; > > namespace WebKit { >@@ -215,6 +219,14 @@ void ChildProcess::didReceiveInvalidMessage(IPC::Connection&, IPC::StringReferen > WTFLogAlways("Received invalid message: '%s::%s'", messageReceiverName.toString().data(), messageName.toString().data()); > CRASH(); > } >+ >+#if OS(LINUX) >+void ChildProcess::didReceiveMemoryPressureEvent() >+{ >+ MemoryPressureHandler::singleton().triggerMemoryPressureEventFromUIProcess(); >+} > #endif > >+#endif // !PLATFORM(COCOA) >+ > } // namespace WebKit >diff --git a/Source/WebKit/Shared/ChildProcess.h b/Source/WebKit/Shared/ChildProcess.h >index bfd16ea45eb81fff60f6f23fec0657e37f9ab281..0181b200c8a4b560569165706c506b7828780358 100644 >--- a/Source/WebKit/Shared/ChildProcess.h >+++ b/Source/WebKit/Shared/ChildProcess.h >@@ -107,6 +107,9 @@ protected: > void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override; > > void registerURLSchemeServiceWorkersCanHandle(const String&) const; >+#if OS(LINUX) >+ void didReceiveMemoryPressureEvent(); >+#endif > > private: > // IPC::MessageSender >diff --git a/Source/WebKit/Shared/ChildProcess.messages.in b/Source/WebKit/Shared/ChildProcess.messages.in >index 062691fd271faa67ef1c4ae3cf39004877836e97..386216c245f743dd72a424033eb7b9d32e20fe63 100644 >--- a/Source/WebKit/Shared/ChildProcess.messages.in >+++ b/Source/WebKit/Shared/ChildProcess.messages.in >@@ -23,4 +23,7 @@ > messages -> ChildProcess { > ShutDown() > RegisterURLSchemeServiceWorkersCanHandle(String scheme) >+#if OS(LINUX) >+ void DidReceiveMemoryPressureEvent() >+#endif > } >diff --git a/Source/WebKit/Shared/Plugins/PluginProcessCreationParameters.cpp b/Source/WebKit/Shared/Plugins/PluginProcessCreationParameters.cpp >index 7bd78b6c3305525768d328c2f10c92912c3f2272..5e44035a3eab8220b5f1aecb0ac59633ce8efdb0 100644 >--- a/Source/WebKit/Shared/Plugins/PluginProcessCreationParameters.cpp >+++ b/Source/WebKit/Shared/Plugins/PluginProcessCreationParameters.cpp >@@ -49,9 +49,6 @@ void PluginProcessCreationParameters::encode(IPC::Encoder& encoder) const > encoder << acceleratedCompositingPort; > IPC::encode(encoder, networkATSContext.get()); > #endif >-#if OS(LINUX) >- encoder << memoryPressureMonitorHandle; >-#endif > } > > bool PluginProcessCreationParameters::decode(IPC::Decoder& decoder, PluginProcessCreationParameters& result) >@@ -70,10 +67,6 @@ bool PluginProcessCreationParameters::decode(IPC::Decoder& decoder, PluginProces > if (!IPC::decode(decoder, result.networkATSContext)) > return false; > #endif >-#if OS(LINUX) >- if (!decoder.decode(result.memoryPressureMonitorHandle)) >- return false; >-#endif > > return true; > } >diff --git a/Source/WebKit/Shared/Plugins/PluginProcessCreationParameters.h b/Source/WebKit/Shared/Plugins/PluginProcessCreationParameters.h >index 186cb3b9889fb8d81d126bc0aecf8a310646e4c5..d326880a9477b3abeb3ab3960aad0bac12a53a8f 100644 >--- a/Source/WebKit/Shared/Plugins/PluginProcessCreationParameters.h >+++ b/Source/WebKit/Shared/Plugins/PluginProcessCreationParameters.h >@@ -27,7 +27,6 @@ > > #if ENABLE(NETSCAPE_PLUGIN_API) > >-#include "Attachment.h" > #include "PluginProcessAttributes.h" > #include <wtf/Seconds.h> > >@@ -58,9 +57,6 @@ struct PluginProcessCreationParameters { > WTF::MachSendRight acceleratedCompositingPort; > RetainPtr<CFDataRef> networkATSContext; > #endif >-#if OS(LINUX) >- IPC::Attachment memoryPressureMonitorHandle; >-#endif > }; > > } // namespace WebKit >diff --git a/Source/WebKit/Shared/WebProcessCreationParameters.cpp b/Source/WebKit/Shared/WebProcessCreationParameters.cpp >index c3c503dba126d5f6942c09a51e652f415e0975aa..455dbef1adb0daef6d14998bde038cb0291badbb 100644 >--- a/Source/WebKit/Shared/WebProcessCreationParameters.cpp >+++ b/Source/WebKit/Shared/WebProcessCreationParameters.cpp >@@ -139,10 +139,6 @@ void WebProcessCreationParameters::encode(IPC::Encoder& encoder) const > IPC::encode(encoder, networkATSContext.get()); > #endif > >-#if OS(LINUX) >- encoder << memoryPressureMonitorHandle; >-#endif >- > #if PLATFORM(WAYLAND) > encoder << waylandCompositorDisplayName; > #endif >@@ -381,11 +377,6 @@ bool WebProcessCreationParameters::decode(IPC::Decoder& decoder, WebProcessCreat > return false; > #endif > >-#if OS(LINUX) >- if (!decoder.decode(parameters.memoryPressureMonitorHandle)) >- return false; >-#endif >- > #if PLATFORM(WAYLAND) > if (!decoder.decode(parameters.waylandCompositorDisplayName)) > return false; >diff --git a/Source/WebKit/Shared/WebProcessCreationParameters.h b/Source/WebKit/Shared/WebProcessCreationParameters.h >index 21f9151750a6d858125d022d7ce7837359188ae0..d5b6bad8873dfb986d0c2d601fd204372ad3bcc8 100644 >--- a/Source/WebKit/Shared/WebProcessCreationParameters.h >+++ b/Source/WebKit/Shared/WebProcessCreationParameters.h >@@ -173,10 +173,6 @@ struct WebProcessCreationParameters { > RetainPtr<CFDataRef> networkATSContext; > #endif > >-#if OS(LINUX) >- IPC::Attachment memoryPressureMonitorHandle; >-#endif >- > #if PLATFORM(WAYLAND) > String waylandCompositorDisplayName; > #endif >diff --git a/Source/WebKit/UIProcess/Plugins/PluginProcessProxy.cpp b/Source/WebKit/UIProcess/Plugins/PluginProcessProxy.cpp >index 4555daad3e1d379506ee040817698fa900097f4a..87b04a9cdf1bd9575f5ecb5063cb150b5eb90ee5 100644 >--- a/Source/WebKit/UIProcess/Plugins/PluginProcessProxy.cpp >+++ b/Source/WebKit/UIProcess/Plugins/PluginProcessProxy.cpp >@@ -38,10 +38,6 @@ > #include <WebCore/NotImplemented.h> > #include <wtf/RunLoop.h> > >-#if OS(LINUX) >-#include "MemoryPressureMonitor.h" >-#endif >- > using namespace WebCore; > > namespace WebKit { >@@ -234,11 +230,6 @@ void PluginProcessProxy::didFinishLaunching(ProcessLauncher*, IPC::Connection::I > parameters.terminationTimeout = shutdownTimeout; > } > >-#if OS(LINUX) >- if (MemoryPressureMonitor::isEnabled()) >- parameters.memoryPressureMonitorHandle = MemoryPressureMonitor::singleton().createHandle(); >-#endif >- > platformInitializePluginProcess(parameters); > > // Initialize the plug-in host process. >diff --git a/Source/WebKit/UIProcess/WebProcessPool.cpp b/Source/WebKit/UIProcess/WebProcessPool.cpp >index 11cc8bd5c2ceaf5132c1bfa498e8fa9129e620b3..39d3a1bb74ad35982ab40779fecb9910541c874f 100644 >--- a/Source/WebKit/UIProcess/WebProcessPool.cpp >+++ b/Source/WebKit/UIProcess/WebProcessPool.cpp >@@ -267,6 +267,12 @@ WebProcessPool::WebProcessPool(API::ProcessPoolConfiguration& configuration) > > platformInitialize(); > >+ >+#if OS(LINUX) >+ if (MemoryPressureMonitor::isEnabled()) >+ MemoryPressureMonitor::singleton().setProcessPool(this); >+#endif >+ > addMessageReceiver(Messages::WebProcessPool::messageReceiverName(), *this); > > // NOTE: These sub-objects must be initialized after m_messageReceiverMap.. >@@ -411,6 +417,17 @@ void WebProcessPool::fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnable > sendToAllProcesses(Messages::WebProcess::FullKeyboardAccessModeChanged(fullKeyboardAccessEnabled)); > } > >+#if OS(LINUX) >+void WebProcessPool::sendMemoryPressureEvent() >+{ >+ for (auto* processPool : allProcessPools()) { >+ processPool->sendToAllProcesses(Messages::ChildProcess::DidReceiveMemoryPressureEvent()); >+ if (processPool->m_networkProcess) >+ processPool->m_networkProcess->send(Messages::ChildProcess::DidReceiveMemoryPressureEvent(), 0); >+ } >+} >+#endif >+ > void WebProcessPool::textCheckerStateChanged() > { > sendToAllProcesses(Messages::WebProcess::SetTextCheckerState(TextChecker::state())); >@@ -486,11 +503,6 @@ NetworkProcessProxy& WebProcessPool::ensureNetworkProcess(WebsiteDataStore* with > SandboxExtension::createHandle(parentBundleDirectory, SandboxExtension::Type::ReadOnly, parameters.parentBundleDirectoryExtensionHandle); > #endif > >-#if OS(LINUX) >- if (MemoryPressureMonitor::isEnabled()) >- parameters.memoryPressureMonitorHandle = MemoryPressureMonitor::singleton().createHandle(); >-#endif >- > parameters.shouldUseTestingNetworkSession = m_shouldUseTestingNetworkSession; > parameters.presentingApplicationPID = m_configuration->presentingApplicationPID(); > >@@ -905,8 +917,6 @@ void WebProcessPool::initializeNewWebProcess(WebProcessProxy& process, WebsiteDa > > #if OS(LINUX) > parameters.shouldEnableMemoryPressureReliefLogging = true; >- if (MemoryPressureMonitor::isEnabled()) >- parameters.memoryPressureMonitorHandle = MemoryPressureMonitor::singleton().createHandle(); > #endif > > #if PLATFORM(WAYLAND) && USE(EGL) >diff --git a/Source/WebKit/UIProcess/WebProcessPool.h b/Source/WebKit/UIProcess/WebProcessPool.h >index 01f976b631f621f629d3ce6731c8101c1cd8ba9d..73b093335bcd20668bccfab0ab3bd0596dc91275 100644 >--- a/Source/WebKit/UIProcess/WebProcessPool.h >+++ b/Source/WebKit/UIProcess/WebProcessPool.h >@@ -316,6 +316,10 @@ public: > > void fullKeyboardAccessModeChanged(bool fullKeyboardAccessEnabled); > >+#if OS(LINUX) >+ void sendMemoryPressureEvent(); >+#endif >+ > void textCheckerStateChanged(); > > Ref<API::Dictionary> plugInAutoStartOriginHashes() const; >diff --git a/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp b/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp >index 357d9936cffbf81005ccbb96a2580a5de9668687..ae9bc613fb43d550aab49d5d9675358e47970e6e 100644 >--- a/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp >+++ b/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.cpp >@@ -34,7 +34,6 @@ > #include <mutex> > #include <stdlib.h> > #include <string.h> >-#include <sys/eventfd.h> > #include <sys/stat.h> > #include <sys/types.h> > #include <unistd.h> >@@ -48,8 +47,8 @@ static const size_t notSet = static_cast<size_t>(-1); > static const Seconds s_minPollingInterval { 1_s }; > static const Seconds s_maxPollingInterval { 5_s }; > static const double s_minUsedMemoryPercentageForPolling = 50; >-static const double s_maxUsedMemoryPercentageForPolling = 90; >-static const int s_memoryPresurePercentageThreshold = 95; >+static const double s_maxUsedMemoryPercentageForPolling = 85; >+static const int s_memoryPresurePercentageThreshold = 90; > > static size_t lowWatermarkPages() > { >@@ -208,7 +207,7 @@ static inline Seconds pollIntervalForUsedMemoryPercentage(int usedPercentage) > return s_minPollingInterval; > > return s_minPollingInterval + (s_maxPollingInterval - s_minPollingInterval) * >- ((usedPercentage - s_minUsedMemoryPercentageForPolling) / (s_maxUsedMemoryPercentageForPolling - s_minUsedMemoryPercentageForPolling)); >+ ((s_maxUsedMemoryPercentageForPolling - usedPercentage) / (s_maxUsedMemoryPercentageForPolling - s_minUsedMemoryPercentageForPolling)); > } > > static bool isSystemdMemoryPressureMonitorAvailable() >@@ -242,10 +241,7 @@ MemoryPressureMonitor& MemoryPressureMonitor::singleton() > } > > MemoryPressureMonitor::MemoryPressureMonitor() >- : m_eventFD(eventfd(0, EFD_CLOEXEC)) > { >- if (m_eventFD == -1) >- return; > > Thread::create("MemoryPressureMonitor", [this] { > Seconds pollInterval = s_maxPollingInterval; >@@ -259,25 +255,18 @@ MemoryPressureMonitor::MemoryPressureMonitor() > } > > if (usedPercentage >= s_memoryPresurePercentageThreshold) { >- uint64_t fdEvent = 1; >- ssize_t bytesWritten = write(m_eventFD, &fdEvent, sizeof(uint64_t)); >- if (bytesWritten != sizeof(uint64_t)) { >- WTFLogAlways("Error writing to MemoryPressureMonitor eventFD: %s", strerror(errno)); >- break; >- } >+ if (m_processPool) >+ m_processPool->sendMemoryPressureEvent(); >+ > } > pollInterval = pollIntervalForUsedMemoryPercentage(usedPercentage); > } >- close(m_eventFD); > })->detach(); > } > >-IPC::Attachment MemoryPressureMonitor::createHandle() const >+void MemoryPressureMonitor::setProcessPool(WebProcessPool* processPool) > { >- int duplicatedHandle = dupCloseOnExec(m_eventFD); >- if (duplicatedHandle == -1) >- return { }; >- return IPC::Attachment(duplicatedHandle); >+ m_processPool = processPool; > } > > } // namespace WebKit >diff --git a/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.h b/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.h >index e250c855171f839f438966a7b6d85c995dfa5fc0..ee21baaaf3bcbd21c6ca812ccaafcab51cba1db6 100644 >--- a/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.h >+++ b/Source/WebKit/UIProcess/linux/MemoryPressureMonitor.h >@@ -27,6 +27,7 @@ > > #if OS(LINUX) > >+#include "WebProcessPool.h" > #include <wtf/NeverDestroyed.h> > #include <wtf/Noncopyable.h> > >@@ -42,15 +43,13 @@ class MemoryPressureMonitor { > public: > static MemoryPressureMonitor& singleton(); > static bool isEnabled(); >+ void setProcessPool(WebProcessPool*); > > ~MemoryPressureMonitor(); > >- IPC::Attachment createHandle() const; >- > private: > MemoryPressureMonitor(); >- >- int m_eventFD { -1 }; >+ WebProcessPool *m_processPool; > }; > > } // namespace WebKit >diff --git a/Source/WebKit/WebProcess/WebProcess.cpp b/Source/WebKit/WebProcess/WebProcess.cpp >index 0e8370485aa99da8e3e41b91cdf2367c2933204e..50800d03ef72809d425d3dfb100f5e7f9933b792 100644 >--- a/Source/WebKit/WebProcess/WebProcess.cpp >+++ b/Source/WebKit/WebProcess/WebProcess.cpp >@@ -270,8 +270,6 @@ void WebProcess::initializeWebProcess(WebProcessCreationParameters&& parameters) > WebCore::setPresentingApplicationPID(parameters.presentingApplicationPID); > > #if OS(LINUX) >- if (parameters.memoryPressureMonitorHandle.fileDescriptor() != -1) >- MemoryPressureHandler::singleton().setMemoryPressureMonitorHandle(parameters.memoryPressureMonitorHandle.releaseFileDescriptor()); > MemoryPressureHandler::ReliefLogger::setLoggingEnabled(parameters.shouldEnableMemoryPressureReliefLogging); > #endif >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 184261
:
337074
|
340167
|
340174
|
341087
|
341092
|
341194
|
341208