Skip to contentSkip to conversation

sched_ext: Call put_task_struct() only once in scx_ops_enable()

PATCH In review Markus Elfring 2 participants 2 messages Sep 26, 2024 – Sep 27, 2024

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

PATCH 1/1 sched_ext: Call put_task_struct() only once in scx_ops_enable()

From: Markus Elfring <[email protected]>
Date: Thu, 26 Sep 2024 14:51:07 +0200

A put_task_struct() call was immediately used after a return value check for a scx_ops_init_task() call in this function implementation. Thus call such a function only once instead directly before the check.

This issue was detected by using the Coccinelle software.

---
 kernel/sched/ext.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/sched/ext.c +1 -2
index 9ee5a9a261cc..4b89ea20e355 100644
@@ -5091,8 +5091,8 @@ static int scx_ops_enable(struct sched_ext_ops *ops, struct bpf_link *link)
 		spin_unlock_irq(&scx_tasks_lock);
 
 		ret = scx_ops_init_task(p, task_group(p), false);
+		put_task_struct(p);
 		if (ret) {
-			put_task_struct(p);
 			spin_lock_irq(&scx_tasks_lock);
 			scx_task_iter_exit(&sti);
 			spin_unlock_irq(&scx_tasks_lock);
@@ -5101,7 +5101,6 @@ static int scx_ops_enable(struct sched_ext_ops *ops, struct bpf_link *link)
 			goto err_disable_unlock_all;
 		}
 
-		put_task_struct(p);
 		spin_lock_irq(&scx_tasks_lock);
 	}
 	scx_task_iter_exit(&sti);

--
2.46.1

#1 lore raw
Quoted 10 lines · Markus Elfring

From: Markus Elfring <[email protected]>
Date: Thu, 26 Sep 2024 14:51:07 +0200

A put_task_struct() call was immediately used after a return value check for a scx_ops_init_task() call in this function implementation. Thus call such a function only once instead directly before the check.

This issue was detected by using the Coccinelle software.

This no longer applies after 9753358a6a2b ("sched_ext: Fix SCX_TASK_INIT -> SCX_TASK_READY transitions in scx_ops_enable()").

Thanks.

Signature · 1 line
tejun