lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | /* |
| 2 | * tracker.c - System accounting over taskstats interface |
| 3 | * |
| 4 | * Copyright (C) Jay Lan, <jlan@sgi.com> |
| 5 | * |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | */ |
| 18 | #include <linux/module.h> |
| 19 | #include <linux/kernel.h> |
| 20 | #include <linux/sched.h> |
| 21 | #include <linux/jiffies.h> |
| 22 | #include <linux/slab.h> |
| 23 | #include <linux/timer.h> |
| 24 | #include <linux/delay.h> |
| 25 | #include <linux/kthread.h> |
| 26 | #include <mach/iomap.h> |
| 27 | |
| 28 | #ifndef CONFIG_SYSTEM_CAP |
| 29 | #include <linux/proc_fs.h> |
| 30 | #include <linux/string.h> |
| 31 | #include <linux/seq_file.h> |
| 32 | #endif |
| 33 | |
| 34 | /******************************************************************************* |
| 35 | * ºê¶¨Òå * |
| 36 | *******************************************************************************/ |
| 37 | #if defined(_OS_TOS) |
| 38 | # define OS_STATISTIC_IRAM_BASE (IRAM_BASE_ADDR_OS_STATISTIC_PSCPU) |
| 39 | # define OS_STATISTIC_TIME zDrvTimer_Stamp() |
| 40 | #elif defined(_OS_LINUX) |
| 41 | # define OS_STATISTIC_IRAM_BASE g_zxic_trace_apcpu_addr //(IRAM_BASE_ADDR_OS_STATISTIC_APCPU) |
| 42 | # define OS_STATISTIC_TIME (cpu_clock(0)>>10) |
| 43 | #else |
| 44 | # error "unknown os" |
| 45 | #endif |
| 46 | |
| 47 | #define OS_IRAM_STATISTIC_CNT (8) |
| 48 | #define OS_IRAM_STATISTIC_NAME_LEN (16) |
| 49 | #define OS_DDR_STATISTIC_CNT (1000) |
| 50 | |
| 51 | #define OS_IRAM_THREAD_SWAPIN (OS_STATISTIC_IRAM_BASE) |
| 52 | #define OS_IRAM_IRQ_START (OS_IRAM_THREAD_SWAPIN + sizeof(t_os_iram_thread_statistic)) |
| 53 | #define OS_IRAM_IRQ_END (OS_IRAM_IRQ_START + sizeof(t_os_iram_statistic)) |
| 54 | |
| 55 | #if defined(_OS_TOS) |
| 56 | #define OS_IRAM_DSR_START (OS_IRAM_IRQ_END + sizeof(t_os_iram_statistic)) |
| 57 | #define OS_IRAM_DSR_END (OS_IRAM_DSR_START + sizeof(t_os_iram_statistic)) |
| 58 | #elif defined(_OS_LINUX) |
| 59 | #define OS_IRAM_SOFTIRQ_START (OS_IRAM_IRQ_END + sizeof(t_os_iram_statistic)) |
| 60 | #define OS_IRAM_SOFTIRQ_END (OS_IRAM_SOFTIRQ_START + sizeof(t_os_iram_statistic)) |
| 61 | #define OS_IRAM_TIMER_START (OS_IRAM_SOFTIRQ_END + sizeof(t_os_iram_statistic)) |
| 62 | #define OS_IRAM_TIMER_END (OS_IRAM_TIMER_START + sizeof(t_os_iram_statistic)) |
| 63 | #endif |
| 64 | |
| 65 | #define os_statistic_check() *((volatile unsigned long *)OS_STATISTIC_IRAM_BASE) |
| 66 | #define os_statistic_enabled() g_os_statistic_enable |
| 67 | |
| 68 | #ifndef CONFIG_SYSTEM_CAP |
| 69 | #define KERNEL_L1W_IRAM_LOG_DROP (IRAM_BASE_ADDR_LOG_DROP_TRACE) |
| 70 | #define KERNEL_L1l_IRAM_LOG_DROP (KERNEL_L1W_IRAM_LOG_DROP + sizeof(T_LogIram_Record)) |
| 71 | #endif |
| 72 | /******************************************************************************* |
| 73 | * Êý¾Ý½á¹¹¶¨Òå * |
| 74 | *******************************************************************************/ |
| 75 | typedef volatile struct { |
| 76 | unsigned int enable; |
| 77 | unsigned int cnt; |
| 78 | unsigned int index; |
| 79 | struct { |
| 80 | unsigned char name[OS_IRAM_STATISTIC_NAME_LEN]; |
| 81 | unsigned int data2; |
| 82 | } statistics[OS_IRAM_STATISTIC_CNT]; |
| 83 | }t_os_iram_thread_statistic; |
| 84 | |
| 85 | typedef volatile struct { |
| 86 | unsigned int cnt; |
| 87 | unsigned int index; |
| 88 | struct { |
| 89 | unsigned int data1; |
| 90 | unsigned int data2; |
| 91 | } statistics[OS_IRAM_STATISTIC_CNT]; |
| 92 | }t_os_iram_statistic; |
| 93 | |
| 94 | typedef struct { |
| 95 | unsigned int cnt; |
| 96 | unsigned int index; |
| 97 | struct { |
| 98 | unsigned int data1; |
| 99 | unsigned int data2; |
| 100 | } statistics[OS_DDR_STATISTIC_CNT]; |
| 101 | }t_os_ddr_statistic; |
| 102 | |
| 103 | #ifndef CONFIG_SYSTEM_CAP |
| 104 | typedef struct |
| 105 | { |
| 106 | unsigned int no_lock; |
| 107 | unsigned int no_mem; |
| 108 | }T_LogIram_Record; |
| 109 | #endif |
| 110 | |
| 111 | /******************************************************************************* |
| 112 | * È«¾Ö±äÁ¿ * |
| 113 | *******************************************************************************/ |
| 114 | #if defined(_OS_LINUX) |
| 115 | static char *g_zxic_trace_apcpu_addr; |
| 116 | #endif |
| 117 | |
| 118 | static int g_os_statistic_enable; |
| 119 | static unsigned int g_os_statistic_cnt; |
| 120 | |
| 121 | static t_os_iram_thread_statistic *g_os_iram_swapin_statistic; |
| 122 | static t_os_iram_statistic *g_os_iram_irq_start_statistic; |
| 123 | static t_os_iram_statistic *g_os_iram_irq_end_statistic; |
| 124 | |
| 125 | #if defined(_OS_TOS) |
| 126 | static t_os_iram_statistic *g_os_iram_dsr_start_statistic; |
| 127 | static t_os_iram_statistic *g_os_iram_dsr_end_statistic; |
| 128 | #elif defined(_OS_LINUX) |
| 129 | static t_os_iram_statistic *g_os_iram_softirq_start_statistic; |
| 130 | static t_os_iram_statistic *g_os_iram_softirq_end_statistic; |
| 131 | static t_os_iram_statistic *g_os_iram_timer_start_statistic; |
| 132 | static t_os_iram_statistic *g_os_iram_timer_end_statistic; |
| 133 | #endif |
| 134 | |
| 135 | static t_os_ddr_statistic *g_os_ddr_swapin_statistic; |
| 136 | static t_os_ddr_statistic *g_os_ddr_irq_start_statistic; |
| 137 | static t_os_ddr_statistic *g_os_ddr_irq_end_statistic; |
| 138 | |
| 139 | #if defined(_OS_TOS) |
| 140 | static t_os_ddr_statistic *g_os_ddr_dsr_start_statistic; |
| 141 | static t_os_ddr_statistic *g_os_ddr_dsr_end_statistic; |
| 142 | #elif defined(_OS_LINUX) |
| 143 | static t_os_ddr_statistic *g_os_ddr_softirq_start_statistic; |
| 144 | static t_os_ddr_statistic *g_os_ddr_softirq_end_statistic; |
| 145 | static t_os_ddr_statistic *g_os_ddr_timer_start_statistic; |
| 146 | static t_os_ddr_statistic *g_os_ddr_timer_end_statistic; |
| 147 | #endif |
| 148 | |
| 149 | #ifndef CONFIG_SYSTEM_CAP |
| 150 | T_LogIram_Record *gL1w_LogMissPoint = (T_LogIram_Record *)KERNEL_L1W_IRAM_LOG_DROP; |
| 151 | T_LogIram_Record *gL11_LogMissPoint = (T_LogIram_Record *)KERNEL_L1l_IRAM_LOG_DROP; |
| 152 | #endif |
| 153 | |
| 154 | /******************************************************************************* |
| 155 | * È«¾Öº¯ÊýÉùÃ÷ * |
| 156 | *******************************************************************************/ |
| 157 | void os_statistic_enable(void); |
| 158 | /******************************************************************************* |
| 159 | * ¾Ö²¿º¯Êý * |
| 160 | *******************************************************************************/ |
| 161 | /******************************************************************************* |
| 162 | * ¹¦ÄÜÃèÊö: ¹ì¼£Í³¼Æµ½IRAM |
| 163 | * ²ÎÊý˵Ã÷: |
| 164 | * (´«Èë²ÎÊý) iram_addr: µØÖ· |
| 165 | data: ʼþÏî |
| 166 | time: ʱ¼ä |
| 167 | * (´«³ö²ÎÊý) void |
| 168 | * ·µ »Ø Öµ: void |
| 169 | * ÆäËü˵Ã÷: ÎÞ |
| 170 | *******************************************************************************/ |
| 171 | static inline void os_statistic_in_iram(volatile void *iram_addr, void *data, unsigned long time) |
| 172 | { |
| 173 | unsigned long index; |
| 174 | t_os_iram_statistic *iram; |
| 175 | |
| 176 | iram = (t_os_iram_statistic *)iram_addr; |
| 177 | |
| 178 | index = iram->index; |
| 179 | if(index >= OS_IRAM_STATISTIC_CNT) |
| 180 | { |
| 181 | index = 0; |
| 182 | } |
| 183 | |
| 184 | iram->statistics[index].data1 = (unsigned int)data; |
| 185 | iram->statistics[index].data2 = time; |
| 186 | index++; |
| 187 | |
| 188 | iram->index = index; |
| 189 | iram->cnt = g_os_statistic_cnt; |
| 190 | } |
| 191 | |
| 192 | /******************************************************************************* |
| 193 | * ¹¦ÄÜÃèÊö: Ï̹߳켣ͳ¼Æµ½IRAM |
| 194 | * ²ÎÊý˵Ã÷: |
| 195 | * (´«Èë²ÎÊý) iram_addr: µØÖ· |
| 196 | data: ʼþÏî |
| 197 | time: ʱ¼ä |
| 198 | * (´«³ö²ÎÊý) void |
| 199 | * ·µ »Ø Öµ: void |
| 200 | * ÆäËü˵Ã÷: ÎÞ |
| 201 | *******************************************************************************/ |
| 202 | static inline void os_statistic_thread_in_iram(volatile void *iram_addr, void *data, unsigned long time) |
| 203 | { |
| 204 | unsigned long index; |
| 205 | t_os_iram_thread_statistic *iram; |
| 206 | |
| 207 | iram = (t_os_iram_thread_statistic *)iram_addr; |
| 208 | |
| 209 | index = iram->index; |
| 210 | if(index >= OS_IRAM_STATISTIC_CNT) |
| 211 | { |
| 212 | index = 0; |
| 213 | } |
| 214 | |
| 215 | #if defined(_OS_TOS) |
| 216 | strncpy((char *)(iram->statistics[index].name), cyg_thread_get_name((cyg_handle_t)data), OS_IRAM_STATISTIC_NAME_LEN - 1); |
| 217 | #elif defined(_OS_LINUX) |
| 218 | strncpy((char *)(iram->statistics[index].name), ((struct task_struct *)data)->comm, OS_IRAM_STATISTIC_NAME_LEN - 1); |
| 219 | #else |
| 220 | # error "unkown os" |
| 221 | #endif |
| 222 | iram->statistics[index].name[OS_IRAM_STATISTIC_NAME_LEN - 1] = 0; |
| 223 | iram->statistics[index].data2 = time; |
| 224 | index++; |
| 225 | |
| 226 | iram->index = index; |
| 227 | iram->cnt = g_os_statistic_cnt; |
| 228 | } |
| 229 | |
| 230 | /******************************************************************************* |
| 231 | * ¹¦ÄÜÃèÊö: ¹ì¼£Í³¼Æµ½DDR |
| 232 | * ²ÎÊý˵Ã÷: |
| 233 | * (´«Èë²ÎÊý) iram_addr: µØÖ· |
| 234 | data: ʼþÏî |
| 235 | time: ʱ¼ä |
| 236 | * (´«³ö²ÎÊý) void |
| 237 | * ·µ »Ø Öµ: void |
| 238 | * ÆäËü˵Ã÷: ÎÞ |
| 239 | *******************************************************************************/ |
| 240 | static inline void os_statistic_in_ddr(void *ddr_addr, void *data, unsigned long time) |
| 241 | { |
| 242 | unsigned long index; |
| 243 | t_os_ddr_statistic *ddr; |
| 244 | |
| 245 | ddr = (t_os_ddr_statistic *)ddr_addr; |
| 246 | |
| 247 | index = ddr->index; |
| 248 | if (index >= OS_DDR_STATISTIC_CNT) |
| 249 | { |
| 250 | index = 0; |
| 251 | } |
| 252 | ddr->statistics[index].data1 = (unsigned int)data; |
| 253 | ddr->statistics[index].data2 = time; |
| 254 | index++; |
| 255 | |
| 256 | ddr->index = index; |
| 257 | ddr->cnt = g_os_statistic_cnt; |
| 258 | } |
| 259 | |
| 260 | /******************************************************************************* |
| 261 | * ¹¦ÄÜÃèÊö: ¹ì¼£Í³¼Æµ½DDR |
| 262 | * ²ÎÊý˵Ã÷: |
| 263 | * (´«Èë²ÎÊý) iram_addr: µØÖ· |
| 264 | data: ʼþÏî |
| 265 | time: ʱ¼ä |
| 266 | * (´«³ö²ÎÊý) void |
| 267 | * ·µ »Ø Öµ: void |
| 268 | * ÆäËü˵Ã÷: ÎÞ |
| 269 | *******************************************************************************/ |
| 270 | static inline void os_statistic_info_update(void) |
| 271 | { |
| 272 | g_os_statistic_cnt++; |
| 273 | } |
| 274 | |
| 275 | /******************************************************************************* |
| 276 | * ¹¦ÄÜÃèÊö: ¶¨Ê±Æ÷»Øµ÷¹³×Ó |
| 277 | * ²ÎÊý˵Ã÷: |
| 278 | * (´«Èë²ÎÊý) |
| 279 | * (´«³ö²ÎÊý) void |
| 280 | * ·µ »Ø Öµ: void |
| 281 | * ÆäËü˵Ã÷: ÎÞ |
| 282 | *******************************************************************************/ |
| 283 | static int os_statistic_delayed_work_timer_fn(unsigned long data) |
| 284 | { |
| 285 | int sec = 0; |
| 286 | msleep(20000); |
| 287 | while(!os_statistic_check()) |
| 288 | { |
| 289 | //³¬¹ý40s£¬Ö±½ÓÍ˳ö |
| 290 | if(sec >= 4) |
| 291 | return; |
| 292 | msleep(10000); |
| 293 | sec++; |
| 294 | } |
| 295 | os_statistic_enable(); |
| 296 | return 0; |
| 297 | } |
| 298 | |
| 299 | /******************************************************************************* |
| 300 | * È«¾Öº¯ÊýʵÏÖ * |
| 301 | *******************************************************************************/ |
| 302 | /******************************************************************************* |
| 303 | * ¹¦ÄÜÃèÊö: ¹ì¼£Í³¼Æ³õʼ»¯ |
| 304 | * ²ÎÊý˵Ã÷: |
| 305 | * (´«Èë²ÎÊý) void |
| 306 | * (´«³ö²ÎÊý) void |
| 307 | * ·µ »Ø Öµ: void |
| 308 | * ÆäËü˵Ã÷: psºËµ÷Óà |
| 309 | *******************************************************************************/ |
| 310 | void os_statistic_init(void) |
| 311 | { |
| 312 | memset((void *)IRAM_BASE_ADDR_LINUX_STATISTIC, 0x0, IRAM_BASE_LEN_LINUX_STATISTIC); |
| 313 | } |
| 314 | EXPORT_SYMBOL(os_statistic_init); |
| 315 | |
| 316 | /******************************************************************************* |
| 317 | * ¹¦ÄÜÃèÊö: ʹÄܹ켣ͳ¼Æ¹¦ÄÜ |
| 318 | * ²ÎÊý˵Ã÷: |
| 319 | * (´«Èë²ÎÊý) address: ¼Ç¼µ½IRAMÖеĵØÖ· |
| 320 | size: IRAM¿Õ¼ä´óС |
| 321 | * (´«³ö²ÎÊý) void |
| 322 | * ·µ »Ø Öµ: void |
| 323 | * ÆäËü˵Ã÷: ÎÞ |
| 324 | *******************************************************************************/ |
| 325 | void os_statistic_enable(void) |
| 326 | { |
| 327 | #if defined(_OS_TOS) |
| 328 | g_os_iram_swapin_statistic = (t_os_iram_thread_statistic *)OS_IRAM_THREAD_SWAPIN; |
| 329 | g_os_iram_irq_start_statistic = (t_os_iram_statistic *)OS_IRAM_IRQ_START; |
| 330 | g_os_iram_irq_end_statistic = (t_os_iram_statistic *)OS_IRAM_IRQ_END; |
| 331 | g_os_iram_dsr_start_statistic = (t_os_iram_statistic *)OS_IRAM_DSR_START; |
| 332 | g_os_iram_dsr_end_statistic = (t_os_iram_statistic *)OS_IRAM_DSR_END; |
| 333 | |
| 334 | g_os_ddr_swapin_statistic = (t_os_ddr_statistic *)zOss_Malloc(sizeof(t_os_ddr_statistic)); |
| 335 | g_os_ddr_irq_start_statistic = (t_os_ddr_statistic *)zOss_Malloc(sizeof(t_os_ddr_statistic)); |
| 336 | g_os_ddr_irq_end_statistic = (t_os_ddr_statistic *)zOss_Malloc(sizeof(t_os_ddr_statistic)); |
| 337 | g_os_ddr_dsr_start_statistic = (t_os_ddr_statistic *)zOss_Malloc(sizeof(t_os_ddr_statistic)); |
| 338 | g_os_ddr_dsr_end_statistic = (t_os_ddr_statistic *)zOss_Malloc(sizeof(t_os_ddr_statistic)); |
| 339 | #elif defined(_OS_LINUX) |
| 340 | g_os_iram_swapin_statistic = (t_os_iram_thread_statistic *)OS_IRAM_THREAD_SWAPIN; |
| 341 | g_os_iram_irq_start_statistic = (t_os_iram_statistic *)OS_IRAM_IRQ_START; |
| 342 | g_os_iram_irq_end_statistic = (t_os_iram_statistic *)OS_IRAM_IRQ_END; |
| 343 | g_os_iram_softirq_start_statistic = (t_os_iram_statistic *)OS_IRAM_SOFTIRQ_START; |
| 344 | g_os_iram_softirq_end_statistic = (t_os_iram_statistic *)OS_IRAM_SOFTIRQ_END; |
| 345 | g_os_iram_timer_start_statistic = (t_os_iram_statistic *)OS_IRAM_TIMER_START; |
| 346 | g_os_iram_timer_end_statistic = (t_os_iram_statistic *)OS_IRAM_TIMER_END; |
| 347 | |
| 348 | g_os_ddr_swapin_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL); |
| 349 | g_os_ddr_irq_start_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL); |
| 350 | g_os_ddr_irq_end_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL); |
| 351 | g_os_ddr_softirq_start_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL); |
| 352 | g_os_ddr_softirq_end_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL); |
| 353 | g_os_ddr_timer_start_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL); |
| 354 | g_os_ddr_timer_end_statistic = (t_os_ddr_statistic *)kmalloc(sizeof(t_os_ddr_statistic), GFP_KERNEL); |
| 355 | |
| 356 | #else |
| 357 | # error "unkown os" |
| 358 | #endif |
| 359 | |
| 360 | g_os_statistic_enable = 1; |
| 361 | } |
| 362 | EXPORT_SYMBOL(os_statistic_enable); |
| 363 | |
| 364 | /******************************************************************************* |
| 365 | * ¹¦ÄÜÃèÊö: ¹ì¼£Í³¼ÆÊ¹ÄÜ֪ͨ |
| 366 | * ²ÎÊý˵Ã÷: |
| 367 | * (´«Èë²ÎÊý) void |
| 368 | * (´«³ö²ÎÊý) void |
| 369 | * ·µ »Ø Öµ: void |
| 370 | * ÆäËü˵Ã÷: psºËµ÷Óà |
| 371 | *******************************************************************************/ |
| 372 | void os_statistic_enable_notify(void) |
| 373 | { |
| 374 | *(volatile unsigned long *)IRAM_BASE_ADDR_LINUX_STATISTIC_PSCPU = 1; |
| 375 | *(volatile unsigned long *)IRAM_BASE_ADDR_LINUX_STATISTIC_PHYCPU = 1; |
| 376 | *(volatile unsigned long *)IRAM_BASE_ADDR_LINUX_STATISTIC_APCPU = 1; |
| 377 | } |
| 378 | EXPORT_SYMBOL(os_statistic_enable_notify); |
| 379 | |
| 380 | |
| 381 | void zxic_trace_task_switch(struct task_struct *next) |
| 382 | { |
| 383 | unsigned long time; |
| 384 | if (!g_os_statistic_enable) |
| 385 | return ; |
| 386 | |
| 387 | time = OS_STATISTIC_TIME; |
| 388 | os_statistic_thread_in_iram(g_os_iram_swapin_statistic, next, time); |
| 389 | os_statistic_in_ddr(g_os_ddr_swapin_statistic, next, time); |
| 390 | os_statistic_info_update(); |
| 391 | } |
| 392 | |
| 393 | void zxic_trace_irq_enter(u32 irq) |
| 394 | { |
| 395 | unsigned long time; |
| 396 | if (!g_os_statistic_enable) |
| 397 | return ; |
| 398 | |
| 399 | time = OS_STATISTIC_TIME; |
| 400 | os_statistic_in_iram(g_os_iram_irq_start_statistic, irq, time); |
| 401 | os_statistic_in_ddr(g_os_ddr_irq_start_statistic, irq, time); |
| 402 | os_statistic_info_update(); |
| 403 | } |
| 404 | |
| 405 | void zxic_trace_irq_exit(u32 irq) |
| 406 | { |
| 407 | unsigned long time; |
| 408 | if (!g_os_statistic_enable) |
| 409 | return ; |
| 410 | |
| 411 | time = OS_STATISTIC_TIME; |
| 412 | os_statistic_in_iram(g_os_iram_irq_end_statistic, irq, time); |
| 413 | os_statistic_in_ddr(g_os_ddr_irq_end_statistic, irq, time); |
| 414 | os_statistic_info_update(); |
| 415 | } |
| 416 | |
| 417 | void zxic_trace_softirq_enter(u32 vec_nr) |
| 418 | { |
| 419 | unsigned long time; |
| 420 | if (!g_os_statistic_enable) |
| 421 | return ; |
| 422 | |
| 423 | time = OS_STATISTIC_TIME; |
| 424 | os_statistic_in_iram(g_os_iram_softirq_start_statistic, vec_nr, time); |
| 425 | os_statistic_in_ddr(g_os_ddr_softirq_start_statistic, vec_nr, time); |
| 426 | os_statistic_info_update(); |
| 427 | } |
| 428 | |
| 429 | void zxic_trace_softirq_exit(u32 vec_nr) |
| 430 | { |
| 431 | unsigned long time; |
| 432 | if (!g_os_statistic_enable) |
| 433 | return ; |
| 434 | |
| 435 | time = OS_STATISTIC_TIME; |
| 436 | os_statistic_in_iram(g_os_iram_softirq_end_statistic, vec_nr, time); |
| 437 | os_statistic_in_ddr(g_os_ddr_softirq_end_statistic, vec_nr, time); |
| 438 | os_statistic_info_update(); |
| 439 | } |
| 440 | |
| 441 | void zxic_trace_timer_enter(void *func) |
| 442 | { |
| 443 | unsigned long time; |
| 444 | if (!g_os_statistic_enable) |
| 445 | return ; |
| 446 | |
| 447 | time = OS_STATISTIC_TIME; |
| 448 | os_statistic_in_iram(g_os_iram_timer_start_statistic, func, time); |
| 449 | os_statistic_in_ddr(g_os_ddr_timer_start_statistic, func, time); |
| 450 | os_statistic_info_update(); |
| 451 | } |
| 452 | |
| 453 | void zxic_trace_timer_exit(void *func) |
| 454 | { |
| 455 | unsigned long time; |
| 456 | if (!g_os_statistic_enable) |
| 457 | return ; |
| 458 | |
| 459 | time = OS_STATISTIC_TIME; |
| 460 | os_statistic_in_iram(g_os_iram_timer_end_statistic, func, time); |
| 461 | os_statistic_in_ddr(g_os_ddr_timer_end_statistic, func, time); |
| 462 | os_statistic_info_update(); |
| 463 | } |
| 464 | |
| 465 | #ifndef CONFIG_SYSTEM_CAP |
| 466 | |
| 467 | /** |
| 468 | * kernel_log_miss_point_show - show the log miss cnt |
| 469 | * @m: proc file structure |
| 470 | * @v: |
| 471 | * |
| 472 | * Returns -errno, or 0 for success. |
| 473 | */ |
| 474 | static int kernel_log_miss_point_show(struct seq_file *m, void *v) |
| 475 | { |
| 476 | int index = 0; |
| 477 | T_LogIram_Record *iram = NULL; |
| 478 | |
| 479 | iram = (T_LogIram_Record *)gL1w_LogMissPoint; |
| 480 | if (iram) |
| 481 | printk("kernel_log_miss_point_show iram = %x\n",iram); |
| 482 | else |
| 483 | { |
| 484 | printk("iram is NULL\n"); |
| 485 | return -1; |
| 486 | } |
| 487 | |
| 488 | seq_printf(m,"L1W phy: log miss point count is:\n"); |
| 489 | |
| 490 | for (; index < 2; index++) |
| 491 | { |
| 492 | if (index == 1) |
| 493 | seq_printf(m,"L1l phy: log miss point count is:\n"); |
| 494 | |
| 495 | if (iram != NULL) |
| 496 | { |
| 497 | seq_printf(m,"1. Due to allocMem fail count: %u\n", iram->no_mem); |
| 498 | seq_printf(m,"2. Due to multi thread conflict count: %u\n", iram->no_lock); |
| 499 | } |
| 500 | iram = (T_LogIram_Record *)gL11_LogMissPoint; |
| 501 | } |
| 502 | |
| 503 | seq_printf(m,"done\n"); |
| 504 | |
| 505 | return 0; |
| 506 | } |
| 507 | |
| 508 | /** |
| 509 | * cpumask_parse_user - open funution |
| 510 | * @inode: file inode |
| 511 | * @file: file descriptor |
| 512 | * |
| 513 | * Returns -errno, or 0 for success. |
| 514 | */ |
| 515 | static int kernel_log_tracker_open(struct inode *inode, struct file *file) |
| 516 | { |
| 517 | return single_open(file, kernel_log_miss_point_show, NULL); |
| 518 | } |
| 519 | |
| 520 | /** |
| 521 | * kernel_log_tracker_proc_fops - proc file ops |
| 522 | * @open: open the registed proc file. |
| 523 | * @read: read the registed proc file. |
| 524 | * @write: write to the registed proc file. |
| 525 | * |
| 526 | * Returns -errno, or 0 for success. |
| 527 | */ |
| 528 | static const struct file_operations kernel_log_tracker_proc_fops = { |
| 529 | .open = kernel_log_tracker_open, |
| 530 | .read = seq_read, |
| 531 | .write = NULL |
| 532 | }; |
| 533 | |
| 534 | #endif |
| 535 | |
| 536 | /******************************************************************************* |
| 537 | * ¹¦ÄÜÃèÊö: ¹ì¼£Í³¼Æµ½DDR |
| 538 | * ²ÎÊý˵Ã÷: |
| 539 | * (´«Èë²ÎÊý) iram_addr: µØÖ· |
| 540 | data: ʼþÏî |
| 541 | time: ʱ¼ä |
| 542 | * (´«³ö²ÎÊý) void |
| 543 | * ·µ »Ø Öµ: void |
| 544 | * ÆäËü˵Ã÷: ÎÞ |
| 545 | *******************************************************************************/ |
| 546 | int __init zxic_enable_trace(void) |
| 547 | { |
| 548 | struct timer_list timer; |
| 549 | struct task_struct *task; |
| 550 | |
| 551 | #ifdef IRAM_BASE_ADDR_VA |
| 552 | g_zxic_trace_apcpu_addr = IRAM_BASE_ADDR_LINUX_STATISTIC_APCPU; |
| 553 | #else |
| 554 | |
| 555 | g_zxic_trace_apcpu_addr = ioremap(IRAM_BASE_ADDR_LINUX_STATISTIC_APCPU, IRAM_BASE_LEN_LINUX_STATISTIC_APCPU); |
| 556 | #endif |
| 557 | |
| 558 | #ifndef CONFIG_SYSTEM_CAP |
| 559 | proc_create("kernel_log_tracker", 0, NULL, &kernel_log_tracker_proc_fops); |
| 560 | #endif |
| 561 | /* |
| 562 | init_timer(&timer); |
| 563 | timer.expires = jiffies + 40*HZ;//msecs_to_jiffies(40*1000);//ÑÓ³Ù40Ãë |
| 564 | timer.data = 0; |
| 565 | timer.function = os_statistic_delayed_work_timer_fn; |
| 566 | setup_timer(&timer, os_statistic_delayed_work_timer_fn, 0); |
| 567 | add_timer(&timer); |
| 568 | */ |
| 569 | //task = kthread_create(os_statistic_delayed_work_timer_fn, 0, "g_zxic_trace_sync_thread", 0); |
| 570 | //wake_up_process(task); |
| 571 | |
| 572 | return 0x0; |
| 573 | } |
| 574 | module_init(zxic_enable_trace); |
| 575 | |
| 576 | |
| 577 | |