<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi Chris,</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>You said that this kind of scene also existed in other source code, these has same method.</span></div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<div>in amdgpu_trace.h file, <span>this usage case is exits in amdgpu driver.</span></div>
<div>likes TRACE_EVENT(amdgpu_cs_ioctl) -> timeline :</div>
<div>
<div>            TP_printk("sched_job=%llu, <b>timeline</b>=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",                                                     <br>
</div>
<div>                      __entry->sched_job_id, <b>__get_str(timeline)</b>, __entry->context,                                                                                                        <br>
</div>
<span>                      __entry->seqno, __get_str(ring), __entry->num_ibs) </span></div>
<div><span>and do you have other better way to do it?</span></div>
<div><span>thanks.</span></div>
<div><span></span></div>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Best Regards,<br>
Kevin</div>
<div id="appendonsend"></div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Koenig, Christian <Christian.Koenig@amd.com><br>
<b>Sent:</b> Wednesday, October 16, 2019 8:15 PM<br>
<b>To:</b> Wang, Kevin(Yang) <Kevin1.Wang@amd.com>; amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Subject:</b> Re: [PATCH] drm/amdgpu: fix amdgpu trace event print string format error</font>
<div> </div>
</div>
<div style="background-color:#FFFFFF">
<div class="x_moz-cite-prefix">Hi Kevin,<br>
<br>
well that copies the string into the ring buffer every time the trace event is called which is not necessary a good idea for a constant string.<br>
<br>
Can't we avoid that somehow?<br>
<br>
Thanks,<br>
Christian.<br>
<br>
Am 16.10.19 um 14:01 schrieb Wang, Kevin(Yang):<br>
</div>
<blockquote type="cite">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
add <a id="OWAAM231809" class="x__1OtrSZdhKXVv3UhaivrdJ4 x_mention x_ms-bgc-nlr x_ms-fcl-b" href="mailto:Christian.Koenig@amd.com">
@Koenig, Christian</a>,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
could you help me review it?</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
Best Regards,<br>
Kevin</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif; font-size:12pt; color:rgb(0,0,0)">
<br>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Wang, Kevin(Yang)
<a class="x_moz-txt-link-rfc2396E" href="mailto:Kevin1.Wang@amd.com"><Kevin1.Wang@amd.com></a><br>
<b>Sent:</b> Wednesday, October 16, 2019 11:06 AM<br>
<b>To:</b> <a class="x_moz-txt-link-abbreviated" href="mailto:amd-gfx@lists.freedesktop.org">
amd-gfx@lists.freedesktop.org</a> <a class="x_moz-txt-link-rfc2396E" href="mailto:amd-gfx@lists.freedesktop.org">
<amd-gfx@lists.freedesktop.org></a><br>
<b>Cc:</b> Wang, Kevin(Yang) <a class="x_moz-txt-link-rfc2396E" href="mailto:Kevin1.Wang@amd.com">
<Kevin1.Wang@amd.com></a><br>
<b>Subject:</b> [PATCH] drm/amdgpu: fix amdgpu trace event print string format error</font>
<div> </div>
</div>
<div class="x_BodyFragment"><font size="2"><span style="font-size:11pt">
<div class="x_PlainText">the trace event print string format error.<br>
(use integer type to handle string)<br>
<br>
before:<br>
amdgpu_test_kev-1556  [002]   138.508781: amdgpu_cs_ioctl:<br>
sched_job=8, timeline=gfx_0.0.0, context=177, seqno=1,<br>
ring_name=ffff94d01c207bf0, num_ibs=2<br>
<br>
after:<br>
amdgpu_test_kev-1506  [004]   370.703783: amdgpu_cs_ioctl:<br>
sched_job=12, timeline=gfx_0.0.0, context=234, seqno=2,<br>
ring_name=gfx_0.0.0, num_ibs=1<br>
<br>
change trace event list:<br>
1.amdgpu_cs_ioctl<br>
2.amdgpu_sched_run_job<br>
3.amdgpu_ib_pipe_sync<br>
<br>
Signed-off-by: Kevin Wang <a class="x_moz-txt-link-rfc2396E" href="mailto:kevin1.wang@amd.com">
<kevin1.wang@amd.com></a><br>
---<br>
 drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h | 18 +++++++++---------<br>
 1 file changed, 9 insertions(+), 9 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h<br>
index 8227ebd0f511..f940526c5889 100644<br>
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h<br>
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_trace.h<br>
@@ -170,7 +170,7 @@ TRACE_EVENT(amdgpu_cs_ioctl,<br>
                              __field(unsigned int, context)<br>
                              __field(unsigned int, seqno)<br>
                              __field(struct dma_fence *, fence)<br>
-                            __field(char *, ring_name)<br>
+                            __string(ring, to_amdgpu_ring(job->base.sched)->name)<br>
                              __field(u32, num_ibs)<br>
                              ),<br>
 <br>
@@ -179,12 +179,12 @@ TRACE_EVENT(amdgpu_cs_ioctl,<br>
                            __assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))<br>
                            __entry->context = job->base.s_fence->finished.context;<br>
                            __entry->seqno = job->base.s_fence->finished.seqno;<br>
-                          __entry->ring_name = to_amdgpu_ring(job->base.sched)->name;<br>
+                          __assign_str(ring, to_amdgpu_ring(job->base.sched)->name)<br>
                            __entry->num_ibs = job->num_ibs;<br>
                            ),<br>
             TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",<br>
                       __entry->sched_job_id, __get_str(timeline), __entry->context,<br>
-                     __entry->seqno, __entry->ring_name, __entry->num_ibs)<br>
+                     __entry->seqno, __get_str(ring), __entry->num_ibs)<br>
 );<br>
 <br>
 TRACE_EVENT(amdgpu_sched_run_job,<br>
@@ -195,7 +195,7 @@ TRACE_EVENT(amdgpu_sched_run_job,<br>
                              __string(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))<br>
                              __field(unsigned int, context)<br>
                              __field(unsigned int, seqno)<br>
-                            __field(char *, ring_name)<br>
+                            __string(ring, to_amdgpu_ring(job->base.sched)->name)<br>
                              __field(u32, num_ibs)<br>
                              ),<br>
 <br>
@@ -204,12 +204,12 @@ TRACE_EVENT(amdgpu_sched_run_job,<br>
                            __assign_str(timeline, AMDGPU_JOB_GET_TIMELINE_NAME(job))<br>
                            __entry->context = job->base.s_fence->finished.context;<br>
                            __entry->seqno = job->base.s_fence->finished.seqno;<br>
-                          __entry->ring_name = to_amdgpu_ring(job->base.sched)->name;<br>
+                          __assign_str(ring, to_amdgpu_ring(job->base.sched)->name)<br>
                            __entry->num_ibs = job->num_ibs;<br>
                            ),<br>
             TP_printk("sched_job=%llu, timeline=%s, context=%u, seqno=%u, ring_name=%s, num_ibs=%u",<br>
                       __entry->sched_job_id, __get_str(timeline), __entry->context,<br>
-                     __entry->seqno, __entry->ring_name, __entry->num_ibs)<br>
+                     __entry->seqno, __get_str(ring), __entry->num_ibs)<br>
 );<br>
 <br>
 <br>
@@ -473,7 +473,7 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,<br>
             TP_PROTO(struct amdgpu_job *sched_job, struct dma_fence *fence),<br>
             TP_ARGS(sched_job, fence),<br>
             TP_STRUCT__entry(<br>
-                            __field(const char *,name)<br>
+                            __string(ring, sched_job->base.sched->name);<br>
                              __field(uint64_t, id)<br>
                              __field(struct dma_fence *, fence)<br>
                              __field(uint64_t, ctx)<br>
@@ -481,14 +481,14 @@ TRACE_EVENT(amdgpu_ib_pipe_sync,<br>
                              ),<br>
 <br>
             TP_fast_assign(<br>
-                          __entry->name = sched_job->base.sched->name;<br>
+                          __assign_str(ring, sched_job->base.sched->name)<br>
                            __entry->id = sched_job->base.id;<br>
                            __entry->fence = fence;<br>
                            __entry->ctx = fence->context;<br>
                            __entry->seqno = fence->seqno;<br>
                            ),<br>
             TP_printk("job ring=%s, id=%llu, need pipe sync to fence=%p, context=%llu, seq=%u",<br>
-                     __entry->name, __entry->id,<br>
+                     __get_str(ring), __entry->id,<br>
                       __entry->fence, __entry->ctx,<br>
                       __entry->seqno)<br>
 );<br>
-- <br>
2.17.1<br>
<br>
</div>
</span></font></div>
</blockquote>
<br>
</div>
</body>
</html>