* [PATCH 0/3] drm/xe: Fix races on fdinfo
@ 2024-10-26 6:26 Lucas De Marchi
2024-10-26 6:26 ` [PATCH 1/3] drm/xe: Add trace to lrc timestamp update Lucas De Marchi
` (5 more replies)
0 siblings, 6 replies; 11+ messages in thread
From: Lucas De Marchi @ 2024-10-26 6:26 UTC (permalink / raw)
To: intel-gfx; +Cc: Jonathan Cavitt, Umesh Nerlige Ramappa, Lucas De Marchi
The current reading of engine utilization has same races. This should
fix most of them while also drastically reducing the update rate needed
on "normal apps".
I left tests/xe_drm_fdinfo running on 2 systems and saw no failures
after 100 iterations.
Lucas De Marchi (3):
drm/xe: Add trace to lrc timestamp update
drm/xe: Accumulate exec queue timestamp on destroy
drm/xe: Stop accumulating LRC timestamp on job_free
drivers/gpu/drm/xe/Makefile | 1 +
drivers/gpu/drm/xe/xe_exec_queue.c | 14 ++++++++
drivers/gpu/drm/xe/xe_guc_submit.c | 2 --
drivers/gpu/drm/xe/xe_lrc.c | 3 ++
drivers/gpu/drm/xe/xe_trace_lrc.c | 9 ++++++
drivers/gpu/drm/xe/xe_trace_lrc.h | 52 ++++++++++++++++++++++++++++++
6 files changed, 79 insertions(+), 2 deletions(-)
create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.c
create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.h
--
2.47.0
^ permalink raw reply [flat|nested] 11+ messages in thread* [PATCH 1/3] drm/xe: Add trace to lrc timestamp update 2024-10-26 6:26 [PATCH 0/3] drm/xe: Fix races on fdinfo Lucas De Marchi @ 2024-10-26 6:26 ` Lucas De Marchi 2024-10-28 12:40 ` Nirmoy Das 2024-10-26 6:26 ` [PATCH 2/3] drm/xe: Accumulate exec queue timestamp on destroy Lucas De Marchi ` (4 subsequent siblings) 5 siblings, 1 reply; 11+ messages in thread From: Lucas De Marchi @ 2024-10-26 6:26 UTC (permalink / raw) To: intel-gfx; +Cc: Jonathan Cavitt, Umesh Nerlige Ramappa, Lucas De Marchi Help debugging when LRC timestamp is updated for a exec queue. Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> --- drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_lrc.c | 3 ++ drivers/gpu/drm/xe/xe_trace_lrc.c | 9 ++++++ drivers/gpu/drm/xe/xe_trace_lrc.h | 52 +++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.c create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.h diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile index bc7a04ce69fd..21d69935c336 100644 --- a/drivers/gpu/drm/xe/Makefile +++ b/drivers/gpu/drm/xe/Makefile @@ -101,6 +101,7 @@ xe-y += xe_bb.o \ xe_trace.o \ xe_trace_bo.o \ xe_trace_guc.o \ + xe_trace_lrc.o \ xe_ttm_sys_mgr.o \ xe_ttm_stolen_mgr.o \ xe_ttm_vram_mgr.o \ diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c index 4f64c7f4e68d..4b65da77c6e0 100644 --- a/drivers/gpu/drm/xe/xe_lrc.c +++ b/drivers/gpu/drm/xe/xe_lrc.c @@ -25,6 +25,7 @@ #include "xe_map.h" #include "xe_memirq.h" #include "xe_sriov.h" +#include "xe_trace_lrc.h" #include "xe_vm.h" #include "xe_wa.h" @@ -1758,5 +1759,7 @@ u32 xe_lrc_update_timestamp(struct xe_lrc *lrc, u32 *old_ts) lrc->ctx_timestamp = xe_lrc_ctx_timestamp(lrc); + trace_xe_lrc_update_timestamp(lrc, *old_ts); + return lrc->ctx_timestamp; } diff --git a/drivers/gpu/drm/xe/xe_trace_lrc.c b/drivers/gpu/drm/xe/xe_trace_lrc.c new file mode 100644 index 000000000000..ab9b7e2970bc --- /dev/null +++ b/drivers/gpu/drm/xe/xe_trace_lrc.c @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright © 2024 Intel Corporation + */ + +#ifndef __CHECKER__ +#define CREATE_TRACE_POINTS +#include "xe_trace_lrc.h" +#endif diff --git a/drivers/gpu/drm/xe/xe_trace_lrc.h b/drivers/gpu/drm/xe/xe_trace_lrc.h new file mode 100644 index 000000000000..5c669a0b2180 --- /dev/null +++ b/drivers/gpu/drm/xe/xe_trace_lrc.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright © 2024 Intel Corporation + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM xe + +#if !defined(_XE_TRACE_LRC_H_) || defined(TRACE_HEADER_MULTI_READ) +#define _XE_TRACE_LRC_H_ + +#include <linux/tracepoint.h> +#include <linux/types.h> + +#include "xe_gt_types.h" +#include "xe_lrc.h" +#include "xe_lrc_types.h" + +#define __dev_name_lrc(lrc) dev_name(gt_to_xe((lrc)->fence_ctx.gt)->drm.dev) + +TRACE_EVENT(xe_lrc_update_timestamp, + TP_PROTO(struct xe_lrc *lrc, uint32_t old), + TP_ARGS(lrc, old), + TP_STRUCT__entry( + __field(struct xe_lrc *, lrc) + __field(u32, old) + __field(u32, new) + __string(name, lrc->fence_ctx.name) + __string(device_id, __dev_name_lrc(lrc)) + ), + + TP_fast_assign( + __entry->lrc = lrc; + __entry->old = old; + __entry->new = lrc->ctx_timestamp; + __assign_str(name); + __assign_str(device_id); + ), + TP_printk("lrc=:%p lrc->name=%s old=%u new=%u device_id:%s", + __entry->lrc, __get_str(name), + __entry->old, __entry->new, + __get_str(device_id)) +); + +#endif + +/* This part must be outside protection */ +#undef TRACE_INCLUDE_PATH +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/xe +#define TRACE_INCLUDE_FILE xe_trace_lrc +#include <trace/define_trace.h> -- 2.47.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 1/3] drm/xe: Add trace to lrc timestamp update 2024-10-26 6:26 ` [PATCH 1/3] drm/xe: Add trace to lrc timestamp update Lucas De Marchi @ 2024-10-28 12:40 ` Nirmoy Das 0 siblings, 0 replies; 11+ messages in thread From: Nirmoy Das @ 2024-10-28 12:40 UTC (permalink / raw) To: Lucas De Marchi, intel-gfx; +Cc: Jonathan Cavitt, Umesh Nerlige Ramappa On 10/26/2024 8:26 AM, Lucas De Marchi wrote: > Help debugging when LRC timestamp is updated for a exec queue. > > Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> Reviewed-by: Nirmoy Das <nirmoy.das@intel.com> > --- > drivers/gpu/drm/xe/Makefile | 1 + > drivers/gpu/drm/xe/xe_lrc.c | 3 ++ > drivers/gpu/drm/xe/xe_trace_lrc.c | 9 ++++++ > drivers/gpu/drm/xe/xe_trace_lrc.h | 52 +++++++++++++++++++++++++++++++ > 4 files changed, 65 insertions(+) > create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.c > create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.h > > diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile > index bc7a04ce69fd..21d69935c336 100644 > --- a/drivers/gpu/drm/xe/Makefile > +++ b/drivers/gpu/drm/xe/Makefile > @@ -101,6 +101,7 @@ xe-y += xe_bb.o \ > xe_trace.o \ > xe_trace_bo.o \ > xe_trace_guc.o \ > + xe_trace_lrc.o \ > xe_ttm_sys_mgr.o \ > xe_ttm_stolen_mgr.o \ > xe_ttm_vram_mgr.o \ > diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c > index 4f64c7f4e68d..4b65da77c6e0 100644 > --- a/drivers/gpu/drm/xe/xe_lrc.c > +++ b/drivers/gpu/drm/xe/xe_lrc.c > @@ -25,6 +25,7 @@ > #include "xe_map.h" > #include "xe_memirq.h" > #include "xe_sriov.h" > +#include "xe_trace_lrc.h" > #include "xe_vm.h" > #include "xe_wa.h" > > @@ -1758,5 +1759,7 @@ u32 xe_lrc_update_timestamp(struct xe_lrc *lrc, u32 *old_ts) > > lrc->ctx_timestamp = xe_lrc_ctx_timestamp(lrc); > > + trace_xe_lrc_update_timestamp(lrc, *old_ts); > + > return lrc->ctx_timestamp; > } > diff --git a/drivers/gpu/drm/xe/xe_trace_lrc.c b/drivers/gpu/drm/xe/xe_trace_lrc.c > new file mode 100644 > index 000000000000..ab9b7e2970bc > --- /dev/null > +++ b/drivers/gpu/drm/xe/xe_trace_lrc.c > @@ -0,0 +1,9 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright © 2024 Intel Corporation > + */ > + > +#ifndef __CHECKER__ > +#define CREATE_TRACE_POINTS > +#include "xe_trace_lrc.h" > +#endif > diff --git a/drivers/gpu/drm/xe/xe_trace_lrc.h b/drivers/gpu/drm/xe/xe_trace_lrc.h > new file mode 100644 > index 000000000000..5c669a0b2180 > --- /dev/null > +++ b/drivers/gpu/drm/xe/xe_trace_lrc.h > @@ -0,0 +1,52 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Copyright © 2024 Intel Corporation > + */ > + > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM xe > + > +#if !defined(_XE_TRACE_LRC_H_) || defined(TRACE_HEADER_MULTI_READ) > +#define _XE_TRACE_LRC_H_ > + > +#include <linux/tracepoint.h> > +#include <linux/types.h> > + > +#include "xe_gt_types.h" > +#include "xe_lrc.h" > +#include "xe_lrc_types.h" > + > +#define __dev_name_lrc(lrc) dev_name(gt_to_xe((lrc)->fence_ctx.gt)->drm.dev) > + > +TRACE_EVENT(xe_lrc_update_timestamp, > + TP_PROTO(struct xe_lrc *lrc, uint32_t old), > + TP_ARGS(lrc, old), > + TP_STRUCT__entry( > + __field(struct xe_lrc *, lrc) > + __field(u32, old) > + __field(u32, new) > + __string(name, lrc->fence_ctx.name) > + __string(device_id, __dev_name_lrc(lrc)) > + ), > + > + TP_fast_assign( > + __entry->lrc = lrc; > + __entry->old = old; > + __entry->new = lrc->ctx_timestamp; > + __assign_str(name); > + __assign_str(device_id); > + ), > + TP_printk("lrc=:%p lrc->name=%s old=%u new=%u device_id:%s", > + __entry->lrc, __get_str(name), > + __entry->old, __entry->new, > + __get_str(device_id)) > +); > + > +#endif > + > +/* This part must be outside protection */ > +#undef TRACE_INCLUDE_PATH > +#undef TRACE_INCLUDE_FILE > +#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/xe > +#define TRACE_INCLUDE_FILE xe_trace_lrc > +#include <trace/define_trace.h> ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 2/3] drm/xe: Accumulate exec queue timestamp on destroy 2024-10-26 6:26 [PATCH 0/3] drm/xe: Fix races on fdinfo Lucas De Marchi 2024-10-26 6:26 ` [PATCH 1/3] drm/xe: Add trace to lrc timestamp update Lucas De Marchi @ 2024-10-26 6:26 ` Lucas De Marchi 2024-10-28 12:46 ` Nirmoy Das 2024-10-26 6:26 ` [PATCH 3/3] drm/xe: Stop accumulating LRC timestamp on job_free Lucas De Marchi ` (3 subsequent siblings) 5 siblings, 1 reply; 11+ messages in thread From: Lucas De Marchi @ 2024-10-26 6:26 UTC (permalink / raw) To: intel-gfx; +Cc: Jonathan Cavitt, Umesh Nerlige Ramappa, Lucas De Marchi When the exec queue is destroyed, there's a race between a query to the fdinfo and the exec queue value being updated: after the destroy ioctl, if the fdinfo is queried before a call to guc_exec_queue_free_job(), the wrong utilization is reported: it's not accumulated on the query since the queue was removed from the array, and the value wasn't updated yet by the free_job(). Explicitly accumulate the engine utilization so the right value is visible after the ioctl return. Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2667 Cc: Jonathan Cavitt <jonathan.cavitt@intel.com> Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> --- drivers/gpu/drm/xe/xe_exec_queue.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c index d098d2dd1b2d..b15ca84b2422 100644 --- a/drivers/gpu/drm/xe/xe_exec_queue.c +++ b/drivers/gpu/drm/xe/xe_exec_queue.c @@ -829,6 +829,14 @@ int xe_exec_queue_destroy_ioctl(struct drm_device *dev, void *data, xe_exec_queue_kill(q); + /* + * After killing and destroying the exec queue, make sure userspace has + * an updated view of the run ticks, regardless if this was the last + * ref: since the exec queue is removed from xef->exec_queue.xa, a + * query to fdinfo after this returns could not account for this load. + */ + xe_exec_queue_update_run_ticks(q); + trace_xe_exec_queue_close(q); xe_exec_queue_put(q); -- 2.47.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 2/3] drm/xe: Accumulate exec queue timestamp on destroy 2024-10-26 6:26 ` [PATCH 2/3] drm/xe: Accumulate exec queue timestamp on destroy Lucas De Marchi @ 2024-10-28 12:46 ` Nirmoy Das 0 siblings, 0 replies; 11+ messages in thread From: Nirmoy Das @ 2024-10-28 12:46 UTC (permalink / raw) To: Lucas De Marchi, intel-gfx; +Cc: Jonathan Cavitt, Umesh Nerlige Ramappa On 10/26/2024 8:26 AM, Lucas De Marchi wrote: > When the exec queue is destroyed, there's a race between a query to the > fdinfo and the exec queue value being updated: after the destroy ioctl, > if the fdinfo is queried before a call to guc_exec_queue_free_job(), > the wrong utilization is reported: it's not accumulated on the query > since the queue was removed from the array, and the value wasn't updated > yet by the free_job(). > > Explicitly accumulate the engine utilization so the right value is > visible after the ioctl return. > > Link: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/2667 > Cc: Jonathan Cavitt <jonathan.cavitt@intel.com> > Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> LGTM Reviewed-by: Nirmoy Das <nirmoy.das@intel.com> > --- > drivers/gpu/drm/xe/xe_exec_queue.c | 8 ++++++++ > 1 file changed, 8 insertions(+) > > diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c > index d098d2dd1b2d..b15ca84b2422 100644 > --- a/drivers/gpu/drm/xe/xe_exec_queue.c > +++ b/drivers/gpu/drm/xe/xe_exec_queue.c > @@ -829,6 +829,14 @@ int xe_exec_queue_destroy_ioctl(struct drm_device *dev, void *data, > > xe_exec_queue_kill(q); > > + /* > + * After killing and destroying the exec queue, make sure userspace has > + * an updated view of the run ticks, regardless if this was the last > + * ref: since the exec queue is removed from xef->exec_queue.xa, a > + * query to fdinfo after this returns could not account for this load. > + */ > + xe_exec_queue_update_run_ticks(q); > + > trace_xe_exec_queue_close(q); > xe_exec_queue_put(q); > ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 3/3] drm/xe: Stop accumulating LRC timestamp on job_free 2024-10-26 6:26 [PATCH 0/3] drm/xe: Fix races on fdinfo Lucas De Marchi 2024-10-26 6:26 ` [PATCH 1/3] drm/xe: Add trace to lrc timestamp update Lucas De Marchi 2024-10-26 6:26 ` [PATCH 2/3] drm/xe: Accumulate exec queue timestamp on destroy Lucas De Marchi @ 2024-10-26 6:26 ` Lucas De Marchi 2024-10-28 15:39 ` ✗ Fi.CI.CHECKPATCH: warning for drm/xe: Fix races on fdinfo Patchwork ` (2 subsequent siblings) 5 siblings, 0 replies; 11+ messages in thread From: Lucas De Marchi @ 2024-10-26 6:26 UTC (permalink / raw) To: intel-gfx; +Cc: Jonathan Cavitt, Umesh Nerlige Ramappa, Lucas De Marchi The exec queue timestamp is only really useful when it's being queried through the fdinfo. There's no need to update it so often, on every job_free. Tracing a simple app like vkcube running shows an update rate of ~ 120Hz. The update on job_free() is used to cover a gap: if exec queue is created and destroyed rapidily, before a new query, the timestamp still needs to be accumulated and accounted on the xef. Initial implementation in commit 6109f24f87d7 ("drm/xe: Add helper to accumulate exec queue runtime") couldn't do it on the exec_queue_fini since the xef could be gone at that point. However since commit ce8c161cbad4 ("drm/xe: Add ref counting for xe_file") the xef is refcounted and the exec queue has a reference. Improve the fix in commit 2149ded63079 ("drm/xe: Fix use after free when client stats are captured") by reducing the frequency in which the update is needed. Fixes: 2149ded63079 ("drm/xe: Fix use after free when client stats are captured") Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> --- drivers/gpu/drm/xe/xe_exec_queue.c | 6 ++++++ drivers/gpu/drm/xe/xe_guc_submit.c | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/xe/xe_exec_queue.c b/drivers/gpu/drm/xe/xe_exec_queue.c index b15ca84b2422..bc2fc917e0de 100644 --- a/drivers/gpu/drm/xe/xe_exec_queue.c +++ b/drivers/gpu/drm/xe/xe_exec_queue.c @@ -260,8 +260,14 @@ void xe_exec_queue_fini(struct xe_exec_queue *q) { int i; + /* + * Before releasing our ref to lrc and xef, accumulate our run ticks + */ + xe_exec_queue_update_run_ticks(q); + for (i = 0; i < q->width; ++i) xe_lrc_put(q->lrc[i]); + __xe_exec_queue_free(q); } diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c index e5d7c767a744..ebe4665d9159 100644 --- a/drivers/gpu/drm/xe/xe_guc_submit.c +++ b/drivers/gpu/drm/xe/xe_guc_submit.c @@ -747,8 +747,6 @@ static void guc_exec_queue_free_job(struct drm_sched_job *drm_job) { struct xe_sched_job *job = to_xe_sched_job(drm_job); - xe_exec_queue_update_run_ticks(job->q); - trace_xe_sched_job_free(job); xe_sched_job_put(job); } -- 2.47.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* ✗ Fi.CI.CHECKPATCH: warning for drm/xe: Fix races on fdinfo 2024-10-26 6:26 [PATCH 0/3] drm/xe: Fix races on fdinfo Lucas De Marchi ` (2 preceding siblings ...) 2024-10-26 6:26 ` [PATCH 3/3] drm/xe: Stop accumulating LRC timestamp on job_free Lucas De Marchi @ 2024-10-28 15:39 ` Patchwork 2024-10-28 15:39 ` ✗ Fi.CI.SPARSE: " Patchwork 2024-10-28 15:43 ` ✓ Fi.CI.BAT: success " Patchwork 5 siblings, 0 replies; 11+ messages in thread From: Patchwork @ 2024-10-28 15:39 UTC (permalink / raw) To: Lucas De Marchi; +Cc: intel-gfx == Series Details == Series: drm/xe: Fix races on fdinfo URL : https://patchwork.freedesktop.org/series/140538/ State : warning == Summary == Error: dim checkpatch failed be111ababfbe drm/xe: Add trace to lrc timestamp update -:44: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating? #44: new file mode 100644 -:87: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #87: FILE: drivers/gpu/drm/xe/xe_trace_lrc.h:24: + TP_STRUCT__entry( -:95: CHECK:OPEN_ENDED_LINE: Lines should not end with a '(' #95: FILE: drivers/gpu/drm/xe/xe_trace_lrc.h:32: + TP_fast_assign( -:113: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #113: FILE: drivers/gpu/drm/xe/xe_trace_lrc.h:50: +#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/xe ^ -:113: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #113: FILE: drivers/gpu/drm/xe/xe_trace_lrc.h:50: +#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/xe ^ -:113: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #113: FILE: drivers/gpu/drm/xe/xe_trace_lrc.h:50: +#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/xe ^ -:113: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #113: FILE: drivers/gpu/drm/xe/xe_trace_lrc.h:50: +#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/xe ^ -:113: CHECK:SPACING: spaces preferred around that '/' (ctx:VxV) #113: FILE: drivers/gpu/drm/xe/xe_trace_lrc.h:50: +#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/xe ^ total: 0 errors, 1 warnings, 7 checks, 82 lines checked d88c0ee83457 drm/xe: Accumulate exec queue timestamp on destroy 8a635cead973 drm/xe: Stop accumulating LRC timestamp on job_free ^ permalink raw reply [flat|nested] 11+ messages in thread
* ✗ Fi.CI.SPARSE: warning for drm/xe: Fix races on fdinfo 2024-10-26 6:26 [PATCH 0/3] drm/xe: Fix races on fdinfo Lucas De Marchi ` (3 preceding siblings ...) 2024-10-28 15:39 ` ✗ Fi.CI.CHECKPATCH: warning for drm/xe: Fix races on fdinfo Patchwork @ 2024-10-28 15:39 ` Patchwork 2024-10-28 15:43 ` ✓ Fi.CI.BAT: success " Patchwork 5 siblings, 0 replies; 11+ messages in thread From: Patchwork @ 2024-10-28 15:39 UTC (permalink / raw) To: Lucas De Marchi; +Cc: intel-gfx == Series Details == Series: drm/xe: Fix races on fdinfo URL : https://patchwork.freedesktop.org/series/140538/ State : warning == Summary == Error: dim sparse failed Sparse version: v0.6.2 Fast mode used, each commit won't be checked separately. ^ permalink raw reply [flat|nested] 11+ messages in thread
* ✓ Fi.CI.BAT: success for drm/xe: Fix races on fdinfo 2024-10-26 6:26 [PATCH 0/3] drm/xe: Fix races on fdinfo Lucas De Marchi ` (4 preceding siblings ...) 2024-10-28 15:39 ` ✗ Fi.CI.SPARSE: " Patchwork @ 2024-10-28 15:43 ` Patchwork 5 siblings, 0 replies; 11+ messages in thread From: Patchwork @ 2024-10-28 15:43 UTC (permalink / raw) To: Lucas De Marchi; +Cc: intel-gfx [-- Attachment #1: Type: text/plain, Size: 3381 bytes --] == Series Details == Series: drm/xe: Fix races on fdinfo URL : https://patchwork.freedesktop.org/series/140538/ State : success == Summary == CI Bug Log - changes from CI_DRM_15602 -> Patchwork_140538v1 ==================================================== Summary ------- **SUCCESS** No regressions found. External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_140538v1/index.html Participating hosts (47 -> 46) ------------------------------ Missing (1): fi-snb-2520m Known issues ------------ Here are the changes found in Patchwork_140538v1 that come from known issues: ### IGT changes ### #### Issues hit #### * igt@i915_selftest@live: - bat-mtlp-8: [PASS][1] -> [ABORT][2] ([i915#12133] / [i915#12216]) [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15602/bat-mtlp-8/igt@i915_selftest@live.html [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_140538v1/bat-mtlp-8/igt@i915_selftest@live.html - bat-atsm-1: [PASS][3] -> [ABORT][4] ([i915#12133]) [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15602/bat-atsm-1/igt@i915_selftest@live.html [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_140538v1/bat-atsm-1/igt@i915_selftest@live.html * igt@i915_selftest@live@guc_multi_lrc: - bat-atsm-1: [PASS][5] -> [ABORT][6] ([i915#12305]) [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15602/bat-atsm-1/igt@i915_selftest@live@guc_multi_lrc.html [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_140538v1/bat-atsm-1/igt@i915_selftest@live@guc_multi_lrc.html * igt@i915_selftest@live@workarounds: - bat-mtlp-8: [PASS][7] -> [ABORT][8] ([i915#12216]) [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15602/bat-mtlp-8/igt@i915_selftest@live@workarounds.html [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_140538v1/bat-mtlp-8/igt@i915_selftest@live@workarounds.html #### Possible fixes #### * igt@i915_selftest@live: - bat-dg2-8: [ABORT][9] ([i915#12133]) -> [PASS][10] [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15602/bat-dg2-8/igt@i915_selftest@live.html [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_140538v1/bat-dg2-8/igt@i915_selftest@live.html * igt@i915_selftest@live@guc_multi_lrc: - bat-dg2-8: [ABORT][11] ([i915#12133] / [i915#12305]) -> [PASS][12] [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15602/bat-dg2-8/igt@i915_selftest@live@guc_multi_lrc.html [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_140538v1/bat-dg2-8/igt@i915_selftest@live@guc_multi_lrc.html [i915#12133]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/12133 [i915#12216]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/12216 [i915#12305]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/12305 Build changes ------------- * Linux: CI_DRM_15602 -> Patchwork_140538v1 CI-20190529: 20190529 CI_DRM_15602: 24707cf2a7c47d4cd192c97e73d58aa4011de154 @ git://anongit.freedesktop.org/gfx-ci/linux IGT_8086: 18939acec2446c6644644186b090d16e366af8bc @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git Patchwork_140538v1: 24707cf2a7c47d4cd192c97e73d58aa4011de154 @ git://anongit.freedesktop.org/gfx-ci/linux == Logs == For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_140538v1/index.html [-- Attachment #2: Type: text/html, Size: 4473 bytes --] ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 0/3] drm/xe: Fix races on fdinfo @ 2024-10-26 17:08 Lucas De Marchi 2024-10-26 17:08 ` [PATCH 1/3] drm/xe: Add trace to lrc timestamp update Lucas De Marchi 0 siblings, 1 reply; 11+ messages in thread From: Lucas De Marchi @ 2024-10-26 17:08 UTC (permalink / raw) To: intel-xe; +Cc: Jonathan Cavitt, Umesh Nerlige Ramappa, Lucas De Marchi [ I sent this yesterday to the i915 mailing list only: https://patchwork.freedesktop.org/series/140538/ Re-sending to the right one ] The current reading of engine utilization has same races. This should fix most of them while also drastically reducing the update rate needed on "normal apps". I left tests/xe_drm_fdinfo running on 2 systems and saw no failures after 100 iterations. Lucas De Marchi (3): drm/xe: Add trace to lrc timestamp update drm/xe: Accumulate exec queue timestamp on destroy drm/xe: Stop accumulating LRC timestamp on job_free drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_exec_queue.c | 14 ++++++++ drivers/gpu/drm/xe/xe_guc_submit.c | 2 -- drivers/gpu/drm/xe/xe_lrc.c | 3 ++ drivers/gpu/drm/xe/xe_trace_lrc.c | 9 ++++++ drivers/gpu/drm/xe/xe_trace_lrc.h | 52 ++++++++++++++++++++++++++++++ 6 files changed, 79 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.c create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.h -- 2.47.0 ^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/3] drm/xe: Add trace to lrc timestamp update 2024-10-26 17:08 [PATCH 0/3] " Lucas De Marchi @ 2024-10-26 17:08 ` Lucas De Marchi 2024-10-28 14:37 ` Cavitt, Jonathan 0 siblings, 1 reply; 11+ messages in thread From: Lucas De Marchi @ 2024-10-26 17:08 UTC (permalink / raw) To: intel-xe; +Cc: Jonathan Cavitt, Umesh Nerlige Ramappa, Lucas De Marchi Help debugging when LRC timestamp is updated for a exec queue. Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> --- drivers/gpu/drm/xe/Makefile | 1 + drivers/gpu/drm/xe/xe_lrc.c | 3 ++ drivers/gpu/drm/xe/xe_trace_lrc.c | 9 ++++++ drivers/gpu/drm/xe/xe_trace_lrc.h | 52 +++++++++++++++++++++++++++++++ 4 files changed, 65 insertions(+) create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.c create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.h diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile index bc7a04ce69fd..21d69935c336 100644 --- a/drivers/gpu/drm/xe/Makefile +++ b/drivers/gpu/drm/xe/Makefile @@ -101,6 +101,7 @@ xe-y += xe_bb.o \ xe_trace.o \ xe_trace_bo.o \ xe_trace_guc.o \ + xe_trace_lrc.o \ xe_ttm_sys_mgr.o \ xe_ttm_stolen_mgr.o \ xe_ttm_vram_mgr.o \ diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c index 4f64c7f4e68d..4b65da77c6e0 100644 --- a/drivers/gpu/drm/xe/xe_lrc.c +++ b/drivers/gpu/drm/xe/xe_lrc.c @@ -25,6 +25,7 @@ #include "xe_map.h" #include "xe_memirq.h" #include "xe_sriov.h" +#include "xe_trace_lrc.h" #include "xe_vm.h" #include "xe_wa.h" @@ -1758,5 +1759,7 @@ u32 xe_lrc_update_timestamp(struct xe_lrc *lrc, u32 *old_ts) lrc->ctx_timestamp = xe_lrc_ctx_timestamp(lrc); + trace_xe_lrc_update_timestamp(lrc, *old_ts); + return lrc->ctx_timestamp; } diff --git a/drivers/gpu/drm/xe/xe_trace_lrc.c b/drivers/gpu/drm/xe/xe_trace_lrc.c new file mode 100644 index 000000000000..ab9b7e2970bc --- /dev/null +++ b/drivers/gpu/drm/xe/xe_trace_lrc.c @@ -0,0 +1,9 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Copyright © 2024 Intel Corporation + */ + +#ifndef __CHECKER__ +#define CREATE_TRACE_POINTS +#include "xe_trace_lrc.h" +#endif diff --git a/drivers/gpu/drm/xe/xe_trace_lrc.h b/drivers/gpu/drm/xe/xe_trace_lrc.h new file mode 100644 index 000000000000..5c669a0b2180 --- /dev/null +++ b/drivers/gpu/drm/xe/xe_trace_lrc.h @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright © 2024 Intel Corporation + */ + +#undef TRACE_SYSTEM +#define TRACE_SYSTEM xe + +#if !defined(_XE_TRACE_LRC_H_) || defined(TRACE_HEADER_MULTI_READ) +#define _XE_TRACE_LRC_H_ + +#include <linux/tracepoint.h> +#include <linux/types.h> + +#include "xe_gt_types.h" +#include "xe_lrc.h" +#include "xe_lrc_types.h" + +#define __dev_name_lrc(lrc) dev_name(gt_to_xe((lrc)->fence_ctx.gt)->drm.dev) + +TRACE_EVENT(xe_lrc_update_timestamp, + TP_PROTO(struct xe_lrc *lrc, uint32_t old), + TP_ARGS(lrc, old), + TP_STRUCT__entry( + __field(struct xe_lrc *, lrc) + __field(u32, old) + __field(u32, new) + __string(name, lrc->fence_ctx.name) + __string(device_id, __dev_name_lrc(lrc)) + ), + + TP_fast_assign( + __entry->lrc = lrc; + __entry->old = old; + __entry->new = lrc->ctx_timestamp; + __assign_str(name); + __assign_str(device_id); + ), + TP_printk("lrc=:%p lrc->name=%s old=%u new=%u device_id:%s", + __entry->lrc, __get_str(name), + __entry->old, __entry->new, + __get_str(device_id)) +); + +#endif + +/* This part must be outside protection */ +#undef TRACE_INCLUDE_PATH +#undef TRACE_INCLUDE_FILE +#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/xe +#define TRACE_INCLUDE_FILE xe_trace_lrc +#include <trace/define_trace.h> -- 2.47.0 ^ permalink raw reply related [flat|nested] 11+ messages in thread
* RE: [PATCH 1/3] drm/xe: Add trace to lrc timestamp update 2024-10-26 17:08 ` [PATCH 1/3] drm/xe: Add trace to lrc timestamp update Lucas De Marchi @ 2024-10-28 14:37 ` Cavitt, Jonathan 0 siblings, 0 replies; 11+ messages in thread From: Cavitt, Jonathan @ 2024-10-28 14:37 UTC (permalink / raw) To: De Marchi, Lucas, intel-xe@lists.freedesktop.org Cc: Nerlige Ramappa, Umesh, Cavitt, Jonathan -----Original Message----- From: De Marchi, Lucas <lucas.demarchi@intel.com> Sent: Saturday, October 26, 2024 10:09 AM To: intel-xe@lists.freedesktop.org Cc: Cavitt, Jonathan <jonathan.cavitt@intel.com>; Nerlige Ramappa, Umesh <umesh.nerlige.ramappa@intel.com>; De Marchi, Lucas <lucas.demarchi@intel.com> Subject: [PATCH 1/3] drm/xe: Add trace to lrc timestamp update > > Help debugging when LRC timestamp is updated for a exec queue. > > Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> LGTM Reviewed-by: Jonathan Cavitt <jonathan.cavitt@intel.com> -Jonathan Cavitt > --- > drivers/gpu/drm/xe/Makefile | 1 + > drivers/gpu/drm/xe/xe_lrc.c | 3 ++ > drivers/gpu/drm/xe/xe_trace_lrc.c | 9 ++++++ > drivers/gpu/drm/xe/xe_trace_lrc.h | 52 +++++++++++++++++++++++++++++++ > 4 files changed, 65 insertions(+) > create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.c > create mode 100644 drivers/gpu/drm/xe/xe_trace_lrc.h > > diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile > index bc7a04ce69fd..21d69935c336 100644 > --- a/drivers/gpu/drm/xe/Makefile > +++ b/drivers/gpu/drm/xe/Makefile > @@ -101,6 +101,7 @@ xe-y += xe_bb.o \ > xe_trace.o \ > xe_trace_bo.o \ > xe_trace_guc.o \ > + xe_trace_lrc.o \ > xe_ttm_sys_mgr.o \ > xe_ttm_stolen_mgr.o \ > xe_ttm_vram_mgr.o \ > diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c > index 4f64c7f4e68d..4b65da77c6e0 100644 > --- a/drivers/gpu/drm/xe/xe_lrc.c > +++ b/drivers/gpu/drm/xe/xe_lrc.c > @@ -25,6 +25,7 @@ > #include "xe_map.h" > #include "xe_memirq.h" > #include "xe_sriov.h" > +#include "xe_trace_lrc.h" > #include "xe_vm.h" > #include "xe_wa.h" > > @@ -1758,5 +1759,7 @@ u32 xe_lrc_update_timestamp(struct xe_lrc *lrc, u32 *old_ts) > > lrc->ctx_timestamp = xe_lrc_ctx_timestamp(lrc); > > + trace_xe_lrc_update_timestamp(lrc, *old_ts); > + > return lrc->ctx_timestamp; > } > diff --git a/drivers/gpu/drm/xe/xe_trace_lrc.c b/drivers/gpu/drm/xe/xe_trace_lrc.c > new file mode 100644 > index 000000000000..ab9b7e2970bc > --- /dev/null > +++ b/drivers/gpu/drm/xe/xe_trace_lrc.c > @@ -0,0 +1,9 @@ > +// SPDX-License-Identifier: GPL-2.0-only > +/* > + * Copyright © 2024 Intel Corporation > + */ > + > +#ifndef __CHECKER__ > +#define CREATE_TRACE_POINTS > +#include "xe_trace_lrc.h" > +#endif > diff --git a/drivers/gpu/drm/xe/xe_trace_lrc.h b/drivers/gpu/drm/xe/xe_trace_lrc.h > new file mode 100644 > index 000000000000..5c669a0b2180 > --- /dev/null > +++ b/drivers/gpu/drm/xe/xe_trace_lrc.h > @@ -0,0 +1,52 @@ > +/* SPDX-License-Identifier: GPL-2.0-only */ > +/* > + * Copyright © 2024 Intel Corporation > + */ > + > +#undef TRACE_SYSTEM > +#define TRACE_SYSTEM xe > + > +#if !defined(_XE_TRACE_LRC_H_) || defined(TRACE_HEADER_MULTI_READ) > +#define _XE_TRACE_LRC_H_ > + > +#include <linux/tracepoint.h> > +#include <linux/types.h> > + > +#include "xe_gt_types.h" > +#include "xe_lrc.h" > +#include "xe_lrc_types.h" > + > +#define __dev_name_lrc(lrc) dev_name(gt_to_xe((lrc)->fence_ctx.gt)->drm.dev) > + > +TRACE_EVENT(xe_lrc_update_timestamp, > + TP_PROTO(struct xe_lrc *lrc, uint32_t old), > + TP_ARGS(lrc, old), > + TP_STRUCT__entry( > + __field(struct xe_lrc *, lrc) > + __field(u32, old) > + __field(u32, new) > + __string(name, lrc->fence_ctx.name) > + __string(device_id, __dev_name_lrc(lrc)) > + ), > + > + TP_fast_assign( > + __entry->lrc = lrc; > + __entry->old = old; > + __entry->new = lrc->ctx_timestamp; > + __assign_str(name); > + __assign_str(device_id); > + ), > + TP_printk("lrc=:%p lrc->name=%s old=%u new=%u device_id:%s", > + __entry->lrc, __get_str(name), > + __entry->old, __entry->new, > + __get_str(device_id)) > +); > + > +#endif > + > +/* This part must be outside protection */ > +#undef TRACE_INCLUDE_PATH > +#undef TRACE_INCLUDE_FILE > +#define TRACE_INCLUDE_PATH ../../drivers/gpu/drm/xe > +#define TRACE_INCLUDE_FILE xe_trace_lrc > +#include <trace/define_trace.h> > -- > 2.47.0 > > ^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-10-28 15:43 UTC | newest] Thread overview: 11+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2024-10-26 6:26 [PATCH 0/3] drm/xe: Fix races on fdinfo Lucas De Marchi 2024-10-26 6:26 ` [PATCH 1/3] drm/xe: Add trace to lrc timestamp update Lucas De Marchi 2024-10-28 12:40 ` Nirmoy Das 2024-10-26 6:26 ` [PATCH 2/3] drm/xe: Accumulate exec queue timestamp on destroy Lucas De Marchi 2024-10-28 12:46 ` Nirmoy Das 2024-10-26 6:26 ` [PATCH 3/3] drm/xe: Stop accumulating LRC timestamp on job_free Lucas De Marchi 2024-10-28 15:39 ` ✗ Fi.CI.CHECKPATCH: warning for drm/xe: Fix races on fdinfo Patchwork 2024-10-28 15:39 ` ✗ Fi.CI.SPARSE: " Patchwork 2024-10-28 15:43 ` ✓ Fi.CI.BAT: success " Patchwork -- strict thread matches above, loose matches on Subject: below -- 2024-10-26 17:08 [PATCH 0/3] " Lucas De Marchi 2024-10-26 17:08 ` [PATCH 1/3] drm/xe: Add trace to lrc timestamp update Lucas De Marchi 2024-10-28 14:37 ` Cavitt, Jonathan
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.