public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Andrea Righi <arighi@nvidia.com>
Cc: David Vernet <void@manifault.com>,
	Changwoo Min <changwoo@igalia.com>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/6] sched_ext: idle: Introduce the concept of allowed CPUs
Date: Fri, 7 Mar 2025 12:17:23 -1000	[thread overview]
Message-ID: <Z8twc3pc7I9SyIMC@slm.duckdns.org> (raw)
In-Reply-To: <20250307200502.253867-4-arighi@nvidia.com>

Hello,

On Fri, Mar 07, 2025 at 09:01:05PM +0100, Andrea Righi wrote:
> Many scx schedulers define their own concept of scheduling domains to
> represent topology characteristics, such as heterogeneous architectures

I'm not sure "domain" is a good choice given that sched_domain is already an
established construct in kernel and means something specific.

> (e.g., big.LITTLE, P-cores/E-cores), or to categorize tasks based on
> specific properties (e.g., setting the soft-affinity of certain tasks to
> a subset of CPUs).
> 
> Currently, there is no mechanism to share these domains with the
> built-in idle CPU selection policy. As a result, schedulers often
> implement their own idle CPU selection policies, which are typically
> similar to one another, leading to a lot of code duplication.
> 
> To address this, introduce the concept of allowed domain (represented as
> a cpumask) that can be used by the BPF schedulers to apply the built-in
> idle CPU selection policy to a subset of preferred CPUs.

We don't need a new term here, do we? All that's being added is an extra
mask when picking CPUs.

> With this concept the idle CPU selection policy becomes the following:
>  - always prioritize CPUs from fully idle SMT cores (if SMT is enabled),
>  - select the same CPU if it's idle and in the allowed domain,
>  - select an idle CPU within the same LLC domain, if the LLC domain is a
>    subset of the allowed domain,

Why not select from the intersection of the same LLC domain and the cpumask?

>  - select an idle CPU within the same node, if the node domain is a
>    subset of the allowed domain,

Ditto.

>  - select an idle CPU within the allowed domain.
> 
> If the allowed domain is empty or NULL, the behavior of the built-in
> idle CPU selection policy remains unchanged.
> 
> This only introduces the core concept of allowed domain. This
> functionality will be exposed through a dedicated kfunc in a separate
> patch.
...
> -s32 scx_select_cpu_dfl(struct task_struct *p, s32 prev_cpu, u64 wake_flags, u64 flags)
> +s32 scx_select_cpu_dfl(struct task_struct *p, const struct cpumask *cpus_allowed,
> +		       s32 prev_cpu, u64 wake_flags, u64 flags)

Maybe rearrange them (p, prev_cpu, wake_flags, and_cpumask, pick_idle_flags)
so that the first three args align with select_task_rq() and we don't have
three consecutive integer arguments? Two back-to-back flag args increase the
chance of subtle bugs.

Thanks.

-- 
tejun

  reply	other threads:[~2025-03-07 22:17 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-07 20:01 [PATCHSET v2 sched_ext/for-6.15] sched_ext: Enhance built-in idle selection with allowed CPUs Andrea Righi
2025-03-07 20:01 ` [PATCH 1/6] sched_ext: idle: Honor idle flags in the built-in idle selection policy Andrea Righi
2025-03-07 20:01 ` [PATCH 2/6] sched_ext: idle: Refactor scx_select_cpu_dfl() Andrea Righi
2025-03-07 20:01 ` [PATCH 3/6] sched_ext: idle: Introduce the concept of allowed CPUs Andrea Righi
2025-03-07 22:17   ` Tejun Heo [this message]
2025-03-08  6:48     ` Andrea Righi
2025-03-09 14:56       ` Tejun Heo
2025-03-09 15:39         ` Andrea Righi
2025-03-10 16:07           ` Tejun Heo
2025-03-10 17:15             ` Andrea Righi
2025-03-07 20:01 ` [PATCH 4/6] sched_ext: idle: Introduce scx_bpf_select_cpu_and() Andrea Righi
2025-03-07 20:01 ` [PATCH 5/6] selftests/sched_ext: Add test for scx_bpf_select_cpu_and() Andrea Righi
2025-03-07 20:01 ` [PATCH 6/6] sched_ext: idle: Deprecate scx_bpf_select_cpu_dfl() 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=Z8twc3pc7I9SyIMC@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=arighi@nvidia.com \
    --cc=bpf@vger.kernel.org \
    --cc=changwoo@igalia.com \
    --cc=linux-kernel@vger.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