The Linux Kernel Mailing List
 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>,
	sched-ext@lists.linux.dev, Emil Tsalapatis <emil@etsalapatis.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH sched_ext/for-7.3 4/4] sched_ext: Split sub-scheduler implementation into sub.c
Date: Wed, 1 Jul 2026 12:04:05 +0200	[thread overview]
Message-ID: <akTmFanypN_dRJiG@gpd4> (raw)
In-Reply-To: <20260701031429.1892218-5-tj@kernel.org>

Hi Tejun,

On Tue, Jun 30, 2026 at 05:14:29PM -1000, Tejun Heo wrote:
> The sub-scheduler implementation has grown and will continue to expand. Move
> the sub-scheduler functions from ext.c into a new kernel/sched/ext/sub.c.
> sub.h holds the prototypes and the !CONFIG_EXT_SUB_SCHED no-op stubs.
> 
> No functional change.
> 
> Signed-off-by: Tejun Heo <tj@kernel.org>
> ---

...

> +/**
> + * scx_bpf_sub_dispatch - Trigger dispatching on a child scheduler
> + * @cgroup_id: cgroup ID of the child scheduler to dispatch
> + * @aux: implicit BPF argument to access bpf_prog_aux hidden from BPF progs
> + *
> + * Allows a parent scheduler to trigger dispatching on one of its direct
> + * child schedulers. The child scheduler runs its dispatch operation to
> + * move tasks from dispatch queues to the local runqueue.
> + *
> + * Returns: true on success, false if cgroup_id is invalid, not a direct
> + * child, or caller lacks dispatch permission.
> + */
> +__bpf_kfunc bool scx_bpf_sub_dispatch(u64 cgroup_id, const struct bpf_prog_aux *aux)
> +{
> +	struct rq *this_rq = this_rq();
> +	struct scx_sched *parent, *child;
> +
> +	guard(rcu)();
> +	parent = scx_prog_sched(aux);
> +	if (unlikely(!parent))
> +		return false;
> +
> +	child = scx_find_sub_sched(cgroup_id);
> +
> +	if (unlikely(!child))
> +		return false;
> +
> +	if (unlikely(scx_parent(child) != parent)) {
> +		scx_error(parent, "trying to dispatch a distant sub-sched on cgroup %llu",
> +			  cgroup_id);
> +		return false;
> +	}
> +
> +	return scx_dispatch_sched(child, this_rq, this_rq->scx.sub_dispatch_prev,
> +				  true);

clangd isn't happy here, because we're missing the declaration of
scx_dispatch_sched(). It needs to be always inline. We can move the whole
function to internal.h, but that would require extra restructuring. Otherwise,
can relax the always inline condition?

From a local build the stack allocation in bytes looks like this:

                         scx_bpf_sub_dispatch()  scx_dispatch_sched()  Per level  4 levels
                         -----------------------------------------------------------------
__always_inline                    104                    -               104        416
non-inline                          72                   72               144        576
                         -----------------------------------------------------------------
delta                                                                     +40       +160

I think the saving is quite still small compared with nested BPF frames. WDYT?

Thanks,
-Andrea

  reply	other threads:[~2026-07-01 10:04 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01  3:14 [PATCHSET sched_ext/for-7.3] sched_ext: Split sub-scheduler implementation into sub.c Tejun Heo
2026-07-01  3:14 ` [PATCH sched_ext/for-7.3 1/4] sched_ext: Prefix file-local ext.c helpers exposed by the sub.c split Tejun Heo
2026-07-01  3:14 ` [PATCH sched_ext/for-7.3 2/4] sched_ext: Expose the ext.c internals used " Tejun Heo
2026-07-01  3:14 ` [PATCH sched_ext/for-7.3 3/4] sched_ext: Inline small ext.c helpers shared across " Tejun Heo
2026-07-01  3:14 ` [PATCH sched_ext/for-7.3 4/4] sched_ext: Split sub-scheduler implementation into sub.c Tejun Heo
2026-07-01 10:04   ` Andrea Righi [this message]
2026-07-01 17:34     ` Tejun Heo
2026-07-01 10:06 ` [PATCHSET sched_ext/for-7.3] " 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=akTmFanypN_dRJiG@gpd4 \
    --to=arighi@nvidia.com \
    --cc=changwoo@igalia.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