Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Daniel Charles" <daniel.charles@intel.com>,
	intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v2 1/3] drm/xe: Read scheduler message opcode under lock
Date: Tue, 13 Oct 2026 20:32:25 +0000	[thread overview]
Message-ID: <sashiko-outbox-170465@kernel.org> (raw)
In-Reply-To: <20261013201508.514480-2-daniel.charles@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] drm/xe: Data race and incorrect logging of msg->opcode in tracepoint
--

commit f517649f63cf100c02e712b78a83d6be3724e252
Author: Matthew Brost <matthew.brost@intel.com>

drm/xe: Read scheduler message opcode under lock

For static scheduler messages, the opcode is only guaranteed to remain
stable while the message is on the pending message list. Read the opcode
under the message lock before removing the message from the pending list,
and pass it through the processing pipeline.

> diff --git a/drivers/gpu/drm/xe/xe_guc_submit.c b/drivers/gpu/drm/xe/xe_guc_submit.c
> index 7ce73489c35fc..c4ef3e9bf7a18 100644
> --- a/drivers/gpu/drm/xe/xe_guc_submit.c
> +++ b/drivers/gpu/drm/xe/xe_guc_submit.c
> @@ -2056,16 +2056,17 @@ static void __guc_exec_queue_process_msg_cgp_sync(struct xe_sched_msg *msg,
>  #define MSG_HEAD	BIT(9)
>  #define MSG_PM_REF	BIT(10)
>  
> -static void guc_exec_queue_process_msg(struct xe_sched_msg *msg)
> +static void guc_exec_queue_process_msg(struct xe_sched_msg *msg,
> +				       unsigned int opcode)
>  {
>  	struct xe_device *xe = guc_to_xe(exec_queue_to_guc(msg->private_data));
>  	int idx;
> -	bool pm_ref = !!(msg->opcode & MSG_PM_REF);
> +	bool pm_ref = !!(opcode & MSG_PM_REF);
>  	bool bound = drm_dev_enter(&xe->drm, &idx);
>  
>  	trace_xe_sched_msg_recv(msg);

[Severity: Medium]
Since the commit stabilizes the opcode under the message lock and passes it
in as the opcode parameter, does calling trace_xe_sched_msg_recv() outside
the lock still risk a data race?

Looking at drivers/gpu/drm/xe/xe_trace.h:

DECLARE_EVENT_CLASS(xe_sched_msg,
    ...
    TP_fast_assign(
           __assign_str(dev);
           __entry->opcode = msg->opcode;
           ...

It appears the trace macro dereferences msg->opcode unprotected, which
could log the opcode of a re-enqueued message rather than the opcode
currently being processed. Should the trace event be updated to accept the
stabilized opcode parameter instead?

>  
> -	switch (msg->opcode & OPCODE_MASK) {
> +	switch (opcode & OPCODE_MASK) {
>  	case CLEANUP:
>  		__guc_exec_queue_process_msg_cleanup(msg, bound);
>  		break;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261013201508.514480-1-daniel.charles@intel.com?part=1

  reply	other threads:[~2026-10-13 20:32 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-13 20:15 [PATCH v2 0/3] FD close cleanup for XE Daniel Charles
2026-10-13 20:15 ` [PATCH v2 1/3] drm/xe: Read scheduler message opcode under lock Daniel Charles
2026-10-13 20:32   ` sashiko-bot [this message]
2026-10-13 20:15 ` [PATCH v2 2/3] drm/xe: Disable scheduling early on FD close to avoid CAT error cascade Daniel Charles
2026-10-13 20:15 ` [PATCH v2 3/3] drm/xe: Synchronously wait for queue kill on FD close Daniel Charles
2026-10-13 21:03   ` sashiko-bot
2026-10-13 20:40 ` ✗ CI.checkpatch: warning for FD close cleanup for XE (rev2) Patchwork
2026-10-13 20:43 ` ✓ CI.KUnit: success " Patchwork
2026-10-14  2:10 ` ✓ Xe.CI.BAT: " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-170465@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=daniel.charles@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox