Skip to contentSkip to conversation

drm/amdgpu: Replace rcu_assign_pointer() with RCU_INIT_POINTER()

PATCH Applied Muhammad Falak R Wani 3 participants 3 messages Apr 30, 2016 – May 2, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdgpu: Replace rcu_assign_pointer() with RCU_INIT_POINTER()

The rcu_assign_pointer() ensures that the initialization of a structure is carried out before storing a pointer to that structre. It is always safe to use RCU_INIT_POINTER() to NULL a pointer, instead of rcu_assign_pointer().
This results in slightly smaller/faster code.

The following semantic patch was used:
<smpl>

@@
@@

- rcu_assign_pointer
+ RCU_INIT_POINTER
(..., NULL)

</smpl>

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +1 -1
index d81f1f4..4500ff1 100644
@@ -198,7 +198,7 @@ void amdgpu_fence_process(struct amdgpu_ring *ring)
 
 		/* There is always exactly one thread signaling this fence slot */
 		fence = rcu_dereference_protected(*ptr, 1);
-		rcu_assign_pointer(*ptr, NULL);
+		RCU_INIT_POINTER(*ptr, NULL);
 
 		BUG_ON(!fence);
 
Signature · 1 line
1.9.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 30.04.2016 um 21:00 schrieb Muhammad Falak R Wani:

Quoted 5 lines

The rcu_assign_pointer() ensures that the initialization of a structure is carried out before storing a pointer to that structre. It is always safe to use RCU_INIT_POINTER() to NULL a pointer, instead of rcu_assign_pointer().
This results in slightly smaller/faster code.

Thanks for the detailed explanation, I was already wondering what the difference is between the two.

Quoted 7 lines

The following semantic patch was used:
<smpl>

@@
@@

Quoted 7 lines

- rcu_assign_pointer
+ RCU_INIT_POINTER
(..., NULL)

</smpl>

Regards,
Christian.

Quoted 17 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +1 -1
index d81f1f4..4500ff1 100644
@@ -198,7 +198,7 @@ void amdgpu_fence_process(struct amdgpu_ring *ring)
 
  		/* There is always exactly one thread signaling this fence slot */
  		fence = rcu_dereference_protected(*ptr, 1);
-		rcu_assign_pointer(*ptr, NULL);
+		RCU_INIT_POINTER(*ptr, NULL);
 
  		BUG_ON(!fence);
 
Applied
#2 lore raw
Quoted 23 lines · Christian König

Am 30.04.2016 um 21:00 schrieb Muhammad Falak R Wani:

Quoted 6 lines

The rcu_assign_pointer() ensures that the initialization of a structure is carried out before storing a pointer to that structre. It is always safe to use RCU_INIT_POINTER() to NULL a pointer, instead of rcu_assign_pointer().
This results in slightly smaller/faster code.

Thanks for the detailed explanation, I was already wondering what the difference is between the two.

Quoted 11 lines

The following semantic patch was used:
<smpl>

@@
@@

- rcu_assign_pointer
+ RCU_INIT_POINTER
(..., NULL)

Quoted 6 lines
Quoted 3 lines

</smpl>

Applied. thanks!

Alex

Quoted 19 lines

Regards,
Christian.

Quoted 15 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +0 -0
index d81f1f4..4500ff1 100644
@@ -198,7 +198,7 @@ void amdgpu_fence_process(struct amdgpu_ring *ring)
                /* There is always exactly one thread signaling this fence

slot */

                fence = rcu_dereference_protected(*ptr, 1);
drivers/gpu/drm/amd/amdgpu/amdgpu_fence.c +1 -1
-               rcu_assign_pointer(*ptr, NULL);
+               RCU_INIT_POINTER(*ptr, NULL);
Quoted 8 lines
Quoted 2 lines
                BUG_ON(!fence);

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel

_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel