public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Tejun Heo <tj@kernel.org>
Cc: David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>,
	David Carlier <devnexen@gmail.com>,
	Emil Tsalapatis <emil@etsalapatis.com>,
	sched-ext@lists.linux.dev, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] sched_ext: Fix cgroup double-put on sub-sched abort path
Date: Mon, 16 Mar 2026 07:11:44 +0100	[thread overview]
Message-ID: <abefIFqKlWofXRN4@gpd4> (raw)
In-Reply-To: <20260316054328.838304-2-tj@kernel.org>

On Sun, Mar 15, 2026 at 07:43:27PM -1000, Tejun Heo wrote:
> The abort path in scx_sub_enable_workfn() fell through to out_put_cgrp,
> double-putting the cgroup ref already owned by sch->cgrp. It also skipped
> kthread_flush_work() needed to flush the disable path.
> 
> Relocate the abort block above err_unlock_and_disable so it falls through to
> err_disable.
> 
> Fixes: ebeca1f930ea ("sched_ext: Introduce cgroup sub-sched support")

Maybe we should point to commit 337ec00b1d9c ("sched_ext: Implement cgroup
sub-sched enabling and disabling")

That's where we added the real sub-sched enable/disable implementation and
the abort block.

Apart from that looks good.

Reviewed-by: Andrea Righi <arighi@nvidia.com>

Thanks,
-Andrea

> Signed-off-by: Tejun Heo <tj@kernel.org>
> ---
>  kernel/sched/ext.c | 16 +++++++---------
>  1 file changed, 7 insertions(+), 9 deletions(-)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 9202c6d7a771..2f70effcc4a6 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -7050,6 +7050,13 @@ static void scx_sub_enable_workfn(struct kthread_work *work)
>  	ret = 0;
>  	goto out_unlock;
>  
> +out_put_cgrp:
> +	cgroup_put(cgrp);
> +out_unlock:
> +	mutex_unlock(&scx_enable_mutex);
> +	cmd->ret = ret;
> +	return;
> +
>  abort:
>  	put_task_struct(p);
>  	scx_task_iter_stop(&sti);
> @@ -7063,15 +7070,6 @@ static void scx_sub_enable_workfn(struct kthread_work *work)
>  		}
>  	}
>  	scx_task_iter_stop(&sti);
> -	scx_cgroup_unlock();
> -	percpu_up_write(&scx_fork_rwsem);
> -out_put_cgrp:
> -	cgroup_put(cgrp);
> -out_unlock:
> -	mutex_unlock(&scx_enable_mutex);
> -	cmd->ret = ret;
> -	return;
> -
>  err_unlock_and_disable:
>  	/* we'll soon enter disable path, keep bypass on */
>  	scx_cgroup_unlock();
> -- 
> 2.53.0
> 

  reply	other threads:[~2026-03-16  6:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-16  5:43 [PATCHSET sched_ext/for-7.1] sched_ext: Fix kobject and cgroup ref error handling in scx_alloc_and_add_sched() Tejun Heo
2026-03-16  5:43 ` [PATCH 1/2] sched_ext: Fix cgroup double-put on sub-sched abort path Tejun Heo
2026-03-16  6:11   ` Andrea Righi [this message]
2026-03-16  9:31   ` Tejun Heo
2026-03-16  5:43 ` [PATCH 2/2] sched_ext: Use kobject_put() for kobject_init_and_add() failure in scx_alloc_and_add_sched() Tejun Heo
2026-03-16  6:13   ` Andrea Righi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=abefIFqKlWofXRN4@gpd4 \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=devnexen@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox