mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Pierre-Eric Pelloux-Prayer <pierre-eric@damsy.net>
To: "Philipp Stanner" <phasta@kernel.org>,
	"Matthew Brost" <matthew.brost@intel.com>,
	"Danilo Krummrich" <dakr@kernel.org>,
	"Christian König" <ckoenig.leichtzumerken@gmail.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	linux-media@vger.kernel.org
Subject: Re: [PATCH v3] drm/sched: Add warning for removing hack in drm_sched_fini()
Date: Fri, 31 Oct 2025 15:10:43 +0100	[thread overview]
Message-ID: <ebc028f2-3d2d-4f42-a667-df7d6c2b7eb0@damsy.net> (raw)
In-Reply-To: <20251023123429.139848-2-phasta@kernel.org>

Hi Philipp,

Le 23/10/2025 à 14:34, Philipp Stanner a écrit :
> The assembled developers agreed at the X.Org Developers Conference 2025
> that the hack added for amdgpu in drm_sched_fini() shall be removed. It
> shouldn't be needed by amdgpu anymore.
> 
> As it's unclear whether all drivers really follow the life time rule of
> entities having to be torn down before their scheduler, it is reasonable
> to warn for a while before removing the hack.
> 
> Add a warning in drm_sched_fini() that fires if an entity is still
> active.
> 
> Signed-off-by: Philipp Stanner <phasta@kernel.org>
> ---
> Changes in v3:
>    - Add a READ_ONCE() + comment to make the warning slightly less
>      horrible.
> 
> Changes in v2:
>    - Fix broken brackets.
> ---
>   drivers/gpu/drm/scheduler/sched_main.c | 9 ++++++++-
>   1 file changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/scheduler/sched_main.c
> index 46119aacb809..31039b08c7b9 100644
> --- a/drivers/gpu/drm/scheduler/sched_main.c
> +++ b/drivers/gpu/drm/scheduler/sched_main.c
> @@ -1419,7 +1419,7 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)
>   		struct drm_sched_rq *rq = sched->sched_rq[i];
>   
>   		spin_lock(&rq->lock);
> -		list_for_each_entry(s_entity, &rq->entities, list)
> +		list_for_each_entry(s_entity, &rq->entities, list) {
>   			/*
>   			 * Prevents reinsertion and marks job_queue as idle,
>   			 * it will be removed from the rq in drm_sched_entity_fini()
> @@ -1440,8 +1440,15 @@ void drm_sched_fini(struct drm_gpu_scheduler *sched)
>   			 * For now, this remains a potential race in all
>   			 * drivers that keep entities alive for longer than
>   			 * the scheduler.
> +			 *
> +			 * The READ_ONCE() is there to make the lockless read
> +			 * (warning about the lockless write below) slightly
> +			 * less broken...
>   			 */
> +			if (!READ_ONCE(s_entity->stopped))
> +				dev_warn(sched->dev, "Tearing down scheduler with active entities!\n");
>   			s_entity->stopped = true;
> +		}

The patch is Acked-by: Pierre-Eric Pelloux-Prayer 
<pierre-eric.pelloux-prayer@amd.com>

Thanks.


>   		spin_unlock(&rq->lock);
>   		kfree(sched->sched_rq[i]);
>   	}


  parent reply	other threads:[~2025-10-31 14:11 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-23 12:34 Philipp Stanner
2025-10-30 15:23 ` Philipp Stanner
2025-10-31 14:10 ` Pierre-Eric Pelloux-Prayer [this message]
2025-10-31 14:41   ` Philipp Stanner

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=ebc028f2-3d2d-4f42-a667-df7d6c2b7eb0@damsy.net \
    --to=pierre-eric@damsy.net \
    --cc=airlied@gmail.com \
    --cc=ckoenig.leichtzumerken@gmail.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=matthew.brost@intel.com \
    --cc=phasta@kernel.org \
    --cc=simona@ffwll.ch \
    --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

all inboxes | Powered by JetHome®