Split header file of 'lowmem' module 04/286504/1 accepted/tizen/7.0/unified/20230111.015120
authorSangYoun Kwak <sy.kwak@samsung.com>
Mon, 9 Jan 2023 03:02:47 +0000 (12:02 +0900)
committerSangYoun Kwak <sy.kwak@samsung.com>
Mon, 9 Jan 2023 05:26:46 +0000 (14:26 +0900)
'lowmem.h' was split into 4 files:
    lowmem.h (lowmem.c)
    lowmem-dbus.h (lowmem-dbus.c)
    lowmem-limit.h (lowmem-limit.c)
    lowmem-system.h (lowmem-system.c)
Each header file is a header of its .c file.

As the 'lowmem.h' was split, source files containing
'lowmem.h' were modified.

Change-Id: Ic6ff839bbfd7e83df2558356deec5ed4534ae3fe
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
src/resource-limiter/memory/lowmem-dbus.c
src/resource-limiter/memory/lowmem-dbus.h [new file with mode: 0644]
src/resource-limiter/memory/lowmem-limit.c
src/resource-limiter/memory/lowmem-limit.h [new file with mode: 0644]
src/resource-limiter/memory/lowmem-system.c
src/resource-limiter/memory/lowmem-system.h [new file with mode: 0644]
src/resource-limiter/memory/lowmem.c
src/resource-limiter/memory/lowmem.h

index 268e1b14376237318553a7c4c4de42c813be36c8..1719d0fd21dc90265b745cdf84ebb5001ae1d95a 100644 (file)
@@ -27,6 +27,8 @@
 
 #include "trace.h"
 #include "lowmem.h"
+#include "lowmem-dbus.h"
+#include "lowmem-limit.h"
 #include "dbus-handler.h"
 #include "resourced.h"
 #include "macro.h"
diff --git a/src/resource-limiter/memory/lowmem-dbus.h b/src/resource-limiter/memory/lowmem-dbus.h
new file mode 100644 (file)
index 0000000..59904a6
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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 express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @file lowmem-dbus.h
+ * @desc Function for dbus initialization.
+ **/
+
+#ifndef __LOWMEM_DBUS_H__
+#define __LOWMEM_DBUS_H__
+
+#include <proc-common.h>
+#include <memory-cgroup.h>
+#include "fd-handler.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+void lowmem_dbus_init(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LOWMEM_DBUS_H__ */
index 96e7ca5ac46a80e5487372bf78cef9cc625590a3..985103528fbd5b86a0224e317b67fa35fa3d1249 100644 (file)
@@ -38,6 +38,7 @@
 #include "module.h"
 #include "module-data.h"
 #include "lowmem.h"
+#include "lowmem-limit.h"
 #include "notifier.h"
 #include "procfs.h"
 #include "cgroup.h"
diff --git a/src/resource-limiter/memory/lowmem-limit.h b/src/resource-limiter/memory/lowmem-limit.h
new file mode 100644 (file)
index 0000000..4a9ee8c
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * 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 express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @file lowmem-limit.h
+ * @desc Functions for memory-limiting features.
+ **/
+
+#ifndef __LOWMEM_LIMIT_H__
+#define __LOWMEM_LIMIT_H__
+
+#include <proc-common.h>
+#include <memory-cgroup.h>
+#include "fd-handler.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+struct memory_limit_event {
+       int fd;
+       unsigned long long threshold_bytes;             /* byte */
+       char *path;
+       enum proc_action action;
+};
+
+int lowmem_reassign_limit(const char *dir, unsigned long long limit_bytes, enum proc_action action);
+int lowmem_limit_move_cgroup(struct proc_app_info *pai);
+int lowmem_limit_set_system_service(pid_t pid, unsigned long long limit_bytes, const char *name, enum proc_action action);
+int lowmem_limit_set_app(unsigned long long limit_bytes, struct proc_app_info *pai, enum proc_action action);
+void lowmem_memory_init(unsigned long long service_limit_bytes, unsigned long long widget_limit_bytes, unsigned long long guiapp_limit_bytes, unsigned long long bgapp_limit_bytes);
+void lowmem_action_init(int service_action, int widget_action, int guiapp_action, int bgapp_action);
+void lowmem_limit_init(void);
+void lowmem_limit_exit(void);
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LOWMEM_LIMIT_H__ */
index dd202f522ec88ec45484435e9e20cf02ee557ea0..b9e63b10eb718673dfb082f677db174216a642cd 100644 (file)
@@ -37,6 +37,8 @@
 #include "module.h"
 #include "module-data.h"
 #include "lowmem.h"
+#include "lowmem-system.h"
+#include "lowmem-limit.h"
 #include "notifier.h"
 #include "procfs.h"
 #include "cgroup.h"
diff --git a/src/resource-limiter/memory/lowmem-system.h b/src/resource-limiter/memory/lowmem-system.h
new file mode 100644 (file)
index 0000000..2c90c28
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * 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 express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+ * @file lowmem-system.h
+ * @desc Function for initialize lowmem-system features
+ **/
+
+#ifndef __LOWMEM_SYSTEM_H__
+#define __LOWMEM_SYSTEM_H__
+
+#include <proc-common.h>
+#include <memory-cgroup.h>
+#include "fd-handler.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+void lowmem_system_init();
+void lowmem_system_exit();
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __LOWMEM_SYSTEM_H__ */
index 4437f821eb3d766dcf899e2477feaa70abb851c2..862aa07338c49016d9cbcb7bcbea90cb53bdb25b 100644 (file)
@@ -49,6 +49,9 @@
 #include "trace.h"
 #include "cgroup.h"
 #include "lowmem.h"
+#include "lowmem-dbus.h"
+#include "lowmem-system.h"
+#include "lowmem-limit.h"
 #include "proc-common.h"
 #include "procfs.h"
 #include "freezer.h"
index 154ff129b74c2625df04bc6a004dd407b57d6580..beaa8baf4aa053bcd68c9a05268bfc934c6c08d2 100644 (file)
  */
 
 /**
- * @file lowmem_handler.h
+ * @file lowmem.h
  * @desc handler function for setting memcgroup memory controller and
  *     receiving event fd.
  **/
 
-#ifndef __LOWMEM_HANDLER_H__
-#define __LOWMEM_HANDLER_H__
+#ifndef __LOWMEM_H__
+#define __LOWMEM_H__
 
 #include <proc-common.h>
 #include <memory-cgroup.h>
@@ -59,52 +59,20 @@ struct task_info {
        struct proc_app_info *pai;
 };
 
-struct memory_limit_event {
-       int fd;
-       unsigned long long threshold_bytes;             /* byte */
-       char *path;
-       enum proc_action action;
-};
-
-/**
- * @desc execute /usr/bin/memps and make log file with pid and process name
- */
-//void make_memps_log(enum mem_log path, pid_t pid, char *victim_name);
-
-void lowmem_memory_init(unsigned long long service_limit_bytes, unsigned long long widget_limit_bytes,
-               unsigned long long guiapp_limit_bytes, unsigned long long bgapp_limit_bytes);
-void lowmem_action_init(int service_action, int widget_action,
-               int guiapp_action, int bgapp_action);
-int lowmem_limit_set_app(unsigned long long limit_bytes, struct proc_app_info *pai,
-               enum proc_action action);
-int lowmem_limit_set_system_service(pid_t pid, unsigned long long limit_bytes,
-               const char *name, enum proc_action action);
-void lowmem_dbus_init(void);
+unsigned int lowmem_get_task_mem_usage_rss(const struct task_info *tsk);
+void lowmem_trigger_swap(pid_t pid, char *path, bool move);
 int lowmem_trigger_reclaim(int flags, int victims, enum oom_score score, int threshold);
 void lowmem_trigger_swap_reclaim(enum oom_score score, unsigned long long swap_size_bytes);
-void lowmem_change_memory_state(int state, int force);
-unsigned long lowmem_get_ktotalram(void);
-unsigned long long lowmem_get_totalram(void);
-void lowmem_trigger_swap(pid_t pid, char *path, bool move);
-void lowmem_limit_init(void);
-void lowmem_limit_exit(void);
-int lowmem_limit_move_cgroup(struct proc_app_info *pai);
-int lowmem_reassign_limit(const char *dir,
-               unsigned long long limit_bytes, enum proc_action action);
-unsigned int lowmem_get_task_mem_usage_rss(const struct task_info *tsk);
 bool lowmem_fragmentated(void);
 unsigned int lowmem_get_proactive_thres(void);
-void lowmem_system_init();
-void lowmem_system_exit();
+void lowmem_change_memory_state(int state, int force);
 
 /**
  * @desc restore memory cgroup from pid when resourced is restarted
  */
 void lowmem_restore_memcg(struct proc_app_info *pai);
-
-/*
- * Return memcg pointer to selected cgroup.
- */
+unsigned long lowmem_get_ktotalram(void);
+unsigned long long lowmem_get_totalram(void);
 
 enum oom_killer_cb_flags {
        OOM_NONE                = 0x0,          /* for main oom killer thread */
@@ -144,4 +112,4 @@ enum {
 }
 #endif /* __cplusplus */
 
-#endif /*__LOWMEM_HANDLER_H__*/
+#endif /*__LOWMEM_H__*/