mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>
To: Luke.Wildhardt@proton.me
Cc: Danilo Krummrich <dakr@kernel.org>,
	Philipp Stanner <phasta@mailbox.org>,
	phasta@kernel.org,
	"matthew.brost@intel.com" <matthew.brost@intel.com>,
	"ckoenig.leichtzumerken@gmail.com"
	<ckoenig.leichtzumerken@gmail.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"regressions@lists.linux.dev" <regressions@lists.linux.dev>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [REGRESSION] drm/sched: FAIR policy causes serious performance degradation at max GPU load on 9070XT
Date: Thu, 13 Aug 2026 08:58:47 +0100	[thread overview]
Message-ID: <61a96635-e143-4d69-b0f7-0f312f5a3a3c@igalia.com> (raw)
In-Reply-To: <ylme_dYqb7yeNvmFl3ZeH3v8d_46-oAWr6t95wEZTYGiLMdbNTzXBFoV1zueOeHcKXcFrMMsoF0s_57Hzj0wwEfxDRjPhmu-xquKmeXKehg=@proton.me>


On 13/08/2026 07:42, Luke.Wildhardt@proton.me wrote:
> Ok, after a lot of A/B testing, it appears that trying your "drm-intel/drm-sched-fair-fixed" branch, the stuttering is still there. It's definitely paced differently though, I will attach a video. It's "choppier" when it happens. I tested in a few different areas / times of day, in case you notice the scenery isn't the same; this is representative of what I experienced in other places. I will note, that I tried playing 4 times, 3/4 times, shortly after boot. 1/4 times I left my desktop to idle for about 30 minutes while I did something else, and I didn't encounter the issue at all in 10 minutes. Not sure how significant that is, or if it's just noise.
> 
> https://www.youtube.com/watch?v=GWyIVEuhooM
> 
> To make sure I wasn't insane, I went back to the patch Claude gave me, applied against a clean 7.2.0-rc7. At least again in a few sessions after boot, no issue. I'll post that exact code below.

Yes, I had a brain fart yesterday and had only pulled the lock out on 
the pop side. I have now pushed the updated branch, with both the add 
and pop side made symmetric in lock taking aspect.

If you could pull and re-test once more that would be great.

Regards,

Tvrtko

> If you need any other info from me let me know.
> 
> 
> --- a/drivers/gpu/drm/scheduler/sched_rq.c
> +++ b/drivers/gpu/drm/scheduler/sched_rq.c
> @@ -2,6 +2,7 @@
>   /* Copyright 2015 Advanced Micro Devices, Inc. */
>   /* Copyright (c) 2025 Valve Corporation */
> 
> +#include <linux/moduleparam.h>
>   #include <linux/rbtree.h>
> 
>   #include <drm/drm_print.h>
> @@ -9,6 +10,32 @@
> 
>   #include "sched_internal.h"
> 
> +/*
> + * Diagnostic counters. Not for submission.
> + *
> + * dbg_pop_stayed  - pops where the entity had another job queued and so stayed
> + *                   in the tree. No save/restore of vruntime occurs.
> + * dbg_pop_left    - pops where the entity queue drained, so it left the tree
> + *                   and drm_sched_entity_save_vruntime() ran. Only this path
> + *                   arms a later restore.
> + * dbg_add_restore - calls to drm_sched_rq_add_entity(), i.e. restores.
> + * dbg_add_race    - restores where the entity was still linked in the tree,
> + *                   meaning the vruntime being restored is still absolute.
> + *
> + * Incremented under rq->lock, so exact per scheduler and only mildly lossy
> + * when summed across rings. Writable so they can be reset between runs:
> + *   echo 0 > /sys/module/gpu_sched/parameters/dbg_pop_left
> + */
> +static unsigned long dbg_pop_stayed;
> +static unsigned long dbg_pop_left;
> +static unsigned long dbg_add_restore;
> +static unsigned long dbg_add_race;
> +
> +module_param(dbg_pop_stayed, ulong, 0644);
> +module_param(dbg_pop_left, ulong, 0644);
> +module_param(dbg_add_restore, ulong, 0644);
> +module_param(dbg_add_race, ulong, 0644);
> +
>   static __always_inline bool
>   drm_sched_entity_compare_before(struct rb_node *a, const struct rb_node *b)
>   {
> @@ -266,14 +293,40 @@
>   	sched = container_of(rq, typeof(*sched), rq);
>   	spin_lock(&rq->lock);
> 
> +	dbg_add_restore++;
> +	if (!RB_EMPTY_NODE(&entity->rb_tree_node)) {
> +		dbg_add_race++;
> +		pr_warn_ratelimited("drm_sched: vruntime race on ring %s (comm %s)\n",
> +				    sched->name, current->comm);
> +	}
> +
>   	if (list_empty(&entity->list)) {
>   		atomic_inc(sched->score);
>   		list_add_tail(&entity->list, &rq->entities);
>   	}
> 
> -	ts = drm_sched_rq_get_min_vruntime(rq);
> -	ts = drm_sched_entity_restore_vruntime(entity, ts, rq->head_prio);
> -	drm_sched_rq_update_tree_locked(entity, rq, ts);
> +	/*
> +	 * Only restore the vruntime if the entity actually left the run queue.
> +	 *
> +	 * drm_sched_entity_pop_job() dequeues the last job and only afterwards
> +	 * calls drm_sched_rq_pop_entity(), which is where the entity is removed
> +	 * from the tree and drm_sched_entity_save_vruntime() converts its
> +	 * vruntime to min_vruntime-relative form. A push landing in that window
> +	 * sees an empty queue, takes the "first job" path to here, and would
> +	 * restore a vruntime which is still absolute -- adding min_vruntime to
> +	 * it a second time. If the entity is also the leftmost one,
> +	 * drm_sched_rq_get_min_vruntime() returns the entity's own vruntime and
> +	 * the value is doubled, placing it far to the right of the tree where it
> +	 * will not be selected again until the run queue catches up.
> +	 *
> +	 * A still-linked entity never left, so its vruntime is already absolute
> +	 * and its tree position is valid. The concurrent pop will update both.
> +	 */
> +	if (RB_EMPTY_NODE(&entity->rb_tree_node)) {
> +		ts = drm_sched_rq_get_min_vruntime(rq);
> +		ts = drm_sched_entity_restore_vruntime(entity, ts, rq->head_prio);
> +		drm_sched_rq_update_tree_locked(entity, rq, ts);
> +	}
> 
>   	spin_unlock(&rq->lock);
>   	spin_unlock(&entity->lock);
> @@ -330,11 +383,13 @@
>   	if (next_job) {
>   		ktime_t ts;
> 
> +		dbg_pop_stayed++;
>   		ts = drm_sched_entity_update_vruntime(entity);
>   		drm_sched_rq_update_tree_locked(entity, rq, ts);
>   	} else {
>   		ktime_t min_vruntime;
> 
> +		dbg_pop_left++;
>   		drm_sched_rq_remove_tree_locked(entity, rq);
>   		min_vruntime = drm_sched_rq_get_min_vruntime(rq);
>   		drm_sched_entity_save_vruntime(entity, min_vruntime);
> 
> 
> 


  reply	other threads:[~2026-08-13  7:59 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-08 23:33 Luke.Wildhardt
2026-08-10  8:28 ` Philipp Stanner
2026-08-10 12:45   ` Danilo Krummrich
2026-08-10 13:48     ` Tvrtko Ursulin
2026-08-10 16:40       ` Luke.Wildhardt
2026-08-11  7:29         ` Philipp Stanner
2026-08-11  7:49         ` Tvrtko Ursulin
2026-08-11 17:59         ` Luke.Wildhardt
2026-08-12 11:37           ` Tvrtko Ursulin
2026-08-12 11:58             ` Philipp Stanner
2026-08-12 12:29               ` Tvrtko Ursulin
2026-09-16  7:37                 ` Philipp Stanner
2026-08-12 15:12             ` Luke.Wildhardt
2026-08-13  6:42               ` Luke.Wildhardt
2026-08-13  7:58                 ` Tvrtko Ursulin [this message]
2026-08-13 14:27                   ` Luke.Wildhardt
2026-08-14  6:49                     ` Luke.Wildhardt
2026-08-14  8:32                     ` Feng, Kenneth
2026-08-10 11:36 ` Tvrtko Ursulin
2026-08-11  7:46 ` Tvrtko Ursulin
2026-08-12  4:52   ` Luke.Wildhardt

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=61a96635-e143-4d69-b0f7-0f312f5a3a3c@igalia.com \
    --to=tvrtko.ursulin@igalia.com \
    --cc=Luke.Wildhardt@proton.me \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=phasta@kernel.org \
    --cc=phasta@mailbox.org \
    --cc=regressions@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

all inboxes | Powered by JetHome®