From: Tvrtko Ursulin <tursulin@ursulin.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>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/sched: Don't crash kernel on wrong params
Date: Fri, 7 Nov 2025 15:18:08 +0000 [thread overview]
Message-ID: <f39d38c8-8a07-4a63-a09f-3319b5ebb5f6@ursulin.net> (raw)
In-Reply-To: <c4a10ad7-22c0-412c-a456-d2dd0f049ac9@ursulin.net>
On 07/11/2025 14:42, Tvrtko Ursulin wrote:
>
> On 07/11/2025 12:55, Philipp Stanner wrote:
>> drm_sched_job_arm() just panics the kernel with BUG_ON() in case of an
>> entity being NULL. While drm_sched_job_arm() crashing or not effectively
>> arming jobs is certainly a huge issue that needs to be noticed,
>> completely shooting down the kernel reduces the probability of reaching
>> and debugging a system to 0.
>>
>> Moreover, the checkpatch script by now strongly discourages all new uses
>> of BUG_ON() for this reason.
>>
>> Replace the BUG_ON() in drm_sched_job_arm() with a WARN_ON().
>>
>> Signed-off-by: Philipp Stanner <phasta@kernel.org>
>> ---
>> drivers/gpu/drm/scheduler/sched_main.c | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/scheduler/sched_main.c b/drivers/gpu/drm/
>> scheduler/sched_main.c
>> index 1d4f1b822e7b..3bf4ae0ca4bc 100644
>> --- a/drivers/gpu/drm/scheduler/sched_main.c
>> +++ b/drivers/gpu/drm/scheduler/sched_main.c
>> @@ -857,7 +857,7 @@ void drm_sched_job_arm(struct drm_sched_job *job)
>> struct drm_gpu_scheduler *sched;
>> struct drm_sched_entity *entity = job->entity;
>> - BUG_ON(!entity);
>> + WARN_ON(!entity);
>> drm_sched_entity_select_rq(entity);
>
> void drm_sched_entity_select_rq(struct drm_sched_entity *entity)
> {
> struct dma_fence *fence;
> struct drm_gpu_scheduler *sched;
> struct drm_sched_rq *rq;
>
> /* single possible engine and already selected */
> if (!entity->sched_list)
>
> Still the same end result.
>
> I believe best practice is to simply not have BUG_ON's followed by null
Sorry I meant WARN_ONs. If we think there is scope for bad things to
happen after letting the execution proceed then I would add an early
return to the WARN_ON (_ONCE?). That probably means to push job as well.
Regards,
Tvrtko
> pointer dereferences since they add no value. Ie. it should just be
> removed and not replaced.
>
> Regards,
>
> Tvrtko
>
> Regards,
>
> Tvrtko
>
>> sched = entity->rq->sched;
>
next prev parent reply other threads:[~2025-11-07 15:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-07 12:55 Philipp Stanner
2025-11-07 14:27 ` Alex Deucher
2025-11-07 14:42 ` Tvrtko Ursulin
2025-11-07 15:18 ` Tvrtko Ursulin [this message]
2025-11-10 8:30 ` 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=f39d38c8-8a07-4a63-a09f-3319b5ebb5f6@ursulin.net \
--to=tursulin@ursulin.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=maarten.lankhorst@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=mripard@kernel.org \
--cc=phasta@kernel.org \
--cc=simona@ffwll.ch \
--cc=tzimmermann@suse.de \
/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®