dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>,
	dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 10/10] drm/sched: Address the fence_seq fixme
Date: Thu, 03 Dec 2026 14:30:19 +0000	[thread overview]
Message-ID: <sashiko-outbox-247969@kernel.org> (raw)
In-Reply-To: <20261203140128.6813-11-tvrtko.ursulin@igalia.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/sched: unconditional entity->lock in drm_sched_job_arm()
  regresses hot path
--

commit e186c89420ee185250eb89c11064089f96c74447
Author: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>

drm/sched: Address the fence_seq fixme

This commit moves entity->lock acquisition from drm_sched_entity_select_rq()
up into drm_sched_job_arm() and converts entity->fence_seq from atomic_t to
unsigned long.

> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index 85a49e2198370..9c0d8c1d2395d 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -646,6 +646,9 @@ void drm_sched_job_arm(struct drm_sched_job *job)
>  	struct drm_sched_entity *entity = job->entity;
>  
>  	BUG_ON(!entity);
> +
> +	spin_lock(&entity->lock);
> +
>  	drm_sched_entity_select_rq(entity);
>  	sched = entity->rq->sched;
>  
> @@ -653,7 +656,9 @@ void drm_sched_job_arm(struct drm_sched_job *job)
>  	job->s_priority = entity->priority;
>  	job->entity_stats = drm_sched_entity_stats_get(entity->stats);
>  
> -	drm_sched_fence_init(job->s_fence, job->entity);
> +	drm_sched_fence_init(job->s_fence, entity);
> +
> +	spin_unlock(&entity->lock);
>  }
>  EXPORT_SYMBOL(drm_sched_job_arm);

[Severity: Medium]
Does taking entity->lock unconditionally in drm_sched_job_arm() regress the
submission hot path on busy entities?

Previously, drm_sched_entity_select_rq() returned before acquiring
entity->lock whenever spsc_queue_count(&entity->job_queue) was non-zero,
leaving drm_sched_job_arm() lockless on pipelined workloads with only a
producer-local atomic_inc_return(&entity->fence_seq).

Now every job submission acquires entity->lock here (in addition to
drm_sched_entity_push_job()) and holds it across drm_sched_entity_stats_get()
and both dma_fence_init() calls in drm_sched_fence_init().

Because the scheduler worker acquires entity->lock in
drm_sched_entity_pop_job() and nests rq->lock in drm_sched_rq_pop_entity(),
this trades an uncontended atomic increment for cross-CPU spinlock contention
and stalls submitters behind rq->lock.

Since callers already serialize drm_sched_job_arm() and
drm_sched_entity_push_job() per entity, fence_seq can be converted without
widening entity->lock across the non-empty queue fast path and fence init.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203140128.6813-1-tvrtko.ursulin@igalia.com?part=10

  reply	other threads:[~2026-12-03 14:30 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 14:01 [PATCH v2 00/10] drm/sched: Entity handling cleanups Tvrtko Ursulin
2026-12-03 14:01 ` [PATCH v2 01/10] drm/amdgpu/vcn3: Fail job submission if VCN0 decode is disabled under SR-IOV Tvrtko Ursulin
2026-12-03 14:01 ` [PATCH v2 02/10] drm/etnaviv: Release context id on failure Tvrtko Ursulin
2026-12-03 14:18   ` sashiko-bot
2026-12-03 14:01 ` [PATCH v2 03/10] drm/etnaviv: Check drm_sched_entity_init() return value Tvrtko Ursulin
2026-12-03 14:19   ` sashiko-bot
2026-12-03 14:24   ` Tvrtko Ursulin
2026-12-03 14:01 ` [PATCH v2 04/10] drm/msm: " Tvrtko Ursulin
2026-12-03 14:23   ` sashiko-bot
2026-12-03 14:24   ` Tvrtko Ursulin
2026-12-03 14:01 ` [PATCH v2 05/10] drm/sched: Mark drm_sched_entity_init() as __must_check Tvrtko Ursulin
2026-12-03 14:01 ` [PATCH v2 06/10] drm/sched: Disallow initializing entities with un-initialized schedulers Tvrtko Ursulin
2026-12-03 14:23   ` sashiko-bot
2026-12-05  4:20   ` Sidong Yang
2026-12-03 14:01 ` [PATCH v2 07/10] drm/sched: Clamp priority againsts all provided schedulers Tvrtko Ursulin
2026-12-03 14:01 ` [PATCH v2 08/10] drm/sched: Ignore stopped entity attempt to change its run-queue Tvrtko Ursulin
2026-12-03 14:01 ` [PATCH v2 09/10] drm/sched: Remove the single scheduler special case Tvrtko Ursulin
2026-12-03 14:31   ` sashiko-bot
2026-12-03 14:01 ` [PATCH v2 10/10] drm/sched: Address the fence_seq fixme Tvrtko Ursulin
2026-12-03 14:30   ` sashiko-bot [this message]
2026-12-03 19:29 ` [PATCH v2 00/10] drm/sched: Entity handling cleanups Maíra Canal

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-247969@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tvrtko.ursulin@igalia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox