Skip to contentSkip to conversation

refperf: Remove redundant kfree() after torture_stop_kthread()

PATCH In review Kaushlendra Kumar 2 participants 2 messages Sep 10, 2025

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

PATCH v2 1/1 refperf: Remove redundant kfree() after torture_stop_kthread()

Remove unnecessary kfree(main_task) call in ref_scale_cleanup() as torture_stop_kthread() already handles the memory cleanup for the task structure internally.

The additional kfree(main_task) call after torture_stop_kthread() is redundant and confusing since torture_stop_kthread() sets the pointer to NULL, making this a no-op.

This pattern is consistent with other torture test modules where torture_stop_kthread() is called without explicit kfree() of the task pointer, as the torture framework manages the task lifecycle internally.

---
Changes in v2:
- Corrected commit message based on review feedback

 kernel/rcu/refscale.c | 1 -
 1 file changed, 1 deletion(-)
kernel/rcu/refscale.c +0 -1
index 2c2648a3ad30..2bfa987f4ba9 100644
@@ -1050,7 +1050,6 @@ ref_scale_cleanup(void)
 	kfree(reader_tasks);
 
 	torture_stop_kthread("main_task", main_task);
-	kfree(main_task);
 
 	// Do scale-type-specific cleanup operations.
 	if (cur_ops->cleanup != NULL)
Signature · 1 line
2.34.1
maintainer
#1 lore raw
Quoted 8 lines · Kaushlendra Kumar

Remove unnecessary kfree(main_task) call in ref_scale_cleanup() as torture_stop_kthread() already handles the memory cleanup for the task structure internally.

The additional kfree(main_task) call after torture_stop_kthread() is redundant and confusing since torture_stop_kthread() sets the pointer to NULL, making this a no-op.

Quoted 6 lines

This pattern is consistent with other torture test modules where torture_stop_kthread() is called without explicit kfree() of the task pointer, as the torture framework manages the task lifecycle internally.

Queued for further review and testing, thank you!

Thanx, Paul

Quoted 22 lines

---
Changes in v2:
- Corrected commit message based on review feedback

 kernel/rcu/refscale.c | 1 -
 1 file changed, 1 deletion(-)
kernel/rcu/refscale.c +0 -1
index 2c2648a3ad30..2bfa987f4ba9 100644
@@ -1050,7 +1050,6 @@ ref_scale_cleanup(void)
 	kfree(reader_tasks);
 
 	torture_stop_kthread("main_task", main_task);
-	kfree(main_task);
 
 	// Do scale-type-specific cleanup operations.
 	if (cur_ops->cleanup != NULL)
Signature · 1 line
2.34.1