mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] sched_ext: Call put_task_struct() only once in scx_ops_enable()
@ 2024-09-26 13:30 Markus Elfring
  2024-09-27 20:11 ` Tejun Heo
  0 siblings, 1 reply; 2+ messages in thread
From: Markus Elfring @ 2024-09-26 13:30 UTC (permalink / raw)
  To: kernel-janitors, Barret Rhoden, Ben Segall, David Vernet,
	Dietmar Eggemann, Ingo Molnar, Josh Don, Juri Lelli, Hao Luo,
	Mel Gorman, Peter Zijlstra, Steven Rostedt, Tejun Heo,
	Valentin Schneider, Vincent Guittot
  Cc: LKML, Andrea Righi

From: Markus Elfring <elfring@users.sourceforge.net>
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.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 kernel/sched/ext.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
index 9ee5a9a261cc..4b89ea20e355 100644
--- a/kernel/sched/ext.c
+++ b/kernel/sched/ext.c
@@ -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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] sched_ext: Call put_task_struct() only once in scx_ops_enable()
  2024-09-26 13:30 [PATCH] sched_ext: Call put_task_struct() only once in scx_ops_enable() Markus Elfring
@ 2024-09-27 20:11 ` Tejun Heo
  0 siblings, 0 replies; 2+ messages in thread
From: Tejun Heo @ 2024-09-27 20:11 UTC (permalink / raw)
  To: Markus Elfring
  Cc: kernel-janitors, Barret Rhoden, Ben Segall, David Vernet,
	Dietmar Eggemann, Ingo Molnar, Josh Don, Juri Lelli, Hao Luo,
	Mel Gorman, Peter Zijlstra, Steven Rostedt, Valentin Schneider,
	Vincent Guittot, LKML, Andrea Righi

On Thu, Sep 26, 2024 at 03:30:12PM +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
> 
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>

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

Thanks.

-- 
tejun

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-09-27 20:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-26 13:30 [PATCH] sched_ext: Call put_task_struct() only once in scx_ops_enable() Markus Elfring
2024-09-27 20:11 ` Tejun Heo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®