<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GLib] Use a GSource instead of a thread to poll memory pressure eventFD in linux implementation"
   href="https://bugs.webkit.org/show_bug.cgi?id=159346#c7">Comment # 7</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - [GLib] Use a GSource instead of a thread to poll memory pressure eventFD in linux implementation"
   href="https://bugs.webkit.org/show_bug.cgi?id=159346">bug 159346</a>
              from <span class="vcard"><a class="email" href="mailto:tonikitoo&#64;webkit.org" title="Antonio Gomes &lt;tonikitoo&#64;webkit.org&gt;"> <span class="fn">Antonio Gomes</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=283522&amp;action=diff" name="attach_283522" title="Updated patch">attachment 283522</a> <a href="attachment.cgi?id=283522&amp;action=edit" title="Updated patch">[details]</a></span>
Updated patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=283522&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=283522&amp;action=review</a>

<span class="quote">&gt; Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp:108
&gt; +    EventFDSource* eventFDSource = reinterpret_cast&lt;EventFDSource*&gt;(m_source.get());</span >

that reinterpret_cast was a bit tricky to understand, but Zan cleared it up (line 101 allocates m_source with &quot;sizeof(EventFDSource)&quot;.

<span class="quote">&gt; Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp:145
&gt; +        LOG(MemoryPressure, &quot;Invalidate eventfd.&quot;);</span >

s/Invalidate/Invalid/g

<span class="quote">&gt; Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp:230
&gt; +    m_eventFDPoller = std::make_unique&lt;EventFDPoller&gt;(m_eventFD.value(), [this] {</span >

So my understand is that m_eventFDPoller is an alternative memory pressure source that works independent from the existing 'cgroup' solution, right?

However, it gets initialized after the cgroup initialization stuff (lines 209 and 215). So, if cgroup fails to initialize - which happens in most cases - then ::install bails out earlier (lines 218 and 225) and line 230 is not executed.

Should line 230 be our first option, and cgroup the second?

<span class="quote">&gt; Source/WebCore/platform/linux/MemoryPressureHandlerLinux.cpp:234
&gt; +        // FIXME: Current memcg does not provide any way for users to know how serious the memory pressure is.
&gt; +        // So we assume all notifications from memcg are critical for now. If memcg had better inferfaces
&gt; +        // to get a detailed memory pressure level in the future, we should update here accordingly.
&gt; +        bool critical = true;</span >

I believe a similar comment could be in MemoryPressureHandler::EventFDPoller::readAndNotify(), before we call m_nofityHandler(); Maybe a reduced version of it?</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>