The handler for psi events is modified like the vmpressure's one.
- Get available memory by calling proc_get_mem_available()
- Get memory status(level) by calling lowmem_check_mem_state()
- Do an action by calling lowmem_trigger_memory_state_action
- Do nothing if the available memory is same as the previous one.
Change-Id: I770093c1ad501c63620444a6aede91f500978fd3
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
static void *psi_memory_monitor_handler(struct psi_memory_monitor_info *info)
{
+ static unsigned int prev_available_mb;
+ unsigned int available_mb;
+ int mem_level;
+
assert_mem_level(info->mem_level);
- lowmem_trigger_memory_state_action(info->mem_level);
+ available_mb = proc_get_mem_available();
+ if (prev_available_mb == available_mb)
+ return NULL;
+
+ mem_level = lowmem_check_mem_state(available_mb);
+ lowmem_trigger_memory_state_action(mem_level);
+ prev_available_mb = available_mb;
return NULL;
}