gpu_scheduler_trace.h 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /*
  2. * Copyright 2017 Advanced Micro Devices, Inc.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in
  12. * all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
  18. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  19. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
  20. * OTHER DEALINGS IN THE SOFTWARE.
  21. *
  22. */
  23. #if !defined(_GPU_SCHED_TRACE_H_) || defined(TRACE_HEADER_MULTI_READ)
  24. #define _GPU_SCHED_TRACE_H_
  25. #include <linux/stringify.h>
  26. #include <linux/types.h>
  27. #include <linux/tracepoint.h>
  28. #undef TRACE_SYSTEM
  29. #define TRACE_SYSTEM gpu_scheduler
  30. #define TRACE_INCLUDE_FILE gpu_scheduler_trace
  31. /**
  32. * DOC: uAPI trace events
  33. *
  34. * ``drm_sched_job_queue``, ``drm_sched_job_run``, ``drm_sched_job_add_dep``,
  35. * ``drm_sched_job_done`` and ``drm_sched_job_unschedulable`` are considered
  36. * stable uAPI.
  37. *
  38. * Common trace events attributes:
  39. *
  40. * * ``dev`` - the dev_name() of the device running the job.
  41. *
  42. * * ``ring`` - the hardware ring running the job. Together with ``dev`` it
  43. * uniquely identifies where the job is going to be executed.
  44. *
  45. * * ``fence`` - the &struct dma_fence.context and the &struct dma_fence.seqno of
  46. * &struct drm_sched_fence.finished
  47. *
  48. * All the events depends on drm_sched_job_arm() having been called already for
  49. * the job because they use &struct drm_sched_job.sched or
  50. * &struct drm_sched_job.s_fence.
  51. */
  52. DECLARE_EVENT_CLASS(drm_sched_job,
  53. TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
  54. TP_ARGS(sched_job, entity),
  55. TP_STRUCT__entry(
  56. __string(name, sched_job->sched->name)
  57. __field(u32, job_count)
  58. __field(int, hw_job_count)
  59. __string(dev, dev_name(sched_job->sched->dev))
  60. __field(u64, fence_context)
  61. __field(u64, fence_seqno)
  62. __field(u64, client_id)
  63. ),
  64. TP_fast_assign(
  65. __assign_str(name);
  66. __entry->job_count = spsc_queue_count(&entity->job_queue);
  67. __entry->hw_job_count = atomic_read(
  68. &sched_job->sched->credit_count);
  69. __assign_str(dev);
  70. __entry->fence_context = sched_job->s_fence->finished.context;
  71. __entry->fence_seqno = sched_job->s_fence->finished.seqno;
  72. __entry->client_id = sched_job->s_fence->drm_client_id;
  73. ),
  74. TP_printk("dev=%s, fence=%llu:%llu, ring=%s, job count:%u, hw job count:%d, client_id:%llu",
  75. __get_str(dev),
  76. __entry->fence_context, __entry->fence_seqno, __get_str(name),
  77. __entry->job_count, __entry->hw_job_count, __entry->client_id)
  78. );
  79. DEFINE_EVENT(drm_sched_job, drm_sched_job_queue,
  80. TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
  81. TP_ARGS(sched_job, entity)
  82. );
  83. DEFINE_EVENT(drm_sched_job, drm_sched_job_run,
  84. TP_PROTO(struct drm_sched_job *sched_job, struct drm_sched_entity *entity),
  85. TP_ARGS(sched_job, entity)
  86. );
  87. TRACE_EVENT(drm_sched_job_done,
  88. TP_PROTO(struct drm_sched_fence *fence),
  89. TP_ARGS(fence),
  90. TP_STRUCT__entry(
  91. __field(u64, fence_context)
  92. __field(u64, fence_seqno)
  93. ),
  94. TP_fast_assign(
  95. __entry->fence_context = fence->finished.context;
  96. __entry->fence_seqno = fence->finished.seqno;
  97. ),
  98. TP_printk("fence=%llu:%llu signaled",
  99. __entry->fence_context, __entry->fence_seqno)
  100. );
  101. TRACE_EVENT(drm_sched_job_add_dep,
  102. TP_PROTO(struct drm_sched_job *sched_job, struct dma_fence *fence),
  103. TP_ARGS(sched_job, fence),
  104. TP_STRUCT__entry(
  105. __field(u64, fence_context)
  106. __field(u64, fence_seqno)
  107. __field(u64, ctx)
  108. __field(u64, seqno)
  109. ),
  110. TP_fast_assign(
  111. __entry->fence_context = sched_job->s_fence->finished.context;
  112. __entry->fence_seqno = sched_job->s_fence->finished.seqno;
  113. __entry->ctx = fence->context;
  114. __entry->seqno = fence->seqno;
  115. ),
  116. TP_printk("fence=%llu:%llu depends on fence=%llu:%llu",
  117. __entry->fence_context, __entry->fence_seqno,
  118. __entry->ctx, __entry->seqno)
  119. );
  120. TRACE_EVENT(drm_sched_job_unschedulable,
  121. TP_PROTO(struct drm_sched_job *sched_job, struct dma_fence *fence),
  122. TP_ARGS(sched_job, fence),
  123. TP_STRUCT__entry(
  124. __field(u64, fence_context)
  125. __field(u64, fence_seqno)
  126. __field(u64, ctx)
  127. __field(u64, seqno)
  128. ),
  129. TP_fast_assign(
  130. __entry->fence_context = sched_job->s_fence->finished.context;
  131. __entry->fence_seqno = sched_job->s_fence->finished.seqno;
  132. __entry->ctx = fence->context;
  133. __entry->seqno = fence->seqno;
  134. ),
  135. TP_printk("fence=%llu:%llu depends on unsignalled fence=%llu:%llu",
  136. __entry->fence_context, __entry->fence_seqno,
  137. __entry->ctx, __entry->seqno)
  138. );
  139. #endif /* _GPU_SCHED_TRACE_H_ */
  140. /* This part must be outside protection */
  141. #undef TRACE_INCLUDE_PATH
  142. #define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/scheduler
  143. #include <trace/define_trace.h>