Skip to content

Commit

Permalink
Add memnotify plugin for signaling memory pressure level changes
Browse files Browse the repository at this point in the history
If /dev/memnotify is available the plugin will set up two memory use
triggering levels. These are used to determine normal/warning/critical
memory pressure situations. The current state can be queried via D-Bus
method call "get_memory_level" and changes are broadcast as D-Bus signal
"sig_memory_level_ind".

Introspect data for new signal and method call is:
  <node name="/com/nokia/mce/signal">
    <interface name="com.nokia.mce.signal">
      <signal name="sig_memory_level_ind">
        <arg name="memory_level" type="s"/>
      </signal>
    </interface>
  </node>

  <node name="/com/nokia/mce/request">
    <interface name="com.nokia.mce.request">
      <method name="get_memory_level">
        <arg direction="out" name="memory_level" type="s"/>
      </method>
    </interface>
  </node>

While it is up to other components to react to changes in memory
pressure, it is expected that on warning level non-essential caches
should be released and on critical level non-essential processes
should be terminated.

As the actual level limits must device specific, the built in config
does not specify warning/critical levels.

The levels can be specified by installing configuration files to
"/etc/mce/<priority><name>.conf". Where priority is two digit
number from 00 to 99 (60 is used for other device specific configs)
and name should be something unique enough (say, package name).

The levels can be adjusted during mce runtime via mcetool options
      --set-memuse-warning-used=<page_count>
      --set-memuse-warning-active=<page_count>
      --set-memuse-critical-used=<page_count>
      --set-memuse-critical-active=<page_count>

The mcetool --status option shows the current memory use level.

[mce] Add memnotify plugin for signaling memory pressure level changes. Fixes JB#22490
  • Loading branch information
spiiroin committed Sep 3, 2014
1 parent 2b1719b commit be261b4
Show file tree
Hide file tree
Showing 8 changed files with 1,266 additions and 4 deletions.
24 changes: 24 additions & 0 deletions .depend
Expand Up @@ -4,13 +4,15 @@ builtin-gconf.o:\
mce-dbus.h\
mce-io.h\
mce-log.h\
modules/memnotify.h\

builtin-gconf.pic.o:\
builtin-gconf.c\
builtin-gconf.h\
mce-dbus.h\
mce-io.h\
mce-log.h\
modules/memnotify.h\

datapipe.o:\
datapipe.c\
Expand Down Expand Up @@ -634,6 +636,26 @@ modules/led.pic.o:\
mce.h\
modules/led.h\

modules/memnotify.o:\
modules/memnotify.c\
builtin-gconf.h\
datapipe.h\
mce-dbus.h\
mce-gconf.h\
mce-log.h\
mce.h\
modules/memnotify.h\

modules/memnotify.pic.o:\
modules/memnotify.c\
builtin-gconf.h\
datapipe.h\
mce-dbus.h\
mce-gconf.h\
mce-log.h\
mce.h\
modules/memnotify.h\

modules/packagekit.o:\
modules/packagekit.c\
builtin-gconf.h\
Expand Down Expand Up @@ -1013,6 +1035,7 @@ tools/mcetool.o:\
modules/display.h\
modules/doubletap.h\
modules/filter-brightness-als.h\
modules/memnotify.h\
modules/powersavemode.h\
modules/proximity.h\
powerkey.h\
Expand All @@ -1027,6 +1050,7 @@ tools/mcetool.pic.o:\
modules/display.h\
modules/doubletap.h\
modules/filter-brightness-als.h\
modules/memnotify.h\
modules/powersavemode.h\
modules/proximity.h\
powerkey.h\
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Expand Up @@ -148,6 +148,7 @@ MODULES += $(MODULE_DIR)/keypad.so
MODULES += $(MODULE_DIR)/inactivity.so
MODULES += $(MODULE_DIR)/camera.so
MODULES += $(MODULE_DIR)/alarm.so
MODULES += $(MODULE_DIR)/memnotify.so
MODULES += $(MODULE_DIR)/battery-bme.so
MODULES += $(MODULE_DIR)/battery-upower.so
MODULES += $(MODULE_DIR)/bluetooth.so
Expand Down Expand Up @@ -558,6 +559,8 @@ NORMALIZE_USES_SPC =\
modules/doubletap.h\
modules/filter-brightness-simple.h\
modules/keypad.h\
modules/memnotify.c\
modules/memnotify.h\
modules/packagekit.c\
modules/powersavemode.h\
modules/radiostates.h\
Expand Down Expand Up @@ -617,7 +620,7 @@ NORMALIZE_USES_TAB =\
systemui/tklock-dbus-names.h\

NORMALIZE_KNOWN := $(NORMALIZE_USES_SPC) $(NORMALIZE_USES_TAB)
SOURCEFILES_ALL := $(wildcard *.[ch])
SOURCEFILES_ALL := $(wildcard *.[ch] modules/*.[ch])
NORMALIZE_UNKNOWN = $(filter-out $(NORMALIZE_KNOWN), $(SOURCEFILES_ALL))

.PHONY: normalize
Expand Down
22 changes: 22 additions & 0 deletions builtin-gconf.c
Expand Up @@ -22,6 +22,8 @@
#include "mce-io.h"
#include "mce-dbus.h"

#include "modules/memnotify.h"

#include <stdlib.h>
#include <string.h>
#include <errno.h>
Expand Down Expand Up @@ -1470,6 +1472,26 @@ static const setting_t gconf_defaults[] =
.type = "i",
.def = "0", // = PWRKEY_BLANK_TO_OFF
},
{
.key = MCE_GCONF_MEMNOTIFY_WARNING_USED,
.type = "i",
.def = "0", // = disabled
},
{
.key = MCE_GCONF_MEMNOTIFY_WARNING_ACTIVE,
.type = "i",
.def = "0", // = disabled
},
{
.key = MCE_GCONF_MEMNOTIFY_CRITICAL_USED,
.type = "i",
.def = "0", // = disabled
},
{
.key = MCE_GCONF_MEMNOTIFY_CRITICAL_ACTIVE,
.type = "i",
.def = "0", // = disabled
},
{
.key = NULL,
}
Expand Down
2 changes: 1 addition & 1 deletion inifiles/mce.ini
Expand Up @@ -16,7 +16,7 @@ ModulePath=/usr/lib/mce/modules
# to avoid unnecessary brightness fluctuations on mce startup
#
# Note: the name should not include the "lib"-prefix
Modules=radiostates;filter-brightness-als;display;keypad;led;battery-upower;inactivity;alarm;callstate;audiorouting;proximity;powersavemode;cpu-keepalive;doubletap;packagekit;sensor-gestures;bluetooth;
Modules=radiostates;filter-brightness-als;display;keypad;led;battery-upower;inactivity;alarm;callstate;audiorouting;proximity;powersavemode;cpu-keepalive;doubletap;packagekit;sensor-gestures;bluetooth;memnotify;

[HomeKey]

Expand Down

0 comments on commit be261b4

Please sign in to comment.