lowmem-controller was just a library and used by lowmem.c.
lowmem-controller is now a module which is registered to module manager
of resourced and initialized as an independent module.
Change-Id: I207fa4404e076f2555cc00730e79e7c540c898dc
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
#include <limits.h>
#include "lowmem.h"
-#include "lowmem-controller.h"
#include "proc-common.h"
#include "proc-main.h"
#include "resourced.h"
#include "trace.h"
#include "util.h"
#include "safe-kill.h"
+#include "module.h"
#define MAX_VICTIMS_BETWEEN_CHECK 3
return LOWMEM_RECLAIM_CONT;
}
-int lowmem_controller_kill_candidates(GArray *candidates,
+static int lowmem_controller_kill_candidates(GArray *candidates,
unsigned should_be_freed, unsigned int threshold,
int max_victims, int flags,
int *status, unsigned int *total_victim_size,
return victim_cnt;
}
+
+static int lowmem_controller_initialize(void *data)
+{
+ lowmem_initialize_kill_candidates(lowmem_controller_kill_candidates);
+ return RESOURCED_ERROR_NONE;
+}
+
+static int lowmem_controller_finalize(void *data)
+{
+ return RESOURCED_ERROR_NONE;
+}
+
+static struct module_ops lowmem_controller_module_ops = {
+ .priority = MODULE_PRIORITY_INITIAL,
+ .name = "lowmem-controller",
+ .init = lowmem_controller_initialize,
+ .exit = lowmem_controller_finalize,
+};
+
+MODULE_REGISTER(&lowmem_controller_module_ops)
+++ /dev/null
-/**
- * resourced
- *
- * Copyright (c) 2023 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either excontroller or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
-
-/**
- * @file lowmem-controller.h
- * @desc Functions for controller features.
- */
-
-#ifndef __LOWMEM_CONTROLLER_H__
-#define __LOWMEM_CONTROLLER_H__
-
-int lowmem_controller_kill_candidates(GArray *candidates,
- unsigned should_be_freed, unsigned int threshold,
- int max_victims, int flags,
- int *status, unsigned int *total_victim_size,
- unsigned lmk_start_threshold_mb,
- void(*oom_popup)(void));
-
-#endif /* __LOWMEM_CONTROLLER_H__ */
#include "lowmem-dbus.h"
#include "lowmem-system.h"
#include "lowmem-limit.h"
-#include "lowmem-controller.h"
#include "proc-common.h"
#include "procfs.h"
#include "freezer.h"
governor_ops.get_kill_candidates = get_kill_candidates;
}
+static int(*lowmem_controller_kill_candidates)(GArray *, unsigned, unsigned int,
+ int, int, int *, unsigned int *,
+ unsigned, void(*)(void));
+void lowmem_initialize_kill_candidates(int(*kill_candidates)(GArray *, unsigned,
+ unsigned int, int, int, int *,
+ unsigned int *, unsigned,
+ void(*)(void)))
+{
+ lowmem_controller_kill_candidates = kill_candidates;
+}
+
/**
* @brief Terminate up to max_victims processes after finding them from pai.
It depends on proc_app_info lists
goto leave;
}
+ assert(lowmem_controller_kill_candidates != NULL);
victim_cnt = lowmem_controller_kill_candidates(lowmem_kill_candidates,
should_be_freed, threshold,
max_victims, flags,
void lowmem_initialize_governor_ops(int(*)(GArray *, GArray *, GArray *,
unsigned long));
+void lowmem_initialize_kill_candidates(int(*kill_candidates)(GArray *, unsigned,
+ unsigned int, int, int, int *,
+ unsigned int *, unsigned,
+ void(*)(void)));
+
+
#ifdef __cplusplus
}
#endif /* __cplusplus */