All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrea Righi <arighi@nvidia.com>
To: Cheng-Yang Chou <yphbchou0911@gmail.com>
Cc: sched-ext@lists.linux.dev, tj@kernel.org, void@manifault.com,
	changwoo@igalia.com, jserv@ccns.ncku.edu.tw
Subject: Re: [PATCH v2 1/2] sched_ext: Update demo schedulers and selftests to use scx_bpf_task_set_dsq_vtime()
Date: Thu, 12 Mar 2026 21:57:45 +0100	[thread overview]
Message-ID: <abMoyauzdQlqUxz3@gpd4> (raw)
In-Reply-To: <20260312175527.1220540-2-yphbchou0911@gmail.com>

Hi Cheng-Yang,

On Fri, Mar 13, 2026 at 01:55:26AM +0800, Cheng-Yang Chou wrote:
> Direct writes to p->scx.dsq_vtime are deprecated in favor of
> scx_bpf_task_set_dsq_vtime(). Update scx_simple, scx_flatcg, and
> select_cpu_vtime selftest to use the new kfunc with scale_by_task_weight.

Sorry, that's my mistake, we should use scale_by_task_weight_inverse(), not
scale_by_task_weight() as I suggested in my previous email.

> 
> Signed-off-by: Cheng-Yang Chou <yphbchou0911@gmail.com>
> ---
>  tools/sched_ext/scx_flatcg.bpf.c                         | 9 +++++----
>  tools/sched_ext/scx_simple.bpf.c                         | 6 ++++--
>  tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c | 7 +++++--
>  3 files changed, 14 insertions(+), 8 deletions(-)
> 
> diff --git a/tools/sched_ext/scx_flatcg.bpf.c b/tools/sched_ext/scx_flatcg.bpf.c
> index a8a9234bb41e..5cb92b4f1635 100644
> --- a/tools/sched_ext/scx_flatcg.bpf.c
> +++ b/tools/sched_ext/scx_flatcg.bpf.c
> @@ -551,9 +551,10 @@ void BPF_STRUCT_OPS(fcg_stopping, struct task_struct *p, bool runnable)
>  	 * too much, determine the execution time by taking explicit timestamps
>  	 * instead of depending on @p->scx.slice.
>  	 */
> +	u64 delta = scale_by_task_weight(p, SCX_SLICE_DFL - p->scx.slice);

Here.

> +
>  	if (!fifo_sched)
> -		p->scx.dsq_vtime +=
> -			(SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
> +		scx_bpf_task_set_dsq_vtime(p, p->scx.dsq_vtime + delta);
>  
>  	taskc = bpf_task_storage_get(&task_ctx, p, 0, 0);
>  	if (!taskc) {
> @@ -822,7 +823,7 @@ s32 BPF_STRUCT_OPS(fcg_init_task, struct task_struct *p,
>  	if (!(cgc = find_cgrp_ctx(args->cgroup)))
>  		return -ENOENT;
>  
> -	p->scx.dsq_vtime = cgc->tvtime_now;
> +	scx_bpf_task_set_dsq_vtime(p, cgc->tvtime_now);
>  
>  	return 0;
>  }
> @@ -924,7 +925,7 @@ void BPF_STRUCT_OPS(fcg_cgroup_move, struct task_struct *p,
>  		return;
>  
>  	delta = time_delta(p->scx.dsq_vtime, from_cgc->tvtime_now);
> -	p->scx.dsq_vtime = to_cgc->tvtime_now + delta;
> +	scx_bpf_task_set_dsq_vtime(p, to_cgc->tvtime_now + delta);
>  }
>  
>  s32 BPF_STRUCT_OPS_SLEEPABLE(fcg_init)
> diff --git a/tools/sched_ext/scx_simple.bpf.c b/tools/sched_ext/scx_simple.bpf.c
> index b456bd7cae77..a61a7df81e49 100644
> --- a/tools/sched_ext/scx_simple.bpf.c
> +++ b/tools/sched_ext/scx_simple.bpf.c
> @@ -121,12 +121,14 @@ void BPF_STRUCT_OPS(simple_stopping, struct task_struct *p, bool runnable)
>  	 * too much, determine the execution time by taking explicit timestamps
>  	 * instead of depending on @p->scx.slice.
>  	 */
> -	p->scx.dsq_vtime += (SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
> +	u64 delta = scale_by_task_weight(p, SCX_SLICE_DFL - p->scx.slice);

Here.

> +
> +	scx_bpf_task_set_dsq_vtime(p, p->scx.dsq_vtime + delta);
>  }
>  
>  void BPF_STRUCT_OPS(simple_enable, struct task_struct *p)
>  {
> -	p->scx.dsq_vtime = vtime_now;
> +	scx_bpf_task_set_dsq_vtime(p, vtime_now);
>  }
>  
>  s32 BPF_STRUCT_OPS_SLEEPABLE(simple_init)
> diff --git a/tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c b/tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c
> index bfcb96cd4954..63e03fe5d983 100644
> --- a/tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c
> +++ b/tools/testing/selftests/sched_ext/select_cpu_vtime.bpf.c
> @@ -66,12 +66,15 @@ void BPF_STRUCT_OPS(select_cpu_vtime_running, struct task_struct *p)
>  void BPF_STRUCT_OPS(select_cpu_vtime_stopping, struct task_struct *p,
>  		    bool runnable)
>  {
> -	p->scx.dsq_vtime += (SCX_SLICE_DFL - p->scx.slice) * 100 / p->scx.weight;
> +	u64 delta = scale_by_task_weight(p, SCX_SLICE_DFL - p->scx.slice);

And here.

> +
> +	scx_bpf_task_set_dsq_vtime(p, p->scx.dsq_vtime + delta);
> +
>  }
>  
>  void BPF_STRUCT_OPS(select_cpu_vtime_enable, struct task_struct *p)
>  {
> -	p->scx.dsq_vtime = vtime_now;
> +	scx_bpf_task_set_dsq_vtime(p, vtime_now);
>  }
>  
>  s32 BPF_STRUCT_OPS_SLEEPABLE(select_cpu_vtime_init)
> -- 
> 2.48.1
> 

With s/scale_by_task_weight/scale_by_task_weight_inverse/

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

Thanks,
-Andrea

  reply	other threads:[~2026-03-12 20:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12 17:55 [PATCH v2 0/2] sched_ext: Update demo schedulers and selftests for deprecated APIs Cheng-Yang Chou
2026-03-12 17:55 ` [PATCH v2 1/2] sched_ext: Update demo schedulers and selftests to use scx_bpf_task_set_dsq_vtime() Cheng-Yang Chou
2026-03-12 20:57   ` Andrea Righi [this message]
2026-03-13  1:22     ` Cheng-Yang Chou
2026-03-12 17:55 ` [PATCH v2 2/2] sched_ext: Update demo schedulers and selftests to drop ops.cpu_acquire/release() Cheng-Yang Chou
2026-03-12 20:58   ` 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=abMoyauzdQlqUxz3@gpd4 \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.com \
    --cc=jserv@ccns.ncku.edu.tw \
    --cc=sched-ext@lists.linux.dev \
    --cc=tj@kernel.org \
    --cc=void@manifault.com \
    --cc=yphbchou0911@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.