rt_ext.c 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * Copyright (C) 2016 MediaTek Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  11. * See http://www.gnu.org/licenses/gpl-2.0.html for more details.
  12. */
  13. /* sched: add rt exec info*/
  14. DEFINE_PER_CPU(u64, old_rt_time);
  15. DEFINE_PER_CPU(u64, init_rt_time);
  16. DEFINE_PER_CPU(u64, rt_period_time);
  17. DEFINE_PER_CPU(u64, rt_throttling_start);
  18. DEFINE_PER_CPU(u64, exec_delta_time);
  19. DEFINE_PER_CPU(u64, clock_task);
  20. DEFINE_PER_CPU(u64, update_curr_exec_start);
  21. DEFINE_PER_CPU(u64, pick_exec_start);
  22. DEFINE_PER_CPU(u64, sched_pick_exec_start);
  23. DEFINE_PER_CPU(u64, set_curr_exec_start);
  24. DEFINE_PER_CPU(u64, sched_set_curr_exec_start);
  25. DEFINE_PER_CPU(u64, update_exec_start);
  26. DEFINE_PER_CPU(u64, sched_update_exec_start);
  27. DEFINE_PER_CPU(struct task_struct, exec_task);
  28. /* sched: print __disable_runtime unthrottled */
  29. static inline void print_disable_runtime_unthrottle(struct rt_rq *rt_rq)
  30. {
  31. #ifdef CONFIG_RT_GROUP_SCHED
  32. struct rq *rq = rt_rq->rq;
  33. #else
  34. struct rq *rq = container_of(rt_rq, struct rq, rt);
  35. #endif
  36. rt_rq->rt_throttled = 0;
  37. printk_deferred("[name:rt&]sched: disable_runtime: RT throttling inactivated cpu=%d\n",
  38. cpu_of(rq));
  39. printk_deferred("[name:rt&]sched: cpu=%d, rt_time[%llu] rt_throttled=%d, rt_runtime[%llu]\n",
  40. cpu_of(rq),
  41. rt_rq->rt_time,
  42. rt_rq->rt_throttled,
  43. rt_rq->rt_runtime);
  44. }
  45. /* sched: print throttle info */
  46. static inline void print_rt_throttle_info(int cpu, struct rt_rq *rt_rq,
  47. u64 runtime_pre, u64 runtime)
  48. {
  49. /* sched: print throttle*/
  50. printk_deferred("[name:rt&]sched: initial rt_time %llu, start at %llu\n",
  51. per_cpu(init_rt_time, cpu),
  52. per_cpu(rt_period_time, cpu));
  53. printk_deferred("[name:rt&]sched: cpu=%d rt_time %llu <-> runtime[%llu -> %llu]",
  54. cpu, rt_rq->rt_time, runtime_pre, runtime);
  55. printk_deferred("exec_task[%d: %s] prio:%d exec_delta[%llu] clock[%llu] exec_start[%llu]\n",
  56. per_cpu(exec_task, cpu).pid,
  57. per_cpu(exec_task, cpu).comm,
  58. per_cpu(exec_task, cpu).prio,
  59. per_cpu(exec_delta_time, cpu),
  60. per_cpu(clock_task, cpu),
  61. per_cpu(update_exec_start, cpu));
  62. printk_deferred("[name:rt&]sched: update[%llu, %llu] pick[%llu, %llu] set_curr[%llu, %llu]\n",
  63. per_cpu(update_exec_start, cpu),
  64. per_cpu(sched_update_exec_start, cpu),
  65. per_cpu(pick_exec_start, cpu),
  66. per_cpu(sched_pick_exec_start, cpu),
  67. per_cpu(set_curr_exec_start, cpu),
  68. per_cpu(sched_set_curr_exec_start, cpu));
  69. }
  70. /* sched: update rt exec info*/
  71. static inline void update_rt_exec_info(struct task_struct *curr,
  72. u64 delta_exec, struct rq *rq)
  73. {
  74. per_cpu(exec_task, rq->cpu).pid = curr->pid;
  75. per_cpu(exec_task, rq->cpu).prio = curr->prio;
  76. strncpy(per_cpu(exec_task, rq->cpu).comm,
  77. curr->comm, sizeof(per_cpu(exec_task, rq->cpu).comm));
  78. per_cpu(exec_delta_time, rq->cpu) = delta_exec;
  79. per_cpu(clock_task, rq->cpu) = rq->clock_task;
  80. per_cpu(update_exec_start, rq->cpu) = curr->se.exec_start;
  81. }