resource: system: Broadcast dbus signal for memory pressure stall sandbox/dwlee08/psi
authorDongwoo Lee <dwoo08.lee@samsung.com>
Thu, 9 Feb 2023 04:35:53 +0000 (20:35 -0800)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Thu, 9 Feb 2023 04:35:53 +0000 (20:35 -0800)
Change-Id: Ic2716b954f1ead094496f34f8b4b00cff3d7e867
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
include/util/gdbus-definition.h
src/resource/resource-system.c

index 86ea5cb122b97d9d51540eceb0c8ef5b1ee53c88..779aba964b59649617c4ef435749db1e810ec154 100644 (file)
@@ -45,6 +45,7 @@ typedef enum {
 #define DBUS_MONITOR_INTERFACE                 "org.tizen.system.pass.monitor"
 #define DBUS_MONITOR_PATH                      "/Org/Tizen/System/Pass/Monitor"
 #define DBUS_MONITOR_I_SET_DEBUG_HANDLER       "handle_set_debug"
+#define DBUS_MONITOR_SIGNAL_MEM_PRESSURE       "MemoryPressure"
 
 #define DBUS_THERMAL_BUS_NAME                  "org.tizen.system.thermal"
 #define DBUS_THERMAL_INTERFACE                 "org.tizen.system.thermal"
index 79406634ea3b41e1d40ac27f2b01ada431b74e43..b623bc18e2730f61483b96e2945f72b9ede2b35b 100644 (file)
@@ -32,6 +32,7 @@
 #include <util/log.h>
 #include <util/kernel.h>
 #include <util/thread.h>
+#include <util/gdbus-util.h>
 
 #include <libsyscommon/resource-manager.h>
 #include <libsyscommon/resource-type.h>
@@ -287,6 +288,23 @@ static void system_handle_psi_listener(int resource_id,
 
        sysdata->memory_pressure_level = memory_pressure_level;
        sysdata->memory_pressure_last_update = current_msec;
+
+       /* signal only the occurance of pressure stall  */
+       if (memory_pressure_level) {
+               int ret;
+               GVariant *gvar = g_variant_new("(i)", memory_pressure_level);
+
+               ret = gdbus_send_broadcast_signal(PASS_DBUS_CORE,
+                                                 DBUS_MONITOR_PATH,
+                                                 DBUS_MONITOR_INTERFACE,
+                                                 DBUS_MONITOR_SIGNAL_MEM_PRESSURE,
+                                                 gvar);
+               if (ret < 0)
+                       _W("failed to broadcast %s via %s (%d)\n",
+                                       DBUS_MONITOR_SIGNAL_MEM_PRESSURE,
+                                       DBUS_MONITOR_INTERFACE,
+                                       ret);
+       }
 }
 
 static int