public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Cheng-Yang Chou <yphbchou0911@gmail.com>
To: Richard Cheng <icheng@nvidia.com>
Cc: tj@kernel.org, void@manifault.com, arighi@nvidia.com,
	 changwoo@igalia.com, mingo@redhat.com, peterz@infradead.org,
	juri.lelli@redhat.com,  vincent.guittot@linaro.org,
	dietmar.eggemann@arm.com, rostedt@goodmis.org,
	 bsegall@google.com, mgorman@suse.de, vschneid@redhat.com,
	kprateek.nayak@amd.com,  sched-ext@lists.linux.dev,
	linux-kernel@vger.kernel.org, newtonl@nvidia.com,
	 kristinc@nvidia.com, kaihengf@nvidia.com, kobak@nvidia.com,
	jserv@ccns.ncku.edu.tw,  chia7712@gmail.com
Subject: Re: [PATCH v2] sched_ext: sync disable_irq_work in bpf_scx_unreg()
Date: Fri, 24 Apr 2026 18:21:37 +0800	[thread overview]
Message-ID: <20260424181151.Ge109@cchengyang.duckdns.org> (raw)
In-Reply-To: <20260424100221.32407-1-icheng@nvidia.com>

Hi Richard,

On Fri, Apr 24, 2026 at 06:02:21PM +0800, Richard Cheng wrote:
[...]
> ---
>  kernel/sched/ext.c | 20 +++++++++++++++++---
>  1 file changed, 17 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/sched/ext.c b/kernel/sched/ext.c
> index 012ca8bd70fb..ff42ac197bfd 100644
> --- a/kernel/sched/ext.c
> +++ b/kernel/sched/ext.c
> @@ -5921,6 +5921,20 @@ static void scx_disable(struct scx_sched *sch, enum scx_exit_kind kind)
>  		irq_work_queue(&sch->disable_irq_work);
>  }
>  
> +/**
> + * scx_flush_disable_work - flush the disable work and wait for it to finish
> + * @sch: the scheduler

Not to be picky here, but I think '@sch: the scheduler' is a bit vague.
Since nearly every 'sch' in ext.c is a scheduler instance,
maybe '@sch: sched to be flushed' would be more descriptive?

You can check more specific comments for 'sch' elsewhere in ext.c as well.
WDYT, thanks!

> + *
> + * sch->disable_work might still not queued, causing kthread_flush_work()
> + * as a noop. Syncing the irq_work first is required to guarantee the
> + * kthread work has been queued before waiting for it.
> + */
> +static void scx_flush_disable_work(struct scx_sched *sch)
> +{
> +	irq_work_sync(&sch->disable_irq_work);
> +	kthread_flush_work(&sch->disable_work);
> +}
> +
>  static void dump_newline(struct seq_buf *s)
>  {
>  	trace_sched_ext_dump("");
> @@ -6821,7 +6835,7 @@ static void scx_root_enable_workfn(struct kthread_work *work)
>  	 * completion. sch's base reference will be put by bpf_scx_unreg().
>  	 */
>  	scx_error(sch, "scx_root_enable() failed (%d)", ret);
> -	kthread_flush_work(&sch->disable_work);
> +	scx_flush_disable_work(sch);
>  	cmd->ret = 0;
>  }
>  
> @@ -7088,7 +7102,7 @@ static void scx_sub_enable_workfn(struct kthread_work *work)
>  	percpu_up_write(&scx_fork_rwsem);
>  err_disable:
>  	mutex_unlock(&scx_enable_mutex);
> -	kthread_flush_work(&sch->disable_work);
> +	scx_flush_disable_work(sch);
>  	cmd->ret = 0;
>  }
>  
> @@ -7349,7 +7363,7 @@ static void bpf_scx_unreg(void *kdata, struct bpf_link *link)
>  	struct scx_sched *sch = rcu_dereference_protected(ops->priv, true);
>  
>  	scx_disable(sch, SCX_EXIT_UNREG);
> -	kthread_flush_work(&sch->disable_work);
> +	scx_flush_disable_work(sch);
>  	RCU_INIT_POINTER(ops->priv, NULL);
>  	kobject_put(&sch->kobj);
>  }
> -- 
> 2.43.0
> 

-- 
Cheers,
Cheng-Yang

  reply	other threads:[~2026-04-24 10:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-24 10:02 [PATCH v2] sched_ext: sync disable_irq_work in bpf_scx_unreg() Richard Cheng
2026-04-24 10:21 ` Cheng-Yang Chou [this message]
2026-04-24 17:29 ` Tejun Heo

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=20260424181151.Ge109@cchengyang.duckdns.org \
    --to=yphbchou0911@gmail.com \
    --cc=arighi@nvidia.com \
    --cc=bsegall@google.com \
    --cc=changwoo@igalia.com \
    --cc=chia7712@gmail.com \
    --cc=dietmar.eggemann@arm.com \
    --cc=icheng@nvidia.com \
    --cc=jserv@ccns.ncku.edu.tw \
    --cc=juri.lelli@redhat.com \
    --cc=kaihengf@nvidia.com \
    --cc=kobak@nvidia.com \
    --cc=kprateek.nayak@amd.com \
    --cc=kristinc@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mgorman@suse.de \
    --cc=mingo@redhat.com \
    --cc=newtonl@nvidia.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=vincent.guittot@linaro.org \
    --cc=void@manifault.com \
    --cc=vschneid@redhat.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