From: Andrea Righi <arighi@nvidia.com>
To: Tejun Heo <tj@kernel.org>
Cc: David Vernet <void@manifault.com>,
Changwoo Min <changwoo@igalia.com>,
Joel Fernandes <joelagnelf@nvidia.com>,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/6] sched_ext: idle: Introduce scx_bpf_select_cpu_and()
Date: Tue, 1 Apr 2025 08:35:23 +0200 [thread overview]
Message-ID: <Z-uJK3LiiG2l5wZP@gpd3> (raw)
In-Reply-To: <Z-sQTkz8mOuUKar7@slm.duckdns.org>
On Mon, Mar 31, 2025 at 11:59:42AM -1000, Tejun Heo wrote:
> Hello,
>
> On Fri, Mar 21, 2025 at 11:10:50PM +0100, Andrea Righi wrote:
> ...
> > +__bpf_kfunc s32 scx_bpf_select_cpu_and(struct task_struct *p, s32 prev_cpu, u64 wake_flags,
> > + const struct cpumask *cpus_allowed, u64 flags)
> > +{
> > + s32 cpu;
> > +
> > + if (!ops_cpu_valid(prev_cpu, NULL))
> > + return -EINVAL;
> > +
> > + if (!check_builtin_idle_enabled())
> > + return -EBUSY;
> > +
> > + if (!scx_kf_allowed(SCX_KF_SELECT_CPU | SCX_KF_ENQUEUE))
> > + return -EPERM;
> > +
> > +#ifdef CONFIG_SMP
> > + cpu = scx_select_cpu_dfl(p, prev_cpu, wake_flags, cpus_allowed, flags);
> > +#else
> > + cpu = -EBUSY;
> > +#endif
> > +
> > + return cpu;
> > +}
>
> Later in the series, I find scx_bpf_select_cpu_and() being called with
> p->cpus_ptr really confusing. scx_bpf_select_cpu_and() is always constrained
> by p->cpus_ptr (except for the currently buggy case where p->nr_cpus_allowed
> is used while p->cpus_ptr is overridden), so what does it mean to call
> scx_bpf_select_cpu_and() with p->cpus_ptr as @cpus_allowed? I'd much prefer
> if the convention in such cases is calling with NULL @cpus_allowed.
> @cpus_allowed is the extra mask to and to p->cpus_ptr when searching for an
> idle CPU. If we're going to use p->cpus_ptr, we just don't have the extra
> cpumask to and.
Exactly, as mentioned in a previous email I also agree that using NULL as
@cpus_allowed would be much more clear and less bug prone. Will change
that.
-Andrea
next prev parent reply other threads:[~2025-04-01 6:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-21 22:10 [PATCHSET v6 sched_ext/for-6.15] sched_ext: Enhance built-in idle selection with allowed CPUs Andrea Righi
2025-03-21 22:10 ` [PATCH 1/6] sched_ext: idle: Extend topology optimizations to all tasks Andrea Righi
2025-03-21 22:10 ` [PATCH 2/6] sched_ext: idle: Explicitly pass allowed cpumask to scx_select_cpu_dfl() Andrea Righi
2025-03-31 21:50 ` Tejun Heo
2025-04-01 6:21 ` Andrea Righi
2025-03-21 22:10 ` [PATCH 3/6] sched_ext: idle: Accept an arbitrary cpumask in scx_select_cpu_dfl() Andrea Righi
2025-03-31 21:56 ` Tejun Heo
2025-04-01 6:33 ` Andrea Righi
2025-03-21 22:10 ` [PATCH 4/6] sched_ext: idle: Introduce scx_bpf_select_cpu_and() Andrea Righi
2025-03-31 21:59 ` Tejun Heo
2025-04-01 6:35 ` Andrea Righi [this message]
2025-03-21 22:10 ` [PATCH 5/6] selftests/sched_ext: Add test for scx_bpf_select_cpu_and() Andrea Righi
2025-03-21 22:10 ` [PATCH 6/6] sched_ext: idle: Deprecate scx_bpf_select_cpu_dfl() Andrea Righi
2025-03-31 22:01 ` Tejun Heo
2025-04-01 6:38 ` Andrea Righi
2025-03-22 3:56 ` [PATCHSET v6 sched_ext/for-6.15] sched_ext: Enhance built-in idle selection with allowed CPUs Changwoo Min
-- strict thread matches above, loose matches on Subject: below --
2025-03-20 7:36 [PATCHSET v5 " Andrea Righi
2025-03-20 7:36 ` [PATCH 4/6] sched_ext: idle: Introduce scx_bpf_select_cpu_and() Andrea Righi
2025-03-17 17:53 [PATCHSET v4 sched_ext/for-6.15] sched_ext: Enhance built-in idle selection with allowed CPUs Andrea Righi
2025-03-17 17:53 ` [PATCH 4/6] sched_ext: idle: Introduce scx_bpf_select_cpu_and() Andrea Righi
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 4/6] sched_ext: idle: Introduce scx_bpf_select_cpu_and() 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=Z-uJK3LiiG2l5wZP@gpd3 \
--to=arighi@nvidia.com \
--cc=changwoo@igalia.com \
--cc=joelagnelf@nvidia.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox