* [PATCH] drm/scheduler: add NULL pointer check for run queue (v2) @ 2018-07-16 9:23 Junwei Zhang [not found] ` <1531733034-22183-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org> 0 siblings, 1 reply; 4+ messages in thread From: Junwei Zhang @ 2018-07-16 9:23 UTC (permalink / raw) To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW Cc: Junwei Zhang, christian.koenig-5C7GfCeVMHo To check rq pointer before adding entity into it. That avoids NULL pointer access in some case. v2: move the check to caller Suggested-by: Christian König <christian.koenig@amd.com> Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com> --- drivers/gpu/drm/scheduler/gpu_scheduler.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c index 16bf446..dac71e3 100644 --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c @@ -547,6 +547,11 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job, if (first) { /* Add the entity to the run queue */ spin_lock(&entity->rq_lock); + if (!entity->rq) { + DRM_ERROR("Trying to push to a killed entity\n"); + spin_unlock(&entity->rq_lock); + return; + } drm_sched_rq_add_entity(entity->rq, entity); spin_unlock(&entity->rq_lock); drm_sched_wakeup(sched); -- 1.9.1 _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply related [flat|nested] 4+ messages in thread
[parent not found: <1531733034-22183-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org>]
* Re: [PATCH] drm/scheduler: add NULL pointer check for run queue (v2) [not found] ` <1531733034-22183-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org> @ 2018-07-16 9:27 ` Christian König 2018-07-16 9:54 ` Michel Dänzer 1 sibling, 0 replies; 4+ messages in thread From: Christian König @ 2018-07-16 9:27 UTC (permalink / raw) To: Junwei Zhang, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW Am 16.07.2018 um 11:23 schrieb Junwei Zhang: > To check rq pointer before adding entity into it. > That avoids NULL pointer access in some case. > > v2: move the check to caller > > Suggested-by: Christian König <christian.koenig@amd.com> > Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com> Reviewed-by: Christian König <christian.koenig@amd.com> > --- > drivers/gpu/drm/scheduler/gpu_scheduler.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c > index 16bf446..dac71e3 100644 > --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c > +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c > @@ -547,6 +547,11 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job, > if (first) { > /* Add the entity to the run queue */ > spin_lock(&entity->rq_lock); > + if (!entity->rq) { > + DRM_ERROR("Trying to push to a killed entity\n"); > + spin_unlock(&entity->rq_lock); > + return; > + } > drm_sched_rq_add_entity(entity->rq, entity); > spin_unlock(&entity->rq_lock); > drm_sched_wakeup(sched); _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] drm/scheduler: add NULL pointer check for run queue (v2) [not found] ` <1531733034-22183-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org> 2018-07-16 9:27 ` Christian König @ 2018-07-16 9:54 ` Michel Dänzer [not found] ` <e62a1051-00c9-99b2-dd83-d8f47e9038f4-otUistvHUpPR7s880joybQ@public.gmane.org> 1 sibling, 1 reply; 4+ messages in thread From: Michel Dänzer @ 2018-07-16 9:54 UTC (permalink / raw) To: Junwei Zhang Cc: christian.koenig-5C7GfCeVMHo, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW On 2018-07-16 11:23 AM, Junwei Zhang wrote: > To check rq pointer before adding entity into it. > That avoids NULL pointer access in some case. > > v2: move the check to caller > > Suggested-by: Christian König <christian.koenig@amd.com> > Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com> > --- > drivers/gpu/drm/scheduler/gpu_scheduler.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c > index 16bf446..dac71e3 100644 > --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c > +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c > @@ -547,6 +547,11 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job, > if (first) { > /* Add the entity to the run queue */ > spin_lock(&entity->rq_lock); > + if (!entity->rq) { > + DRM_ERROR("Trying to push to a killed entity\n"); This could result in spamming dmesg with this error message. I suggest if (WARN_ON_ONCE(!entity->rq)) { instead, no DRM_ERROR. That will produce a single warning with a backtrace. -- Earthling Michel Dänzer | http://www.amd.com Libre software enthusiast | Mesa and X developer _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 4+ messages in thread
[parent not found: <e62a1051-00c9-99b2-dd83-d8f47e9038f4-otUistvHUpPR7s880joybQ@public.gmane.org>]
* Re: [PATCH] drm/scheduler: add NULL pointer check for run queue (v2) [not found] ` <e62a1051-00c9-99b2-dd83-d8f47e9038f4-otUistvHUpPR7s880joybQ@public.gmane.org> @ 2018-07-17 3:11 ` Zhang, Jerry (Junwei) 0 siblings, 0 replies; 4+ messages in thread From: Zhang, Jerry (Junwei) @ 2018-07-17 3:11 UTC (permalink / raw) To: Michel Dänzer Cc: christian.koenig-5C7GfCeVMHo, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW On 07/16/2018 05:54 PM, Michel Dänzer wrote: > On 2018-07-16 11:23 AM, Junwei Zhang wrote: >> To check rq pointer before adding entity into it. >> That avoids NULL pointer access in some case. >> >> v2: move the check to caller >> >> Suggested-by: Christian König <christian.koenig@amd.com> >> Signed-off-by: Junwei Zhang <Jerry.Zhang@amd.com> >> --- >> drivers/gpu/drm/scheduler/gpu_scheduler.c | 5 +++++ >> 1 file changed, 5 insertions(+) >> >> diff --git a/drivers/gpu/drm/scheduler/gpu_scheduler.c b/drivers/gpu/drm/scheduler/gpu_scheduler.c >> index 16bf446..dac71e3 100644 >> --- a/drivers/gpu/drm/scheduler/gpu_scheduler.c >> +++ b/drivers/gpu/drm/scheduler/gpu_scheduler.c >> @@ -547,6 +547,11 @@ void drm_sched_entity_push_job(struct drm_sched_job *sched_job, >> if (first) { >> /* Add the entity to the run queue */ >> spin_lock(&entity->rq_lock); >> + if (!entity->rq) { >> + DRM_ERROR("Trying to push to a killed entity\n"); > > This could result in spamming dmesg with this error message. I suggest Thanks for your comments. Actually it will cause App or GPU hang, as the job is unexpected to push to a non-existing entity run queue. Now we're trying to predict that before kernel panic or BUG_ON. Regards, Jerry > > if (WARN_ON_ONCE(!entity->rq)) { > > instead, no DRM_ERROR. That will produce a single warning with a backtrace. > > _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-07-17 3:11 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2018-07-16 9:23 [PATCH] drm/scheduler: add NULL pointer check for run queue (v2) Junwei Zhang [not found] ` <1531733034-22183-1-git-send-email-Jerry.Zhang-5C7GfCeVMHo@public.gmane.org> 2018-07-16 9:27 ` Christian König 2018-07-16 9:54 ` Michel Dänzer [not found] ` <e62a1051-00c9-99b2-dd83-d8f47e9038f4-otUistvHUpPR7s880joybQ@public.gmane.org> 2018-07-17 3:11 ` Zhang, Jerry (Junwei)
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.