#include "trace.h"
#include "lowmem.h"
+#include "lowmem-dbus.h"
+#include "lowmem-limit.h"
#include "dbus-handler.h"
#include "resourced.h"
#include "macro.h"
--- /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 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__ */
#include "module.h"
#include "module-data.h"
#include "lowmem.h"
+#include "lowmem-limit.h"
#include "notifier.h"
#include "procfs.h"
#include "cgroup.h"
--- /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 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__ */
#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"
--- /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 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__ */
#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"
*/
/**
- * @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>
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 */
}
#endif /* __cplusplus */
-#endif /*__LOWMEM_HANDLER_H__*/
+#endif /*__LOWMEM_H__*/