public inbox for linux-kernel@vger.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>,
	sched-ext@lists.linux.dev, Emil Tsalapatis <emil@etsalapatis.com>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCHSET v3 sched_ext/for-7.2] sched_ext: Topological CPU IDs and cid-form struct_ops
Date: Wed, 29 Apr 2026 16:11:53 +0200	[thread overview]
Message-ID: <afIRqTwn7UbMo2v0@gpd4> (raw)
In-Reply-To: <afIHuXXJWHEJnzaO@gpd4>

On Wed, Apr 29, 2026 at 03:29:43PM +0200, Andrea Righi wrote:
> Hi Tejun,
> 
> On Tue, Apr 28, 2026 at 10:35:28AM -1000, Tejun Heo wrote:
> > Hello,
> > 
> > v3 (all from the Sashiko AI review at
> > https://sashiko.dev/#/patchset/20260424172721.3458520-1-tj%40kernel.org):
> > 
> > - cid: drop leaked cpus_read_lock() on scx_cid_init() failure;
> >   BUILD_BUG_ON tightened to NR_CPUS<=8192 to match the BPF cmask
> >   helpers' CMASK_MAX_WORDS coverage.
> > - bpf-struct-size: use offsetof() in struct_size() to match the
> >   kernel <linux/overflow.h> macro semantics (no inflation from
> >   trailing struct padding).
> > - cmask: cmask_copy_from_kernel() validates src->base==0 via
> >   probe-read; nr_bits check is bit-level rather than rounded-up
> >   word-count.
> > - cid-qmap-idle: qmap_init() refuses to load when scx_bpf_nr_cids()
> >   exceeds SCX_QMAP_MAX_CPUS; the task_ctx flex array would otherwise
> >   overflow into the next slab entry.
> > 
> > v2: https://lore.kernel.org/r/20260424172721.3458520-1-tj@kernel.org
> > v1: https://lore.kernel.org/r/20260421071945.3110084-1-tj@kernel.org
> > 
> > This patchset introduces topological CPU IDs (cids) - dense,
> > topology-ordered cpu identifiers - and an alternative cid-form struct_ops
> > type that lets BPF schedulers operate in cid space directly.
> > 
> > Key pieces:
> > 
> > - cid space: scx_cid_init() walks nodes * LLCs * cores * threads and packs
> >   a dense cid mapping. The mapping can be overridden via
> >   scx_bpf_cid_override(). See "Topological CPU IDs" in ext_cid.h for the
> >   model.
> > 
> > - cmask: a base-windowed bitmap over cid space. Kernel and BPF helpers with
> >   identical semantics. Used by scx_qmap for per-task affinity and idle-cid
> >   tracking; meant to be the substrate for sub-sched cid allocation.
> > 
> > - bpf_sched_ext_ops_cid: a parallel struct_ops type whose callbacks take
> >   cids/cmasks instead of cpus/cpumasks. Kernel translates at the boundary
> >   via scx_cpu_arg() / scx_cpu_ret(); the two struct types share offsets up
> >   through @priv (verified by BUILD_BUG_ON) so the union view in scx_sched
> >   works without function-pointer casts. Sub-sched support is tied to
> >   cid-form: validate_ops() rejects cpu-form sub-scheds and cpu-form roots
> >   that expose sub_attach / sub_detach.
> > 
> > - cid-form kfuncs: scx_bpf_kick_cid, scx_bpf_cidperf_{cap,cur,set},
> >   scx_bpf_cid_curr, scx_bpf_task_cid, scx_bpf_this_cid,
> >   scx_bpf_nr_{cids,online_cids}, scx_bpf_cid_to_cpu, scx_bpf_cpu_to_cid.
> >   A cid-form program may not call cpu-only kfuncs (enforced at verifier
> >   load via scx_kfunc_context_filter); the reverse is intentionally
> >   permissive to ease migration.
> 
> So, IIUC scx schedulers attached to bpf_sched_ext_ops_cid can't use the built-in
> idle CPU selection kfuncs (ext_idle.c), right?
> 
> And that also means sub-sched support => no built-in idle CPU selection. That's
> a bit unfortunate... I guess we could implement a similar logic in cid/cmask
> space, maybe in BPF.

And apart from this and the other comments in PATCH 8/17 and PATCH 16/17,
everything else looks good to me.

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

Thanks,
-Andrea

  reply	other threads:[~2026-04-29 14:12 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-28 20:35 [PATCHSET v3 sched_ext/for-7.2] sched_ext: Topological CPU IDs and cid-form struct_ops Tejun Heo
2026-04-28 20:35 ` [PATCH 01/17] sched_ext: Add ext_types.h for early subsystem-wide defs Tejun Heo
2026-04-28 20:35 ` [PATCH 02/17] sched_ext: Rename ops_cpu_valid() to scx_cpu_valid() and expose it Tejun Heo
2026-04-28 20:35 ` [PATCH 03/17] sched_ext: Move scx_exit(), scx_error() and friends to ext_internal.h Tejun Heo
2026-04-28 20:35 ` [PATCH 04/17] sched_ext: Shift scx_kick_cpu() validity check to scx_bpf_kick_cpu() Tejun Heo
2026-04-28 20:35 ` [PATCH 05/17] sched_ext: Relocate cpu_acquire/cpu_release to end of struct sched_ext_ops Tejun Heo
2026-04-28 20:35 ` [PATCH 06/17] sched_ext: Make scx_enable() take scx_enable_cmd Tejun Heo
2026-04-28 20:35 ` [PATCH 07/17] sched_ext: Add topological CPU IDs (cids) Tejun Heo
2026-04-28 20:35 ` [PATCH 08/17] sched_ext: Add scx_bpf_cid_override() kfunc Tejun Heo
2026-04-29 14:07   ` Andrea Righi
2026-04-29 17:06     ` Tejun Heo
2026-04-29 17:20       ` Andrea Righi
2026-04-28 20:35 ` [PATCH 09/17] tools/sched_ext: Add struct_size() helpers to common.bpf.h Tejun Heo
2026-04-28 20:35 ` [PATCH 10/17] sched_ext: Add cmask, a base-windowed bitmap over cid space Tejun Heo
2026-04-29 12:47   ` Changwoo Min
2026-04-29 17:16     ` Tejun Heo
2026-04-28 20:35 ` [PATCH 11/17] sched_ext: Add cid-form kfunc wrappers alongside cpu-form Tejun Heo
2026-04-28 20:35 ` [PATCH 12/17] sched_ext: Add bpf_sched_ext_ops_cid struct_ops type Tejun Heo
2026-04-28 20:35 ` [PATCH 13/17] sched_ext: Forbid cpu-form kfuncs from cid-form schedulers Tejun Heo
2026-04-28 20:35 ` [PATCH 14/17] tools/sched_ext: scx_qmap: Restart on hotplug instead of cpu_online/offline Tejun Heo
2026-04-28 20:35 ` [PATCH 15/17] tools/sched_ext: scx_qmap: Add cmask-based idle tracking and cid-based idle pick Tejun Heo
2026-04-28 20:35 ` [PATCH 16/17] tools/sched_ext: scx_qmap: Port to cid-form struct_ops Tejun Heo
2026-04-29 12:47   ` Changwoo Min
2026-04-29 13:53     ` Andrea Righi
2026-04-29 16:42       ` Tejun Heo
2026-04-28 20:35 ` [PATCH 17/17] sched_ext: Require cid-form struct_ops for sub-sched support Tejun Heo
2026-04-29 12:49 ` [PATCHSET v3 sched_ext/for-7.2] sched_ext: Topological CPU IDs and cid-form struct_ops Changwoo Min
2026-04-29 13:29 ` Andrea Righi
2026-04-29 14:11   ` Andrea Righi [this message]
2026-04-29 17:06   ` 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=afIRqTwn7UbMo2v0@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