2 #ifndef _LINUX_SYSTEM_LOAD_ANALYZER_H
3 #define _LINUX_SYSTEM_LOAD_ANALYZER_H
5 #define CPU_NUM NR_CPUS
8 /*** FUNCTION OPTION ***/
9 #if defined(CONFIG_SLP_KERNEL_ENG)
10 #define CPU_LOAD_HISTORY_NUM 2000
11 #define CPU_TASK_HISTORY_NUM 30000
13 #define CPU_LOAD_HISTORY_NUM 300
14 #define CPU_TASK_HISTORY_NUM 30
18 #define CONFIG_SLP_CHECK_BUS_LOAD 1
19 //#define CONFIG_SLP_CHECK_BUSY_LEVEL 1
20 //#define CONFIG_SLP_BUS_CLK_CHECK_LOAD 1
21 #define CONFIG_SLP_MINI_TRACER 1
24 #define CONFIG_SLP_CPU_TESTER 1
26 #define CONFIG_SLP_CHECK_RESOURCE 1
28 /*******************************************************/
29 #define CONFIG_CHECK_WORK_HISTORY 1
30 #if defined(CONFIG_SLP_KERNEL_ENG)
31 #define CPU_WORK_HISTORY_NUM 1000
33 #define CPU_WORK_HISTORY_NUM 30
35 /********************************************************/
37 #if defined(CONFIG_SLP_KERNEL_ENG)
38 #define CONFIG_SLP_CURRENT_MONITOR 1
40 #define CONFIG_SLP_CHECK_PHY_ADDR 1
41 //#define CONFIG_CHECK_NOT_CPUIDLE_CAUSE 1
42 //#define CONFIG_CHECK_ENTER_AFTR 1
43 #define CONFIG_LOAD_ANALYZER_PMQOS 1
44 #define CONFIG_SLP_INPUT_REC 1
45 #define CONFIG_SLP_BUSY_LEVEL 1
48 /* You should choose one of them */
49 //#define CONFIG_SLP_MSM_BUS 1
50 #define CONFIG_SLP_EXYNOS_BUS 1
53 #if defined(CONFIG_SLP_EXYNOS_BUS)
54 #define PWR_DOMAINS_NUM 1
55 #define CLK_GATES_NUM 4
56 #elif defined(CONFIG_SLP_MSM_BUS)
57 #define PWR_DOMAINS_NUM 3
58 #define CLK_GATES_NUM 5
60 #define PWR_DOMAINS_NUM 3
61 #define CLK_GATES_NUM 5
78 #ifdef CONFIG_SLP_CHECK_RESOURCE
88 struct saved_load_factor_tag {
89 unsigned int nr_running_task;
90 unsigned int mif_bus_freq;
91 unsigned int mif_bus_load;
92 unsigned int int_bus_freq;
93 unsigned int int_bus_load;
94 unsigned int gpu_freq;
95 unsigned int gpu_utilization;
96 unsigned int active_app_pid;
97 unsigned int battery_soc;
98 unsigned int lcd_brightness;
99 unsigned int suspend_state;
100 unsigned int suspend_count;
101 #ifdef CONFIG_SLP_CHECK_RESOURCE
102 unsigned int bt_tx_bytes;
103 unsigned int bt_rx_bytes;
104 unsigned int bt_enabled;
105 unsigned int wifi_tx_bytes;
106 unsigned int wifi_rx_bytes;
107 unsigned int wifi_enabled;
111 extern struct saved_load_factor_tag saved_load_factor;
113 extern bool cpu_task_history_onoff;
115 extern int value_for_debug;
117 extern int current_monitor_en;
119 extern struct cpuidle_device *cpu_idle_dev;
121 extern int kernel_mini_tracer_i2c_log_on;
123 void cpu_print_buf_to_klog(char *buffer);
125 void store_external_load_factor(int type, unsigned int data);
127 void store_cpu_load(unsigned int cpufreq[], unsigned int cpu_load[]);
129 void cpu_load_touch_event(unsigned int event);
131 void __slp_store_task_history(unsigned int cpu, struct task_struct *task);
133 static inline void slp_store_task_history(unsigned int cpu
134 , struct task_struct *task)
136 __slp_store_task_history(cpu, task);
139 u64 get_load_analyzer_time(void);
141 void __slp_store_work_history(struct work_struct *work, work_func_t func
142 , u64 start_time, u64 end_time);
144 void __slp_store_input_history(void *dev,
145 unsigned int type, unsigned int code, int value);
147 void store_killed_task(struct task_struct *tsk);
148 int search_killed_task(unsigned int pid, char *task_name);
150 void cpu_last_load_freq(unsigned int range, int max_list_num);
157 #if defined(CONFIG_LOAD_ANALYZER_INTERNAL)
159 struct cpu_process_runtime_tag {
160 struct list_head list;
161 unsigned long long runtime;
162 struct task_struct *task;
168 #if defined (CONFIG_CHECK_WORK_HISTORY)
169 struct cpu_work_runtime_tag {
170 struct list_head list;
175 struct task_struct *task;
179 struct work_struct *work;
184 struct cpu_load_freq_history_tag {
186 unsigned long long time_stamp;
187 unsigned int cpufreq[CPU_NUM];
188 int cpu_max_locked_freq;
189 int cpu_min_locked_freq;
190 int cpu_max_locked_online;
191 int cpu_min_locked_online;
193 unsigned int cpu_load[CPU_NUM];
194 unsigned int cpu_idle_time[3];
196 unsigned int touch_event;
197 unsigned int nr_onlinecpu;
198 unsigned int nr_run_avg;
199 unsigned int task_history_cnt[CPU_NUM];
200 unsigned int gpu_freq;
201 unsigned int gpu_utilization;
204 unsigned int suspend_count;
206 unsigned int battery_soc;
207 unsigned int lcd_brightness;
208 #if defined (CONFIG_CHECK_WORK_HISTORY)
209 unsigned int work_history_cnt[CPU_NUM];
212 //#if defined (CONFIG_SLP_INPUT_REC)
213 unsigned int input_rec_history_cnt;
216 #if defined(CONFIG_SLP_CHECK_BUS_LOAD)
218 #if defined(CONFIG_SLP_EXYNOS_BUS)
219 unsigned int mif_bus_freq;
220 unsigned int mif_bus_load;
221 unsigned int int_bus_freq;
222 unsigned int int_bus_load;
223 #elif defined(CONFIG_SLP_MSM_BUS)
224 unsigned int bimc_clk;
225 unsigned int cnoc_clk;
226 unsigned int pnoc_clk;
227 unsigned int snoc_clk;
231 #if defined(CONFIG_SLP_BUS_CLK_CHECK_LOAD)
232 unsigned int power_domains[PWR_DOMAINS_NUM];
233 unsigned int clk_gates[CLK_GATES_NUM];
235 #if defined(CONFIG_SLP_CHECK_RESOURCE)
236 unsigned int bt_tx_bytes;
237 unsigned int bt_rx_bytes;
238 unsigned int bt_enabled;
240 unsigned int wifi_tx_bytes;
241 unsigned int wifi_rx_bytes;
242 unsigned int wifi_enabled;
245 unsigned int modem_tx_bytes;
246 unsigned int modem_rx_bytes;
251 struct cpu_task_history_tag {
252 unsigned long long time;
253 struct task_struct *task;
256 static struct cpu_task_history_tag (*cpu_task_history)[CPU_NUM];
257 static struct cpu_task_history_tag (*cpu_task_history_view)[CPU_NUM];
258 #define CPU_TASK_HISTORY_SIZE (sizeof(struct cpu_task_history_tag) \
259 * cpu_task_history_num * CPU_NUM)
262 unsigned int show_cpu_load_freq_sub(int cnt, int show_cnt, char *buf, unsigned int buf_size, int ret);
264 extern char cpu_load_freq_menu[];
266 #if defined(CONFIG_SLP_CHECK_BUS_LOAD)
267 extern char cpu_bus_load_freq_menu[];
268 unsigned int show_cpu_bus_load_freq_sub(int cnt, int show_cnt
269 , char *buf, unsigned int buf_size, int ret);
272 #if defined(CONFIG_SLP_BUS_CLK_CHECK_LOAD)
273 extern char cpu_bus_clk_load_freq_menu[];
274 unsigned int show_cpu_bus_clk_load_freq_sub(int cnt
275 , int show_cnt, char *buf, int ret);
280 /******** +CONFIG_SLP_CURRENT_MONITOR+ ********/
282 #if defined (CONFIG_SLP_CURRENT_MONITOR)
283 void current_monitor_manager(int cnt);
284 unsigned int show_current_monitor_read_sub(int cnt, int show_cnt
285 , char *buf, unsigned int buf_size, int ret);
287 /******** -CONFIG_SLP_CURRENT_MONITOR- ********/
292 /******** +CONFIG_CHECK_NOT_CPUIDLE_CAUSE+ ********/
293 #if defined(CONFIG_CHECK_NOT_CPUIDLE_CAUSE)
294 static ssize_t not_lpa_cause_check(struct file *file,
295 char __user *buffer, size_t count, loff_t *ppos);
296 static int not_lpa_cause_check_sub(char *buf, int buf_size);
298 /******** -CONFIG_CHECK_NOT_CPUIDLE_CAUSE- ********/
303 /******** +CONFIG_CHECK_WORK_HISTORY+ ********/
304 #if defined (CONFIG_CHECK_WORK_HISTORY)
305 struct cpu_work_history_tag {
310 struct task_struct *task;
312 struct work_struct *work;
316 #define CPU_WORK_HISTORY_SIZE (sizeof(struct cpu_work_history_tag) \
317 * cpu_work_history_num * CPU_NUM)
319 static unsigned int cpu_work_history_cnt[CPU_NUM];
320 static struct cpu_work_history_tag (*cpu_work_history)[CPU_NUM];
321 static struct cpu_work_history_tag (*cpu_work_history_view)[CPU_NUM];
322 unsigned int cpu_work_history_num = CPU_WORK_HISTORY_NUM;
323 static unsigned int cpu_work_history_show_start_cnt;
324 static unsigned int cpu_work_history_show_end_cnt;
325 static int cpu_work_history_show_select_cpu;
327 static struct list_head work_headlist;
329 bool cpu_work_history_onoff;
331 /******** -CONFIG_CHECK_WORK_HISTORY- ********/
334 /******** +CONFIG_SLP_INPUT_REC+ ********/
335 #if defined (CONFIG_SLP_INPUT_REC)
336 #if defined(CONFIG_SLP_KERNEL_ENG)
337 #define INPUT_REC_HISTORY_NUM 20000
339 #define INPUT_REC_HISTORY_NUM 20
341 #define MAX_INPUT_DEVICES 256
343 struct input_rec_history_tag {
345 struct input_dev *dev;
351 #define MAX_INPUT_DEV_NAME_LEN 64
352 struct input_dev_info_tag {
353 struct input_dev *dev;
354 char name[MAX_INPUT_DEV_NAME_LEN];
358 unsigned int input_rec_history_num = INPUT_REC_HISTORY_NUM;
359 #define INPUT_REC_HISTORY_SIZE (sizeof(struct input_rec_history_tag) \
360 * input_rec_history_num)
362 static unsigned int input_rec_history_cnt;
363 static struct input_rec_history_tag (*input_rec_history);
364 static struct input_rec_history_tag (*input_rec_history_view);
365 static unsigned int input_rec_history_show_start_cnt;
366 static unsigned int input_rec_history_show_end_cnt;
367 static int input_rec_history_show_select_cpu;
368 bool input_rec_history_onoff;
369 int b_input_load_data;
370 int input_dev_info_current_num;
371 unsigned int input_dev_info_saved_num;
372 struct input_dev_info_tag input_dev_info_current[MAX_INPUT_DEVICES];
373 struct input_dev_info_tag input_dev_info_saved[MAX_INPUT_DEVICES];
375 struct input_dev * input_rec_change_dev(struct input_dev *old_dev);
377 /******** -CONFIG_SLP_INPUT_REC- ********/
380 #endif /* end of CONFIG_LOAD_ANALYZER_INTERNAL */
383 /******** +CONFIG_SLP_MINI_TRACER+ ********/
384 #if defined(CONFIG_SLP_MINI_TRACER)
386 #define TIME_ON (1 << 0)
387 #define FLUSH_CACHE (1 << 1)
389 void kernel_mini_tracer(char *input_string, int option);
390 void kernel_mini_tracer_smp(char *input_string);
391 #define mini_trace_log { \
393 sprintf(str, "%s %d\n", __FUNCTION__, __LINE__); \
394 kernel_mini_tracer(str, TIME_ON | FLUSH_CACHE); \
397 #define mini_trace_log
399 /******** -CONFIG_SLP_MINI_TRACER- ********/
402 /******** +CONFIG_SLP_CPU_TESTER+ ********/
403 #if defined (CONFIG_SLP_CPU_TESTER)
404 #define CPU_TEST_START_TIME 50 /* 50 sec after boot */
413 struct cpu_test_list_tag {
416 int test_time; /* ms */
417 unsigned int test_cnt;
421 struct cpu_test_freq_table_tag {
427 struct cpu_test_idle_table_tag {
433 extern struct cpu_test_freq_table_tag cpu_test_freq_table[];
434 extern struct cpu_test_idle_table_tag cpu_test_idle_table[];
436 extern int cpu_tester_en;
437 extern int cpufreq_tester_en;
438 extern int cpuidle_tester_en;
440 extern int cpu_idle_trace_en;
441 extern int cpufreq_force_state;
443 int cpu_freq_to_enum(int cpufreq);
444 int cpuidle_force_set(int *force_state, int next_state);
445 int cpufreq_force_set(int *force_state, int target_freq);
446 void set_cpufreq_force_state(int cpufreq_enum);
450 /******** +CONFIG_SLP_BUSY_LEVEL+ ********/
451 #if defined (CONFIG_SLP_BUSY_LEVEL)
458 extern int cpu_busy_level;
459 int la_get_cpu_busy_level(void);
460 void la_set_cpu_busy_level(int set_cpu_busy_level);
461 int check_load_level(unsigned int current_cnt);