From: sashiko-bot@kernel.org
To: "Umesh Nerlige Ramappa" <umesh.nerlige.ramappa@intel.com>
Cc: intel-xe@lists.freedesktop.org
Subject: Re: [PATCH 3/3] drm/xe/xe_oa: Add a lag to the reports that is exported to user
Date: Fri, 21 Aug 2026 20:21:12 +0000 [thread overview]
Message-ID: <20260821202113.1B6BA1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260821200728.1048699-8-umesh.nerlige.ramappa@intel.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Readers can block indefinitely on disabled streams because `stream->enabled` is set to false too late, failing to flush the final OA reports.
- [Medium] Data race on `stream->enabled` between `xe_oa_buffer_check_unlocked` and `xe_oa_disable_locked`/`xe_oa_enable_locked`.
--
--- Patch [3]: [PATCH 3/3] drm/xe/xe_oa: Add a lag to the reports that is exported to user ---
commit 4ec3e1c770bffdf39a86c1db169059b4bc510058
Author: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
drm/xe/xe_oa: Add a lag to the reports that is exported to user
This commit delays the visibility of OA reports to user space by holding
back the tail by 32 reports to ensure they have landed in memory. It also
attempts to flush all remaining reports when the stream is disabled.
> diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
> --- a/drivers/gpu/drm/xe/xe_oa.c
> +++ b/drivers/gpu/drm/xe/xe_oa.c
[ ... ]
> @@ -234,17 +234,23 @@ static bool xe_oa_buffer_check_unlocked(struct xe_oa_stream *stream)
> /* Subtract partial amount off the hw_tail */
> hw_tail = xe_oa_circ_diff(stream, hw_tail, partial_report_size);
>
> - stream->oa_buffer.tail = hw_tail;
> +#define LAG_REPORTS 32
> + lag = xe_oa_circ_diff(stream, hw_tail, stream->oa_buffer.tail);
> + if (!stream->enabled)
[Severity: Medium]
Is it safe to read stream->enabled here? It appears to be read while holding
the stream->oa_buffer.ptr_lock spinlock, but modified in
xe_oa_disable_locked() and xe_oa_enable_locked() while holding the
stream->stream_lock mutex. Could this cause data races?
[Severity: High]
Will readers waiting on a disabled stream block indefinitely?
When a thread calls DRM_XE_OBSERVATION_IOCTL_DISABLE, xe_oa_disable_locked()
is executed:
xe_oa_disable_locked() {
xe_oa_stream_disable(stream);
...
stream->enabled = false;
}
xe_oa_stream_disable() cancels the poll timer and calls
xe_oa_buffer_check_unlocked() to flush the final reports. However, since
stream->enabled is still true when xe_oa_buffer_check_unlocked() is called,
this bypass check will evaluate to false.
If the tail is held back by the lag, pollin evaluates to false, and
wake_up() is never called, could this cause userspace threads blocking in
read() or poll() to hang indefinitely with stranded reports?
> + stream->oa_buffer.tail = hw_tail;
> + else if (lag > LAG_REPORTS * report_size)
> + stream->oa_buffer.tail = xe_oa_circ_diff(stream, hw_tail,
> + LAG_REPORTS * report_size);
>
> available = xe_oa_circ_diff(stream, stream->oa_buffer.tail, stream->oa_buffer.head);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260821200728.1048699-5-umesh.nerlige.ramappa@intel.com?part=3
next prev parent reply other threads:[~2026-08-21 20:21 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 20:07 [PATCH 0/3] Modify the SW tail logic in OA Umesh Nerlige Ramappa
2026-08-21 20:07 ` [PATCH 1/3] drm/xe/xe_oa: Clear status only if relevant bits are set Umesh Nerlige Ramappa
2026-08-21 20:07 ` [PATCH 2/3] drm/xe/xe_oa: Avoid checking and setting fields in the OA report Umesh Nerlige Ramappa
2026-08-21 20:24 ` sashiko-bot
2026-08-21 20:07 ` [PATCH 3/3] drm/xe/xe_oa: Add a lag to the reports that is exported to user Umesh Nerlige Ramappa
2026-08-21 20:21 ` sashiko-bot [this message]
2026-08-21 20:14 ` ✓ CI.KUnit: success for Modify the SW tail logic in OA Patchwork
2026-08-21 21:03 ` ✓ Xe.CI.BAT: " Patchwork
2026-08-21 22:35 ` ✓ Xe.CI.FULL: " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2026-08-21 22:23 [PATCH 0/3] " Umesh Nerlige Ramappa
2026-08-21 22:23 ` [PATCH 3/3] drm/xe/xe_oa: Add a lag to the reports that is exported to user Umesh Nerlige Ramappa
2026-08-21 22:37 ` sashiko-bot
2026-08-06 22:47 [PATCH 0/3] Modify the SW tail logic in OA Umesh Nerlige Ramappa
2026-08-06 22:47 ` [PATCH 3/3] drm/xe/xe_oa: Add a lag to the reports that is exported to user Umesh Nerlige Ramappa
2026-08-14 15:42 ` Dixit, Ashutosh
2026-08-14 19:01 ` Umesh Nerlige Ramappa
2026-08-18 4:38 ` Dixit, Ashutosh
2026-07-30 23:35 [PATCH 0/3] Modify the SW tail logic in OA Umesh Nerlige Ramappa
2026-07-30 23:35 ` [PATCH 3/3] drm/xe/xe_oa: Add a lag to the reports that is exported to user Umesh Nerlige Ramappa
2026-07-22 21:54 [PATCH 0/3] Modify the SW tail logic in OA Umesh Nerlige Ramappa
2026-07-22 21:54 ` [PATCH 3/3] drm/xe/xe_oa: Add a lag to the reports that is exported to user Umesh Nerlige Ramappa
2026-07-21 23:48 [PATCH 0/3] Modify the SW tail logic in OA Umesh Nerlige Ramappa
2026-07-21 23:48 ` [PATCH 3/3] drm/xe/xe_oa: Add a lag to the reports that is exported to user Umesh Nerlige Ramappa
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=20260821202113.1B6BA1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=umesh.nerlige.ramappa@intel.com \
/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 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.