All of lore.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>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 3/6] sched_ext: idle: Introduce the concept of allowed CPUs
Date: Mon, 10 Mar 2025 18:15:25 +0100	[thread overview]
Message-ID: <Z88eLdtwNzpkde02@gpd3> (raw)
In-Reply-To: <Z88OOena_fucXLVl@slm.duckdns.org>

On Mon, Mar 10, 2025 at 06:07:21AM -1000, Tejun Heo wrote:
> Hello,
> 
> On Sun, Mar 09, 2025 at 04:39:40PM +0100, Andrea Righi wrote:
> > > Would just using a pre-allocated cpumask to do pre-and on @cpus_allowed
> > > work? This won't only be used for topology support (e.g. soft partitioning
> > > in scx_layered and scx_mitosis may want to use multi-topology-unit spanning
> > > subsets) and I'm not sure assuming and optimizing for that is a good idea
> > > for generic API.
> > 
> > We can pre-allocate two additional (per-cpu) cpumasks to do:
> >  - cpumask_and(numa_cpus, numa_span(cpu), cpus_allowed)
> >  - cpumask_and(llc_cpus, llc_span(cpu), cpus_allowed)
> > 
> > And update/use them only when it's needed. In this way the API would be
> > generic without making any implicit assumption about @cpus_allowed.
> 
> I'm not quite following why two masks would be necessary. The user is
> providing two masks and and'ing those two masks result in a single
> cpus_allowed mask which can then be passed down to the existing pick
> functions, no?

When you say the user is providing two masks, you mean p->cpus_ptr
and @cpus_allowed, right? Or am I missing something?

So, internally we have three levels of cpumasks, used in this order:
 1) p->cpus_ptr & cpus_allowed & llc_span(prev_cpu)
 2) p->cpus_ptr & cpus_allowed & numa_span(prev_cpu)
 3) p->cpus_ptr & cpus_allowed

The current logic (without @cpus_allowed) is applying LLC and NUMA
optimization only for tasks that can run on all CPUs (p->cpus_ptr == all),
to avoid doing extra "and" operations internally and simply use
llc_span(prev_cpu) and numa_span(prev_cpu).

With @cpus_allowed this optimization doesn't work anymore and we can't
just re-apply the current logic to "p->cpus_ptr & cpus_allowed", since it
would result in ignoring the LLC and NUMA cpumasks.

Maybe we could use a single pre-allocated temporary cpumask and do the
"and" at each step when it's needed, instead of using two separate cpumasks
to evaluate "cpus_allowed & llc_span(prev_cpu)" and "cpus_allowed &
numa_span(prev_cpu). Is this what you mean?

Thanks,
-Andrea

  reply	other threads:[~2025-03-10 17:15 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
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 [this message]
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=Z88eLdtwNzpkde02@gpd3 \
    --to=arighi@nvidia.com \
    --cc=bpf@vger.kernel.org \
    --cc=changwoo@igalia.com \
    --cc=linux-kernel@vger.kernel.org \
    --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 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.