RESOURCED_NOTIFIER_LOW_BATTERY,
RESOURCED_NOTIFIER_CPU_ON,
RESOURCED_NOTIFIER_CPU_OFF,
+ RESOURCED_NOTIFIER_LCD_ON,
+ RESOURCED_NOTIFIER_LCD_OFF,
RESOURCED_NOTIFIER_DEDUP_START,
RESOURCED_NOTIFIER_DEDUP_SCAN,
EXPORT_TEST void proc_dbus_lcd_on(GVariant *params)
{
current_lcd_state = LCD_STATE_ON;
- /* nothing */
+ resourced_notify(RESOURCED_NOTIFIER_LCD_ON, NULL);
}
EXPORT_TEST void proc_dbus_lcd_off(GVariant *params)
{
current_lcd_state = LCD_STATE_OFF;
+ resourced_notify(RESOURCED_NOTIFIER_LCD_OFF, NULL);
}
EXPORT_TEST void booting_done_signal_handler(GVariant *params)
return RESOURCED_ERROR_NONE;
}
+static int lowmem_bg_reclaim_handler(void *data)
+{
+ if (swap_get_state() != SWAP_ON)
+ return RESOURCED_ERROR_NONE;
+
+ if (!is_bg_reclaim_supported())
+ return RESOURCED_ERROR_NONE;
+
+ /*
+ * Proactively reclaiming memory used by long-lived background processes
+ * (such as widget instances) may be efficient on devices with limited
+ * memory constraints. The pages used by such processes could be reclaimed
+ * (if swap is enabled) earlier than they used to while minimizing the
+ * impact on the user experience.
+ */
+ resourced_notify(RESOURCED_NOTIFIER_SWAP_START,
+ get_memcg_info(MEMCG_BACKGROUND_MRU)->name);
+
+ return RESOURCED_ERROR_NONE;
+}
+
static void medium_cb(struct lowmem_control *ctl)
{
if (ctl->status == LOWMEM_RECLAIM_DONE)
lowmem_register_mem_level_controller(MEM_LEVEL_OOM, oom_mem_control);
register_notifier(RESOURCED_NOTIFIER_MEM_CONTROL, lowmem_control_handler);
+ register_notifier(RESOURCED_NOTIFIER_LCD_OFF, lowmem_bg_reclaim_handler);
return RESOURCED_ERROR_NONE;
}
static int lowmem_controller_finalize(void *data)
{
unregister_notifier(RESOURCED_NOTIFIER_MEM_CONTROL, lowmem_control_handler);
+ unregister_notifier(RESOURCED_NOTIFIER_LCD_OFF, lowmem_bg_reclaim_handler);
return RESOURCED_ERROR_NONE;
}