<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - MemoryPressureHandler doesn't work if cgroups aren't present in Linux"
   href="https://bugs.webkit.org/show_bug.cgi?id=155255#c26">Comment # 26</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - MemoryPressureHandler doesn't work if cgroups aren't present in Linux"
   href="https://bugs.webkit.org/show_bug.cgi?id=155255">bug 155255</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>(In reply to <a href="show_bug.cgi?id=155255#c25">comment #25</a>)
<span class="quote">&gt; Comment on <span class=""><a href="attachment.cgi?id=273833&amp;action=diff" name="attach_273833" title="Patch">attachment 273833</a> <a href="attachment.cgi?id=273833&amp;action=edit" title="Patch">[details]</a></span>
&gt; Patch
&gt; 
&gt; I think this patch needs to address clopez's feedback:
&gt; 
&gt; &quot;&quot;&quot;Regarding the concerns about that the wakeups could affect the battery
&gt; life I propose that we only enable this fallback memory pressure handler
&gt; when the system is not running on battery.
&gt; 
&gt; We can reliably detect this by inspecting some values on /sys. For example,
&gt; we can borrow either the systemd implementation to detect this
&gt; &lt;<a href="https://github.com/systemd/systemd/blob/master/src/basic/util.c#L498">https://github.com/systemd/systemd/blob/master/src/basic/util.c#L498</a>&gt; or
&gt; the e2fsprogs one
&gt; &lt;<a href="http://git.kernel.org/cgit/fs/ext2/e2fsprogs.git/tree/e2fsck/unix.c#n284">http://git.kernel.org/cgit/fs/ext2/e2fsprogs.git/tree/e2fsck/unix.c#n284</a>&gt;
&gt; (yes, fsck avoids running automatically if it detects you are on battery)
&gt; 
&gt; 
&gt; And I don't think we should hide this feature behind an obscure environment
&gt; variable than other than we developers and power users will know about, but
&gt; make it run by default when the cgroup based memory pressure handler fails
&gt; and when the system is not running on battery.&quot;&quot;&quot;</span >

For the record, on ChromeOS, the kernel provides a file (available for reading if system is under low mem conditions):

// This is the file that will exist if low memory notification is available
// on the device.  Whenever it becomes readable, it signals a low memory
// condition.
const char kLowMemFile[] = &quot;/dev/chromeos-low-mem&quot;;

No parsing needed of its content, just verifying its presence is enough.
The check happens every 1s, and I believe it would not be as expensive as actually reading and parsing /proc/meminfo every 1s.
If Linux would have something like this by default, it would do it, as far as I can tell.</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>