Modify module name, add dlog and add governor
authorSangYoun Kwak <sy.kwak@samsung.com>
Fri, 10 Feb 2023 07:52:29 +0000 (16:52 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Fri, 21 Apr 2023 08:17:42 +0000 (17:17 +0900)
Module name changed.
 * low_memory_killer -> resourced-memory-lmk
 * According to this, the name of library, source directory, source file
   name, and symbols are modified.
Governor source code added.
Dlog feature is added.

Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
CMakeLists.txt
packaging/plugin-backend-resourced-rpi.spec
src/low_memory_killer/CMakeLists.txt [deleted file]
src/low_memory_killer/low_memory_killer.c [deleted file]
src/resourced-memory-lmk/CMakeLists.txt [new file with mode: 0644]
src/resourced-memory-lmk/common.h [new file with mode: 0644]
src/resourced-memory-lmk/resourced-memory-lmk-governor.c [new file with mode: 0644]
src/resourced-memory-lmk/resourced-memory-lmk-governor.h [new file with mode: 0644]
src/resourced-memory-lmk/resourced-memory-lmk.c [new file with mode: 0644]

index a319c0838f335f606f5b1e3a2039bd37fb31c116..ef29410e66603f3491fe1542b98df1cc9b86d97e 100644 (file)
@@ -12,4 +12,4 @@ ENDIF()
 INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE.Apache-2.0
        DESTINATION ${PLUGIN_LICENSE_DIR})
 
-ADD_SUBDIRECTORY(src/low_memory_killer)
+ADD_SUBDIRECTORY(src/resourced-memory-lmk)
index c8486a0762f3963742a1264c76b00dda9235bed8..b7cca9503965de84bf21c172a9a94bf6e87a959e 100644 (file)
@@ -1,4 +1,4 @@
-%define PLUGIN_LIBDIR %{_libdir}/plugin/%{name}
+%define PLUGIN_LIBDIR %{_libdir}/plugin
 %define PLUGIN_LICENSEDIR /usr/share/plugin/%{name}
 
 Name:       plugin-backend-resourced-rpi
@@ -42,6 +42,6 @@ make %{?jobs:-j%jobs}
 /sbin/ldconfig
 
 %files
-%{PLUGIN_LIBDIR}/libplugin-backend-resourced-low_memory_killer.so
+%{PLUGIN_LIBDIR}/libplugin-backend-resourced-memory-lmk.so
 %manifest %{name}.manifest
 %{PLUGIN_LICENSEDIR}/LICENSE.Apache-2.0
diff --git a/src/low_memory_killer/CMakeLists.txt b/src/low_memory_killer/CMakeLists.txt
deleted file mode 100644 (file)
index 7aa1534..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
-PROJECT(plugin-backend-resourced-low_memory_killer C)
-
-SET(PREFIX ${CMAKE_INSTALL_PREFIX})
-
-SET(PKG_MODULES
-       libsyscommon)
-
-INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
-FOREACH(flag ${pkgs_CFLAGS})
-       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
-ENDFOREACH(flag)
-
-SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
-
-ADD_LIBRARY(${PROJECT_NAME} SHARED low_memory_killer.c)
-MESSAGE("pkgs_LDFLAGS: ${pkgs_LDFLAGS}")
-TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
-INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${PLUGIN_LIB_DIR} COMPONENT RuntimeLibraries)
diff --git a/src/low_memory_killer/low_memory_killer.c b/src/low_memory_killer/low_memory_killer.c
deleted file mode 100644 (file)
index a5461c9..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-#include <stdlib.h>
-
-#include <plugin/plugin-common-interface.h>
-#include <plugin/plugin-low_memory_killer-interface.h>
-
-#define EXPORT __attribute__ ((visibility("default")))
-
-GArray *get_kill_candidates(GSList *proc_app_list, int start_oom, int end_oom, int killer_flags)
-{
-       return (GArray *)100;
-}
-
-int low_memory_killer_init(void **data)
-{
-       plugin_backend_low_memory_killer_funcs *funcs = NULL;
-
-       funcs = calloc(1, sizeof(*funcs));
-       if (!funcs)
-               return -ENOMEM;
-
-       funcs->get_kill_candidates = get_kill_candidates;
-
-       *data = (void *)funcs;
-
-       return 0;
-}
-
-int low_memory_killer_exit(void *data)
-{
-       free(data);
-       return 0;
-}
-
-plugin_backend EXPORT plugin_backend_resourced_low_memory_killer_data = {
-       .name = "low_memory_killer",
-       .vendor = "Samsung",
-       .abi_version = PLUGIN_ABI_VERSION_TIZEN_7_5,
-       .init = low_memory_killer_init,
-       .exit = low_memory_killer_exit,
-};
diff --git a/src/resourced-memory-lmk/CMakeLists.txt b/src/resourced-memory-lmk/CMakeLists.txt
new file mode 100644 (file)
index 0000000..dfec877
--- /dev/null
@@ -0,0 +1,29 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(plugin-backend-resourced-memory-lmk C)
+
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+if (${PLUGIN_BACKEND_RESOURCED_MEMORY_LMK_ENABLE_DLOG})
+       SET(PKG_MODULES
+               libsyscommon
+               glib-2.0)
+       ADD_DEFINITIONS("-DENABLE_DLOG")
+       ADD_DEFINITIONS("-DLOG_TAG=\"PLUGIN_BACKEND_RESOURCED_MEMORY_LMK\"")
+else()
+       SET(PKG_MODULES
+               libsyscommon)
+endif()
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
+FOREACH(flag ${pkgs_CFLAGS})
+       SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+
+ADD_LIBRARY(${PROJECT_NAME} SHARED resourced-memory-lmk.c)
+MESSAGE("pkgs_LDFLAGS: ${pkgs_LDFLAGS}")
+TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS})
+INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${PLUGIN_LIB_DIR} COMPONENT RuntimeLibraries)
diff --git a/src/resourced-memory-lmk/common.h b/src/resourced-memory-lmk/common.h
new file mode 100644 (file)
index 0000000..1591089
--- /dev/null
@@ -0,0 +1,36 @@
+/**
+ * plugin-backend-resourced-rpi
+ *
+ * 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 express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __COMMON_H__
+#define __COMMON_H__
+
+#ifdef ENABLE_DLOG
+#include <dlog.h>
+
+#define _D(fmt, args...) SLOGD(fmt, ##args)
+#define _I(fmt, args...) SLOGI(fmt, ##args)
+#define _W(fmt, args...) SLOGW(fmt, ##args)
+#define _E(fmt, args...) SLOGE(fmt, ##args)
+#else
+#define _D(fmt, args...) do { } while(0)
+#define _I(fmt, args...) do { } while(0)
+#define _W(fmt, args...) do { } while(0)
+#define _E(fmt, args...) do { } while(0)
+#endif
+
+#endif /* __COMMON_H__ */
diff --git a/src/resourced-memory-lmk/resourced-memory-lmk-governor.c b/src/resourced-memory-lmk/resourced-memory-lmk-governor.c
new file mode 100644 (file)
index 0000000..2251e58
--- /dev/null
@@ -0,0 +1,29 @@
+/**
+ * plugin-backend-resourced-rpi
+ *
+ * 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 express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <glib.h>
+
+#include "common.h"
+#include "resourced-memory-lmk-governor.h"
+
+GArray *lowmem_governor_get_kill_candidates(GSList *proc_app_list, int start_oom, int end_oom, int killer_flags)
+{
+       _D("lowmem_governor_get_kill_candidates called");
+
+       return NULL;
+}
diff --git a/src/resourced-memory-lmk/resourced-memory-lmk-governor.h b/src/resourced-memory-lmk/resourced-memory-lmk-governor.h
new file mode 100644 (file)
index 0000000..9328607
--- /dev/null
@@ -0,0 +1,24 @@
+/**
+ * plugin-backend-resourced-rpi
+ *
+ * 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 express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef __RESOURCED_MEMORY_LMK_GOVERNOR_H__
+#define __RESOURCED_MEMORY_LMK_GOVERNOR_H__
+
+GArray *lowmem_governor_get_kill_candidates(GSList *proc_app_list, int start_oom, int end_oom, int killer_flags);
+
+#endif /* __RESOURCED_MEMORY_LMK_GOVERNOR_H__ */
diff --git a/src/resourced-memory-lmk/resourced-memory-lmk.c b/src/resourced-memory-lmk/resourced-memory-lmk.c
new file mode 100644 (file)
index 0000000..39b0b4a
--- /dev/null
@@ -0,0 +1,64 @@
+/**
+ * plugin-backend-resourced-rpi
+ *
+ * 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 express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+
+#include <plugin/plugin-common-interface.h>
+#include <plugin/plugin-resourced-memory-lmk-interface.h>
+
+#include "common.h"
+#include "resourced-memory-lmk-governor.h" /* TODO: Remove this line */
+
+#define EXPORT __attribute__ ((visibility("default")))
+
+/*
+GArray *get_kill_candidates(GSList *proc_app_list, int start_oom, int end_oom, int killer_flags)
+{
+       return NULL;
+}
+*/
+
+int resourced_memory_lmk_init(void **data)
+{
+       plugin_backend_resourced_memory_lmk_funcs *funcs = NULL;
+
+       funcs = calloc(1, sizeof(*funcs));
+       if (!funcs)
+               return -ENOMEM;
+
+       /* funcs->get_kill_candidates = get_kill_candidates; */ /* TODO: Use this line instead of a line below */
+       funcs->get_kill_candidates = lowmem_governor_get_kill_candidates; /* TODO: Remove this line */
+
+       *data = (void *)funcs;
+
+       return 0;
+}
+
+int resourced_memory_lmk_exit(void *data)
+{
+       free(data);
+       return 0;
+}
+
+plugin_backend EXPORT plugin_backend_resourced_memory_lmk_data = {
+       .name = "resourced-memory-lmk",
+       .vendor = "Samsung",
+       .abi_version = PLUGIN_ABI_VERSION_TIZEN_7_5,
+       .init = resourced_memory_lmk_init,
+       .exit = resourced_memory_lmk_exit,
+};