Changeset 177216 in webkit


Ignore:
Timestamp:
Dec 12, 2014 1:21:15 AM (9 years ago)
Author:
ChangSeok Oh
Message:

Implement MemoryPressureHandler for Linux system
https://bugs.webkit.org/show_bug.cgi?id=123532

Reviewed by Sergio Villar Senin.

This is an initial implementation to support MemoryPressureHandler for linux system.
The patch is based on Tomeu's last patch and improved on top of it.
Most of current linux distributions support cgroup, so that we use the memory.pressure_level
mechanism of cgroup to get notifications when an application reaches the 'low' memory
pressure level.

No new tests since no engine behavior changed.

  • PlatformEfl.cmake:
  • PlatformGTK.cmake:
  • platform/MemoryPressureHandler.cpp:

(WebCore::MemoryPressureHandler::MemoryPressureHandler):

  • platform/MemoryPressureHandler.h:
  • platform/linux/MemoryPressureHandlerLinux.cpp: Added.

(WebCore::nextToken):
(WebCore::MemoryPressureHandler::~MemoryPressureHandler):
(WebCore::MemoryPressureHandler::waitForMemoryPressureEvent): run in a seperated thread
to listen 'low' level event.
(WebCore::MemoryPressureHandler::logErrorAndCloseFDs):
(WebCore::MemoryPressureHandler::install):
(WebCore::MemoryPressureHandler::uninstall):
(WebCore::MemoryPressureHandler::holdOffTimerFired):
(WebCore::MemoryPressureHandler::holdOff):
(WebCore::MemoryPressureHandler::respondToMemoryPressure):
(WebCore::MemoryPressureHandler::platformReleaseMemory):
(WebCore::MemoryPressureHandler::ReliefLogger::platformLog):
(WebCore::MemoryPressureHandler::ReliefLogger::platformMemoryUsage): read /proc/self/status
to get VM amount used by current process.

Location:
trunk/Source/WebCore
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r177214 r177216  
     12014-12-12  ChangSeok Oh  <changseok.oh@collabora.com>
     2
     3        Implement MemoryPressureHandler for Linux system
     4        https://bugs.webkit.org/show_bug.cgi?id=123532
     5
     6        Reviewed by Sergio Villar Senin.
     7
     8        This is an initial implementation to support MemoryPressureHandler for linux system.
     9        The patch is based on Tomeu's last patch and improved on top of it.
     10        Most of current linux distributions support cgroup, so that we use the memory.pressure_level
     11        mechanism of cgroup to get notifications when an application reaches the 'low' memory
     12        pressure level.
     13
     14        No new tests since no engine behavior changed.
     15
     16        * PlatformEfl.cmake:
     17        * PlatformGTK.cmake:
     18        * platform/MemoryPressureHandler.cpp:
     19        (WebCore::MemoryPressureHandler::MemoryPressureHandler):
     20        * platform/MemoryPressureHandler.h:
     21        * platform/linux/MemoryPressureHandlerLinux.cpp: Added.
     22        (WebCore::nextToken):
     23        (WebCore::MemoryPressureHandler::~MemoryPressureHandler):
     24        (WebCore::MemoryPressureHandler::waitForMemoryPressureEvent): run in a seperated thread
     25        to listen 'low' level event.
     26        (WebCore::MemoryPressureHandler::logErrorAndCloseFDs):
     27        (WebCore::MemoryPressureHandler::install):
     28        (WebCore::MemoryPressureHandler::uninstall):
     29        (WebCore::MemoryPressureHandler::holdOffTimerFired):
     30        (WebCore::MemoryPressureHandler::holdOff):
     31        (WebCore::MemoryPressureHandler::respondToMemoryPressure):
     32        (WebCore::MemoryPressureHandler::platformReleaseMemory):
     33        (WebCore::MemoryPressureHandler::ReliefLogger::platformLog):
     34        (WebCore::MemoryPressureHandler::ReliefLogger::platformMemoryUsage): read /proc/self/status
     35        to get VM amount used by current process.
     36
    1372014-12-12  Simon Fraser  <simon.fraser@apple.com>
    238
  • trunk/Source/WebCore/PlatformEfl.cmake

    r177058 r177216  
    213213
    214214    platform/linux/GamepadDeviceLinux.cpp
     215    platform/linux/MemoryPressureHandlerLinux.cpp
    215216
    216217    platform/mediastream/gstreamer/MediaStreamCenterGStreamer.cpp
  • trunk/Source/WebCore/PlatformGTK.cmake

    r177148 r177216  
    157157
    158158    platform/linux/GamepadDeviceLinux.cpp
     159    platform/linux/MemoryPressureHandlerLinux.cpp
    159160
    160161    platform/mediastream/gstreamer/MediaStreamCenterGStreamer.cpp
  • trunk/Source/WebCore/platform/MemoryPressureHandler.cpp

    r177167 r177216  
    6565    , m_releaseMemoryBlock(0)
    6666    , m_observer(0)
     67#elif OS(LINUX)
     68    , m_eventFD(0)
     69    , m_pressureLevelFD(0)
     70    , m_threadID(0)
     71    , m_holdOffTimer(*this, &MemoryPressureHandler::holdOffTimerFired)
    6772#endif
    6873{
     
    144149}
    145150
    146 #if !PLATFORM(COCOA)
     151#if !PLATFORM(COCOA) && !OS(LINUX)
    147152void MemoryPressureHandler::install() { }
    148153void MemoryPressureHandler::uninstall() { }
  • trunk/Source/WebCore/platform/MemoryPressureHandler.h

    r172862 r177216  
    11/*
    22 * Copyright (C) 2011 Apple Inc. All Rights Reserved.
     3 * Copyright (C) 2014 Raspberry Pi Foundation. All Rights Reserved.
    34 *
    45 * Redistribution and use in source and binary forms, with or without
     
    3334#if PLATFORM(IOS)
    3435#include <wtf/ThreadingPrimitives.h>
     36#elif OS(LINUX)
     37#include "Timer.h"
    3538#endif
    3639
     
    7073    WEBCORE_EXPORT bool shouldWaitForMemoryClearMessage();
    7174    void respondToMemoryPressureIfNeeded();
     75#elif OS(LINUX)
     76    static void waitForMemoryPressureEvent(void*);
    7277#endif
    7378
     
    128133    CFRunLoopObserverRef m_observer;
    129134    Mutex m_observerMutex;
     135#elif OS(LINUX)
     136    int m_eventFD;
     137    int m_pressureLevelFD;
     138    WTF::ThreadIdentifier m_threadID;
     139    Timer m_holdOffTimer;
     140    void holdOffTimerFired();
     141    void logErrorAndCloseFDs(const char* error);
    130142#endif
    131143};
    132  
     144
    133145// Function to obtain the global memory pressure object.
    134146WEBCORE_EXPORT MemoryPressureHandler& memoryPressureHandler();
Note: See TracChangeset for help on using the changeset viewer.