internal.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* common and private utility for mtprof */
  2. #include <linux/seq_file.h>
  3. #include <linux/sched.h>
  4. #include <linux/cputime.h>
  5. #define SEQ_printf(m, x...) \
  6. do { \
  7. if (m) \
  8. seq_printf(m, x); \
  9. else \
  10. pr_err(x); \
  11. } while (0)
  12. #define MT_DEBUG_ENTRY(name) \
  13. static int mt_##name##_show(struct seq_file *m, void *v);\
  14. static ssize_t mt_##name##_write(struct file *filp, const char *ubuf, size_t cnt, loff_t *data);\
  15. static int mt_##name##_open(struct inode *inode, struct file *file) \
  16. { \
  17. return single_open(file, mt_##name##_show, inode->i_private); \
  18. } \
  19. \
  20. static const struct file_operations mt_##name##_fops = { \
  21. .open = mt_##name##_open, \
  22. .write = mt_##name##_write, \
  23. .read = seq_read, \
  24. .llseek = seq_lseek, \
  25. .release = single_release, \
  26. }; \
  27. void mt_##name##_switch(int on)
  28. /*
  29. * Ease the printing of nsec fields:
  30. */
  31. long long nsec_high(unsigned long long nsec);
  32. unsigned long nsec_low(unsigned long long nsec);
  33. long long usec_high(unsigned long long usec);
  34. unsigned long usec_low(unsigned long long usec);
  35. const char *isr_name(int irq);
  36. /* for bootprof.c */
  37. unsigned int gpt_boot_time(void);
  38. void mt_disable_uart(void);
  39. extern int printk_too_much_enable;
  40. /* for cputime */
  41. struct mt_proc_struct {
  42. int pid;
  43. int tgid;
  44. int index;
  45. u64 cputime;
  46. u64 cputime_init;
  47. u64 prof_start;
  48. u64 prof_end;
  49. u64 cost_cputime;
  50. u32 cputime_percen_6;
  51. u64 isr_time;
  52. u64 isr_time_init;
  53. int isr_count;
  54. struct mtk_isr_info *mtk_isr;
  55. cputime_t utime_init;
  56. cputime_t utime;
  57. cputime_t stime_init;
  58. cputime_t stime;
  59. char comm[TASK_COMM_LEN];
  60. struct mt_proc_struct *next;
  61. };
  62. struct mt_cpu_info {
  63. unsigned long long cpu_idletime_start;
  64. unsigned long long cpu_idletime_end;
  65. unsigned long long cpu_iowait_start;
  66. unsigned long long cpu_iowait_end;
  67. };
  68. extern struct mt_cpu_info *mt_cpu_info_head;
  69. extern int mt_cpu_num;
  70. extern struct mt_proc_struct *mt_proc_head;
  71. extern unsigned long long prof_start_ts, prof_end_ts, prof_dur_ts;
  72. extern bool boot_trace;
  73. void mt_task_times(struct task_struct *p, cputime_t *ut, cputime_t *st);
  74. unsigned long long mtprof_get_cpu_idle(int cpu);
  75. unsigned long long mtprof_get_cpu_iowait(int cpu);
  76. void start_record_task(void);
  77. void stop_record_task(void);
  78. void reset_record_task(void);