cpu-boosting: Check whether cpu stall handler is turned on
[platform/core/system/resourced.git] / src / common / conf / cpu-common.h
1 #ifndef __CPU_COMMON_H__
2 #define __CPU_COMMON_H__
3
4 #include <stdbool.h>
5
6 #include <cpu-boosting-type.h>
7 #include <cpu-boosting-private.h>
8
9 #include "util.h"
10
11 #ifdef __cplusplus
12 extern "C" {
13 #endif /* __cplusplus */
14
15 #define CPU_INIT_NICE         100
16 #define CPU_MAX_NICE          19
17 #define CPU_MIN_NICE          -20
18 #define CPU_DEFAULT_NICE      0
19
20 #define CPU_INIT_PRIO         0
21 #define CPU_MAX_PRIO          99
22 #define CPU_MIN_PRIO          1
23
24 #define CPU_DEFAULT_SHARE     1024
25 #define CPU_THROTTLING_SHARE  64
26
27 enum cpu_sched_flag {
28         CPU_SCHED_UNINITIALIZED = 0,
29         CPU_SCHED_RUNTIME_SHARE = 1,
30         CPU_SCHED_NO_RUNTIME_SHARE = 2,
31         CPU_SCHED_RUNTIME_GREED = 4,
32 };
33
34 enum cpu_sched_type {
35         CPU_SCHED_NONE = 0,
36         CPU_SCHED_IDLE = 1,
37         CPU_SCHED_BATCH,
38         CPU_SCHED_OTHER,
39         CPU_SCHED_FIFO,
40         CPU_SCHED_RR,
41         CPU_SCHED_DEADLINE,
42 };
43
44 struct cpu_sched_info {
45         enum cpu_sched_type cpu_sched_type;
46         int cpu_nice;                        /* fixed cpu nice */
47         int cpu_rt_priority;                 /* fixed cpu priority for rt schedulers */
48 };
49
50 struct cpuset_cgroup_info {
51         char name[64];
52         char value[64];
53 };
54
55 struct cpu_info {
56         int cpu_id;
57         bool online;
58 };
59
60 struct cpuset_info {
61         GSList *cpu_info;
62         char *name;
63         bool disclaimer_shown;
64 };
65
66 struct cpu_cgroup_info {
67         long long cfs_runtime_us;
68         long long rt_runtime_us;
69         unsigned long long cfs_period_us;
70         unsigned long long rt_period_us;
71         unsigned long long cpu_share;
72 };
73
74 struct cpu_sched_conf {
75         enum cpu_sched_flag cpu_sched_flag;
76         struct cpu_cgroup_info cpu_cgroup_info;
77 };
78
79 struct cpu_affinity_conf {
80         struct cpuset_cgroup_info cpuset_cgroup_info;
81 };
82
83 struct cpu_throttling_conf {
84         bool enable;
85         struct cpu_sched_info cpu_sched_info;
86         struct cpu_cgroup_info cpu_cgroup_info;
87 };
88
89 struct cpu_boosting_conf {
90         bool enable;
91         struct cpu_sched_info cpu_sched_info;
92 };
93
94 void cpu_boosting_enable_cpu_stall_handler(void);
95 bool cpu_boosting_is_enabled_of_cpu_stall_handler(void);
96
97
98 struct cpu_sched_conf *get_cpu_sched_conf(void);
99 void free_cpu_sched_conf(void);
100
101 char *get_cpu_affinity_conf_name(void);
102 char *get_cpu_affinity_conf_value(void);
103 int set_cpu_affinity_conf(const char *name, const char *value);
104 void free_cpu_affinity_conf(void);
105
106 struct cpu_throttling_conf *get_cpu_throttling_conf(void);
107 void free_cpu_throttling_conf(void);
108
109 struct cpu_boosting_conf *get_cpu_boosting_conf(cpu_boosting_level_e level);
110 void free_cpu_boosting_conf(cpu_boosting_level_e level);
111
112 #ifdef __cplusplus
113 }
114 #endif /* __cplusplus */
115
116 #endif /* __CPU_COMMON_H__ */