tizen 2.3 release
[kernel/api/system-resource.git] / src / memory / lowmem-handler.h
1 /*
2  * resourced
3  *
4  * Copyright (c) 2013 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  */
19
20 /**
21  * @file lowmem_handler.h
22  * @desc handler function for setting memcgroup memory controller and
23  *      receiving event fd.
24  **/
25
26 #ifndef __LOWMEM_HANDLER_H__
27 #define __LOWMEM_HANDLER_H__
28
29 void lowmem_dbus_init(void);
30 int lowmem_oom_killer_cb(int memcg_idx, int flags);
31 void lowmem_dynamic_process_killer(int type);
32 unsigned int get_available(void);
33 void change_memory_state(int state, int force);
34
35 void set_threshold(int level, int thres);
36 void set_leave_threshold(int thres);
37
38 #define NUM_FOREGROUND                  3
39 enum {
40         MEMCG_MEMORY,
41         MEMCG_FOREGROUND,
42         MEMCG_BACKGROUND = MEMCG_FOREGROUND + NUM_FOREGROUND,
43         MEMCG_MAX_GROUPS,
44 };
45
46 enum {
47         MEMNOTIFY_NORMAL,
48         MEMNOTIFY_SWAP,
49         MEMNOTIFY_LOW,
50         MEMNOTIFY_MEDIUM,
51         MEMNOTIFY_MAX_LEVELS,
52 };
53
54 enum oom_killer_cb_flags {
55         OOM_NONE                = 0x00000000,   /* for main oom killer thread */
56         OOM_FORCE               = 0x00000001,   /* for forced kill */
57         OOM_TIMER_CHECK         = 0x00000002,   /* for timer oom killer cb */
58         OOM_NOMEMORY_CHECK      = 0x00000004,   /* check victims' memory */
59 };
60
61 enum {
62         DYNAMIC_KILL_LARGEHEAP,
63         DYNAMIC_KILL_LUNCH,
64         DYNAMIC_KILL_MAX,
65 };
66
67 #endif /*__LOWMEM_HANDLER_H__*/