Skip to contentSkip to conversation

gpu: drm/amd: Remove the redundant null pointer check in list_for_each_entry() loops

PATCH In review Lu Hongfei 3 participants 3 messages Jun 12, 2023

Subsystems (3)
lore
Share & tools
lore

Lu Hongfei

author
#0 lore raw

PATCH v2 1/1 gpu: drm/amd: Remove the redundant null pointer check in list_for_each_entry() loops

pqn bound in list_for_each_entry loop will not be null, so there is no need to check whether pqn is NULL or not.
Thus remove a redundant null pointer check.

---
The filename of the previous version was:
0001-gpu-drm-amd-Fix-the-bug-in-list_for_each_entry-loops.patch

The modifications made compared to the previous version are as follows:
1. Modified the patch title
2. "Thus remove a redundant null pointer check." is used instead of "We could remove this check."

 drivers/gpu/drm/amd/amdkfd/kfd_debug.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_debug.c +0 -3
index cd34e7aaead4..10d0cef844f0 100644
@@ -1097,9 +1097,6 @@ void kfd_dbg_set_enabled_debug_exception_mask(struct kfd_process *target,
 
 	pqm = &target->pqm;
 	list_for_each_entry(pqn, &pqm->queues, process_queue_list) {
-		if (!pqn)
-			continue;
-
 		found_mask |= pqn->q->properties.exception_status;
 	}
 
Signature · 1 line
2.39.0
maintainer
#1 lore raw

[+Jon]

Am 2023-06-12 um 07:58 schrieb Lu Hongfei:

Quoted 22 lines

pqn bound in list_for_each_entry loop will not be null, so there is no need to check whether pqn is NULL or not.
Thus remove a redundant null pointer check.

---
The filename of the previous version was:
0001-gpu-drm-amd-Fix-the-bug-in-list_for_each_entry-loops.patch

The modifications made compared to the previous version are as follows:
1. Modified the patch title
2. "Thus remove a redundant null pointer check." is used instead of "We could remove this check."

  drivers/gpu/drm/amd/amdkfd/kfd_debug.c | 3 ---
  1 file changed, 3 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_debug.c +0 -0
index cd34e7aaead4..10d0cef844f0 100644

drivers/gpu/drm/amd/amdkfd/kfd_debug.c void kfd_dbg_set_enabled_debug_exception_mask(struct kfd_process *target, · line 1100

Quoted 4 lines
drivers/gpu/drm/amd/amdkfd/kfd_debug.c +0 -1
@@ -1097,9 +1097,6 @@ void kfd_dbg_set_enabled_debug_exception_mask(struct kfd_process *target,
 
  	pqm = &target->pqm;
  	list_for_each_entry(pqn, &pqm->queues, process_queue_list) {
-		if (!pqn)

Right, this check doesn't make a lot of sense. Jon, was this meant to check pqn->q?

Regards,
  Felix

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_debug.c +0 -2
-			continue;
-
  		found_mask |= pqn->q->properties.exception_status;
  	}
 
#2 lore raw

[Public]

Quoted 42 lines

-----Original Message-----
From: Kuehling, Felix <[email protected]>
Sent: Monday, June 12, 2023 11:25 AM
To: Lu Hongfei <[email protected]>; Deucher, Alexander <[email protected]>; Koenig, Christian <[email protected]>; Pan, Xinhui <[email protected]>; David Airlie <[email protected]>; Daniel Vetter <[email protected]>; open list:AMD KFD <[email protected]>; open list:DRM DRIVERS <dri- [email protected]>; open list <[email protected]>; Kim, Jonathan <[email protected]>
Cc: [email protected]
Subject: Re: [PATCH v2] gpu: drm/amd: Remove the redundant null pointer check in list_for_each_entry() loops

[+Jon]

Am 2023-06-12 um 07:58 schrieb Lu Hongfei:

Quoted 14 lines

pqn bound in list_for_each_entry loop will not be null, so there is no need to check whether pqn is NULL or not.
Thus remove a redundant null pointer check.

---
The filename of the previous version was:
0001-gpu-drm-amd-Fix-the-bug-in-list_for_each_entry-loops.patch

The modifications made compared to the previous version are as follows:
1. Modified the patch title
2. "Thus remove a redundant null pointer check." is used instead of "We could remove this check."

Review

Quoted 4 lines
  drivers/gpu/drm/amd/amdkfd/kfd_debug.c | 3 ---
  1 file changed, 3 deletions(-)
(quoted diff) +0 -0

b/drivers/gpu/drm/amd/amdkfd/kfd_debug.c

drivers/gpu/drm/amd/amdkfd/kfd_debug.c void

Quoted 4 lines

index cd34e7aaead4..10d0cef844f0 100644

drivers/gpu/drm/amd/amdkfd/kfd_debug.c +0 -0
@@ -1097,9 +1097,6 @@ void

kfd_dbg_set_enabled_debug_exception_mask(struct kfd_process *target,

Quoted 1 line
Quoted 6 lines
Quoted 3 lines
    pqm = &target->pqm;
    list_for_each_entry(pqn, &pqm->queues, process_queue_list) {

- if (!pqn)

Right, this check doesn't make a lot of sense. Jon, was this meant to check pqn->q?

Yes that's a bug. It should be a null check on the queue itself. I'll send out the fix shortly.

Thanks,

Jon

Quoted 10 lines

Regards,
Felix

Quoted 5 lines
drivers/gpu/drm/amd/amdkfd/kfd_debug.c +0 -2
-                   continue;
-
            found_mask |= pqn->q->properties.exception_status;
    }