* [PATCH] drm/sched: Don't crash kernel on wrong params
@ 2025-11-07 12:55 Philipp Stanner
2025-11-07 14:27 ` Alex Deucher
2025-11-07 14:42 ` Tvrtko Ursulin
0 siblings, 2 replies; 5+ messages in thread
From: Philipp Stanner @ 2025-11-07 12:55 UTC (permalink / raw)
To: Matthew Brost, Danilo Krummrich, Philipp Stanner,
Christian König, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, linux-kernel
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);
sched = entity->rq->sched;
--
2.49.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/sched: Don't crash kernel on wrong params
2025-11-07 12:55 [PATCH] drm/sched: Don't crash kernel on wrong params Philipp Stanner
@ 2025-11-07 14:27 ` Alex Deucher
2025-11-07 14:42 ` Tvrtko Ursulin
1 sibling, 0 replies; 5+ messages in thread
From: Alex Deucher @ 2025-11-07 14:27 UTC (permalink / raw)
To: Philipp Stanner
Cc: Matthew Brost, Danilo Krummrich, Christian König,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, dri-devel, linux-kernel
On Fri, Nov 7, 2025 at 8:01 AM Philipp Stanner <phasta@kernel.org> 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>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
> ---
> 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);
> sched = entity->rq->sched;
>
> --
> 2.49.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/sched: Don't crash kernel on wrong params
2025-11-07 12:55 [PATCH] drm/sched: Don't crash kernel on wrong params Philipp Stanner
2025-11-07 14:27 ` Alex Deucher
@ 2025-11-07 14:42 ` Tvrtko Ursulin
2025-11-07 15:18 ` Tvrtko Ursulin
2025-11-10 8:30 ` Philipp Stanner
1 sibling, 2 replies; 5+ messages in thread
From: Tvrtko Ursulin @ 2025-11-07 14:42 UTC (permalink / raw)
To: Philipp Stanner, Matthew Brost, Danilo Krummrich,
Christian König, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, linux-kernel
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
pointer dereferences since they add no value. Ie. it should just be
removed and not replaced.
Regards,
Tvrtko
Regards,
Tvrtko
> sched = entity->rq->sched;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/sched: Don't crash kernel on wrong params
2025-11-07 14:42 ` Tvrtko Ursulin
@ 2025-11-07 15:18 ` Tvrtko Ursulin
2025-11-10 8:30 ` Philipp Stanner
1 sibling, 0 replies; 5+ messages in thread
From: Tvrtko Ursulin @ 2025-11-07 15:18 UTC (permalink / raw)
To: Philipp Stanner, Matthew Brost, Danilo Krummrich,
Christian König, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, linux-kernel
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;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] drm/sched: Don't crash kernel on wrong params
2025-11-07 14:42 ` Tvrtko Ursulin
2025-11-07 15:18 ` Tvrtko Ursulin
@ 2025-11-10 8:30 ` Philipp Stanner
1 sibling, 0 replies; 5+ messages in thread
From: Philipp Stanner @ 2025-11-10 8:30 UTC (permalink / raw)
To: Tvrtko Ursulin, Philipp Stanner, Matthew Brost, Danilo Krummrich,
Christian König, Maarten Lankhorst, Maxime Ripard,
Thomas Zimmermann, David Airlie, Simona Vetter
Cc: dri-devel, linux-kernel
On Fri, 2025-11-07 at 14:42 +0000, 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
> pointer dereferences since they add no value. Ie. it should just be
> removed and not replaced.
Hm, right. I agree. Both jobs and entities are initialized to 0
anyways. Existing users work, and new users would notice a null ptr
crash.
Let's remove it altogether.
P.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2025-11-10 8:31 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-07 12:55 [PATCH] drm/sched: Don't crash kernel on wrong params Philipp Stanner
2025-11-07 14:27 ` Alex Deucher
2025-11-07 14:42 ` Tvrtko Ursulin
2025-11-07 15:18 ` Tvrtko Ursulin
2025-11-10 8:30 ` Philipp Stanner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox